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;
60 //!\brief The main window of Quassel's QtUi.
63 : public KMainWindow {
65 : public QMainWindow {
70 MainWin(QWidget *parent = 0);
75 void addBufferView(ClientBufferViewConfig *config);
76 BufferView *allBuffersView() const;
77 BufferView *activeBufferView() const;
79 inline BufferWidget *bufferWidget() const { return _bufferWidget; }
80 inline SystemTray *systemTray() const { return _systemTray; }
82 bool event(QEvent *event);
84 static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
85 static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
87 void saveStateToSettings(UiSettings &);
88 void restoreStateFromSettings(UiSettings &);
90 // We need to override this to add the show/hide menu bar option
91 virtual QMenu *createPopupMenu();
94 void showStatusBarMessage(const QString &message);
95 void hideCurrentBuffer();
96 void nextBufferView(); //!< Activate the next bufferview
97 void previousBufferView(); //!< Activate the previous bufferview
99 void previousBuffer();
101 void showMigrationWarning(bool show);
107 void closeEvent(QCloseEvent *event);
108 void moveEvent(QMoveEvent *event);
109 void resizeEvent(QResizeEvent *event);
112 void connectedToCore();
113 void setConnectedState();
114 void disconnectedFromCore();
115 void setDisconnectedState();
118 void addBufferView(int bufferViewConfigId);
119 void awayLogDestroyed();
120 void removeBufferView(int bufferViewConfigId);
121 void currentBufferChanged(BufferId);
122 void messagesInserted(const QModelIndex &parent, int start, int end);
126 * Show the channel list dialog for the network, optionally searching by channel name
128 * @param networkId Network ID for associated network
129 * @param channelFilters Partial channel name to search for, or empty to show all
130 * @param listImmediately If true, immediately list channels, otherwise just show dialog
132 void showChannelList(NetworkId netId = {}, const QString &channelFilters = {},
133 bool listImmediately = false);
135 void showNetworkConfig(NetworkId netId = NetworkId());
136 void showCoreConnectionDlg();
137 void showCoreConfigWizard(const QVariantList &, const QVariantList &);
138 void showCoreInfoDlg();
140 void showSettingsDlg();
141 void showNotificationsDlg();
142 void showIgnoreList(QString newRule = QString());
143 void showShortcutsDlg();
144 void showPasswordChangeDlg();
145 void showNewTransferDlg(const QUuid &transferId);
146 void onFullScreenToggled();
148 void doAutoConnect();
150 void handleCoreConnectionError(const QString &errorMsg);
151 void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
152 void handleNoSslInClient(bool *accepted);
153 void handleNoSslInCore(bool *accepted);
155 void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
158 void on_actionConfigureNetworks_triggered();
159 void on_actionConfigureViews_triggered();
160 void on_actionLockLayout_toggled(bool lock);
163 * Apply the active color to the input widget selected or typed text
165 * @seealso InputWidget::applyFormatActiveColor()
167 void on_inputFormatApplyColor_triggered();
170 * Apply the active fill color to the input widget selected or typed text background
172 * @seealso InputWidget::applyFormatActiveColorFill()
174 void on_inputFormatApplyColorFill_triggered();
177 * Toggle the boldness of the input widget selected or typed text
179 * @seealso InputWidget::toggleFormatBold()
181 void on_inputFormatBold_triggered();
184 * Toggle the italicness of the input widget selected or typed text
186 * @seealso InputWidget::toggleFormatItalic()
188 void on_inputFormatItalic_triggered();
191 * Toggle the underlining of the input widget selected or typed text
193 * @seealso InputWidget::toggleFormatUnderline()
195 void on_inputFormatUnderline_triggered();
198 * Clear the formatting of the input widget selected or typed text
200 * @seealso InputWidget::clearFormat()
202 void on_inputFormatClear_triggered();
204 void on_jumpHotBuffer_triggered();
205 void on_bufferSearch_triggered();
206 void on_actionDebugNetworkModel_triggered();
207 void on_actionDebugBufferViewOverlay_triggered();
208 void on_actionDebugMessageModel_triggered();
209 void on_actionDebugHotList_triggered();
210 void on_actionDebugLog_triggered();
215 void clientNetworkCreated(NetworkId);
216 void clientNetworkRemoved(NetworkId);
217 void clientNetworkUpdated();
218 void connectOrDisconnectFromNet();
220 void saveMenuBarStatus(bool enabled);
221 void saveStatusBarStatus(bool enabled);
222 void saveMainToolBarStatus(bool enabled);
227 void bufferViewToggled(bool enabled);
228 void bufferViewVisibilityChanged(bool visible);
229 void changeActiveBufferView(bool backwards);
230 void changeActiveBufferView(int bufferViewId);
233 void connectToCore(const QVariantMap &connInfo);
234 void disconnectFromCore();
238 KHelpMenu *_kHelpMenu;
241 MsgProcessorStatusWidget *_msgProcessorStatusWidget;
242 CoreConnectionStatusWidget *_coreConnectionStatusWidget;
243 SystemTray *_systemTray;
245 TitleSetter _titleSetter;
248 void setupBufferWidget();
250 void setupNickWidget();
251 void setupChatMonitor();
252 void setupInputWidget();
253 void setupTopicWidget();
254 void setupTransferWidget();
255 void setupViewMenuTail();
256 void setupStatusBar();
258 void setupTitleSetter();
259 void setupToolBars();
265 QList<BufferViewDock *> _bufferViews;
266 BufferWidget *_bufferWidget;
267 NickListWidget *_nickListWidget;
268 InputWidget *_inputWidget;
269 ChatMonitorView *_chatMonitorView;
270 TopicWidget *_topicWidget;
272 QAction *_fullScreenAction;
273 QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
275 QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
279 QMessageBox* _migrationWarning{nullptr};
283 QSize _normalSize; //!< Size of the non-maximized window
284 QPoint _normalPos; //!< Position of the non-maximized window
286 BufferHotListFilter *_bufferHotList;
287 QHash<int, BufferId> _jumpKeyMap;
288 int _activeBufferViewIndex;
290 bool _aboutToQuit; //closeEvent can occur multiple times on OSX