1 // usystemtray.h - A system tray and notification area
2 // Copyright (C) 2012  Konrad Twardowski
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 
18 #ifndef KSHUTDOWN_USYSTEMTRAY_H
19 #define KSHUTDOWN_USYSTEMTRAY_H
20 
21 #ifdef KS_KF5
22 	#include <KStatusNotifierItem>
23 #else
24 	#include <QSystemTrayIcon>
25 #endif // KS_KF5
26 
27 class MainWindow;
28 
29 class USystemTray: public QObject {
30 	Q_OBJECT
31 public:
32 	explicit USystemTray(MainWindow *mainWindow);
33 	virtual ~USystemTray() = default;
34 	void info(const QString &message) const;
35 	bool isSupported() const;
36 	void setToolTip(const QString &toolTip);
37 	void setVisible(const bool visible);
38 	void updateIcon(MainWindow *mainWindow);
39 	void warning(const QString &message) const;
40 private:
41 	Q_DISABLE_COPY(USystemTray)
42 	#ifdef KS_KF5
43 	KStatusNotifierItem *m_trayIcon = nullptr;
44 	#else
45 	bool m_applyIconHack = true;
46 	bool m_sessionRestored;
47 	QSystemTrayIcon *m_trayIcon = nullptr;
48 	#endif // KS_KF5
49 	QString m_toolTip = QString();
50 #ifdef KS_PURE_QT
51 private slots:
52 	void onRestore(QSystemTrayIcon::ActivationReason reason);
53 #endif // KS_PURE_QT
54 };
55 
56 #endif // KSHUTDOWN_USYSTEMTRAY_H
57