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 ***************************************************************************/
25 #include <QMessageBox>
29 #include <QInputDialog>
34 # include <KShortcutsDialog>
35 # include <KStatusBar>
36 # include <KToggleFullScreenAction>
41 # include <KConfigWidgets/KStandardAction>
42 # include <KXmlGui/KHelpMenu>
43 # include <KXmlGui/KShortcutsDialog>
44 # include <KXmlGui/KToolBar>
45 # include <KWidgetsAddons/KToggleFullScreenAction>
53 #include "awaylogfilter.h"
54 #include "awaylogview.h"
56 #include "actioncollection.h"
57 #include "bufferhotlistfilter.h"
58 #include "buffermodel.h"
59 #include "bufferview.h"
60 #include "bufferviewoverlay.h"
61 #include "bufferviewoverlayfilter.h"
62 #include "bufferwidget.h"
63 #include "channellistdlg.h"
64 #include "chatlinemodel.h"
65 #include "chatmonitorfilter.h"
66 #include "chatmonitorview.h"
69 #include "clientbacklogmanager.h"
70 #include "clientbufferviewconfig.h"
71 #include "clientbufferviewmanager.h"
72 #include "clientignorelistmanager.h"
73 #include "clienttransfer.h"
74 #include "clienttransfermanager.h"
75 #include "coreconfigwizard.h"
76 #include "coreconnectdlg.h"
77 #include "coreconnection.h"
78 #include "coreconnectionstatuswidget.h"
79 #include "coreinfodlg.h"
80 #include "contextmenuactionprovider.h"
81 #include "debugbufferviewoverlay.h"
82 #include "debuglogwidget.h"
83 #include "debugmessagemodelfilter.h"
84 #include "flatproxymodel.h"
86 #include "inputwidget.h"
87 #include "irclistmodel.h"
88 #include "ircconnectionwizard.h"
89 #include "legacysystemtray.h"
90 #include "msgprocessorstatuswidget.h"
91 #include "nicklistwidget.h"
92 #include "passwordchangedlg.h"
93 #include "qtuiapplication.h"
94 #include "qtuimessageprocessor.h"
95 #include "qtuisettings.h"
96 #include "qtuistyle.h"
97 #include "receivefiledlg.h"
98 #include "settingsdlg.h"
99 #include "settingspagedlg.h"
100 #include "statusnotifieritem.h"
101 #include "toolbaractionprovider.h"
102 #include "topicwidget.h"
103 #include "transfermodel.h"
104 #include "verticaldock.h"
107 # ifdef HAVE_QTMULTIMEDIA
108 # include "qtmultimedianotificationbackend.h"
111 # include "phononnotificationbackend.h"
113 # include "systraynotificationbackend.h"
114 # include "taskbarnotificationbackend.h"
116 # include "knotificationbackend.h"
117 #endif /* HAVE_KDE */
118 #include "systrayanimationnotificationbackend.h"
122 # include "snorenotificationbackend.h"
126 # include "sslinfodlg.h"
129 #ifdef HAVE_INDICATEQT
130 #include "indicatornotificationbackend.h"
133 #ifdef HAVE_NOTIFICATION_CENTER
134 #include "osxnotificationbackend.h"
138 #include "dockmanagernotificationbackend.h"
141 #include "settingspages/aliasessettingspage.h"
142 #include "settingspages/appearancesettingspage.h"
143 #include "settingspages/backlogsettingspage.h"
144 #include "settingspages/bufferviewsettingspage.h"
145 #include "settingspages/chatmonitorsettingspage.h"
146 #include "settingspages/chatviewsettingspage.h"
147 #include "settingspages/chatviewcolorsettingspage.h"
148 #include "settingspages/connectionsettingspage.h"
149 #include "settingspages/coreaccountsettingspage.h"
150 #include "settingspages/coreconnectionsettingspage.h"
151 #include <settingspages/corehighlightsettingspage.h>
152 #include "settingspages/dccsettingspage.h"
153 #include "settingspages/highlightsettingspage.h"
154 #include "settingspages/identitiessettingspage.h"
155 #include "settingspages/ignorelistsettingspage.h"
156 #include "settingspages/inputwidgetsettingspage.h"
157 #include "settingspages/itemviewsettingspage.h"
158 #include "settingspages/networkssettingspage.h"
159 #include "settingspages/notificationssettingspage.h"
160 #include "settingspages/topicwidgetsettingspage.h"
163 # include "settingspages/shortcutssettingspage.h"
167 # include "settingspages/sonnetsettingspage.h"
171 MainWin::MainWin(QWidget *parent)
173 : KMainWindow(parent), _kHelpMenu(new KHelpMenu(this)),
175 : QMainWindow(parent),
177 _msgProcessorStatusWidget(new MsgProcessorStatusWidget(this)),
178 _coreConnectionStatusWidget(new CoreConnectionStatusWidget(Client::coreConnection(), this)),
181 _layoutLoaded(false),
182 _activeBufferViewIndex(-1),
185 setAttribute(Qt::WA_DeleteOnClose, false); // we delete the mainwin manually
187 QtUiSettings uiSettings;
188 QString style = uiSettings.value("Style", QString()).toString();
189 if (!style.isEmpty()) {
190 QApplication::setStyle(style);
193 QApplication::setQuitOnLastWindowClosed(false);
195 setWindowTitle("Quassel IRC");
196 setWindowIconText("Quassel IRC");
197 // Set the default icon for all windows
198 QApplication::setWindowIcon(icon::get("quassel"));
205 connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), SLOT(clientNetworkCreated(NetworkId)));
206 connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId)));
207 connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
208 SLOT(messagesInserted(const QModelIndex &, int, int)));
209 connect(GraphicalUi::contextMenuActionProvider(),
210 SIGNAL(showChannelList(NetworkId,QString,bool)),
211 SLOT(showChannelList(NetworkId,QString,bool)));
212 connect(Client::instance(),
213 SIGNAL(showChannelList(NetworkId,QString,bool)),
214 SLOT(showChannelList(NetworkId,QString,bool)));
215 connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showNetworkConfig(NetworkId)), SLOT(showNetworkConfig(NetworkId)));
216 connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
217 connect(Client::instance(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
218 connect(Client::instance(), SIGNAL(dbUpgradeInProgress(bool)), SLOT(showMigrationWarning(bool)));
219 connect(Client::instance(), SIGNAL(exitRequested(QString)), SLOT(onExitRequested(QString)));
221 connect(Client::coreConnection(), SIGNAL(startCoreSetup(QVariantList, QVariantList)), SLOT(showCoreConfigWizard(QVariantList, QVariantList)));
222 connect(Client::coreConnection(), SIGNAL(connectionErrorPopup(QString)), SLOT(handleCoreConnectionError(QString)));
223 connect(Client::coreConnection(), SIGNAL(userAuthenticationRequired(CoreAccount *, bool *, QString)), SLOT(userAuthenticationRequired(CoreAccount *, bool *, QString)));
224 connect(Client::coreConnection(), SIGNAL(handleNoSslInClient(bool *)), SLOT(handleNoSslInClient(bool *)));
225 connect(Client::coreConnection(), SIGNAL(handleNoSslInCore(bool *)), SLOT(handleNoSslInCore(bool *)));
227 connect(Client::coreConnection(), SIGNAL(handleSslErrors(const QSslSocket *, bool *, bool *)), SLOT(handleSslErrors(const QSslSocket *, bool *, bool *)));
231 setDockNestingEnabled(true);
232 setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
233 setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
234 setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
235 setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
237 // Order is sometimes important
241 // setupTransferWidget(); not ready yet
253 _bufferWidget->setFocusProxy(_inputWidget);
254 _chatMonitorView->setFocusProxy(_inputWidget);
257 # ifdef HAVE_QTMULTIMEDIA
258 QtUi::registerNotificationBackend(new QtMultimediaNotificationBackend(this));
261 QtUi::registerNotificationBackend(new PhononNotificationBackend(this));
263 QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
265 QtUi::registerNotificationBackend(new KNotificationBackend(this));
266 #endif /* HAVE_KDE */
269 #ifndef QT_NO_SYSTEMTRAYICON
270 QtUi::registerNotificationBackend(new SystrayAnimationNotificationBackend(this));
273 QtUi::registerNotificationBackend(new SnoreNotificationBackend(this));
274 #elif !defined(QT_NO_SYSTEMTRAYICON) && !defined(HAVE_KDE)
275 QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
278 #ifdef HAVE_INDICATEQT
279 QtUi::registerNotificationBackend(new IndicatorNotificationBackend(this));
282 #ifdef HAVE_NOTIFICATION_CENTER
283 QtUi::registerNotificationBackend(new OSXNotificationBackend(this));
287 QtUi::registerNotificationBackend(new DockManagerNotificationBackend(this));
290 // we assume that at this point, all configurable actions are defined!
291 QtUi::loadShortcuts();
293 connect(bufferWidget(), SIGNAL(currentChanged(BufferId)), SLOT(currentBufferChanged(BufferId)));
295 setDisconnectedState(); // Disable menus and stuff
298 setAutoSaveSettings();
301 // restore mainwin state
303 restoreStateFromSettings(s);
305 // restore locked state of docks
306 QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool());
308 QTimer::singleShot(0, this, SLOT(doAutoConnect()));
320 saveStateToSettings(s);
322 QApplication::quit();
326 void MainWin::saveStateToSettings(UiSettings &s)
328 s.setValue("MainWinSize", _normalSize);
329 s.setValue("MainWinPos", _normalPos);
330 s.setValue("MainWinState", saveState());
331 s.setValue("MainWinGeometry", saveGeometry());
332 s.setValue("MainWinMinimized", isMinimized());
333 s.setValue("MainWinMaximized", isMaximized());
334 s.setValue("MainWinHidden", !isVisible());
335 BufferId lastBufId = Client::bufferModel()->currentBuffer();
336 if (lastBufId.isValid())
337 s.setValue("LastUsedBufferId", lastBufId.toInt());
340 saveAutoSaveSettings();
345 void MainWin::restoreStateFromSettings(UiSettings &s)
347 _normalSize = s.value("MainWinSize", size()).toSize();
348 _normalPos = s.value("MainWinPos", pos()).toPoint();
349 bool maximized = s.value("MainWinMaximized", false).toBool();
352 restoreGeometry(s.value("MainWinGeometry").toByteArray());
355 // restoreGeometry() fails if the windows was maximized, so we resize and position explicitly
360 restoreState(s.value("MainWinState").toByteArray());
366 if ((Quassel::isOptionSet("hidewindow")
367 || s.value("MainWinHidden").toBool())
368 && _systemTray->isSystemTrayAvailable())
369 QtUi::hideMainWidget();
370 else if (s.value("MainWinMinimized").toBool())
378 QMenu *MainWin::createPopupMenu()
380 QMenu *popupMenu = QMainWindow::createPopupMenu();
381 popupMenu->addSeparator();
382 ActionCollection *coll = QtUi::actionCollection("General");
383 popupMenu->addAction(coll->action("ToggleMenuBar"));
388 void MainWin::updateIcon()
391 if (Client::isConnected())
392 icon = icon::get("quassel");
394 icon = icon::get("inactive-quassel");
399 void MainWin::setupActions()
401 ActionCollection *coll = QtUi::actionCollection("General", tr("General"));
403 coll->addAction("ConnectCore", new Action(icon::get("connect-quassel"), tr("&Connect to Core..."), coll,
404 this, SLOT(showCoreConnectionDlg())));
405 coll->addAction("DisconnectCore", new Action(icon::get("disconnect-quassel"), tr("&Disconnect from Core"), coll,
406 Client::instance(), SLOT(disconnectFromCore())));
407 coll->addAction("ChangePassword", new Action(icon::get("dialog-password"), tr("Change &Password..."), coll,
408 this, SLOT(showPasswordChangeDlg())));
409 coll->addAction("CoreInfo", new Action(icon::get("help-about"), tr("Core &Info..."), coll,
410 this, SLOT(showCoreInfoDlg())));
411 coll->addAction("ConfigureNetworks", new Action(icon::get("configure"), tr("Configure &Networks..."), coll,
412 this, SLOT(on_actionConfigureNetworks_triggered())));
413 // QKeySequence::Quit was added in Qt 4.6, and could be used instead. However, that key
414 // sequence is empty by default on Windows, which would remove Ctrl-Q to quit. It may be best
415 // to just keep it this way.
417 // See https://doc.qt.io/qt-5/qkeysequence.html
418 coll->addAction("Quit", new Action(icon::get("application-exit"), tr("&Quit"), coll,
419 this, SLOT(quit()), Qt::CTRL + Qt::Key_Q));
422 coll->addAction("ConfigureBufferViews", new Action(tr("&Configure Chat Lists..."), coll,
423 this, SLOT(on_actionConfigureViews_triggered())));
425 QAction *lockAct = coll->addAction("LockLayout", new Action(tr("&Lock Layout"), coll));
426 lockAct->setCheckable(true);
427 connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockLayout_toggled(bool)));
429 coll->addAction("ToggleSearchBar", new Action(icon::get("edit-find"), tr("Show &Search Bar"), coll,
430 0, 0, QKeySequence::Find))->setCheckable(true);
431 coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll,
432 this, SLOT(showAwayLog())));
433 coll->addAction("ToggleMenuBar", new Action(icon::get("show-menu"), tr("Show &Menubar"), coll,
434 0, 0))->setCheckable(true);
436 coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll,
437 0, 0))->setCheckable(true);
440 _fullScreenAction = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll);
442 _fullScreenAction = new Action(icon::get("view-fullscreen"), tr("&Full Screen Mode"), coll,
443 this, SLOT(onFullScreenToggled()), QKeySequence(Qt::Key_F11));
444 _fullScreenAction->setCheckable(true);
445 coll->addAction("ToggleFullScreen", _fullScreenAction);
449 QAction *configureShortcutsAct = new Action(icon::get("configure-shortcuts"), tr("Configure &Shortcuts..."), coll,
450 this, SLOT(showShortcutsDlg()));
451 configureShortcutsAct->setMenuRole(QAction::NoRole);
452 coll->addAction("ConfigureShortcuts", configureShortcutsAct);
455 QAction *configureQuasselAct = new Action(icon::get("configure"), tr("&Configure Quassel..."), coll,
456 this, SLOT(showSettingsDlg()));
457 configureQuasselAct->setMenuRole(QAction::PreferencesRole);
459 QAction *configureQuasselAct = new Action(icon::get("configure"), tr("&Configure Quassel..."), coll,
460 this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7));
462 coll->addAction("ConfigureQuassel", configureQuasselAct);
465 QAction *aboutQuasselAct = new Action(icon::get("quassel"), tr("&About Quassel"), coll,
466 this, SLOT(showAboutDlg()));
467 aboutQuasselAct->setMenuRole(QAction::AboutRole);
468 coll->addAction("AboutQuassel", aboutQuasselAct);
470 QAction *aboutQtAct = new Action(QIcon(":/pics/qt-logo.png"), tr("About &Qt"), coll,
471 qApp, SLOT(aboutQt()));
472 aboutQtAct->setMenuRole(QAction::AboutQtRole);
473 coll->addAction("AboutQt", aboutQtAct);
474 coll->addAction("DebugNetworkModel", new Action(icon::get("tools-report-bug"), tr("Debug &NetworkModel"), coll,
475 this, SLOT(on_actionDebugNetworkModel_triggered())));
476 coll->addAction("DebugBufferViewOverlay", new Action(icon::get("tools-report-bug"), tr("Debug &BufferViewOverlay"), coll,
477 this, SLOT(on_actionDebugBufferViewOverlay_triggered())));
478 coll->addAction("DebugMessageModel", new Action(icon::get("tools-report-bug"), tr("Debug &MessageModel"), coll,
479 this, SLOT(on_actionDebugMessageModel_triggered())));
480 coll->addAction("DebugHotList", new Action(icon::get("tools-report-bug"), tr("Debug &HotList"), coll,
481 this, SLOT(on_actionDebugHotList_triggered())));
482 coll->addAction("DebugLog", new Action(icon::get("tools-report-bug"), tr("Debug &Log"), coll,
483 this, SLOT(on_actionDebugLog_triggered())));
484 coll->addAction("ReloadStyle", new Action(icon::get("view-refresh"), tr("Reload Stylesheet"), coll,
485 QtUi::style(), SLOT(reload()), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R)));
487 coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll,
488 this, SLOT(hideCurrentBuffer()), QKeySequence::Close));
491 coll = QtUi::actionCollection("TextFormat", tr("Text formatting"));
493 coll->addAction("FormatApplyColor", new Action(
494 icon::get("format-text-color"), tr("Apply foreground color"), coll,
495 this, SLOT(on_inputFormatApplyColor_triggered()),
496 QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G)));
498 coll->addAction("FormatApplyColorFill", new Action(
499 icon::get("format-fill-color"), tr("Apply background color"), coll,
500 this, SLOT(on_inputFormatApplyColorFill_triggered()),
501 QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B)));
503 coll->addAction("FormatClear", new Action(
504 icon::get("edit-clear"), tr("Clear formatting"), coll,
505 this, SLOT(on_inputFormatClear_triggered()),
506 QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C)));
508 coll->addAction("FormatBold", new Action(
509 icon::get("format-text-bold"), tr("Toggle bold"), coll,
510 this, SLOT(on_inputFormatBold_triggered()),
511 QKeySequence::Bold));
513 coll->addAction("FormatItalic", new Action(
514 icon::get("format-text-italic"), tr("Toggle italics"), coll,
515 this, SLOT(on_inputFormatItalic_triggered()),
516 QKeySequence::Italic));
518 coll->addAction("FormatUnderline", new Action(
519 icon::get("format-text-underline"), tr("Toggle underline"), coll,
520 this, SLOT(on_inputFormatUnderline_triggered()), QKeySequence::Underline));
523 coll = QtUi::actionCollection("Navigation", tr("Navigation"));
525 coll->addAction("JumpHotBuffer", new Action(tr("Jump to hot chat"), coll,
526 this, SLOT(on_jumpHotBuffer_triggered()), QKeySequence(Qt::META + Qt::Key_A)));
528 coll->addAction("ActivateBufferFilter", new Action(tr("Activate the buffer search"), coll,
529 this, SLOT(on_bufferSearch_triggered()), QKeySequence(Qt::CTRL + Qt::Key_S)));
533 const int bindModifier = Qt::ControlModifier | Qt::AltModifier;
534 const int jumpModifier = Qt::ControlModifier;
536 const int bindModifier = Qt::ControlModifier;
537 const int jumpModifier = Qt::AltModifier;
540 coll->addAction("BindJumpKey0", new Action(tr("Set Quick Access #0"), coll, this, SLOT(bindJumpKey()),
541 QKeySequence(bindModifier + Qt::Key_0)))->setProperty("Index", 0);
542 coll->addAction("BindJumpKey1", new Action(tr("Set Quick Access #1"), coll, this, SLOT(bindJumpKey()),
543 QKeySequence(bindModifier + Qt::Key_1)))->setProperty("Index", 1);
544 coll->addAction("BindJumpKey2", new Action(tr("Set Quick Access #2"), coll, this, SLOT(bindJumpKey()),
545 QKeySequence(bindModifier + Qt::Key_2)))->setProperty("Index", 2);
546 coll->addAction("BindJumpKey3", new Action(tr("Set Quick Access #3"), coll, this, SLOT(bindJumpKey()),
547 QKeySequence(bindModifier + Qt::Key_3)))->setProperty("Index", 3);
548 coll->addAction("BindJumpKey4", new Action(tr("Set Quick Access #4"), coll, this, SLOT(bindJumpKey()),
549 QKeySequence(bindModifier + Qt::Key_4)))->setProperty("Index", 4);
550 coll->addAction("BindJumpKey5", new Action(tr("Set Quick Access #5"), coll, this, SLOT(bindJumpKey()),
551 QKeySequence(bindModifier + Qt::Key_5)))->setProperty("Index", 5);
552 coll->addAction("BindJumpKey6", new Action(tr("Set Quick Access #6"), coll, this, SLOT(bindJumpKey()),
553 QKeySequence(bindModifier + Qt::Key_6)))->setProperty("Index", 6);
554 coll->addAction("BindJumpKey7", new Action(tr("Set Quick Access #7"), coll, this, SLOT(bindJumpKey()),
555 QKeySequence(bindModifier + Qt::Key_7)))->setProperty("Index", 7);
556 coll->addAction("BindJumpKey8", new Action(tr("Set Quick Access #8"), coll, this, SLOT(bindJumpKey()),
557 QKeySequence(bindModifier + Qt::Key_8)))->setProperty("Index", 8);
558 coll->addAction("BindJumpKey9", new Action(tr("Set Quick Access #9"), coll, this, SLOT(bindJumpKey()),
559 QKeySequence(bindModifier + Qt::Key_9)))->setProperty("Index", 9);
561 coll->addAction("JumpKey0", new Action(tr("Quick Access #0"), coll, this, SLOT(onJumpKey()),
562 QKeySequence(jumpModifier + Qt::Key_0)))->setProperty("Index", 0);
563 coll->addAction("JumpKey1", new Action(tr("Quick Access #1"), coll, this, SLOT(onJumpKey()),
564 QKeySequence(jumpModifier + Qt::Key_1)))->setProperty("Index", 1);
565 coll->addAction("JumpKey2", new Action(tr("Quick Access #2"), coll, this, SLOT(onJumpKey()),
566 QKeySequence(jumpModifier + Qt::Key_2)))->setProperty("Index", 2);
567 coll->addAction("JumpKey3", new Action(tr("Quick Access #3"), coll, this, SLOT(onJumpKey()),
568 QKeySequence(jumpModifier + Qt::Key_3)))->setProperty("Index", 3);
569 coll->addAction("JumpKey4", new Action(tr("Quick Access #4"), coll, this, SLOT(onJumpKey()),
570 QKeySequence(jumpModifier + Qt::Key_4)))->setProperty("Index", 4);
571 coll->addAction("JumpKey5", new Action(tr("Quick Access #5"), coll, this, SLOT(onJumpKey()),
572 QKeySequence(jumpModifier + Qt::Key_5)))->setProperty("Index", 5);
573 coll->addAction("JumpKey6", new Action(tr("Quick Access #6"), coll, this, SLOT(onJumpKey()),
574 QKeySequence(jumpModifier + Qt::Key_6)))->setProperty("Index", 6);
575 coll->addAction("JumpKey7", new Action(tr("Quick Access #7"), coll, this, SLOT(onJumpKey()),
576 QKeySequence(jumpModifier + Qt::Key_7)))->setProperty("Index", 7);
577 coll->addAction("JumpKey8", new Action(tr("Quick Access #8"), coll, this, SLOT(onJumpKey()),
578 QKeySequence(jumpModifier + Qt::Key_8)))->setProperty("Index", 8);
579 coll->addAction("JumpKey9", new Action(tr("Quick Access #9"), coll, this, SLOT(onJumpKey()),
580 QKeySequence(jumpModifier + Qt::Key_9)))->setProperty("Index", 9);
583 coll->addAction("NextBufferView", new Action(icon::get("go-next-view"), tr("Activate Next Chat List"), coll,
584 this, SLOT(nextBufferView()), QKeySequence(QKeySequence::Forward)));
585 coll->addAction("PreviousBufferView", new Action(icon::get("go-previous-view"), tr("Activate Previous Chat List"), coll,
586 this, SLOT(previousBufferView()), QKeySequence::Back));
587 coll->addAction("NextBuffer", new Action(icon::get("go-down"), tr("Go to Next Chat"), coll,
588 this, SLOT(nextBuffer()), QKeySequence(Qt::ALT + Qt::Key_Down)));
589 coll->addAction("PreviousBuffer", new Action(icon::get("go-up"), tr("Go to Previous Chat"), coll,
590 this, SLOT(previousBuffer()), QKeySequence(Qt::ALT + Qt::Key_Up)));
594 void MainWin::setupMenus()
596 ActionCollection *coll = QtUi::actionCollection("General");
598 _fileMenu = menuBar()->addMenu(tr("&File"));
600 static const QStringList coreActions = QStringList()
601 << "ConnectCore" << "DisconnectCore" << "ChangePassword" << "CoreInfo";
604 foreach(QString actionName, coreActions) {
605 coreAction = coll->action(actionName);
606 _fileMenu->addAction(coreAction);
607 flagRemoteCoreOnly(coreAction);
609 flagRemoteCoreOnly(_fileMenu->addSeparator());
611 _networksMenu = _fileMenu->addMenu(tr("&Networks"));
612 _networksMenu->addAction(coll->action("ConfigureNetworks"));
613 _networksMenu->addSeparator();
614 _fileMenu->addSeparator();
615 _fileMenu->addAction(coll->action("Quit"));
617 _viewMenu = menuBar()->addMenu(tr("&View"));
618 _bufferViewsMenu = _viewMenu->addMenu(tr("&Chat Lists"));
619 _bufferViewsMenu->addAction(coll->action("ConfigureBufferViews"));
620 _toolbarMenu = _viewMenu->addMenu(tr("&Toolbars"));
621 _viewMenu->addSeparator();
623 _viewMenu->addAction(coll->action("ToggleMenuBar"));
624 _viewMenu->addAction(coll->action("ToggleStatusBar"));
625 _viewMenu->addAction(coll->action("ToggleSearchBar"));
627 coreAction = coll->action("ShowAwayLog");
628 flagRemoteCoreOnly(coreAction);
629 _viewMenu->addAction(coreAction);
631 _viewMenu->addSeparator();
632 _viewMenu->addAction(coll->action("LockLayout"));
634 _settingsMenu = menuBar()->addMenu(tr("&Settings"));
636 _settingsMenu->addAction(KStandardAction::configureNotifications(this, SLOT(showNotificationsDlg()), this));
637 _settingsMenu->addAction(KStandardAction::keyBindings(this, SLOT(showShortcutsDlg()), this));
639 _settingsMenu->addAction(coll->action("ConfigureShortcuts"));
641 _settingsMenu->addAction(coll->action("ConfigureQuassel"));
644 _helpMenu = menuBar()->addMenu(tr("&Help"));
646 _helpMenu->addAction(coll->action("AboutQuassel"));
648 _helpMenu->addAction(coll->action("AboutQt"));
650 _helpMenu->addAction(KStandardAction::aboutKDE(_kHelpMenu, SLOT(aboutKDE()), this));
652 _helpMenu->addSeparator();
653 _helpDebugMenu = _helpMenu->addMenu(icon::get("tools-report-bug"), tr("Debug"));
654 _helpDebugMenu->addAction(coll->action("DebugNetworkModel"));
655 _helpDebugMenu->addAction(coll->action("DebugBufferViewOverlay"));
656 _helpDebugMenu->addAction(coll->action("DebugMessageModel"));
657 _helpDebugMenu->addAction(coll->action("DebugHotList"));
658 _helpDebugMenu->addAction(coll->action("DebugLog"));
659 _helpDebugMenu->addSeparator();
660 _helpDebugMenu->addAction(coll->action("ReloadStyle"));
663 QAction *showMenuBar = QtUi::actionCollection("General")->action("ToggleMenuBar");
665 QtUiSettings uiSettings;
666 bool enabled = uiSettings.value("ShowMenuBar", QVariant(true)).toBool();
667 showMenuBar->setChecked(enabled);
668 enabled ? menuBar()->show() : menuBar()->hide();
670 connect(showMenuBar, SIGNAL(toggled(bool)), menuBar(), SLOT(setVisible(bool)));
671 connect(showMenuBar, SIGNAL(toggled(bool)), this, SLOT(saveMenuBarStatus(bool)));
675 void MainWin::setupBufferWidget()
677 _bufferWidget = new BufferWidget(this);
678 _bufferWidget->setModel(Client::bufferModel());
679 _bufferWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
680 setCentralWidget(_bufferWidget);
684 void MainWin::addBufferView(int bufferViewConfigId)
686 addBufferView(Client::bufferViewManager()->clientBufferViewConfig(bufferViewConfigId));
690 void MainWin::addBufferView(ClientBufferViewConfig *config)
695 config->setLocked(QtUiSettings().value("LockLayout", false).toBool());
696 BufferViewDock *dock = new BufferViewDock(config, this);
698 //create the view and initialize it's filter
699 BufferView *view = new BufferView(dock);
700 view->setFilteredModel(Client::bufferModel(), config);
701 view->installEventFilter(_inputWidget); // for key presses
703 Client::bufferModel()->synchronizeView(view);
705 dock->setLocked(QtUiSettings().value("LockLayout", false).toBool());
707 dock->setWidget(view);
708 dock->setVisible(_layoutLoaded); // don't show before state has been restored
710 addDockWidget(Qt::LeftDockWidgetArea, dock);
711 _bufferViewsMenu->addAction(dock->toggleViewAction());
713 connect(dock->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(bufferViewToggled(bool)));
714 connect(dock, SIGNAL(visibilityChanged(bool)), SLOT(bufferViewVisibilityChanged(bool)));
715 _bufferViews.append(dock);
717 if (!activeBufferView())
722 void MainWin::removeBufferView(int bufferViewConfigId)
725 BufferViewDock *dock;
726 foreach(QAction *action, _bufferViewsMenu->actions()) {
727 actionData = action->data();
728 if (!actionData.isValid())
731 dock = qobject_cast<BufferViewDock *>(action->parent());
732 if (dock && actionData.toInt() == bufferViewConfigId) {
733 removeAction(action);
734 Client::bufferViewOverlay()->removeView(dock->bufferViewId());
735 _bufferViews.removeAll(dock);
737 if (dock->isActive()) {
738 dock->setActive(false);
739 _activeBufferViewIndex = -1;
749 void MainWin::bufferViewToggled(bool enabled)
751 if (!enabled && !isMinimized()) {
752 // hiding the mainwindow triggers a toggle of the bufferview (which pretty much sucks big time)
753 // since this isn't our fault and we can't do anything about it, we suppress the resulting calls
756 QAction *action = qobject_cast<QAction *>(sender());
758 BufferViewDock *dock = qobject_cast<BufferViewDock *>(action->parent());
761 // Make sure we don't toggle backlog fetch for a view we've already removed
762 if (!_bufferViews.contains(dock))
766 Client::bufferViewOverlay()->addView(dock->bufferViewId());
768 Client::bufferViewOverlay()->removeView(dock->bufferViewId());
772 void MainWin::bufferViewVisibilityChanged(bool visible)
775 BufferViewDock *dock = qobject_cast<BufferViewDock *>(sender());
777 if ((!dock->isHidden() && !activeBufferView()) || (dock->isHidden() && dock->isActive()))
782 BufferView *MainWin::allBuffersView() const
784 // "All Buffers" is always the first dock created
785 if (_bufferViews.count() > 0)
786 return _bufferViews[0]->bufferView();
791 BufferView *MainWin::activeBufferView() const
793 if (_activeBufferViewIndex < 0 || _activeBufferViewIndex >= _bufferViews.count())
795 BufferViewDock *dock = _bufferViews.at(_activeBufferViewIndex);
796 return dock->isActive() ? dock->bufferView() : 0;
800 void MainWin::changeActiveBufferView(int bufferViewId)
802 if (bufferViewId < 0)
805 if (_activeBufferViewIndex >= 0 && _activeBufferViewIndex < _bufferViews.count()) {
806 _bufferViews[_activeBufferViewIndex]->setActive(false);
807 _activeBufferViewIndex = -1;
810 for (int i = 0; i < _bufferViews.count(); i++) {
811 BufferViewDock *dock = _bufferViews.at(i);
812 if (dock->bufferViewId() == bufferViewId && !dock->isHidden()) {
813 _activeBufferViewIndex = i;
814 dock->setActive(true);
819 nextBufferView(); // fallback
823 void MainWin::showPasswordChangeDlg()
825 if(Client::isCoreFeatureEnabled(Quassel::Feature::PasswordChange)) {
826 auto dlg = new PasswordChangeDlg(this);
827 dlg->setAttribute(Qt::WA_DeleteOnClose);
831 auto box = new QMessageBox(QMessageBox::Warning, tr("Feature Not Supported"),
832 tr("<b>Your Quassel Core does not support this feature</b>"),
833 QMessageBox::Ok, this);
834 box->setInformativeText(tr("You need a Quassel Core v0.12.0 or newer in order to be able to remotely change your password."));
835 box->setAttribute(Qt::WA_DeleteOnClose);
841 void MainWin::showMigrationWarning(bool show)
843 if (show && !_migrationWarning) {
844 _migrationWarning = new QMessageBox(QMessageBox::Information,
846 "<b>" + tr("Your database is being upgraded") + "</b>",
847 QMessageBox::NoButton, this);
848 _migrationWarning->setInformativeText("<p>"
849 + tr("In order to support new features, we need to make changes to your backlog database. This may take a long while.")
851 + tr("Do not exit Quassel until the upgrade is complete!")
853 _migrationWarning->setStandardButtons(QMessageBox::NoButton);
854 _migrationWarning->show();
856 else if (!show && _migrationWarning) {
857 _migrationWarning->close();
858 _migrationWarning->deleteLater();
859 _migrationWarning = nullptr;
864 void MainWin::onExitRequested(const QString &reason)
866 if (!reason.isEmpty()) {
867 auto box = new QMessageBox(QMessageBox::Critical,
869 "<b>" + tr("Quassel encountered a fatal error and is terminated.") + "</b>",
870 QMessageBox::Ok, this);
871 box->setInformativeText("<p>" + tr("Reason:<em>") + " " + reason + "</em>");
872 box->setAttribute(Qt::WA_DeleteOnClose);
878 void MainWin::changeActiveBufferView(bool backwards)
880 if (_activeBufferViewIndex >= 0 && _activeBufferViewIndex < _bufferViews.count()) {
881 _bufferViews[_activeBufferViewIndex]->setActive(false);
884 if (!_bufferViews.count())
887 int c = _bufferViews.count();
888 while (c--) { // yes, this will reactivate the current active one if all others fail
890 if (--_activeBufferViewIndex < 0)
891 _activeBufferViewIndex = _bufferViews.count()-1;
894 if (++_activeBufferViewIndex >= _bufferViews.count())
895 _activeBufferViewIndex = 0;
898 BufferViewDock *dock = _bufferViews.at(_activeBufferViewIndex);
899 if (dock->isHidden())
902 dock->setActive(true);
906 _activeBufferViewIndex = -1;
910 void MainWin::nextBufferView()
912 changeActiveBufferView(false);
916 void MainWin::previousBufferView()
918 changeActiveBufferView(true);
922 void MainWin::nextBuffer()
924 BufferView *view = activeBufferView();
930 void MainWin::previousBuffer()
932 BufferView *view = activeBufferView();
934 view->previousBuffer();
938 void MainWin::hideCurrentBuffer()
940 BufferView *view = activeBufferView();
942 view->hideCurrentBuffer();
946 void MainWin::showNotificationsDlg()
948 auto dlg = new SettingsPageDlg(new NotificationsSettingsPage(this), this);
949 dlg->setAttribute(Qt::WA_DeleteOnClose);
954 void MainWin::on_actionConfigureNetworks_triggered()
956 auto dlg = new SettingsPageDlg(new NetworksSettingsPage(this), this);
957 dlg->setAttribute(Qt::WA_DeleteOnClose);
962 void MainWin::on_actionConfigureViews_triggered()
964 auto dlg = new SettingsPageDlg(new BufferViewSettingsPage(this), this);
965 dlg->setAttribute(Qt::WA_DeleteOnClose);
970 void MainWin::on_actionLockLayout_toggled(bool lock)
972 QList<VerticalDock *> docks = findChildren<VerticalDock *>();
973 foreach(VerticalDock *dock, docks) {
974 dock->showTitle(!lock);
977 QList<NickListDock *> nickdocks = findChildren<NickListDock *>();
978 foreach(NickListDock *nickdock, nickdocks) {
979 nickdock->setLocked(lock);
982 QList<BufferViewDock *> bufferdocks = findChildren<BufferViewDock *>();
983 foreach(BufferViewDock *bufferdock, bufferdocks) {
984 bufferdock->setLocked(lock);
987 if (Client::bufferViewManager()) {
988 foreach(ClientBufferViewConfig *config, Client::bufferViewManager()->clientBufferViewConfigs()) {
989 config->setLocked(lock);
993 _mainToolBar->setMovable(!lock);
994 _nickToolBar->setMovable(!lock);
996 QtUiSettings().setValue("LockLayout", lock);
1000 void MainWin::setupNickWidget()
1003 NickListDock *nickDock = new NickListDock(tr("Nicks"), this);
1004 nickDock->setObjectName("NickDock");
1005 nickDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1006 nickDock->setLocked(QtUiSettings().value("LockLayout", false).toBool());
1008 _nickListWidget = new NickListWidget(nickDock);
1009 nickDock->setWidget(_nickListWidget);
1011 addDockWidget(Qt::RightDockWidgetArea, nickDock);
1012 _viewMenu->addAction(nickDock->toggleViewAction());
1013 nickDock->toggleViewAction()->setText(tr("Show Nick List"));
1015 // See NickListDock::NickListDock();
1016 // connect(nickDock->toggleViewAction(), SIGNAL(triggered(bool)), nickListWidget, SLOT(showWidget(bool)));
1018 // attach the NickListWidget to the BufferModel and the default selection
1019 _nickListWidget->setModel(Client::bufferModel());
1020 _nickListWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
1022 _nickListWidget->setVisible(false);
1026 void MainWin::setupChatMonitor()
1028 VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this);
1029 dock->setObjectName("ChatMonitorDock");
1031 ChatMonitorFilter *filter = new ChatMonitorFilter(Client::messageModel(), this);
1032 _chatMonitorView = new ChatMonitorView(filter, this);
1033 _chatMonitorView->show();
1034 dock->setWidget(_chatMonitorView);
1037 addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
1038 _viewMenu->addAction(dock->toggleViewAction());
1039 dock->toggleViewAction()->setText(tr("Show Chat Monitor"));
1043 void MainWin::setupInputWidget()
1045 VerticalDock *dock = new VerticalDock(tr("Inputline"), this);
1046 dock->setObjectName("InputDock");
1048 _inputWidget = new InputWidget(dock);
1049 dock->setWidget(_inputWidget);
1051 addDockWidget(Qt::BottomDockWidgetArea, dock);
1053 _viewMenu->addAction(dock->toggleViewAction());
1054 dock->toggleViewAction()->setText(tr("Show Input Line"));
1056 _inputWidget->setModel(Client::bufferModel());
1057 _inputWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
1059 _inputWidget->inputLine()->installEventFilter(_bufferWidget);
1061 connect(_topicWidget, SIGNAL(switchedPlain()), _bufferWidget, SLOT(setFocus()));
1065 void MainWin::setupTopicWidget()
1067 VerticalDock *dock = new VerticalDock(tr("Topic"), this);
1068 dock->setObjectName("TopicDock");
1069 _topicWidget = new TopicWidget(dock);
1071 dock->setWidget(_topicWidget);
1073 _topicWidget->setModel(Client::bufferModel());
1074 _topicWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
1076 addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
1078 _viewMenu->addAction(dock->toggleViewAction());
1079 dock->toggleViewAction()->setText(tr("Show Topic Line"));
1083 void MainWin::setupTransferWidget()
1085 auto dock = new QDockWidget(tr("Transfers"), this);
1086 dock->setObjectName("TransferDock");
1087 dock->setAllowedAreas(Qt::TopDockWidgetArea|Qt::BottomDockWidgetArea);
1089 auto view = new QTableView(dock); // to be replaced by the real thing
1090 view->setModel(Client::transferModel());
1091 dock->setWidget(view);
1092 dock->hide(); // hidden by default
1093 addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
1095 auto action = dock->toggleViewAction();
1096 action->setText(tr("Show File Transfers"));
1097 action->setIcon(icon::get("download"));
1098 action->setShortcut(QKeySequence(Qt::Key_F6));
1099 QtUi::actionCollection("General")->addAction("ShowTransferWidget", action);
1100 _viewMenu->addAction(action);
1104 void MainWin::setupViewMenuTail()
1106 _viewMenu->addSeparator();
1107 _viewMenu->addAction(_fullScreenAction);
1111 void MainWin::setupTitleSetter()
1113 _titleSetter.setModel(Client::bufferModel());
1114 _titleSetter.setSelectionModel(Client::bufferModel()->standardSelectionModel());
1118 void MainWin::setupStatusBar()
1120 // MessageProcessor progress
1121 statusBar()->addPermanentWidget(_msgProcessorStatusWidget);
1124 _coreConnectionStatusWidget->update();
1125 statusBar()->addPermanentWidget(_coreConnectionStatusWidget);
1127 QAction *showStatusbar = QtUi::actionCollection("General")->action("ToggleStatusBar");
1129 QtUiSettings uiSettings;
1131 bool enabled = uiSettings.value("ShowStatusBar", QVariant(true)).toBool();
1132 showStatusbar->setChecked(enabled);
1133 enabled ? statusBar()->show() : statusBar()->hide();
1135 connect(showStatusbar, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool)));
1136 connect(showStatusbar, SIGNAL(toggled(bool)), this, SLOT(saveStatusBarStatus(bool)));
1138 connect(Client::coreConnection(), SIGNAL(connectionMsg(QString)), statusBar(), SLOT(showMessage(QString)));
1142 void MainWin::setupHotList()
1144 FlatProxyModel *flatProxy = new FlatProxyModel(this);
1145 flatProxy->setSourceModel(Client::bufferModel());
1146 _bufferHotList = new BufferHotListFilter(flatProxy);
1150 void MainWin::saveMenuBarStatus(bool enabled)
1152 QtUiSettings uiSettings;
1153 uiSettings.setValue("ShowMenuBar", enabled);
1157 void MainWin::saveStatusBarStatus(bool enabled)
1159 QtUiSettings uiSettings;
1160 uiSettings.setValue("ShowStatusBar", enabled);
1164 void MainWin::setupSystray()
1167 _systemTray = new StatusNotifierItem(this);
1168 #elif !defined QT_NO_SYSTEMTRAYICON
1169 _systemTray = new LegacySystemTray(this);
1171 _systemTray = new SystemTray(this); // dummy
1176 void MainWin::setupToolBars()
1178 connect(_bufferWidget, SIGNAL(currentChanged(QModelIndex)),
1179 QtUi::toolBarActionProvider(), SLOT(currentBufferChanged(QModelIndex)));
1180 connect(_nickListWidget, SIGNAL(nickSelectionChanged(QModelIndexList)),
1181 QtUi::toolBarActionProvider(), SLOT(nickSelectionChanged(QModelIndexList)));
1184 setUnifiedTitleAndToolBarOnMac(true);
1188 _mainToolBar = new KToolBar("MainToolBar", this, Qt::TopToolBarArea, false, true, true);
1190 _mainToolBar = new QToolBar(this);
1191 _mainToolBar->setObjectName("MainToolBar");
1193 _mainToolBar->setWindowTitle(tr("Main Toolbar"));
1194 addToolBar(_mainToolBar);
1196 if (Quassel::runMode() != Quassel::Monolithic) {
1197 ActionCollection *coll = QtUi::actionCollection("General");
1198 _mainToolBar->addAction(coll->action("ConnectCore"));
1199 _mainToolBar->addAction(coll->action("DisconnectCore"));
1202 _mainToolBar->setMovable(!QtUiSettings().value("LockLayout", false).toBool());
1204 QtUi::toolBarActionProvider()->addActions(_mainToolBar, ToolBarActionProvider::MainToolBar);
1205 _toolbarMenu->addAction(_mainToolBar->toggleViewAction());
1208 _nickToolBar = new KToolBar("NickToolBar", this, Qt::TopToolBarArea, false, true, true);
1210 _nickToolBar = new QToolBar(this);
1211 _nickToolBar->setObjectName("NickToolBar");
1213 _nickToolBar->setWindowTitle(tr("Nick Toolbar"));
1214 _nickToolBar->setVisible(false); //default: not visible
1215 addToolBar(_nickToolBar);
1216 _nickToolBar->setMovable(!QtUiSettings().value("LockLayout", false).toBool());
1218 QtUi::toolBarActionProvider()->addActions(_nickToolBar, ToolBarActionProvider::NickToolBar);
1219 _toolbarMenu->addAction(_nickToolBar->toggleViewAction());
1222 QtUiSettings uiSettings;
1224 bool visible = uiSettings.value("ShowMainToolBar", QVariant(true)).toBool();
1225 _mainToolBar->setVisible(visible);
1226 connect(_mainToolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(saveMainToolBarStatus(bool)));
1230 void MainWin::saveMainToolBarStatus(bool enabled)
1233 QtUiSettings uiSettings;
1234 uiSettings.setValue("ShowMainToolBar", enabled);
1241 void MainWin::doAutoConnect()
1243 if (!Client::coreConnection()->connectToCore()) {
1244 // No autoconnect selected (or no accounts)
1245 showCoreConnectionDlg();
1250 void MainWin::connectedToCore()
1252 Q_CHECK_PTR(Client::bufferViewManager());
1253 connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigAdded(int)), this, SLOT(addBufferView(int)));
1254 connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigDeleted(int)), this, SLOT(removeBufferView(int)));
1255 connect(Client::bufferViewManager(), SIGNAL(initDone()), this, SLOT(loadLayout()));
1257 if (Client::transferManager()) {
1258 connect(Client::transferManager(), SIGNAL(transferAdded(QUuid)), SLOT(showNewTransferDlg(QUuid)));
1261 setConnectedState();
1265 void MainWin::setConnectedState()
1267 ActionCollection *coll = QtUi::actionCollection("General");
1269 coll->action("ConnectCore")->setEnabled(false);
1270 coll->action("DisconnectCore")->setEnabled(true);
1271 coll->action("ChangePassword")->setEnabled(true);
1272 coll->action("CoreInfo")->setEnabled(true);
1274 foreach(QAction *action, _fileMenu->actions()) {
1275 if (isRemoteCoreOnly(action))
1276 action->setVisible(!Client::internalCore());
1279 disconnect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), _msgProcessorStatusWidget, SLOT(setProgress(int, int)));
1280 disconnect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
1281 disconnect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
1282 if (!Client::internalCore()) {
1283 connect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), _msgProcessorStatusWidget, SLOT(setProgress(int, int)));
1284 connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
1285 connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
1288 // _viewMenu->setEnabled(true);
1289 if (!Client::internalCore())
1290 statusBar()->showMessage(tr("Connected to core."));
1292 statusBar()->clearMessage();
1294 _coreConnectionStatusWidget->setVisible(!Client::internalCore());
1296 systemTray()->setState(SystemTray::Active);
1298 if (Client::networkIds().isEmpty()) {
1299 IrcConnectionWizard *wizard = new IrcConnectionWizard(this, Qt::Sheet);
1303 // Monolithic always preselects last used buffer - Client only if the connection died
1304 if (Client::coreConnection()->wasReconnect() || Quassel::runMode() == Quassel::Monolithic) {
1306 BufferId lastUsedBufferId(s.value("LastUsedBufferId").toInt());
1307 if (lastUsedBufferId.isValid())
1308 Client::bufferModel()->switchToBuffer(lastUsedBufferId);
1314 void MainWin::loadLayout()
1317 int accountId = Client::currentCoreAccount().accountId().toInt();
1318 QByteArray state = s.value(QString("MainWinState-%1").arg(accountId)).toByteArray();
1319 if (state.isEmpty()) {
1320 foreach(BufferViewDock *view, _bufferViews)
1322 _layoutLoaded = true;
1325 _nickListWidget->setVisible(true);
1326 restoreState(state, accountId);
1327 int bufferViewId = s.value(QString("ActiveBufferView-%1").arg(accountId), -1).toInt();
1328 if (bufferViewId >= 0)
1329 changeActiveBufferView(bufferViewId);
1331 _layoutLoaded = true;
1335 void MainWin::saveLayout()
1338 int accountId = _bufferViews.count() ? Client::currentCoreAccount().accountId().toInt() : 0; // only save if we still have a layout!
1339 if (accountId > 0) {
1340 s.setValue(QString("MainWinState-%1").arg(accountId), saveState(accountId));
1341 BufferView *view = activeBufferView();
1342 s.setValue(QString("ActiveBufferView-%1").arg(accountId), view ? view->config()->bufferViewId() : -1);
1347 void MainWin::disconnectedFromCore()
1349 // save core specific layout and remove bufferviews;
1351 _layoutLoaded = false;
1353 QVariant actionData;
1354 BufferViewDock *dock;
1355 foreach(QAction *action, _bufferViewsMenu->actions()) {
1356 actionData = action->data();
1357 if (!actionData.isValid())
1360 dock = qobject_cast<BufferViewDock *>(action->parent());
1361 if (dock && actionData.toInt() != -1) {
1362 removeAction(action);
1363 _bufferViews.removeAll(dock);
1364 dock->deleteLater();
1368 // store last active buffer
1370 BufferId lastBufId = _bufferWidget->currentBuffer();
1371 if (lastBufId.isValid()) {
1372 s.setValue("LastUsedBufferId", lastBufId.toInt());
1373 // clear the current selection
1374 Client::bufferModel()->standardSelectionModel()->clearSelection();
1376 restoreState(s.value("MainWinState").toByteArray());
1377 setDisconnectedState();
1381 void MainWin::setDisconnectedState()
1383 ActionCollection *coll = QtUi::actionCollection("General");
1384 //ui.menuCore->setEnabled(false);
1385 coll->action("ConnectCore")->setEnabled(true);
1386 coll->action("DisconnectCore")->setEnabled(false);
1387 coll->action("CoreInfo")->setEnabled(false);
1388 coll->action("ChangePassword")->setEnabled(false);
1389 //_viewMenu->setEnabled(false);
1390 statusBar()->showMessage(tr("Not connected to core."));
1391 if (_msgProcessorStatusWidget)
1392 _msgProcessorStatusWidget->setProgress(0, 0);
1394 systemTray()->setState(SystemTray::Passive);
1395 _nickListWidget->setVisible(false);
1399 void MainWin::userAuthenticationRequired(CoreAccount *account, bool *valid, const QString &errorMessage)
1401 Q_UNUSED(errorMessage)
1402 auto dlg = new CoreConnectAuthDlg(account, this);
1403 dlg->setAttribute(Qt::WA_DeleteOnClose);
1404 *valid = (dlg->exec() == QDialog::Accepted);
1408 void MainWin::handleNoSslInClient(bool *accepted)
1410 auto box = new QMessageBox(QMessageBox::Warning, tr("Unencrypted Connection"), tr("<b>Your client does not support SSL encryption</b>"),
1411 QMessageBox::Ignore|QMessageBox::Cancel, this);
1412 box->setInformativeText(tr("Sensitive data, like passwords, will be transmitted unencrypted to your Quassel core."));
1413 box->setDefaultButton(QMessageBox::Ignore);
1414 box->setAttribute(Qt::WA_DeleteOnClose);
1415 *accepted = (box->exec() == QMessageBox::Ignore);
1419 void MainWin::handleNoSslInCore(bool *accepted)
1421 auto box = new QMessageBox(QMessageBox::Warning, tr("Unencrypted Connection"), tr("<b>Your core does not support SSL encryption</b>"),
1422 QMessageBox::Ignore|QMessageBox::Cancel, this);
1423 box->setInformativeText(tr("Sensitive data, like passwords, will be transmitted unencrypted to your Quassel core."));
1424 box->setDefaultButton(QMessageBox::Ignore);
1425 box->setAttribute(Qt::WA_DeleteOnClose);
1426 *accepted = (box->exec() == QMessageBox::Ignore);
1432 void MainWin::handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently)
1434 QString errorString = "<ul>";
1435 foreach(const QSslError error, socket->sslErrors())
1436 errorString += QString("<li>%1</li>").arg(error.errorString());
1437 errorString += "</ul>";
1439 auto box = new QMessageBox(QMessageBox::Warning,
1440 tr("Untrusted Security Certificate"),
1441 tr("<b>The SSL certificate provided by the core at %1 is untrusted for the following reasons:</b>").arg(socket->peerName()),
1442 QMessageBox::Cancel, this);
1443 box->setInformativeText(errorString);
1444 box->addButton(tr("Continue"), QMessageBox::AcceptRole);
1445 box->setDefaultButton(box->addButton(tr("Show Certificate"), QMessageBox::HelpRole));
1446 box->setAttribute(Qt::WA_DeleteOnClose);
1448 QMessageBox::ButtonRole role;
1451 role = box->buttonRole(box->clickedButton());
1452 if (role == QMessageBox::HelpRole) {
1453 auto dlg = new SslInfoDlg(socket, this);
1454 dlg->setAttribute(Qt::WA_DeleteOnClose);
1458 while (role == QMessageBox::HelpRole);
1460 *accepted = role == QMessageBox::AcceptRole;
1462 auto box2 = new QMessageBox(QMessageBox::Warning,
1463 tr("Untrusted Security Certificate"),
1464 tr("Would you like to accept this certificate forever without being prompted?"),
1466 box2->setDefaultButton(box2->addButton(tr("Current Session Only"), QMessageBox::NoRole));
1467 box2->addButton(tr("Forever"), QMessageBox::YesRole);
1468 box2->setAttribute(Qt::WA_DeleteOnClose);
1470 *permanently = (box2->buttonRole(box2->clickedButton()) == QMessageBox::YesRole);
1475 #endif /* HAVE_SSL */
1477 void MainWin::handleCoreConnectionError(const QString &error)
1479 QMessageBox::critical(this, tr("Core Connection Error"), error, QMessageBox::Ok);
1483 void MainWin::showCoreConnectionDlg()
1485 auto dlg = new CoreConnectDlg(this);
1486 dlg->setAttribute(Qt::WA_DeleteOnClose);
1487 if (dlg->exec() == QDialog::Accepted) {
1488 AccountId accId = dlg->selectedAccount();
1489 if (accId.isValid())
1490 Client::coreConnection()->connectToCore(accId);
1495 void MainWin::showCoreConfigWizard(const QVariantList &backends, const QVariantList &authenticators)
1497 CoreConfigWizard *wizard = new CoreConfigWizard(Client::coreConnection(), backends, authenticators, this);
1503 void MainWin::showChannelList(NetworkId netId, const QString &channelFilters, bool listImmediately)
1505 if (!netId.isValid()) {
1506 QAction *action = qobject_cast<QAction *>(sender());
1508 netId = action->data().value<NetworkId>();
1509 if (!netId.isValid()) {
1510 // We still haven't found a valid network, probably no network selected, e.g. "/list"
1511 // on the client homescreen when no networks are connected.
1512 auto box = new QMessageBox(QMessageBox::Information, tr("No network selected"),
1513 QString("<b>%1</b>").arg(tr("No network selected")),
1514 QMessageBox::Ok, this);
1515 box->setInformativeText(tr("Select a network before trying to view the channel list."));
1516 box->setAttribute(Qt::WA_DeleteOnClose);
1522 ChannelListDlg *channelListDlg = new ChannelListDlg(this);
1523 channelListDlg->setAttribute(Qt::WA_DeleteOnClose);
1524 channelListDlg->setNetwork(netId);
1525 if (!channelFilters.isEmpty()) {
1526 channelListDlg->setChannelFilters(channelFilters);
1528 if (listImmediately) {
1529 channelListDlg->requestSearch();
1531 channelListDlg->show();
1535 void MainWin::showNetworkConfig(NetworkId netId)
1537 auto dlg = new SettingsPageDlg(new NetworksSettingsPage(this), this);
1538 dlg->setAttribute(Qt::WA_DeleteOnClose);
1539 if (netId.isValid())
1540 qobject_cast<NetworksSettingsPage *>(dlg->currentPage())->bufferList_Open(netId);
1545 void MainWin::showIgnoreList(QString newRule)
1547 auto dlg = new SettingsPageDlg(new IgnoreListSettingsPage(this), this);
1548 dlg->setAttribute(Qt::WA_DeleteOnClose);
1549 // prepare config dialog for new rule
1550 if (!newRule.isEmpty())
1551 qobject_cast<IgnoreListSettingsPage *>(dlg->currentPage())->editIgnoreRule(newRule);
1556 void MainWin::showCoreInfoDlg()
1558 auto dlg = new CoreInfoDlg(this);
1559 dlg->setAttribute(Qt::WA_DeleteOnClose);
1564 void MainWin::showAwayLog()
1568 AwayLogFilter *filter = new AwayLogFilter(Client::messageModel());
1569 _awayLog = new AwayLogView(filter, 0);
1570 filter->setParent(_awayLog);
1571 connect(_awayLog, SIGNAL(destroyed()), this, SLOT(awayLogDestroyed()));
1572 _awayLog->setAttribute(Qt::WA_DeleteOnClose);
1577 void MainWin::awayLogDestroyed()
1583 void MainWin::showSettingsDlg()
1585 SettingsDlg *dlg = new SettingsDlg();
1586 dlg->setAttribute(Qt::WA_DeleteOnClose);
1588 //Category: Interface
1589 dlg->registerSettingsPage(new AppearanceSettingsPage(dlg));
1590 dlg->registerSettingsPage(new ChatViewSettingsPage(dlg));
1591 dlg->registerSettingsPage(new ChatViewColorSettingsPage(dlg));
1592 dlg->registerSettingsPage(new ChatMonitorSettingsPage(dlg));
1593 dlg->registerSettingsPage(new ItemViewSettingsPage(dlg));
1594 dlg->registerSettingsPage(new BufferViewSettingsPage(dlg));
1595 dlg->registerSettingsPage(new InputWidgetSettingsPage(dlg));
1596 dlg->registerSettingsPage(new TopicWidgetSettingsPage(dlg));
1598 dlg->registerSettingsPage(new SonnetSettingsPage(dlg));
1600 dlg->registerSettingsPage(new HighlightSettingsPage(dlg));
1601 dlg->registerSettingsPage(new CoreHighlightSettingsPage(dlg));
1602 dlg->registerSettingsPage(new NotificationsSettingsPage(dlg));
1603 dlg->registerSettingsPage(new BacklogSettingsPage(dlg));
1606 dlg->registerSettingsPage(new ConnectionSettingsPage(dlg));
1607 dlg->registerSettingsPage(new IdentitiesSettingsPage(dlg));
1608 dlg->registerSettingsPage(new NetworksSettingsPage(dlg));
1609 dlg->registerSettingsPage(new AliasesSettingsPage(dlg));
1610 dlg->registerSettingsPage(new IgnoreListSettingsPage(dlg));
1611 // dlg->registerSettingsPage(new DccSettingsPage(dlg)); not ready yet
1613 // Category: Remote Cores
1614 if (Quassel::runMode() != Quassel::Monolithic) {
1615 dlg->registerSettingsPage(new CoreAccountSettingsPage(dlg));
1616 dlg->registerSettingsPage(new CoreConnectionSettingsPage(dlg));
1623 void MainWin::showAboutDlg()
1625 auto dlg = new AboutDlg(this);
1626 dlg->setAttribute(Qt::WA_DeleteOnClose);
1631 void MainWin::showShortcutsDlg()
1634 auto dlg = new KShortcutsDialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsDisallowed, this);
1635 foreach(KActionCollection *coll, QtUi::actionCollections()) {
1636 dlg->addCollection(coll, coll->property("Category").toString());
1638 dlg->setAttribute(Qt::WA_DeleteOnClose);
1639 dlg->configure(true);
1641 auto dlg = new SettingsPageDlg(new ShortcutsSettingsPage(QtUi::actionCollections(), this), this);
1642 dlg->setAttribute(Qt::WA_DeleteOnClose);
1648 void MainWin::showNewTransferDlg(const QUuid &transferId)
1650 auto transfer = Client::transferManager()->transfer(transferId);
1652 if (transfer->status() == Transfer::Status::New) {
1653 ReceiveFileDlg *dlg = new ReceiveFileDlg(transfer, this);
1658 qWarning() << "Unknown transfer ID" << transferId;
1663 void MainWin::onFullScreenToggled()
1665 // Relying on QWidget::isFullScreen is discouraged, see the KToggleFullScreenAction docs
1666 // Also, one should not use showFullScreen() or showNormal(), as those reset all other window flags
1669 static_cast<KToggleFullScreenAction*>(_fullScreenAction)->setFullScreen(this, _fullScreenAction->isChecked());
1671 if (_fullScreenAction->isChecked())
1672 setWindowState(windowState() | Qt::WindowFullScreen);
1674 setWindowState(windowState() & ~Qt::WindowFullScreen);
1679 /********************************************************************************************************/
1681 bool MainWin::event(QEvent *event)
1683 switch(event->type()) {
1684 case QEvent::WindowActivate: {
1685 BufferId bufferId = Client::bufferModel()->currentBuffer();
1686 if (bufferId.isValid())
1687 Client::instance()->markBufferAsRead(bufferId);
1690 case QEvent::WindowDeactivate:
1691 if (bufferWidget()->autoMarkerLineOnLostFocus())
1692 bufferWidget()->setMarkerLine();
1697 return QMainWindow::event(event);
1701 void MainWin::moveEvent(QMoveEvent *event)
1703 if (!(windowState() & Qt::WindowMaximized))
1704 _normalPos = event->pos();
1706 QMainWindow::moveEvent(event);
1710 void MainWin::resizeEvent(QResizeEvent *event)
1712 if (!(windowState() & Qt::WindowMaximized))
1713 _normalSize = event->size();
1715 QMainWindow::resizeEvent(event);
1719 void MainWin::closeEvent(QCloseEvent *event)
1722 QtUiApplication *app = qobject_cast<QtUiApplication *> qApp;
1724 // On OSX it can happen that the closeEvent occurs twice. (Especially if packaged with Frameworks)
1725 // This messes up MainWinState/MainWinHidden save/restore.
1726 // It's a bug in Qt: https://bugreports.qt.io/browse/QTBUG-43344
1727 if (!_aboutToQuit && !app->isAboutToQuit() && QtUi::haveSystemTray() && s.value("MinimizeOnClose").toBool()) {
1728 QtUi::hideMainWidget();
1731 else if(!_aboutToQuit) {
1732 _aboutToQuit = true;
1742 void MainWin::messagesInserted(const QModelIndex &parent, int start, int end)
1746 bool hasFocus = QApplication::activeWindow() != 0;
1748 for (int i = start; i <= end; i++) {
1749 QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn);
1750 if (!idx.isValid()) {
1751 qDebug() << "MainWin::messagesInserted(): Invalid model index!";
1754 Message::Flags flags = (Message::Flags)idx.data(ChatLineModel::FlagsRole).toInt();
1755 if (flags.testFlag(Message::Backlog) || flags.testFlag(Message::Self))
1758 BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>();
1759 BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId);
1761 // check if bufferId belongs to the shown chatlists
1762 if (!(Client::bufferViewOverlay()->bufferIds().contains(bufId) ||
1763 Client::bufferViewOverlay()->tempRemovedBufferIds().contains(bufId)))
1766 // check if it's the buffer currently displayed
1767 if (hasFocus && bufId == Client::bufferModel()->currentBuffer())
1770 // only show notifications for higlights or queries
1771 if (bufType != BufferInfo::QueryBuffer && !(flags & Message::Highlight))
1774 // and of course: don't notify for ignored messages
1775 if (Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value<Message>(), Client::networkModel()->networkName(bufId)))
1778 // seems like we have a legit notification candidate!
1779 QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn);
1780 QString sender = senderIdx.data(ChatLineModel::EditRole).toString();
1781 QString contents = idx.data(ChatLineModel::DisplayRole).toString();
1782 AbstractNotificationBackend::NotificationType type;
1784 if (bufType == BufferInfo::QueryBuffer && !hasFocus)
1785 type = AbstractNotificationBackend::PrivMsg;
1786 else if (bufType == BufferInfo::QueryBuffer && hasFocus)
1787 type = AbstractNotificationBackend::PrivMsgFocused;
1788 else if (flags & Message::Highlight && !hasFocus)
1789 type = AbstractNotificationBackend::Highlight;
1791 type = AbstractNotificationBackend::HighlightFocused;
1793 QtUi::instance()->invokeNotification(bufId, type, sender, contents);
1798 void MainWin::currentBufferChanged(BufferId buffer)
1800 if (buffer.isValid())
1801 Client::instance()->markBufferAsRead(buffer);
1805 void MainWin::clientNetworkCreated(NetworkId id)
1807 const Network *net = Client::network(id);
1808 QAction *act = new QAction(net->networkName(), this);
1809 act->setObjectName(QString("NetworkAction-%1").arg(id.toInt()));
1810 act->setData(QVariant::fromValue<NetworkId>(id));
1811 connect(net, SIGNAL(updatedRemotely()), this, SLOT(clientNetworkUpdated()));
1812 connect(act, SIGNAL(triggered()), this, SLOT(connectOrDisconnectFromNet()));
1814 QAction *beforeAction = 0;
1815 foreach(QAction *action, _networksMenu->actions()) {
1816 if (!action->data().isValid()) // ignore stock actions
1818 if (net->networkName().localeAwareCompare(action->text()) < 0) {
1819 beforeAction = action;
1823 _networksMenu->insertAction(beforeAction, act);
1827 void MainWin::clientNetworkUpdated()
1829 const Network *net = qobject_cast<const Network *>(sender());
1833 QAction *action = findChild<QAction *>(QString("NetworkAction-%1").arg(net->networkId().toInt()));
1837 action->setText(net->networkName());
1839 switch (net->connectionState()) {
1840 case Network::Initialized:
1841 action->setIcon(icon::get("network-connect"));
1842 // if we have no currently selected buffer, jump to the first connecting statusbuffer
1843 if (!bufferWidget()->currentBuffer().isValid()) {
1844 QModelIndex idx = Client::networkModel()->networkIndex(net->networkId());
1845 if (idx.isValid()) {
1846 BufferId statusBufferId = idx.data(NetworkModel::BufferIdRole).value<BufferId>();
1847 Client::bufferModel()->switchToBuffer(statusBufferId);
1851 case Network::Disconnected:
1852 action->setIcon(icon::get("network-disconnect"));
1855 action->setIcon(icon::get("network-wired"));
1860 void MainWin::clientNetworkRemoved(NetworkId id)
1862 QAction *action = findChild<QAction *>(QString("NetworkAction-%1").arg(id.toInt()));
1866 action->deleteLater();
1870 void MainWin::connectOrDisconnectFromNet()
1872 QAction *act = qobject_cast<QAction *>(sender());
1874 const Network *net = Client::network(act->data().value<NetworkId>());
1876 if (net->connectionState() == Network::Disconnected) net->requestConnect();
1877 else net->requestDisconnect();
1881 void MainWin::on_inputFormatApplyColor_triggered()
1886 _inputWidget->applyFormatActiveColor();
1890 void MainWin::on_inputFormatApplyColorFill_triggered()
1895 _inputWidget->applyFormatActiveColorFill();
1899 void MainWin::on_inputFormatClear_triggered()
1904 _inputWidget->clearFormat();
1908 void MainWin::on_inputFormatBold_triggered()
1913 _inputWidget->toggleFormatBold();
1917 void MainWin::on_inputFormatItalic_triggered()
1922 _inputWidget->toggleFormatItalic();
1926 void MainWin::on_inputFormatUnderline_triggered()
1931 _inputWidget->toggleFormatUnderline();
1935 void MainWin::on_jumpHotBuffer_triggered()
1937 if (!_bufferHotList->rowCount())
1940 Client::bufferModel()->switchToBuffer(_bufferHotList->hottestBuffer());
1943 void MainWin::on_bufferSearch_triggered()
1945 if (_activeBufferViewIndex < 0 || _activeBufferViewIndex >= _bufferViews.count()) {
1946 qWarning() << "Tried to activate filter on invalid bufferview:" << _activeBufferViewIndex;
1950 _bufferViews[_activeBufferViewIndex]->activateFilter();
1954 void MainWin::onJumpKey()
1956 QAction *action = qobject_cast<QAction *>(sender());
1957 if (!action || !Client::bufferModel())
1959 int idx = action->property("Index").toInt();
1961 if (_jumpKeyMap.isEmpty())
1962 _jumpKeyMap = CoreAccountSettings().jumpKeyMap();
1964 if (!_jumpKeyMap.contains(idx))
1967 BufferId buffer = _jumpKeyMap.value(idx);
1968 if (buffer.isValid())
1969 Client::bufferModel()->switchToBuffer(buffer);
1973 void MainWin::bindJumpKey()
1975 QAction *action = qobject_cast<QAction *>(sender());
1976 if (!action || !Client::bufferModel())
1978 int idx = action->property("Index").toInt();
1980 _jumpKeyMap[idx] = Client::bufferModel()->currentBuffer();
1981 CoreAccountSettings().setJumpKeyMap(_jumpKeyMap);
1985 void MainWin::on_actionDebugNetworkModel_triggered()
1987 QTreeView *view = new QTreeView;
1988 view->setAttribute(Qt::WA_DeleteOnClose);
1989 view->setWindowTitle("Debug NetworkModel View");
1990 view->setModel(Client::networkModel());
1991 view->setColumnWidth(0, 250);
1992 view->setColumnWidth(1, 250);
1993 view->setColumnWidth(2, 80);
1994 view->resize(610, 300);
1999 void MainWin::on_actionDebugHotList_triggered()
2001 _bufferHotList->invalidate();
2002 _bufferHotList->sort(0, Qt::DescendingOrder);
2004 QTreeView *view = new QTreeView;
2005 view->setAttribute(Qt::WA_DeleteOnClose);
2006 view->setModel(_bufferHotList);
2011 void MainWin::on_actionDebugBufferViewOverlay_triggered()
2013 DebugBufferViewOverlay *overlay = new DebugBufferViewOverlay(0);
2014 overlay->setAttribute(Qt::WA_DeleteOnClose);
2019 void MainWin::on_actionDebugMessageModel_triggered()
2021 QTableView *view = new QTableView(0);
2022 DebugMessageModelFilter *filter = new DebugMessageModelFilter(view);
2023 filter->setSourceModel(Client::messageModel());
2024 view->setModel(filter);
2025 view->setAttribute(Qt::WA_DeleteOnClose, true);
2026 view->verticalHeader()->hide();
2027 view->horizontalHeader()->setStretchLastSection(true);
2032 void MainWin::on_actionDebugLog_triggered()
2034 DebugLogWidget *logWidget = new DebugLogWidget(nullptr); // will be deleted on close
2039 void MainWin::showStatusBarMessage(const QString &message)
2041 statusBar()->showMessage(message, 10000);