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