1 /***************************************************************************
2 * Copyright (C) 2005-2015 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 ***************************************************************************/
24 # include <KMainWindow>
25 #elif defined HAVE_KF5
26 # include <KXmlGui/KMainWindow>
28 # include <QMainWindow>
32 #include "titlesetter.h"
33 #include "uisettings.h"
35 class ActionCollection;
36 class BufferHotListFilter;
38 class BufferViewConfig;
39 class ClientBufferViewConfig;
42 class CoreConnectionStatusWidget;
46 class MsgProcessorStatusWidget;
49 class ChatMonitorView;
58 //!\brief The main window of Quassel's QtUi.
61 : public KMainWindow {
63 : public QMainWindow {
68 MainWin(QWidget *parent = 0);
73 void addBufferView(ClientBufferViewConfig *config);
74 BufferView *allBuffersView() const;
75 BufferView *activeBufferView() const;
77 inline BufferWidget *bufferWidget() const { return _bufferWidget; }
78 inline SystemTray *systemTray() const { return _systemTray; }
80 bool event(QEvent *event);
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(); }
85 void saveStateToSettings(UiSettings &);
86 void restoreStateFromSettings(UiSettings &);
88 // We need to override this to add the show/hide menu bar option
89 virtual QMenu *createPopupMenu();
92 void showStatusBarMessage(const QString &message);
93 void hideCurrentBuffer();
94 void nextBufferView(); //!< Activate the next bufferview
95 void previousBufferView(); //!< Activate the previous bufferview
97 void previousBuffer();
103 void closeEvent(QCloseEvent *event);
104 void moveEvent(QMoveEvent *event);
105 void resizeEvent(QResizeEvent *event);
108 void connectedToCore();
109 void setConnectedState();
110 void disconnectedFromCore();
111 void setDisconnectedState();
114 void addBufferView(int bufferViewConfigId);
115 void awayLogDestroyed();
116 void removeBufferView(int bufferViewConfigId);
117 void currentBufferChanged(BufferId);
118 void messagesInserted(const QModelIndex &parent, int start, int end);
120 void showChannelList(NetworkId netId = NetworkId());
121 void showCoreConnectionDlg();
122 void showCoreConfigWizard(const QVariantList &);
123 void showCoreInfoDlg();
125 void showSettingsDlg();
126 void showNotificationsDlg();
127 void showIgnoreList(QString newRule = QString());
128 void showShortcutsDlg();
129 void showPasswordChangeDlg();
130 void showNewTransferDlg(const ClientTransfer *transfer);
131 void onFullScreenToggled();
133 void handleCoreConnectionError(const QString &errorMsg);
134 void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
135 void handleNoSslInClient(bool *accepted);
136 void handleNoSslInCore(bool *accepted);
138 void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
141 void on_actionConfigureNetworks_triggered();
142 void on_actionConfigureViews_triggered();
143 void on_actionLockLayout_toggled(bool lock);
144 void on_jumpHotBuffer_triggered();
145 void on_actionDebugNetworkModel_triggered();
146 void on_actionDebugBufferViewOverlay_triggered();
147 void on_actionDebugMessageModel_triggered();
148 void on_actionDebugHotList_triggered();
149 void on_actionDebugLog_triggered();
154 void clientNetworkCreated(NetworkId);
155 void clientNetworkRemoved(NetworkId);
156 void clientNetworkUpdated();
157 void connectOrDisconnectFromNet();
159 void saveMenuBarStatus(bool enabled);
160 void saveStatusBarStatus(bool enabled);
161 void saveMainToolBarStatus(bool enabled);
166 void bufferViewToggled(bool enabled);
167 void bufferViewVisibilityChanged(bool visible);
168 void changeActiveBufferView(bool backwards);
169 void changeActiveBufferView(int bufferViewId);
172 void connectToCore(const QVariantMap &connInfo);
173 void disconnectFromCore();
177 KHelpMenu *_kHelpMenu;
180 MsgProcessorStatusWidget *_msgProcessorStatusWidget;
181 CoreConnectionStatusWidget *_coreConnectionStatusWidget;
182 SystemTray *_systemTray;
184 TitleSetter _titleSetter;
187 void setupBufferWidget();
189 void setupNickWidget();
190 void setupChatMonitor();
191 void setupInputWidget();
192 void setupTopicWidget();
193 void setupViewMenuTail();
194 void setupStatusBar();
196 void setupTitleSetter();
197 void setupToolBars();
203 QList<BufferViewDock *> _bufferViews;
204 BufferWidget *_bufferWidget;
205 NickListWidget *_nickListWidget;
206 InputWidget *_inputWidget;
207 ChatMonitorView *_chatMonitorView;
208 TopicWidget *_topicWidget;
210 QAction *_fullScreenAction;
211 QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
213 QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
219 QSize _normalSize; //!< Size of the non-maximized window
220 QPoint _normalPos; //!< Position of the non-maximized window
222 BufferHotListFilter *_bufferHotList;
223 QHash<int, BufferId> _jumpKeyMap;
224 int _activeBufferViewIndex;
226 bool _aboutToQuit; //closeEvent can occur multiple times on OSX