Add a shortcut for hiding current buffer.
[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     BufferView *activeBufferView() const;
74
75     inline BufferWidget *bufferWidget() const { return _bufferWidget; }
76     inline SystemTray *systemTray() const { return _systemTray; }
77
78     bool event(QEvent *event);
79
80     static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
81     static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
82
83     void saveStateToSettings(UiSettings &);
84     void restoreStateFromSettings(UiSettings &);
85
86   public slots:
87     void showStatusBarMessage(const QString &message);
88     void hideCurrentBuffer();
89     void nextBufferView();     //!< Activate the next bufferview
90     void previousBufferView(); //!< Activate the previous bufferview
91     void nextBuffer();
92     void previousBuffer();
93
94     //! Quit application
95     void quit();
96
97   protected:
98     void closeEvent(QCloseEvent *event);
99     void moveEvent(QMoveEvent *event);
100     void resizeEvent(QResizeEvent *event);
101
102   protected slots:
103     void connectedToCore();
104     void setConnectedState();
105     void disconnectedFromCore();
106     void setDisconnectedState();
107
108   private slots:
109     void addBufferView(int bufferViewConfigId);
110     void awayLogDestroyed();
111     void removeBufferView(int bufferViewConfigId);
112     void currentBufferChanged(BufferId);
113     void messagesInserted(const QModelIndex &parent, int start, int end);
114     void showAboutDlg();
115     void showChannelList(NetworkId netId = NetworkId());
116     void showCoreConnectionDlg();
117     void showCoreConfigWizard(const QVariantList &);
118     void showCoreInfoDlg();
119     void showAwayLog();
120     void showSettingsDlg();
121     void showNotificationsDlg();
122     void showIgnoreList(QString newRule = QString());
123     void showShortcutsDlg();
124     void toggleFullscreen();
125
126     void handleCoreConnectionError(const QString &errorMsg);
127     void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
128     void handleNoSslInClient(bool *accepted);
129     void handleNoSslInCore(bool *accepted);
130 #ifdef HAVE_SSL
131     void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
132 #endif
133
134     void on_actionConfigureNetworks_triggered();
135     void on_actionConfigureViews_triggered();
136     void on_actionLockLayout_toggled(bool lock);
137     void on_jumpHotBuffer_triggered();
138     void on_actionDebugNetworkModel_triggered();
139     void on_actionDebugBufferViewOverlay_triggered();
140     void on_actionDebugMessageModel_triggered();
141     void on_actionDebugHotList_triggered();
142     void on_actionDebugLog_triggered();
143
144     void bindJumpKey();
145     void onJumpKey();
146
147     void clientNetworkCreated(NetworkId);
148     void clientNetworkRemoved(NetworkId);
149     void clientNetworkUpdated();
150     void connectOrDisconnectFromNet();
151
152     void saveMenuBarStatus(bool enabled);
153     void saveStatusBarStatus(bool enabled);
154
155     void loadLayout();
156     void saveLayout();
157
158     void bufferViewToggled(bool enabled);
159     void bufferViewVisibilityChanged(bool visible);
160     void changeActiveBufferView(bool backwards);
161     void changeActiveBufferView(int bufferViewId);
162
163   signals:
164     void connectToCore(const QVariantMap &connInfo);
165     void disconnectFromCore();
166
167   private:
168 #ifdef HAVE_KDE
169     KHelpMenu *_kHelpMenu;
170 #endif
171
172     MsgProcessorStatusWidget *_msgProcessorStatusWidget;
173     CoreConnectionStatusWidget *_coreConnectionStatusWidget;
174     SystemTray *_systemTray;
175
176     TitleSetter _titleSetter;
177
178     void setupActions();
179     void setupBufferWidget();
180     void setupMenus();
181     void setupNickWidget();
182     void setupChatMonitor();
183     void setupInputWidget();
184     void setupTopicWidget();
185     void setupViewMenuTail();
186     void setupStatusBar();
187     void setupSystray();
188     void setupTitleSetter();
189     void setupToolBars();
190     void setupHotList();
191
192     void updateIcon();
193     void enableMenus();
194
195     QList<BufferViewDock *> _bufferViews;
196     BufferWidget *_bufferWidget;
197     NickListWidget *_nickListWidget;
198     InputWidget *_inputWidget;
199     ChatMonitorView *_chatMonitorView;
200     TopicWidget *_topicWidget;
201
202     QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
203     QMenu *_toolbarMenu;
204     QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
205
206     QWidget *_awayLog;
207
208     bool _layoutLoaded;
209
210     QSize _normalSize; //!< Size of the non-maximized window
211     QPoint _normalPos; //!< Position of the non-maximized window
212
213     BufferHotListFilter *_bufferHotList;
214     QHash<int, BufferId> _jumpKeyMap;
215     int _activeBufferViewIndex;
216
217     friend class QtUi;
218 };
219
220 #endif