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
54 MessageModel *createMessageModel(QObject *parent) override;
55 AbstractMessageProcessor *createMessageProcessor(QObject *parent) override;
57 static QtUi *instance();
58 inline static QtUiStyle *style();
59 inline static MainWin *mainWindow();
61 QString debugLog() const;
63 static bool haveSystemTray();
67 static void registerNotificationBackend(AbstractNotificationBackend *);
68 static void unregisterNotificationBackend(AbstractNotificationBackend *);
69 static void unregisterAllNotificationBackends();
70 static const QList<AbstractNotificationBackend *> ¬ificationBackends();
71 static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
74 * Determine available fallback icon themes.
76 * @returns The list of supported fallback themes (Breeze (Dark), Oxygen) that are available on the system
78 std::vector<std::pair<QString, QString>> availableIconThemes() const;
81 * Determine the system icon theme set when Quassel was started.
83 * This property stores the icon theme initially configured in Qt when starting up (may be empty on platforms
84 * not supporting system icon themes). If the --icontheme option is given, uses that.
86 * Since Qt does not support notifications on theme changes, this property will not be updated when the theme
89 * @returns The system icon theme at startup time
91 QString systemIconTheme() const;
96 uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
97 void closeNotification(uint notificationId);
98 void closeNotifications(BufferId bufferId = BufferId());
101 * Refresh the current icon theme.
103 * @note This will not detect changes in the system icon theme, so if that changes, a client restart
104 * is required for icons to work correctly.
106 void refreshIconTheme();
109 void iconThemeRefreshed();
112 void connectedToCore() override;
113 void disconnectedFromCore() override;
114 void notificationActivated(uint notificationId);
115 void bufferMarkedAsRead(BufferId);
118 void minimizeRestore(bool show) override;
119 bool isHidingMainWidgetAllowed() const override;
122 void useSystemTrayChanged(const QVariant &);
128 * Sets up icon theme handling.
130 void setupIconTheme();
133 static MainWin *_mainWin;
134 static QList<AbstractNotificationBackend *> _notificationBackends;
135 static QList<AbstractNotificationBackend::Notification> _notifications;
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 _mainWin; }