-
Notifications
You must be signed in to change notification settings - Fork 0
/
systray.h
50 lines (41 loc) · 1.36 KB
/
systray.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
// This file is licensed under either of licenses:
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-License-Identifier: BSD-2-Clause
#ifndef SYSTRAY_H
#define SYSTRAY_H
#include <QProperty>
#include <QQuickItem>
#include <QSystemTrayIcon>
class SysTray : public QQuickItem {
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(bool isActive READ default WRITE default BINDABLE isActiveBindable)
Q_PROPERTY(
QString iconPath READ iconPath WRITE setIconPath NOTIFY iconPathChanged)
Q_PROPERTY(bool notificationsAllowed READ default WRITE default BINDABLE
notificationsAllowedBindable)
public:
explicit SysTray(QQuickItem *parent = nullptr);
auto isActiveBindable() -> QBindable<bool> { return {&m_isActive}; }
auto notificationsAllowedBindable() -> QBindable<bool> {
return {&m_notificationsAllowed};
}
[[nodiscard]] QString iconPath() const;
void setIconPath(const QString &newIconPath);
public slots:
void notifyInfo(const QString &, const QString &);
void notifyError(const QString &, const QString &);
void aboutApp();
void aboutQt();
signals:
void iconPathChanged(QString iconPath);
void iconClicked();
private:
QSystemTrayIcon *m_icon;
QProperty<bool> m_isActive{false};
QProperty<QString> m_toolTip;
QProperty<bool> m_notificationsAllowed{false};
QPropertyNotifier m_toolTipChange;
QString m_iconPath;
};
#endif // SYSTRAY_H