1 /***************************************************************************
2 * Copyright (C) 2005-2018 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 showNetworkConfig(NetworkId netId = NetworkId());
123 void showCoreConnectionDlg();
124 void showCoreConfigWizard(const QVariantList &, const QVariantList &);
125 void showCoreInfoDlg();
127 void showSettingsDlg();
128 void showNotificationsDlg();
129 void showIgnoreList(QString newRule = QString());
130 void showShortcutsDlg();
131 void showPasswordChangeDlg();
132 void showNewTransferDlg(const QUuid &transferId);
133 void onFullScreenToggled();
135 void handleCoreConnectionError(const QString &errorMsg);
136 void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
137 void handleNoSslInClient(bool *accepted);
138 void handleNoSslInCore(bool *accepted);
140 void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
143 void on_actionConfigureNetworks_triggered();
144 void on_actionConfigureViews_triggered();
145 void on_actionLockLayout_toggled(bool lock);
148 * Apply the active color to the input widget selected or typed text
150 * @seealso InputWidget::applyFormatActiveColor()
152 void on_inputFormatApplyColor_triggered();
155 * Apply the active fill color to the input widget selected or typed text background
157 * @seealso InputWidget::applyFormatActiveColorFill()
159 void on_inputFormatApplyColorFill_triggered();
162 * Toggle the boldness of the input widget selected or typed text
164 * @seealso InputWidget::toggleFormatBold()
166 void on_inputFormatBold_triggered();
169 * Toggle the italicness of the input widget selected or typed text
171 * @seealso InputWidget::toggleFormatItalic()
173 void on_inputFormatItalic_triggered();
176 * Toggle the underlining of the input widget selected or typed text
178 * @seealso InputWidget::toggleFormatUnderline()
180 void on_inputFormatUnderline_triggered();
183 * Clear the formatting of the input widget selected or typed text
185 * @seealso InputWidget::clearFormat()
187 void on_inputFormatClear_triggered();
189 void on_jumpHotBuffer_triggered();
190 void on_bufferSearch_triggered();
191 void on_actionDebugNetworkModel_triggered();
192 void on_actionDebugBufferViewOverlay_triggered();
193 void on_actionDebugMessageModel_triggered();
194 void on_actionDebugHotList_triggered();
195 void on_actionDebugLog_triggered();
200 void clientNetworkCreated(NetworkId);
201 void clientNetworkRemoved(NetworkId);
202 void clientNetworkUpdated();
203 void connectOrDisconnectFromNet();
205 void saveMenuBarStatus(bool enabled);
206 void saveStatusBarStatus(bool enabled);
207 void saveMainToolBarStatus(bool enabled);
212 void bufferViewToggled(bool enabled);
213 void bufferViewVisibilityChanged(bool visible);
214 void changeActiveBufferView(bool backwards);
215 void changeActiveBufferView(int bufferViewId);
218 void connectToCore(const QVariantMap &connInfo);
219 void disconnectFromCore();
223 KHelpMenu *_kHelpMenu;
226 MsgProcessorStatusWidget *_msgProcessorStatusWidget;
227 CoreConnectionStatusWidget *_coreConnectionStatusWidget;
228 SystemTray *_systemTray;
230 TitleSetter _titleSetter;
233 void setupBufferWidget();
235 void setupNickWidget();
236 void setupChatMonitor();
237 void setupInputWidget();
238 void setupTopicWidget();
239 void setupTransferWidget();
240 void setupViewMenuTail();
241 void setupStatusBar();
243 void setupTitleSetter();
244 void setupToolBars();
250 QList<BufferViewDock *> _bufferViews;
251 BufferWidget *_bufferWidget;
252 NickListWidget *_nickListWidget;
253 InputWidget *_inputWidget;
254 ChatMonitorView *_chatMonitorView;
255 TopicWidget *_topicWidget;
257 QAction *_fullScreenAction;
258 QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
260 QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
266 QSize _normalSize; //!< Size of the non-maximized window
267 QPoint _normalPos; //!< Position of the non-maximized window
269 BufferHotListFilter *_bufferHotList;
270 QHash<int, BufferId> _jumpKeyMap;
271 int _activeBufferViewIndex;
273 bool _aboutToQuit; //closeEvent can occur multiple times on OSX