-
Notifications
You must be signed in to change notification settings - Fork 0
/
entryprovider.h
66 lines (59 loc) · 1.46 KB
/
entryprovider.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
#ifndef ENTRYPROVIDER_H
#define ENTRYPROVIDER_H
#include <QIcon>
#include <QSettings>
#include <optional>
class ConfigFormatException : public std::runtime_error
{
public:
ConfigFormatException() : std::runtime_error("Error in configuration file, misformated line?")
{
}
ConfigFormatException(const std::string &str) : std::runtime_error(str)
{
}
};
enum EntryType
{
USER,
INHERIT,
SYSTEM,
DYNAMIC
};
class EntryConfig
{
public:
EntryType type = SYSTEM;
bool hidden = false;
bool isTerminalCommand = false;
QString entryPath;
QString key;
QString name;
QString command;
QString iconPath;
QStringList arguments;
QString inherit;
int row = 0;
int col = 0;
EntryConfig &update(const EntryConfig &o);
};
class EntryProvider
{
protected:
QStringList _desktopIgnoreArgs;
QStringList userEntriesDirsPaths;
QStringList systemEntriesDirsPaths;
EntryConfig readqsrunFile(const QString &path);
EntryConfig readFromDesktopFile(const QString &path);
std::optional<EntryConfig> readEntryFromPath(const QString &path);
QVector<EntryConfig> readConfig(QStringList paths);
QString resolveEntryPath(QString path);
public:
EntryProvider(QStringList userEntriesDirsPaths, QStringList systemEntriesDirsPaths);
bool isSavable(const EntryConfig &config) const;
QVector<EntryConfig> getUserEntries();
QVector<EntryConfig> getSystemEntries();
void saveUserEntry(const EntryConfig &config);
bool deleteUserEntry(const EntryConfig &config);
};
#endif // ENTRYPROVIDER_H