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;
80 uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
81 void closeNotification(uint notificationId);
82 void closeNotifications(BufferId bufferId = BufferId());
85 * Refresh the current icon theme.
87 * @note This will not detect changes in the system icon theme, so if that changes, a client restart
88 * is required for icons to work correctly.
90 void refreshIconTheme();
93 void iconThemeRefreshed();
96 void connectedToCore() override;
97 void disconnectedFromCore() override;
98 void notificationActivated(uint notificationId);
99 void bufferMarkedAsRead(BufferId);
102 void minimizeRestore(bool show) override;
103 bool isHidingMainWidgetAllowed() const override;
106 void useSystemTrayChanged(const QVariant &);
110 * Sets up icon theme handling.
112 void setupIconTheme();
115 static QtUi *_instance;
116 static MainWin *_mainWin;
117 static QList<AbstractNotificationBackend *> _notificationBackends;
118 static QList<AbstractNotificationBackend::Notification> _notifications;
120 QString _systemIconTheme;
122 #if QT_VERSION >= 0x050000
123 std::unique_ptr<QTemporaryDir> _dummyThemeDir;
130 QtUi *QtUi::instance() { return _instance ? _instance : new QtUi(); }
131 QtUiStyle *QtUi::style() { return qobject_cast<QtUiStyle *>(uiStyle()); }
132 MainWin *QtUi::mainWindow() { return _mainWin; }