db06409c3651306bae5c7c3cd4f982f8ecc831f2
[quassel.git] / src / qtui / qtui.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #ifndef QTUI_H
22 #define QTUI_H
23
24 #include "quasselui.h"
25
26 #include "abstractnotificationbackend.h"
27
28 class ActionCollection;
29 class MainWin;
30 class MessageModel;
31 class QtUiMessageProcessor;
32 class QtUiStyle;
33
34 //! This class encapsulates Quassel's Qt-based GUI.
35 /** This is basically a wrapper around MainWin, which is necessary because we cannot derive MainWin
36  *  from both QMainWindow and AbstractUi (because of multiple inheritance of QObject).
37  */
38 class QtUi : public AbstractUi {
39   Q_OBJECT
40
41 public:
42   QtUi();
43   ~QtUi();
44
45   MessageModel *createMessageModel(QObject *parent);
46   AbstractMessageProcessor *createMessageProcessor(QObject *parent);
47
48   inline static QtUiStyle *style();
49   inline static MainWin *mainWindow();
50
51   //! Access the global ActionCollection.
52   /** This ActionCollection is associated with the main window, i.e. it contains global
53    *  actions (and thus, shortcuts). Widgets providing application-wide shortcuts should
54    *  create appropriate Action objects using QtUi::actionCollection()->add\<Action\>().
55    */
56   inline static ActionCollection *actionCollection();
57
58   /* Notifications */
59
60   static void registerNotificationBackend(AbstractNotificationBackend *);
61   static void unregisterNotificationBackend(AbstractNotificationBackend *);
62   static void unregisterAllNotificationBackends();
63   static const QSet<AbstractNotificationBackend *> &notificationBackends();
64   static uint invokeNotification(BufferId bufId, const QString &sender, const QString &text);
65   static void closeNotification(uint notificationId);
66   static void closeNotifications(BufferId bufferId = BufferId());
67   static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
68
69 public slots:
70   void init();
71
72 protected slots:
73   void connectedToCore();
74   void disconnectedFromCore();
75
76 private:
77   static MainWin *_mainWin;
78   static ActionCollection *_actionCollection;
79   static QtUiStyle *_style;
80   static QSet<AbstractNotificationBackend *> _notificationBackends;
81   static QList<AbstractNotificationBackend::Notification> _notifications;
82 };
83
84 ActionCollection *QtUi::actionCollection() { return _actionCollection; }
85 QtUiStyle *QtUi::style() { return _style; }
86 MainWin *QtUi::mainWindow() { return _mainWin; }
87
88 #endif