Fix wordwrap when using Qt > 4.6.3
[quassel.git] / src / qtui / qtui.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2010 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 "graphicalui.h"
25
26 #include "abstractnotificationbackend.h"
27 #include "qtuistyle.h"
28
29 class MainWin;
30 class MessageModel;
31 class QtUiMessageProcessor;
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 GraphicalUi {
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 QtUi *instance();
48   inline static QtUiStyle *style();
49   inline static MainWin *mainWindow();
50
51   static bool haveSystemTray();
52
53   /* Notifications */
54
55   static void registerNotificationBackend(AbstractNotificationBackend *);
56   static void unregisterNotificationBackend(AbstractNotificationBackend *);
57   static void unregisterAllNotificationBackends();
58   static const QList<AbstractNotificationBackend *> &notificationBackends();
59   static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
60
61 public slots:
62   virtual void init();
63
64   uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
65   void closeNotification(uint notificationId);
66   void closeNotifications(BufferId bufferId = BufferId());
67
68 protected slots:
69   void connectedToCore();
70   void disconnectedFromCore();
71   void notificationActivated(uint notificationId);
72   void bufferMarkedAsRead(BufferId);
73
74 protected:
75   virtual void minimizeRestore(bool show);
76   virtual bool isHidingMainWidgetAllowed() const;
77
78 private slots:
79   void useSystemTrayChanged(const QVariant &);
80
81 private:
82   static QtUi *_instance;
83   static MainWin *_mainWin;
84   static QList<AbstractNotificationBackend *> _notificationBackends;
85   static QList<AbstractNotificationBackend::Notification> _notifications;
86
87   bool _useSystemTray;
88 };
89
90 QtUi *QtUi::instance() { return _instance ? _instance : new QtUi(); }
91 QtUiStyle *QtUi::style() { return qobject_cast<QtUiStyle*>(uiStyle()); }
92 MainWin *QtUi::mainWindow() { return _mainWin; }
93
94 #endif