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 ***************************************************************************/
30 #include <QTemporaryDir>
32 #include "abstractnotificationbackend.h"
33 #include "graphicalui.h"
34 #include "qtuistyle.h"
38 class QtUiMessageProcessor;
40 //! This class encapsulates Quassel's Qt-based GUI.
41 /** This is basically a wrapper around MainWin, which is necessary because we cannot derive MainWin
42 * from both QMainWindow and AbstractUi (because of multiple inheritance of QObject).
44 class QtUi : public GraphicalUi
52 MessageModel *createMessageModel(QObject *parent) override;
53 AbstractMessageProcessor *createMessageProcessor(QObject *parent) override;
55 static QtUi *instance();
56 inline static QtUiStyle *style();
57 inline static MainWin *mainWindow();
59 QString debugLog() const;
61 static bool haveSystemTray();
65 static void registerNotificationBackend(AbstractNotificationBackend *);
66 static void unregisterNotificationBackend(AbstractNotificationBackend *);
67 static void unregisterAllNotificationBackends();
68 static const QList<AbstractNotificationBackend *> ¬ificationBackends();
69 static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
72 * Determine available fallback icon themes.
74 * @returns The list of supported fallback themes (Breeze (Dark), Oxygen) that are available on the system
76 std::vector<std::pair<QString, QString>> availableIconThemes() const;
79 * Determine the system icon theme set when Quassel was started.
81 * This property stores the icon theme initially configured in Qt when starting up (may be empty on platforms
82 * not supporting system icon themes). If the --icontheme option is given, uses that.
84 * Since Qt does not support notifications on theme changes, this property will not be updated when the theme
87 * @returns The system icon theme at startup time
89 QString systemIconTheme() const;
94 uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
95 void closeNotification(uint notificationId);
96 void closeNotifications(BufferId bufferId = BufferId());
99 * Refresh the current icon theme.
101 * @note This will not detect changes in the system icon theme, so if that changes, a client restart
102 * is required for icons to work correctly.
104 void refreshIconTheme();
107 void iconThemeRefreshed();
110 void connectedToCore() override;
111 void disconnectedFromCore() override;
112 void notificationActivated(uint notificationId);
113 void bufferMarkedAsRead(BufferId);
116 void minimizeRestore(bool show) override;
117 bool isHidingMainWidgetAllowed() const override;
120 void useSystemTrayChanged(const QVariant &);
124 * Sets up icon theme handling.
126 void setupIconTheme();
129 static QList<AbstractNotificationBackend *> _notificationBackends;
130 static QList<AbstractNotificationBackend::Notification> _notifications;
132 std::unique_ptr<MainWin> _mainWin;
134 QString _systemIconTheme;
136 std::unique_ptr<QTemporaryDir> _dummyThemeDir;
141 QtUiStyle *QtUi::style() { return qobject_cast<QtUiStyle *>(uiStyle()); }
142 MainWin *QtUi::mainWindow() { return instance()->_mainWin.get(); }