1 /***************************************************************************
2 * Copyright (C) 2005-2016 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
26 # include <KMainWindow>
27 #elif defined HAVE_KF5
28 # include <KXmlGui/KMainWindow>
30 # include <QMainWindow>
34 #include "titlesetter.h"
35 #include "uisettings.h"
37 class ActionCollection;
38 class BufferHotListFilter;
40 class BufferViewConfig;
41 class ChatMonitorView;
42 class ClientBufferViewConfig;
44 class CoreConnectionStatusWidget;
48 class MsgProcessorStatusWidget;
59 //!\brief The main window of Quassel's QtUi.
62 : public KMainWindow {
64 : public QMainWindow {
69 MainWin(QWidget *parent = 0);
74 void addBufferView(ClientBufferViewConfig *config);
75 BufferView *allBuffersView() const;
76 BufferView *activeBufferView() const;
78 inline BufferWidget *bufferWidget() const { return _bufferWidget; }
79 inline SystemTray *systemTray() const { return _systemTray; }
81 bool event(QEvent *event);
83 static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
84 static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
86 void saveStateToSettings(UiSettings &);
87 void restoreStateFromSettings(UiSettings &);
89 // We need to override this to add the show/hide menu bar option
90 virtual QMenu *createPopupMenu();
93 void showStatusBarMessage(const QString &message);
94 void hideCurrentBuffer();
95 void nextBufferView(); //!< Activate the next bufferview
96 void previousBufferView(); //!< Activate the previous bufferview
98 void previousBuffer();
104 void closeEvent(QCloseEvent *event);
105 void moveEvent(QMoveEvent *event);
106 void resizeEvent(QResizeEvent *event);
109 void connectedToCore();
110 void setConnectedState();
111 void disconnectedFromCore();
112 void setDisconnectedState();
115 void addBufferView(int bufferViewConfigId);
116 void awayLogDestroyed();
117 void removeBufferView(int bufferViewConfigId);
118 void currentBufferChanged(BufferId);
119 void messagesInserted(const QModelIndex &parent, int start, int end);
121 void showChannelList(NetworkId netId = NetworkId());
122 void showCoreConnectionDlg();
123 void showCoreConfigWizard(const QVariantList &, const QVariantList &);
124 void showCoreInfoDlg();
126 void showSettingsDlg();
127 void showNotificationsDlg();
128 void showIgnoreList(QString newRule = QString());
129 void showShortcutsDlg();
130 void showPasswordChangeDlg();
131 void showNewTransferDlg(const QUuid &transferId);
132 void onFullScreenToggled();
134 void handleCoreConnectionError(const QString &errorMsg);
135 void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
136 void handleNoSslInClient(bool *accepted);
137 void handleNoSslInCore(bool *accepted);
139 void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
142 void on_actionConfigureNetworks_triggered();
143 void on_actionConfigureViews_triggered();
144 void on_actionLockLayout_toggled(bool lock);
145 void on_jumpHotBuffer_triggered();
146 void on_bufferSearch_triggered();
147 void on_actionDebugNetworkModel_triggered();
148 void on_actionDebugBufferViewOverlay_triggered();
149 void on_actionDebugMessageModel_triggered();
150 void on_actionDebugHotList_triggered();
151 void on_actionDebugLog_triggered();
156 void clientNetworkCreated(NetworkId);
157 void clientNetworkRemoved(NetworkId);
158 void clientNetworkUpdated();
159 void connectOrDisconnectFromNet();
161 void saveMenuBarStatus(bool enabled);
162 void saveStatusBarStatus(bool enabled);
163 void saveMainToolBarStatus(bool enabled);
168 void bufferViewToggled(bool enabled);
169 void bufferViewVisibilityChanged(bool visible);
170 void changeActiveBufferView(bool backwards);
171 void changeActiveBufferView(int bufferViewId);
174 void connectToCore(const QVariantMap &connInfo);
175 void disconnectFromCore();
179 KHelpMenu *_kHelpMenu;
182 MsgProcessorStatusWidget *_msgProcessorStatusWidget;
183 CoreConnectionStatusWidget *_coreConnectionStatusWidget;
184 SystemTray *_systemTray;
186 TitleSetter _titleSetter;
189 void setupBufferWidget();
191 void setupNickWidget();
192 void setupChatMonitor();
193 void setupInputWidget();
194 void setupTopicWidget();
195 void setupTransferWidget();
196 void setupViewMenuTail();
197 void setupStatusBar();
199 void setupTitleSetter();
200 void setupToolBars();
206 QList<BufferViewDock *> _bufferViews;
207 BufferWidget *_bufferWidget;
208 NickListWidget *_nickListWidget;
209 InputWidget *_inputWidget;
210 ChatMonitorView *_chatMonitorView;
211 TopicWidget *_topicWidget;
213 QAction *_fullScreenAction;
214 QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
216 QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
222 QSize _normalSize; //!< Size of the non-maximized window
223 QPoint _normalPos; //!< Position of the non-maximized window
225 BufferHotListFilter *_bufferHotList;
226 QHash<int, BufferId> _jumpKeyMap;
227 int _activeBufferViewIndex;
229 bool _aboutToQuit; //closeEvent can occur multiple times on OSX