forked from Skycoder42/QAutoStart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qautostart.h
70 lines (56 loc) · 1.94 KB
/
qautostart.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
#ifndef QAUTOSTART_H
#define QAUTOSTART_H
#include <QObject>
#include <QHash>
#include <QVariant>
#include <QScopedPointer>
class QAutoStartPrivate;
class QAutoStart : public QObject
{
Q_OBJECT
Q_PROPERTY(QString startId READ startId WRITE setStartId NOTIFY startIdChanged)
Q_PROPERTY(QString program READ program WRITE setProgram NOTIFY programChanged)
Q_PROPERTY(QStringList arguments READ arguments WRITE setArguments NOTIFY argumentsChanged)
Q_PROPERTY(PropertyHash extraProperties READ extraProperties WRITE setExtraProperties NOTIFY extraPropertiesChanged)
Q_PROPERTY(bool autoStartEnabled READ isAutoStartEnabled WRITE setAutoStartEnabled NOTIFY autoStartEnabledChanged)
public:
enum PropertyKey {
DisplayName,
IconName,
Comment,
Interactive,
CustomLocation
};
Q_ENUM(PropertyKey)
using PropertyHash = QHash<PropertyKey, QVariant>;
explicit QAutoStart(QObject *parent = nullptr);
~QAutoStart() override;
QString startId() const;
QString program() const;
QStringList arguments() const;
PropertyHash extraProperties() const;
QVariant extraProperty(PropertyKey key) const;
bool isAutoStartEnabled() const;
#if defined(Q_OS_LINUX)
QString desktopFilePath() const;
#endif
public slots:
void setStartId(QString startId);
void setProgram(QString program);
void setArguments(QStringList arguments);
void setExtraProperties(PropertyHash extraProperties);
void setExtraProperty(PropertyKey key, const QVariant &value);
bool setAutoStartEnabled(bool autoStartEnabled = true);
inline bool setAutoStartDisabled(bool autoStartDisabled = true) {
return setAutoStartEnabled(!autoStartDisabled);
}
signals:
void startIdChanged(const QString &startId);
void programChanged(const QString &program);
void argumentsChanged(const QStringList &arguments);
void extraPropertiesChanged(const PropertyHash &extraProperties);
void autoStartEnabledChanged(bool autoStartEnabled);
private:
QScopedPointer<QAutoStartPrivate> d;
};
#endif // QAUTOSTART_H