Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / tools / client / ryzom_installer / src / utils.h
blobaec5743877309da00d187325d42b7cdfa103f744
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef UTILS_H
18 #define UTILS_H
20 #include <nel/misc/ucstring.h>
22 #include <string>
24 /**
25 * Utils functions
27 * \author Cedric 'Kervala' OCHS
28 * \date 2016
31 // convert a size in bytes to a QString with larger unit (KiB, MiB, etc...)
32 QString qBytesToHumanReadable(qint64 bytes);
34 // return true is the specified directory is empty (has no file inside) (and all its subdirectories if recursize is true)
35 bool isDirectoryEmpty(const QString &directory, bool recursize);
37 // check if specified directory is writable
38 bool isDirectoryWritable(const QString &directory);
40 // return the total size in bytes of specified directtory (and all its subdirectories if recursize is true)
41 qint64 getDirectorySize(const QString &directory, bool recursize);
43 // convert a UTF-8 string to QString
44 QString qFromUtf8(const std::string &str);
46 // convert a QString to UTF-8 string
47 std::string qToUtf8(const QString &str);
49 // convert an UTF-16 string to QString
50 QString qFromUtf16(const ucstring &str);
52 // convert a QString to UTF-16 string
53 ucstring qToUtf16(const QString &str);
55 // convert an wchar_t* to QString
56 QString qFromWide(const wchar_t *str);
58 // convert an QString to wchar_t*
59 wchar_t* qToWide(const QString &str);
61 #define Q2C(x) qToUtf8(x).c_str()
63 // check if a shortcut already exists (the extension will be added)
64 bool shortcutExists(const QString &shortcut);
66 // create a shortcut with the native format of the current platform
67 bool createShortcut(const QString &shortcut, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir);
69 // remove a shortcut (the extension will be added)
70 bool removeShortcut(const QString &shortcut);
72 // return the real path of shortcut
73 bool resolveShortcut(const QWidget &window, const QString &shortcut, QString &pathObj);
75 // append the shortcut of current platform to specified path
76 QString appendShortcutExtension(const QString &shortcut);
78 // launch an executable with --version parameter and parse version string
79 QString getVersionFromExecutable(const QString &path, const QString &workingDirectory);
81 // write a resource in QRC to disk
82 bool writeResource(const QString &resource, const QString &path);
84 // write a resource in QRC to disk and replace all variables by specified values
85 bool writeResourceWithTemplates(const QString &resource, const QString &path, const QMap<QString, QString> &strings);
87 // a little helper class to unintialize COM after using it
88 class CCOMHelper
90 bool m_mustUninit;
92 public:
93 CCOMHelper();
94 ~CCOMHelper();
97 // a little helper class to init/uninit log
98 class CLogHelper
100 public:
101 CLogHelper(const QString &logPath);
102 ~CLogHelper();
105 #endif