1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This file is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Library General Public License (LGPL) *
7 * as published by the Free Software Foundation; either version 2 of the *
8 * License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
29 class SystemTray : public QObject
32 Q_ENUMS(State Mode MessageIcon ActivationReason)
47 // same as in QSystemTrayIcon
55 // same as in QSystemTrayIcon
56 enum ActivationReason {
64 explicit SystemTray(QWidget *parent);
65 ~SystemTray() override;
69 bool isVisible() const;
70 bool isAlerted() const;
72 virtual bool isSystemTrayAvailable() const;
74 QWidget *associatedWidget() const;
77 void setVisible(bool visible = true);
79 void setAlert(bool alerted);
81 void setToolTip(const QString &title, const QString &subtitle);
82 virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int msTimeout = 10000, uint notificationId = 0);
83 virtual void closeMessage(uint notificationId);
86 void modeChanged(Mode mode);
87 void stateChanged(State state);
88 void visibilityChanged(bool isVisible);
90 void animationEnabledChanged(bool);
91 void toolTipChanged(const QString &title, const QString &subtitle);
93 void activated(SystemTray::ActivationReason);
94 void messageClicked(uint notificationId);
95 void messageClosed(uint notificationId);
98 virtual void activate(SystemTray::ActivationReason = Trigger);
101 void setMode(Mode mode);
102 bool animationEnabled() const;
104 QString toolTipTitle() const;
105 QString toolTipSubTitle() const;
106 QMenu *trayMenu() const;
108 QString iconName(State state) const;
111 void minimizeRestore();
112 void trayMenuAboutToShow();
113 void enableAnimationChanged(const QVariant &);
114 void invertTrayIconChanged(const QVariant &);
117 bool _isVisible{false};
118 Mode _mode{Mode::Invalid};
119 State _state{State::Passive};
120 bool _animationEnabled{true};
121 bool _trayIconInverted{false};
123 QString _toolTipTitle, _toolTipSubTitle;
125 QMenu *_trayMenu{nullptr};
126 QWidget *_associatedWidget{nullptr};
127 Action *_minimizeRestoreAction{nullptr};