1 /***************************************************************************
2 * Copyright (C) 2005-2020 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 <KXmlGui/KMainWindow>
28 # include <QMainWindow>
32 #include "titlesetter.h"
33 #include "uisettings.h"
35 class ActionCollection;
36 class BufferHotListFilter;
38 class BufferViewConfig;
39 class ChatMonitorView;
40 class ClientBufferViewConfig;
42 class CoreConnectionStatusWidget;
46 class MsgProcessorStatusWidget;
58 //!\brief The main window of Quassel's QtUi.
70 MainWin(QWidget* parent = nullptr);
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) override;
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 QMenu* createPopupMenu() override;
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();
100 void showMigrationWarning(bool show);
102 void onExitRequested(const QString& reason);
105 void closeEvent(QCloseEvent* event) override;
106 void moveEvent(QMoveEvent* event) override;
107 void resizeEvent(QResizeEvent* event) override;
110 void connectedToCore();
111 void setConnectedState();
112 void disconnectedFromCore();
113 void setDisconnectedState();
116 void addBufferView(int bufferViewConfigId);
117 void awayLogDestroyed();
118 void removeBufferView(int bufferViewConfigId);
119 void currentBufferChanged(BufferId);
120 void messagesInserted(const QModelIndex& parent, int start, int end);
124 * Show the channel list dialog for the network, optionally searching by channel name
126 * @param networkId Network ID for associated network
127 * @param channelFilters Partial channel name to search for, or empty to show all
128 * @param listImmediately If true, immediately list channels, otherwise just show dialog
130 void showChannelList(NetworkId netId = {}, const QString& channelFilters = {}, bool listImmediately = false);
132 void showNetworkConfig(NetworkId netId = NetworkId());
133 void showCoreConnectionDlg();
134 void showCoreConfigWizard(const QVariantList&, const QVariantList&);
135 void showCoreInfoDlg();
137 void showSettingsDlg();
138 void showNotificationsDlg();
139 void showIgnoreList(QString newRule = QString());
140 void showShortcutsDlg();
141 void showPasswordChangeDlg();
142 void showNewTransferDlg(const QUuid& transferId);
143 void onFullScreenToggled();
145 void doAutoConnect();
147 void handleCoreConnectionError(const QString& errorMsg);
148 void userAuthenticationRequired(CoreAccount*, bool* valid, const QString& errorMessage);
149 void handleNoSslInClient(bool* accepted);
150 void handleNoSslInCore(bool* accepted);
151 void handleSslErrors(const QSslSocket* socket, bool* accepted, bool* permanently);
153 void onConfigureNetworksTriggered();
154 void onConfigureViewsTriggered();
155 void onLockLayoutToggled(bool lock);
158 * Apply the active color to the input widget selected or typed text
160 * @seealso InputWidget::applyFormatActiveColor()
162 void onFormatApplyColorTriggered();
165 * Apply the active fill color to the input widget selected or typed text background
167 * @seealso InputWidget::applyFormatActiveColorFill()
169 void onFormatApplyColorFillTriggered();
172 * Toggle the boldness of the input widget selected or typed text
174 * @seealso InputWidget::toggleFormatBold()
176 void onFormatBoldTriggered();
179 * Toggle the italicness of the input widget selected or typed text
181 * @seealso InputWidget::toggleFormatItalic()
183 void onFormatItalicTriggered();
186 * Toggle the underlining of the input widget selected or typed text
188 * @seealso InputWidget::toggleFormatUnderline()
190 void onFormatUnderlineTriggered();
193 * Toggle the strikethrough of the input widget selected or typed text
195 * @seealso InputWidget::toggleFormatStrikethrough()
197 void onFormatStrikethroughTriggered();
200 * Clear the formatting of the input widget selected or typed text
202 * @seealso InputWidget::clearFormat()
204 void onFormatClearTriggered();
206 void onJumpHotBufferTriggered();
207 void onBufferSearchTriggered();
208 void onDebugNetworkModelTriggered();
209 void onDebugBufferViewOverlayTriggered();
210 void onDebugMessageModelTriggered();
211 void onDebugHotListTriggered();
212 void onDebugLogTriggered();
213 void onShowResourceTreeTriggered();
218 void clientNetworkCreated(NetworkId);
219 void clientNetworkRemoved(NetworkId);
220 void clientNetworkUpdated();
221 void connectOrDisconnectFromNet();
223 void saveMenuBarStatus(bool enabled);
224 void saveStatusBarStatus(bool enabled);
225 void saveMainToolBarStatus(bool enabled);
230 void bufferViewToggled(bool enabled);
231 void bufferViewVisibilityChanged(bool visible);
232 void changeActiveBufferView(bool backwards);
233 void changeActiveBufferView(int bufferViewId);
236 void connectToCore(const QVariantMap& connInfo);
237 void disconnectFromCore();
241 KHelpMenu* _kHelpMenu;
244 MsgProcessorStatusWidget* _msgProcessorStatusWidget;
245 CoreConnectionStatusWidget* _coreConnectionStatusWidget;
246 SystemTray* _systemTray;
248 TitleSetter _titleSetter;
251 void setupBufferWidget();
253 void setupNickWidget();
254 void setupChatMonitor();
255 void setupInputWidget();
256 void setupTopicWidget();
257 void setupTransferWidget();
258 void setupViewMenuTail();
259 void setupStatusBar();
261 void setupTitleSetter();
262 void setupToolBars();
268 QList<BufferViewDock*> _bufferViews;
269 BufferWidget* _bufferWidget;
270 NickListWidget* _nickListWidget;
271 InputWidget* _inputWidget;
272 ChatMonitorView* _chatMonitorView;
273 TopicWidget* _topicWidget;
275 QAction* _fullScreenAction{nullptr};
276 QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
278 QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
280 QWidget* _awayLog{nullptr};
282 QMessageBox* _migrationWarning{nullptr};
284 bool _layoutLoaded{false};
286 QSize _normalSize; //!< Size of the non-maximized window
287 QPoint _normalPos; //!< Position of the non-maximized window
289 BufferHotListFilter* _bufferHotList;
290 QHash<int, BufferId> _jumpKeyMap;
291 int _activeBufferViewIndex{-1};
293 bool _aboutToQuit{false}; // closeEvent can occur multiple times on OSX