-
Notifications
You must be signed in to change notification settings - Fork 351
/
Copy pathutilsSystem.h
129 lines (97 loc) · 3.97 KB
/
utilsSystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef Header_UtilsSystem
#define Header_UtilsSystem
#include "mostQtHeaders.h"
#include <QCache>
/*!
* \file utilsSystem.h
* \brief helper functions for general use
*
*/
#define REQUIRE(x) do { Q_ASSERT((x)); if (!(x)) return; } while (0)
#define REQUIRE_RET(x,e) do { Q_ASSERT((x)); if (!(x)) return (e); } while (0)
extern const char *TEXSTUDIO_GIT_REVISION;
bool getDiskFreeSpace(const QString &path, quint64 &freeBytes);
QLocale::Language getKeyboardLanguage();
QKeySequence filterLocaleShortcut(QKeySequence ks);
QString quoteSpaces(const QString &s);
QChar getPathListSeparator();
QStringList splitPaths(const QString &paths);
QString getUserName();
QString getUserDocumentFolder();
QStringList findResourceFiles(const QString &dirName, const QString &filter, QStringList additionalPreferredPaths = QStringList());
///returns the real name of a resource file
QString findResourceFile(const QString &fileName, bool allowOverride = false, QStringList additionalPreferredPaths = QStringList(), QStringList additionalFallbackPaths = QStringList());
/*!
* \brief style used
*
* Global variable conatisn info which style is used.
* 0: classic style
* 1: modern style
* 2: modern style - dark
*/
extern int modernStyle;
/*!
* \brief icon theme used
*
* Global variable storing which icon theme is used.
* 0: Colibre Icon Theme adapted from LibreOffice
* 1: Modern Icon Theme
* 2: Classic Icon Theme
*/
extern int iconTheme;
/*!
* \brief if dark mode is used
*/
extern bool darkMode;
/*!
* \brief use system icons if available
*/
extern bool useSystemTheme;
extern QCache<QString, QIcon>iconCache;
QString getRealIconFile(const QString &icon);
QIcon getRealIcon(const QString &icon);
QIcon getRealIconCached(const QString &icon, bool forceReload=false);
QPixmap loadPixmapFromSVG(const QString &fn,const QSize sz);
///returns if the file is writable (QFileInfo.isWritable works in different ways on Windows and Linux)
bool isFileRealWritable(const QString &filename);
//returns if the file exists and is writable
bool isExistingFileRealWritable(const QString &filename);
QString ensureTrailingDirSeparator(const QString &dirPath);
QString joinPath(const QString &dirname, const QString &filename);
QString joinPath(const QString &dirname, const QString &dirname2, const QString &filename);
// replaces "somdir/file.ext" to "somedir/file.newext"
QString replaceFileExtension(const QString &filename, const QString &newExtension, bool appendIfNoExt = false);
QString getRelativeBaseNameToPath(const QString &file, QString basepath, bool baseFile = false, bool keepSuffix = false);
QString getPathfromFilename(const QString &compFile);
QString findAbsoluteFilePath(const QString &relName, const QString &extension, const QStringList &searchPaths, const QString &fallbackPath);
QString getNonextistentFilename(const QString &guess, const QString &fallback = QString());
QFileInfo getNonSymbolicFileInfo(const QFileInfo &info);
QString getEnvironmentPath();
QStringList getEnvironmentPathList();
void updatePathSettings(QProcess *proc, QString additionalPaths);
void showInGraphicalShell(QWidget *parent, const QString &pathIn);
QString msgGraphicalShellAction();
//returns kde version 0,3,4
int x11desktop_env();
bool isRetinaMac();
QSet<QString> convertStringListtoSet(const QStringList &list);
///check if the run-time qt version is higher than the given version (e.g. 4,3)
bool hasAtLeastQt(int major, int minor);
bool connectUnique(const QObject *sender, const char *signal, const QObject *receiver, const char *method);
class ThreadBreaker : public QThread
{
public:
static void sleep(unsigned long s);
static void msleep(unsigned long ms);
static void forceTerminate(QThread *t = nullptr);
};
class SafeThread: public QThread
{
Q_OBJECT
public:
SafeThread();
SafeThread(QObject *parent);
void wait(unsigned long time = 60000);
bool crashed;
};
#endif // UTILSSYSTEM_H