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 <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.
61 : public KMainWindow {
63 : public QMainWindow {
68 MainWin(QWidget *parent = 0);
72 void addBufferView(ClientBufferViewConfig *config);
73 BufferView *allBuffersView() const;
74 BufferView *activeBufferView() const;
76 inline BufferWidget *bufferWidget() const { return _bufferWidget; }
77 inline SystemTray *systemTray() const { return _systemTray; }
79 bool event(QEvent *event);
81 static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
82 static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
84 void saveStateToSettings(UiSettings &);
85 void restoreStateFromSettings(UiSettings &);
87 // We need to override this to add the show/hide menu bar option
88 virtual QMenu *createPopupMenu();
91 void showStatusBarMessage(const QString &message);
92 void hideCurrentBuffer();
93 void nextBufferView(); //!< Activate the next bufferview
94 void previousBufferView(); //!< Activate the previous bufferview
96 void previousBuffer();
98 void showMigrationWarning(bool show);
100 void onExitRequested(const QString &reason);
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);
122 * Show the channel list dialog for the network, optionally searching by channel name
124 * @param networkId Network ID for associated network
125 * @param channelFilters Partial channel name to search for, or empty to show all
126 * @param listImmediately If true, immediately list channels, otherwise just show dialog
128 void showChannelList(NetworkId netId = {}, const QString &channelFilters = {},
129 bool listImmediately = false);
131 void showNetworkConfig(NetworkId netId = NetworkId());
132 void showCoreConnectionDlg();
133 void showCoreConfigWizard(const QVariantList &, const QVariantList &);
134 void showCoreInfoDlg();
136 void showSettingsDlg();
137 void showNotificationsDlg();
138 void showIgnoreList(QString newRule = QString());
139 void showShortcutsDlg();
140 void showPasswordChangeDlg();
141 void showNewTransferDlg(const QUuid &transferId);
142 void onFullScreenToggled();
144 void doAutoConnect();
146 void handleCoreConnectionError(const QString &errorMsg);
147 void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
148 void handleNoSslInClient(bool *accepted);
149 void handleNoSslInCore(bool *accepted);
151 void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
154 void on_actionConfigureNetworks_triggered();
155 void on_actionConfigureViews_triggered();
156 void on_actionLockLayout_toggled(bool lock);
159 * Apply the active color to the input widget selected or typed text
161 * @seealso InputWidget::applyFormatActiveColor()
163 void on_inputFormatApplyColor_triggered();
166 * Apply the active fill color to the input widget selected or typed text background
168 * @seealso InputWidget::applyFormatActiveColorFill()
170 void on_inputFormatApplyColorFill_triggered();
173 * Toggle the boldness of the input widget selected or typed text
175 * @seealso InputWidget::toggleFormatBold()
177 void on_inputFormatBold_triggered();
180 * Toggle the italicness of the input widget selected or typed text
182 * @seealso InputWidget::toggleFormatItalic()
184 void on_inputFormatItalic_triggered();
187 * Toggle the underlining of the input widget selected or typed text
189 * @seealso InputWidget::toggleFormatUnderline()
191 void on_inputFormatUnderline_triggered();
194 * Clear the formatting of the input widget selected or typed text
196 * @seealso InputWidget::clearFormat()
198 void on_inputFormatClear_triggered();
200 void on_jumpHotBuffer_triggered();
201 void on_bufferSearch_triggered();
202 void on_actionDebugNetworkModel_triggered();
203 void on_actionDebugBufferViewOverlay_triggered();
204 void on_actionDebugMessageModel_triggered();
205 void on_actionDebugHotList_triggered();
206 void on_actionDebugLog_triggered();
211 void clientNetworkCreated(NetworkId);
212 void clientNetworkRemoved(NetworkId);
213 void clientNetworkUpdated();
214 void connectOrDisconnectFromNet();
216 void saveMenuBarStatus(bool enabled);
217 void saveStatusBarStatus(bool enabled);
218 void saveMainToolBarStatus(bool enabled);
223 void bufferViewToggled(bool enabled);
224 void bufferViewVisibilityChanged(bool visible);
225 void changeActiveBufferView(bool backwards);
226 void changeActiveBufferView(int bufferViewId);
229 void connectToCore(const QVariantMap &connInfo);
230 void disconnectFromCore();
234 KHelpMenu *_kHelpMenu;
237 MsgProcessorStatusWidget *_msgProcessorStatusWidget;
238 CoreConnectionStatusWidget *_coreConnectionStatusWidget;
239 SystemTray *_systemTray;
241 TitleSetter _titleSetter;
244 void setupBufferWidget();
246 void setupNickWidget();
247 void setupChatMonitor();
248 void setupInputWidget();
249 void setupTopicWidget();
250 void setupTransferWidget();
251 void setupViewMenuTail();
252 void setupStatusBar();
254 void setupTitleSetter();
255 void setupToolBars();
261 QList<BufferViewDock *> _bufferViews;
262 BufferWidget *_bufferWidget;
263 NickListWidget *_nickListWidget;
264 InputWidget *_inputWidget;
265 ChatMonitorView *_chatMonitorView;
266 TopicWidget *_topicWidget;
268 QAction *_fullScreenAction;
269 QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
271 QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
275 QMessageBox* _migrationWarning{nullptr};
279 QSize _normalSize; //!< Size of the non-maximized window
280 QPoint _normalPos; //!< Position of the non-maximized window
282 BufferHotListFilter *_bufferHotList;
283 QHash<int, BufferId> _jumpKeyMap;
284 int _activeBufferViewIndex;
286 bool _aboutToQuit; //closeEvent can occur multiple times on OSX