1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
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 ***************************************************************************/
31 #if QT_VERSION >= 0x050000
32 # include <QTemporaryDir>
35 #include "abstractnotificationbackend.h"
36 #include "graphicalui.h"
37 #include "qtuistyle.h"
41 class QtUiMessageProcessor;
43 //! This class encapsulates Quassel's Qt-based GUI.
44 /** This is basically a wrapper around MainWin, which is necessary because we cannot derive MainWin
45 * from both QMainWindow and AbstractUi (because of multiple inheritance of QObject).
47 class QtUi : public GraphicalUi
55 MessageModel *createMessageModel(QObject *parent) override;
56 AbstractMessageProcessor *createMessageProcessor(QObject *parent) override;
58 static QtUi *instance();
59 inline static QtUiStyle *style();
60 inline static MainWin *mainWindow();
62 QString debugLog() const;
64 static bool haveSystemTray();
68 static void registerNotificationBackend(AbstractNotificationBackend *);
69 static void unregisterNotificationBackend(AbstractNotificationBackend *);
70 static void unregisterAllNotificationBackends();
71 static const QList<AbstractNotificationBackend *> ¬ificationBackends();
72 static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
75 * Determine available fallback icon themes.
77 * @returns The list of supported fallback themes (Breeze (Dark), Oxygen) that are available on the system
79 std::vector<std::pair<QString, QString>> availableIconThemes() const;
82 * Determine the system icon theme set when Quassel was started.
84 * This property stores the icon theme initially configured in Qt when starting up (may be empty on platforms
85 * not supporting system icon themes). If the --icontheme option is given, uses that.
87 * Since Qt does not support notifications on theme changes, this property will not be updated when the theme
90 * @returns The system icon theme at startup time
92 QString systemIconTheme() const;
97 uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
98 void closeNotification(uint notificationId);
99 void closeNotifications(BufferId bufferId = BufferId());
102 * Refresh the current icon theme.
104 * @note This will not detect changes in the system icon theme, so if that changes, a client restart
105 * is required for icons to work correctly.
107 void refreshIconTheme();
110 void iconThemeRefreshed();
113 void connectedToCore() override;
114 void disconnectedFromCore() override;
115 void notificationActivated(uint notificationId);
116 void bufferMarkedAsRead(BufferId);
119 void minimizeRestore(bool show) override;
120 bool isHidingMainWidgetAllowed() const override;
123 void useSystemTrayChanged(const QVariant &);
127 * Sets up icon theme handling.
129 void setupIconTheme();
132 static QList<AbstractNotificationBackend *> _notificationBackends;
133 static QList<AbstractNotificationBackend::Notification> _notifications;
135 std::unique_ptr<MainWin> _mainWin;
137 QString _systemIconTheme;
139 #if QT_VERSION >= 0x050000
140 std::unique_ptr<QTemporaryDir> _dummyThemeDir;
146 QtUiStyle *QtUi::style() { return qobject_cast<QtUiStyle *>(uiStyle()); }
147 MainWin *QtUi::mainWindow() { return instance()->_mainWin.get(); }