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 ***************************************************************************/
27 #include <QStringList>
29 #if QT_VERSION >= 0x050000
30 # include <QTemporaryDir>
33 #include "abstractnotificationbackend.h"
34 #include "graphicalui.h"
35 #include "qtuistyle.h"
39 class QtUiMessageProcessor;
41 //! This class encapsulates Quassel's Qt-based GUI.
42 /** This is basically a wrapper around MainWin, which is necessary because we cannot derive MainWin
43 * from both QMainWindow and AbstractUi (because of multiple inheritance of QObject).
45 class QtUi : public GraphicalUi
53 MessageModel *createMessageModel(QObject *parent) override;
54 AbstractMessageProcessor *createMessageProcessor(QObject *parent) override;
56 inline static QtUi *instance();
57 inline static QtUiStyle *style();
58 inline static MainWin *mainWindow();
60 static bool haveSystemTray();
64 static void registerNotificationBackend(AbstractNotificationBackend *);
65 static void unregisterNotificationBackend(AbstractNotificationBackend *);
66 static void unregisterAllNotificationBackends();
67 static const QList<AbstractNotificationBackend *> ¬ificationBackends();
68 static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
71 * Determine available fallback icon themes.
73 * @returns The list of supported fallback themes (Breeze (Dark), Oxygen) that are available on the system
75 std::vector<std::pair<QString, QString>> availableIconThemes() const;
78 * Determine the system icon theme set when Quassel was started.
80 * This property stores the icon theme initially configured in Qt when starting up (may be empty on platforms
81 * not supporting system icon themes). If the --icontheme option is given, uses that.
83 * Since Qt does not support notifications on theme changes, this property will not be updated when the theme
86 * @returns The system icon theme at startup time
88 QString systemIconTheme() const;
93 uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
94 void closeNotification(uint notificationId);
95 void closeNotifications(BufferId bufferId = BufferId());
98 * Refresh the current icon theme.
100 * @note This will not detect changes in the system icon theme, so if that changes, a client restart
101 * is required for icons to work correctly.
103 void refreshIconTheme();
106 void iconThemeRefreshed();
109 void connectedToCore() override;
110 void disconnectedFromCore() override;
111 void notificationActivated(uint notificationId);
112 void bufferMarkedAsRead(BufferId);
115 void minimizeRestore(bool show) override;
116 bool isHidingMainWidgetAllowed() const override;
119 void useSystemTrayChanged(const QVariant &);
123 * Sets up icon theme handling.
125 void setupIconTheme();
128 static QtUi *_instance;
129 static MainWin *_mainWin;
130 static QList<AbstractNotificationBackend *> _notificationBackends;
131 static QList<AbstractNotificationBackend::Notification> _notifications;
133 QString _systemIconTheme;
135 #if QT_VERSION >= 0x050000
136 std::unique_ptr<QTemporaryDir> _dummyThemeDir;
143 QtUi *QtUi::instance() { return _instance ? _instance : new QtUi(); }
144 QtUiStyle *QtUi::style() { return qobject_cast<QtUiStyle *>(uiStyle()); }
145 MainWin *QtUi::mainWindow() { return _mainWin; }