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 ***************************************************************************/
30 class SystemTray : public QObject
33 Q_ENUMS(State Mode MessageIcon ActivationReason)
48 // same as in QSystemTrayIcon
56 // same as in QSystemTrayIcon
57 enum ActivationReason {
65 enum class AttentionBehavior {
71 explicit SystemTray(QWidget *parent);
72 ~SystemTray() override;
76 bool isVisible() const;
77 bool isAlerted() const;
79 virtual bool isSystemTrayAvailable() const;
81 QWidget *associatedWidget() const;
84 void setVisible(bool visible = true);
86 void setAlert(bool alerted);
88 void setToolTip(const QString &title, const QString &subtitle);
89 virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int msTimeout = 10000, uint notificationId = 0);
90 virtual void closeMessage(uint notificationId);
93 void modeChanged(Mode mode);
94 void stateChanged(State state);
95 void visibilityChanged(bool isVisible);
97 void currentIconNameChanged();
98 void toolTipChanged(const QString &title, const QString &subtitle);
100 void activated(SystemTray::ActivationReason);
101 void messageClicked(uint notificationId);
102 void messageClosed(uint notificationId);
105 virtual void activate(SystemTray::ActivationReason = Trigger);
108 void setMode(Mode mode);
110 QString toolTipTitle() const;
111 QString toolTipSubTitle() const;
112 QMenu *trayMenu() const;
114 QString iconName(State state) const;
115 QString currentIconName() const;
116 QString currentAttentionIconName() const;
119 void minimizeRestore();
120 void trayMenuAboutToShow();
121 void invertTrayIconChanged(const QVariant &);
122 void enableChangeColorChanged(const QVariant &);
123 void enableBlinkChanged(const QVariant &);
125 void onBlinkTimeout();
128 bool _isVisible{false};
129 Mode _mode{Mode::Invalid};
130 State _state{State::Passive};
131 bool _trayIconInverted{false};
132 AttentionBehavior _attentionBehavior{AttentionBehavior::ChangeColor};
135 bool _blinkState{false};
137 QString _toolTipTitle;
138 QString _toolTipSubTitle;
140 QMenu *_trayMenu{nullptr};
141 QWidget *_associatedWidget{nullptr};
142 Action *_minimizeRestoreAction{nullptr};