1 /***************************************************************************
2 * Copyright (C) 2005-2020 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)
50 // same as in QSystemTrayIcon
59 // same as in QSystemTrayIcon
69 enum class AttentionBehavior
76 explicit SystemTray(QWidget* parent);
77 ~SystemTray() override;
81 bool isVisible() const;
82 bool isAlerted() const;
84 virtual bool isSystemTrayAvailable() const;
86 QWidget* associatedWidget() const;
89 void setVisible(bool visible = true);
91 void setAlert(bool alerted);
93 void setToolTip(const QString& title, const QString& subtitle);
94 virtual void showMessage(
95 const QString& title, const QString& message, MessageIcon icon = Information, int msTimeout = 10000, uint notificationId = 0);
96 virtual void closeMessage(uint notificationId);
99 void modeChanged(Mode mode);
100 void stateChanged(State state);
101 void visibilityChanged(bool isVisible);
103 void currentIconNameChanged();
104 void toolTipChanged(const QString& title, const QString& subtitle);
106 void activated(SystemTray::ActivationReason);
107 void messageClicked(uint notificationId);
108 void messageClosed(uint notificationId);
111 virtual void activate(SystemTray::ActivationReason = Trigger);
114 void setMode(Mode mode);
116 QString toolTipTitle() const;
117 QString toolTipSubTitle() const;
118 QMenu* trayMenu() const;
120 QString iconName(State state) const;
121 QString currentIconName() const;
122 QString currentAttentionIconName() const;
125 void minimizeRestore();
126 void trayMenuAboutToShow();
127 void invertTrayIconChanged(const QVariant&);
128 void enableChangeColorChanged(const QVariant&);
129 void enableBlinkChanged(const QVariant&);
131 void onBlinkTimeout();
134 bool _isVisible{false};
135 Mode _mode{Mode::Invalid};
136 State _state{State::Passive};
137 bool _trayIconInverted{false};
138 AttentionBehavior _attentionBehavior{AttentionBehavior::ChangeColor};
141 bool _blinkState{false};
143 QString _toolTipTitle;
144 QString _toolTipSubTitle;
146 QMenu* _trayMenu{nullptr};
147 QWidget* _associatedWidget{nullptr};
148 Action* _minimizeRestoreAction{nullptr};