33eb1b8766deb3df77e41e4caa769ef0d3648d2d
[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 class AbstractNotificationBackend;
27 class ActionCollection;
28 class MainWin;
29 class MessageModel;
30 class QtUiMessageProcessor;
31 class QtUiStyle;
32
33 //! This class encapsulates Quassel's Qt-based GUI.
34 /** This is basically a wrapper around MainWin, which is necessary because we cannot derive MainWin
35  *  from both QMainWindow and AbstractUi (because of multiple inheritance of QObject).
36  */
37 class QtUi : public AbstractUi {
38   Q_OBJECT
39
40 public:
41   QtUi();
42   ~QtUi();
43
44   MessageModel *createMessageModel(QObject *parent);
45   AbstractMessageProcessor *createMessageProcessor(QObject *parent);
46
47   inline static QtUiStyle *style();
48
49   //! Access the global ActionCollection.
50   /** This ActionCollection is associated with the main window, i.e. it contains global
51    *  actions (and thus, shortcuts). Widgets providing application-wide shortcuts should
52    *  create appropriate Action objects using QtUi::actionCollection()->add\<Action\>().
53    */
54   inline static ActionCollection *actionCollection();
55
56   static void registerNotificationBackend(AbstractNotificationBackend *);
57   static void unregisterNotificationBackend(AbstractNotificationBackend *);
58   static void unregisterAllNotificationBackends();
59   static void notify(BufferId bufId, const QString &sender, const QString &text);
60
61 public slots:
62   void init();
63
64 protected slots:
65   void connectedToCore();
66   void disconnectedFromCore();
67
68 private:
69   MainWin *mainWin;
70   static ActionCollection *_actionCollection;
71   static QtUiStyle *_style;
72   static QSet<AbstractNotificationBackend *> _notificationBackends;
73 };
74
75 ActionCollection *QtUi::actionCollection() { return _actionCollection; }
76 QtUiStyle *QtUi::style() { return _style; }
77
78 #endif