Refactor the markerline into a proper QGraphicsWidget
[quassel.git] / src / qtui / mainwin.h
1 /***************************************************************************
2  *   Copyright (C) 2005-09 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 MAINWIN_H_
22 #define MAINWIN_H_
23
24 #ifdef HAVE_KDE
25 #  include <KMainWindow>
26 #else
27 #  include <QMainWindow>
28 #endif
29
30 #include "qtui.h"
31 #include "titlesetter.h"
32 #include "uisettings.h"
33
34 class ActionCollection;
35 class BufferHotListFilter;
36 class BufferView;
37 class BufferViewConfig;
38 class ClientBufferViewConfig;
39 class CoreAccount;
40 class CoreConnectionStatusWidget;
41 class BufferViewDock;
42 class BufferWidget;
43 class InputWidget;
44 class MsgProcessorStatusWidget;
45 class NickListWidget;
46 class SystemTray;
47 class ChatMonitorView;
48 class TopicWidget;
49
50 class QMenu;
51 class QLabel;
52 class QToolBar;
53
54 class KHelpMenu;
55
56 //!\brief The main window of Quassel's QtUi.
57 class MainWin
58 #ifdef HAVE_KDE
59 : public KMainWindow {
60 #else
61 : public QMainWindow {
62 #endif
63   Q_OBJECT
64
65   public:
66     MainWin(QWidget *parent = 0);
67     virtual ~MainWin();
68
69     void init();
70
71     void addBufferView(ClientBufferViewConfig *config);
72     BufferView *allBuffersView() const;
73
74     inline BufferWidget *bufferWidget() const { return _bufferWidget; }
75     inline SystemTray *systemTray() const { return _systemTray; }
76
77     bool event(QEvent *event);
78
79     static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
80     static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
81
82     void saveStateToSettings(UiSettings &);
83     void restoreStateFromSettings(UiSettings &);
84
85   public slots:
86     void showStatusBarMessage(const QString &message);
87
88     //! Quit application
89     void quit();
90
91   protected:
92     void closeEvent(QCloseEvent *event);
93     void moveEvent(QMoveEvent *event);
94     void resizeEvent(QResizeEvent *event);
95
96   protected slots:
97     void connectedToCore();
98     void setConnectedState();
99     void disconnectedFromCore();
100     void setDisconnectedState();
101
102   private slots:
103     void addBufferView(int bufferViewConfigId);
104     void awayLogDestroyed();
105     void removeBufferView(int bufferViewConfigId);
106     void currentBufferChanged(BufferId);
107     void messagesInserted(const QModelIndex &parent, int start, int end);
108     void showAboutDlg();
109     void showChannelList(NetworkId netId = NetworkId());
110     void showCoreConnectionDlg();
111     void showCoreConfigWizard(const QVariantList &);
112     void showCoreInfoDlg();
113     void showAwayLog();
114     void showSettingsDlg();
115     void showNotificationsDlg();
116     void showIgnoreList(QString newRule = QString());
117     void showShortcutsDlg();
118
119     void handleCoreConnectionError(const QString &errorMsg);
120     void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
121     void handleNoSslInClient(bool *accepted);
122     void handleNoSslInCore(bool *accepted);
123 #ifdef HAVE_SSL
124     void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
125 #endif
126
127     void on_actionConfigureNetworks_triggered();
128     void on_actionConfigureViews_triggered();
129     void on_actionLockLayout_toggled(bool lock);
130     void on_jumpHotBuffer_triggered();
131     void on_actionDebugNetworkModel_triggered();
132     void on_actionDebugBufferViewOverlay_triggered();
133     void on_actionDebugMessageModel_triggered();
134     void on_actionDebugHotList_triggered();
135     void on_actionDebugLog_triggered();
136
137     void bindJumpKey();
138     void onJumpKey();
139
140     void clientNetworkCreated(NetworkId);
141     void clientNetworkRemoved(NetworkId);
142     void clientNetworkUpdated();
143     void connectOrDisconnectFromNet();
144
145     void saveMenuBarStatus(bool enabled);
146     void saveStatusBarStatus(bool enabled);
147
148     void loadLayout();
149     void saveLayout();
150
151     void bufferViewToggled(bool enabled);
152
153   signals:
154     void connectToCore(const QVariantMap &connInfo);
155     void disconnectFromCore();
156
157   private:
158 #ifdef HAVE_KDE
159     KHelpMenu *_kHelpMenu;
160 #endif
161
162     MsgProcessorStatusWidget *_msgProcessorStatusWidget;
163     CoreConnectionStatusWidget *_coreConnectionStatusWidget;
164     SystemTray *_systemTray;
165
166     TitleSetter _titleSetter;
167
168     void setupActions();
169     void setupBufferWidget();
170     void setupMenus();
171     void setupNickWidget();
172     void setupChatMonitor();
173     void setupInputWidget();
174     void setupTopicWidget();
175     void setupStatusBar();
176     void setupSystray();
177     void setupTitleSetter();
178     void setupToolBars();
179     void setupHotList();
180
181     void updateIcon();
182     void enableMenus();
183
184     QList<BufferViewDock *> _bufferViews;
185     BufferWidget *_bufferWidget;
186     NickListWidget *_nickListWidget;
187     InputWidget *_inputWidget;
188     ChatMonitorView *_chatMonitorView;
189     TopicWidget *_topicWidget;
190
191     QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
192     QMenu *_toolbarMenu;
193     QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
194
195     QWidget *_awayLog;
196
197     bool _layoutLoaded;
198
199     QSize _normalSize; //!< Size of the non-maximized window
200     QPoint _normalPos; //!< Position of the non-maximized window
201
202     BufferHotListFilter *_bufferHotList;
203     QHash<int, BufferId> _jumpKeyMap;
204
205     friend class QtUi;
206 };
207
208 #endif