1 /***************************************************************************
2 * Copyright (C) 2005-09 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 #include "quasselui.h"
26 #include "abstractnotificationbackend.h"
29 class ActionCollection;
32 class QtUiMessageProcessor;
35 //! This class encapsulates Quassel's Qt-based GUI.
36 /** This is basically a wrapper around MainWin, which is necessary because we cannot derive MainWin
37 * from both QMainWindow and AbstractUi (because of multiple inheritance of QObject).
39 class QtUi : public AbstractUi {
46 MessageModel *createMessageModel(QObject *parent);
47 AbstractMessageProcessor *createMessageProcessor(QObject *parent);
49 inline static QtUi *instance();
50 inline static QtUiStyle *style();
51 inline static MainWin *mainWindow();
53 //! Access global ActionCollections.
54 /** These ActionCollections are associated with the main window, i.e. they contain global
55 * actions (and thus, shortcuts). Widgets providing application-wide shortcuts should
56 * create appropriate Action objects using QtUi::actionCollection(cat)->add\<Action\>().
57 * @param category The category (default: "General")
59 static ActionCollection *actionCollection(const QString &category = "General");
60 inline AbstractActionProvider *actionProvider() const;
64 static void registerNotificationBackend(AbstractNotificationBackend *);
65 static void unregisterNotificationBackend(AbstractNotificationBackend *);
66 static void unregisterAllNotificationBackends();
67 static const QList<AbstractNotificationBackend *> ¬ificationBackends();
68 static uint invokeNotification(BufferId bufId, const QString &sender, const QString &text);
69 static void closeNotification(uint notificationId);
70 static void closeNotifications(BufferId bufferId = BufferId());
71 static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
77 void connectedToCore();
78 void disconnectedFromCore();
79 void notificationActivated();
82 AbstractActionProvider *_actionProvider;
84 static QPointer<QtUi> _instance;
85 static QPointer<MainWin> _mainWin;
86 static QHash<QString, ActionCollection *> _actionCollections;
87 static QtUiStyle *_style;
88 static QList<AbstractNotificationBackend *> _notificationBackends;
89 static QList<AbstractNotificationBackend::Notification> _notifications;
92 QtUi *QtUi::instance() { return _instance ? _instance.data() : new QtUi(); }
93 QtUiStyle *QtUi::style() { return _style; }
94 MainWin *QtUi::mainWindow() { return _mainWin; }
95 AbstractActionProvider *QtUi::actionProvider() const { return _actionProvider; }