-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathtrayiconmanager.h
More file actions
66 lines (50 loc) · 1.68 KB
/
trayiconmanager.h
File metadata and controls
66 lines (50 loc) · 1.68 KB
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
#include <QObject>
#include <QSystemTrayIcon>
#include "enums.h"
class QMenu;
class QAction;
class QActionGroup;
class TrayIconManager : public QObject
{
Q_OBJECT
Q_PROPERTY(bool notificationsEnabled READ notificationsEnabled WRITE setNotificationsEnabled NOTIFY notificationsEnabledChanged)
public:
explicit TrayIconManager(QObject *parent = nullptr, bool noTray = false);
void updateBatteryStatus(const QString &status);
void updateNoiseControlState(AirpodsTrayApp::Enums::NoiseControlMode);
void updateConversationalAwareness(bool enabled);
void showNotification(const QString &title, const QString &message);
bool notificationsEnabled() const { return m_notificationsEnabled; }
void setNotificationsEnabled(bool enabled)
{
if (m_notificationsEnabled != enabled)
{
m_notificationsEnabled = enabled;
emit notificationsEnabledChanged(enabled);
}
}
void resetTrayIcon()
{
trayIcon->setIcon(QIcon(":/icons/assets/airpods.png"));
trayIcon->setToolTip("");
}
signals:
void notificationsEnabledChanged(bool enabled);
private slots:
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
private:
QSystemTrayIcon *trayIcon;
QMenu *trayMenu;
QAction *caToggleAction;
QActionGroup *noiseControlGroup;
bool m_notificationsEnabled = true;
bool m_noTray = false;
void setupMenuActions();
void updateIconFromBattery(const QString &status);
signals:
void trayClicked();
void noiseControlChanged(AirpodsTrayApp::Enums::NoiseControlMode);
void conversationalAwarenessToggled(bool enabled);
void openApp();
void openSettings();
};