Add action/shortcut to use the buffer filter/search
[quassel.git] / src / qtui / mainwin.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2016 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #include "mainwin.h"
22
23 #include <QIcon>
24 #include <QMenuBar>
25 #include <QMessageBox>
26 #include <QStatusBar>
27 #include <QToolBar>
28 #include <QInputDialog>
29
30 #ifdef HAVE_KDE4
31 #  include <KHelpMenu>
32 #  include <KMenuBar>
33 #  include <KShortcutsDialog>
34 #  include <KStatusBar>
35 #  include <KToggleFullScreenAction>
36 #  include <KToolBar>
37 #endif
38
39 #ifdef HAVE_KF5
40 #  include <KConfigWidgets/KStandardAction>
41 #  include <KXmlGui/KHelpMenu>
42 #  include <KXmlGui/KShortcutsDialog>
43 #  include <KXmlGui/KToolBar>
44 #  include <KWidgetsAddons/KToggleFullScreenAction>
45 #endif
46
47 #ifdef Q_WS_X11
48 #  include <QX11Info>
49 #endif
50
51 #include "aboutdlg.h"
52 #include "awaylogfilter.h"
53 #include "awaylogview.h"
54 #include "action.h"
55 #include "actioncollection.h"
56 #include "bufferhotlistfilter.h"
57 #include "buffermodel.h"
58 #include "bufferview.h"
59 #include "bufferviewoverlay.h"
60 #include "bufferviewoverlayfilter.h"
61 #include "bufferwidget.h"
62 #include "channellistdlg.h"
63 #include "chatlinemodel.h"
64 #include "chatmonitorfilter.h"
65 #include "chatmonitorview.h"
66 #include "chatview.h"
67 #include "client.h"
68 #include "clientbacklogmanager.h"
69 #include "clientbufferviewconfig.h"
70 #include "clientbufferviewmanager.h"
71 #include "clientignorelistmanager.h"
72 #include "clienttransfer.h"
73 #include "clienttransfermanager.h"
74 #include "coreconfigwizard.h"
75 #include "coreconnectdlg.h"
76 #include "coreconnection.h"
77 #include "coreconnectionstatuswidget.h"
78 #include "coreinfodlg.h"
79 #include "contextmenuactionprovider.h"
80 #include "debugbufferviewoverlay.h"
81 #include "debuglogwidget.h"
82 #include "debugmessagemodelfilter.h"
83 #include "flatproxymodel.h"
84 #include "inputwidget.h"
85 #include "irclistmodel.h"
86 #include "ircconnectionwizard.h"
87 #include "legacysystemtray.h"
88 #include "msgprocessorstatuswidget.h"
89 #include "nicklistwidget.h"
90 #include "passwordchangedlg.h"
91 #include "qtuiapplication.h"
92 #include "qtuimessageprocessor.h"
93 #include "qtuisettings.h"
94 #include "qtuistyle.h"
95 #include "receivefiledlg.h"
96 #include "settingsdlg.h"
97 #include "settingspagedlg.h"
98 #include "statusnotifieritem.h"
99 #include "toolbaractionprovider.h"
100 #include "topicwidget.h"
101 #include "verticaldock.h"
102
103 #ifndef HAVE_KDE
104 #  ifdef HAVE_QTMULTIMEDIA
105 #    include "qtmultimedianotificationbackend.h"
106 #  endif
107 #  ifdef HAVE_PHONON
108 #    include "phononnotificationbackend.h"
109 #  endif
110 #  include "systraynotificationbackend.h"
111 #  include "taskbarnotificationbackend.h"
112 #else /* HAVE_KDE */
113 #  include "knotificationbackend.h"
114 #endif /* HAVE_KDE */
115
116
117 #ifdef HAVE_LIBSNORE
118 #  include "snorenotificationbackend.h"
119 #endif
120
121 #ifdef HAVE_SSL
122 #  include "sslinfodlg.h"
123 #endif
124
125 #ifdef HAVE_INDICATEQT
126   #include "indicatornotificationbackend.h"
127 #endif
128
129 #ifdef HAVE_NOTIFICATION_CENTER
130   #include "osxnotificationbackend.h"
131 #endif
132
133 #ifdef HAVE_DBUS
134   #include "dockmanagernotificationbackend.h"
135 #endif
136
137 #include "settingspages/aliasessettingspage.h"
138 #include "settingspages/appearancesettingspage.h"
139 #include "settingspages/backlogsettingspage.h"
140 #include "settingspages/bufferviewsettingspage.h"
141 #include "settingspages/chatmonitorsettingspage.h"
142 #include "settingspages/chatviewsettingspage.h"
143 #include "settingspages/connectionsettingspage.h"
144 #include "settingspages/coreaccountsettingspage.h"
145 #include "settingspages/coreconnectionsettingspage.h"
146 #include "settingspages/highlightsettingspage.h"
147 #include "settingspages/identitiessettingspage.h"
148 #include "settingspages/ignorelistsettingspage.h"
149 #include "settingspages/inputwidgetsettingspage.h"
150 #include "settingspages/itemviewsettingspage.h"
151 #include "settingspages/networkssettingspage.h"
152 #include "settingspages/notificationssettingspage.h"
153 #include "settingspages/topicwidgetsettingspage.h"
154
155 #ifndef HAVE_KDE
156 #  include "settingspages/shortcutssettingspage.h"
157 #endif
158
159 #ifdef HAVE_SONNET
160 #  include "settingspages/sonnetsettingspage.h"
161 #endif
162
163
164 MainWin::MainWin(QWidget *parent)
165 #ifdef HAVE_KDE
166     : KMainWindow(parent), _kHelpMenu(new KHelpMenu(this)),
167 #else
168     : QMainWindow(parent),
169 #endif
170     _msgProcessorStatusWidget(new MsgProcessorStatusWidget(this)),
171     _coreConnectionStatusWidget(new CoreConnectionStatusWidget(Client::coreConnection(), this)),
172     _titleSetter(this),
173     _awayLog(0),
174     _layoutLoaded(false),
175     _activeBufferViewIndex(-1)
176 {
177     setAttribute(Qt::WA_DeleteOnClose, false); // we delete the mainwin manually
178
179     QtUiSettings uiSettings;
180     QString style = uiSettings.value("Style", QString()).toString();
181     if (!style.isEmpty()) {
182         QApplication::setStyle(style);
183     }
184
185     QApplication::setQuitOnLastWindowClosed(false);
186
187     setWindowTitle("Quassel IRC");
188     setWindowIconText("Quassel IRC");
189     updateIcon();
190 }
191
192
193 void MainWin::init()
194 {
195     connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), SLOT(clientNetworkCreated(NetworkId)));
196     connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId)));
197     connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
198         SLOT(messagesInserted(const QModelIndex &, int, int)));
199     connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
200     connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
201
202     connect(Client::coreConnection(), SIGNAL(startCoreSetup(QVariantList)), SLOT(showCoreConfigWizard(QVariantList)));
203     connect(Client::coreConnection(), SIGNAL(connectionErrorPopup(QString)), SLOT(handleCoreConnectionError(QString)));
204     connect(Client::coreConnection(), SIGNAL(userAuthenticationRequired(CoreAccount *, bool *, QString)), SLOT(userAuthenticationRequired(CoreAccount *, bool *, QString)));
205     connect(Client::coreConnection(), SIGNAL(handleNoSslInClient(bool *)), SLOT(handleNoSslInClient(bool *)));
206     connect(Client::coreConnection(), SIGNAL(handleNoSslInCore(bool *)), SLOT(handleNoSslInCore(bool *)));
207 #ifdef HAVE_SSL
208     connect(Client::coreConnection(), SIGNAL(handleSslErrors(const QSslSocket *, bool *, bool *)), SLOT(handleSslErrors(const QSslSocket *, bool *, bool *)));
209 #endif
210
211     // Setup Dock Areas
212     setDockNestingEnabled(true);
213     setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
214     setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
215     setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
216     setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
217
218     // Order is sometimes important
219     setupActions();
220     setupBufferWidget();
221     setupMenus();
222     setupTopicWidget();
223     setupNickWidget();
224     setupInputWidget();
225     setupChatMonitor();
226     setupViewMenuTail();
227     setupStatusBar();
228     setupToolBars();
229     setupSystray();
230     setupTitleSetter();
231     setupHotList();
232
233 #ifndef HAVE_KDE
234 #  ifdef HAVE_QTMULTIMEDIA
235     QtUi::registerNotificationBackend(new QtMultimediaNotificationBackend(this));
236 #  endif
237 #  ifdef HAVE_PHONON
238     QtUi::registerNotificationBackend(new PhononNotificationBackend(this));
239 #  endif
240     QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
241 #else /* HAVE_KDE */
242     QtUi::registerNotificationBackend(new KNotificationBackend(this));
243 #endif /* HAVE_KDE */
244
245
246 #ifdef HAVE_LIBSNORE
247     QtUi::registerNotificationBackend(new SnoreNotificationBackend(this));
248 #elif !defined(QT_NO_SYSTEMTRAYICON) && !defined(HAVE_KDE)
249     QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
250 #endif
251
252 #ifdef HAVE_INDICATEQT
253     QtUi::registerNotificationBackend(new IndicatorNotificationBackend(this));
254 #endif
255
256 #ifdef HAVE_NOTIFICATION_CENTER
257     QtUi::registerNotificationBackend(new OSXNotificationBackend(this));
258 #endif
259
260 #ifdef HAVE_DBUS
261     QtUi::registerNotificationBackend(new DockManagerNotificationBackend(this));
262 #endif
263
264     // we assume that at this point, all configurable actions are defined!
265     QtUi::loadShortcuts();
266
267     connect(bufferWidget(), SIGNAL(currentChanged(BufferId)), SLOT(currentBufferChanged(BufferId)));
268
269     setDisconnectedState(); // Disable menus and stuff
270
271 #ifdef HAVE_KDE
272     setAutoSaveSettings();
273 #endif
274
275     // restore mainwin state
276     QtUiSettings s;
277     restoreStateFromSettings(s);
278
279     // restore locked state of docks
280     QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool());
281
282     CoreConnection *conn = Client::coreConnection();
283     if (!conn->connectToCore()) {
284         // No autoconnect selected (or no accounts)
285         showCoreConnectionDlg();
286     }
287 }
288
289
290 MainWin::~MainWin()
291 {
292 }
293
294
295 void MainWin::quit()
296 {
297     QtUiSettings s;
298     saveStateToSettings(s);
299     saveLayout();
300     QApplication::quit();
301 }
302
303
304 void MainWin::saveStateToSettings(UiSettings &s)
305 {
306     s.setValue("MainWinSize", _normalSize);
307     s.setValue("MainWinPos", _normalPos);
308     s.setValue("MainWinState", saveState());
309     s.setValue("MainWinGeometry", saveGeometry());
310     s.setValue("MainWinMinimized", isMinimized());
311     s.setValue("MainWinMaximized", isMaximized());
312     s.setValue("MainWinHidden", !isVisible());
313     BufferId lastBufId = Client::bufferModel()->currentBuffer();
314     if (lastBufId.isValid())
315         s.setValue("LastUsedBufferId", lastBufId.toInt());
316
317 #ifdef HAVE_KDE
318     saveAutoSaveSettings();
319 #endif
320 }
321
322
323 void MainWin::restoreStateFromSettings(UiSettings &s)
324 {
325     _normalSize = s.value("MainWinSize", size()).toSize();
326     _normalPos = s.value("MainWinPos", pos()).toPoint();
327     bool maximized = s.value("MainWinMaximized", false).toBool();
328
329 #ifndef HAVE_KDE
330     restoreGeometry(s.value("MainWinGeometry").toByteArray());
331
332     if (maximized) {
333         // restoreGeometry() fails if the windows was maximized, so we resize and position explicitly
334         resize(_normalSize);
335         move(_normalPos);
336     }
337
338     restoreState(s.value("MainWinState").toByteArray());
339
340 #else
341     move(_normalPos);
342 #endif
343
344     if ((Quassel::isOptionSet("hidewindow")
345             || s.value("MainWinHidden").toBool())
346             && _systemTray->isSystemTrayAvailable())
347         QtUi::hideMainWidget();
348     else if (s.value("MainWinMinimized").toBool())
349         showMinimized();
350     else if (maximized)
351         showMaximized();
352     else
353         show();
354 }
355
356
357 void MainWin::updateIcon()
358 {
359     QIcon icon;
360     if (Client::isConnected())
361         icon = QIcon::fromTheme("quassel", QIcon(":/icons/quassel-128.png"));
362     else
363         icon = QIcon::fromTheme("quassel-inactive", QIcon(":/icons/quassel-128.png"));
364     setWindowIcon(icon);
365     qApp->setWindowIcon(icon);
366 }
367
368
369 void MainWin::setupActions()
370 {
371     ActionCollection *coll = QtUi::actionCollection("General", tr("General"));
372     // File
373     coll->addAction("ConnectCore", new Action(QIcon::fromTheme("network-connect"), tr("&Connect to Core..."), coll,
374             this, SLOT(showCoreConnectionDlg())));
375     coll->addAction("DisconnectCore", new Action(QIcon::fromTheme("network-disconnect"), tr("&Disconnect from Core"), coll,
376             Client::instance(), SLOT(disconnectFromCore())));
377     coll->addAction("ChangePassword", new Action(QIcon::fromTheme("dialog-password"), tr("Change &Password..."), coll,
378             this, SLOT(showPasswordChangeDlg())));
379     coll->addAction("CoreInfo", new Action(QIcon::fromTheme("help-about"), tr("Core &Info..."), coll,
380             this, SLOT(showCoreInfoDlg())));
381     coll->addAction("ConfigureNetworks", new Action(QIcon::fromTheme("configure"), tr("Configure &Networks..."), coll,
382             this, SLOT(on_actionConfigureNetworks_triggered())));
383     // FIXME: use QKeySequence::Quit once we depend on Qt 4.6
384     coll->addAction("Quit", new Action(QIcon::fromTheme("application-exit"), tr("&Quit"), coll,
385             this, SLOT(quit()), Qt::CTRL + Qt::Key_Q));
386
387     // View
388     coll->addAction("ConfigureBufferViews", new Action(tr("&Configure Chat Lists..."), coll,
389             this, SLOT(on_actionConfigureViews_triggered())));
390
391     QAction *lockAct = coll->addAction("LockLayout", new Action(tr("&Lock Layout"), coll));
392     lockAct->setCheckable(true);
393     connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockLayout_toggled(bool)));
394
395     coll->addAction("ToggleSearchBar", new Action(QIcon::fromTheme("edit-find"), tr("Show &Search Bar"), coll,
396             0, 0, QKeySequence::Find))->setCheckable(true);
397     coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll,
398             this, SLOT(showAwayLog())));
399     coll->addAction("ToggleMenuBar", new Action(QIcon::fromTheme("show-menu"), tr("Show &Menubar"), coll,
400             0, 0, QKeySequence(Qt::CTRL + Qt::Key_M)))->setCheckable(true);
401
402     coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll,
403             0, 0))->setCheckable(true);
404
405 #ifdef HAVE_KDE
406     _fullScreenAction = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll);
407 #else
408     _fullScreenAction = new Action(QIcon::fromTheme("view-fullscreen"), tr("&Full Screen Mode"), coll,
409         this, SLOT(onFullScreenToggled()), QKeySequence(Qt::Key_F11));
410     _fullScreenAction->setCheckable(true);
411     coll->addAction("ToggleFullScreen", _fullScreenAction);
412 #endif
413
414     // Settings
415     QAction *configureShortcutsAct = new Action(QIcon::fromTheme("configure-shortcuts"), tr("Configure &Shortcuts..."), coll,
416         this, SLOT(showShortcutsDlg()));
417     configureShortcutsAct->setMenuRole(QAction::NoRole);
418     coll->addAction("ConfigureShortcuts", configureShortcutsAct);
419
420 #ifdef Q_OS_MAC
421     QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
422         this, SLOT(showSettingsDlg()));
423     configureQuasselAct->setMenuRole(QAction::PreferencesRole);
424 #else
425     QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
426         this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7));
427 #endif
428     coll->addAction("ConfigureQuassel", configureQuasselAct);
429
430     // Help
431     QAction *aboutQuasselAct = new Action(QIcon(":/icons/quassel.png"), tr("&About Quassel"), coll,
432         this, SLOT(showAboutDlg()));
433     aboutQuasselAct->setMenuRole(QAction::AboutRole);
434     coll->addAction("AboutQuassel", aboutQuasselAct);
435
436     QAction *aboutQtAct = new Action(QIcon(":/pics/qt-logo.png"), tr("About &Qt"), coll,
437         qApp, SLOT(aboutQt()));
438     aboutQtAct->setMenuRole(QAction::AboutQtRole);
439     coll->addAction("AboutQt", aboutQtAct);
440     coll->addAction("DebugNetworkModel", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &NetworkModel"), coll,
441             this, SLOT(on_actionDebugNetworkModel_triggered())));
442     coll->addAction("DebugBufferViewOverlay", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &BufferViewOverlay"), coll,
443             this, SLOT(on_actionDebugBufferViewOverlay_triggered())));
444     coll->addAction("DebugMessageModel", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &MessageModel"), coll,
445             this, SLOT(on_actionDebugMessageModel_triggered())));
446     coll->addAction("DebugHotList", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &HotList"), coll,
447             this, SLOT(on_actionDebugHotList_triggered())));
448     coll->addAction("DebugLog", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &Log"), coll,
449             this, SLOT(on_actionDebugLog_triggered())));
450     coll->addAction("ReloadStyle", new Action(QIcon::fromTheme("view-refresh"), tr("Reload Stylesheet"), coll,
451             QtUi::style(), SLOT(reload()), QKeySequence::Refresh));
452
453     coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll,
454             this, SLOT(hideCurrentBuffer()), QKeySequence::Close));
455
456     // Navigation
457     coll = QtUi::actionCollection("Navigation", tr("Navigation"));
458
459     coll->addAction("JumpHotBuffer", new Action(tr("Jump to hot chat"), coll,
460             this, SLOT(on_jumpHotBuffer_triggered()), QKeySequence(Qt::META + Qt::Key_A)));
461
462     coll->addAction("ActivateBufferFilter", new Action(tr("Activate the buffer search"), coll,
463             this, SLOT(on_bufferSearch_triggered()), QKeySequence(Qt::CTRL + Qt::Key_S)));
464
465     // Jump keys
466 #ifdef Q_OS_MAC
467     const int bindModifier = Qt::ControlModifier | Qt::AltModifier;
468     const int jumpModifier = Qt::ControlModifier;
469 #else
470     const int bindModifier = Qt::ControlModifier;
471     const int jumpModifier = Qt::AltModifier;
472 #endif
473
474     coll->addAction("BindJumpKey0", new Action(tr("Set Quick Access #0"), coll, this, SLOT(bindJumpKey()),
475             QKeySequence(bindModifier + Qt::Key_0)))->setProperty("Index", 0);
476     coll->addAction("BindJumpKey1", new Action(tr("Set Quick Access #1"), coll, this, SLOT(bindJumpKey()),
477             QKeySequence(bindModifier + Qt::Key_1)))->setProperty("Index", 1);
478     coll->addAction("BindJumpKey2", new Action(tr("Set Quick Access #2"), coll, this, SLOT(bindJumpKey()),
479             QKeySequence(bindModifier + Qt::Key_2)))->setProperty("Index", 2);
480     coll->addAction("BindJumpKey3", new Action(tr("Set Quick Access #3"), coll, this, SLOT(bindJumpKey()),
481             QKeySequence(bindModifier + Qt::Key_3)))->setProperty("Index", 3);
482     coll->addAction("BindJumpKey4", new Action(tr("Set Quick Access #4"), coll, this, SLOT(bindJumpKey()),
483             QKeySequence(bindModifier + Qt::Key_4)))->setProperty("Index", 4);
484     coll->addAction("BindJumpKey5", new Action(tr("Set Quick Access #5"), coll, this, SLOT(bindJumpKey()),
485             QKeySequence(bindModifier + Qt::Key_5)))->setProperty("Index", 5);
486     coll->addAction("BindJumpKey6", new Action(tr("Set Quick Access #6"), coll, this, SLOT(bindJumpKey()),
487             QKeySequence(bindModifier + Qt::Key_6)))->setProperty("Index", 6);
488     coll->addAction("BindJumpKey7", new Action(tr("Set Quick Access #7"), coll, this, SLOT(bindJumpKey()),
489             QKeySequence(bindModifier + Qt::Key_7)))->setProperty("Index", 7);
490     coll->addAction("BindJumpKey8", new Action(tr("Set Quick Access #8"), coll, this, SLOT(bindJumpKey()),
491             QKeySequence(bindModifier + Qt::Key_8)))->setProperty("Index", 8);
492     coll->addAction("BindJumpKey9", new Action(tr("Set Quick Access #9"), coll, this, SLOT(bindJumpKey()),
493             QKeySequence(bindModifier + Qt::Key_9)))->setProperty("Index", 9);
494
495     coll->addAction("JumpKey0", new Action(tr("Quick Access #0"), coll, this, SLOT(onJumpKey()),
496             QKeySequence(jumpModifier + Qt::Key_0)))->setProperty("Index", 0);
497     coll->addAction("JumpKey1", new Action(tr("Quick Access #1"), coll, this, SLOT(onJumpKey()),
498             QKeySequence(jumpModifier + Qt::Key_1)))->setProperty("Index", 1);
499     coll->addAction("JumpKey2", new Action(tr("Quick Access #2"), coll, this, SLOT(onJumpKey()),
500             QKeySequence(jumpModifier + Qt::Key_2)))->setProperty("Index", 2);
501     coll->addAction("JumpKey3", new Action(tr("Quick Access #3"), coll, this, SLOT(onJumpKey()),
502             QKeySequence(jumpModifier + Qt::Key_3)))->setProperty("Index", 3);
503     coll->addAction("JumpKey4", new Action(tr("Quick Access #4"), coll, this, SLOT(onJumpKey()),
504             QKeySequence(jumpModifier + Qt::Key_4)))->setProperty("Index", 4);
505     coll->addAction("JumpKey5", new Action(tr("Quick Access #5"), coll, this, SLOT(onJumpKey()),
506             QKeySequence(jumpModifier + Qt::Key_5)))->setProperty("Index", 5);
507     coll->addAction("JumpKey6", new Action(tr("Quick Access #6"), coll, this, SLOT(onJumpKey()),
508             QKeySequence(jumpModifier + Qt::Key_6)))->setProperty("Index", 6);
509     coll->addAction("JumpKey7", new Action(tr("Quick Access #7"), coll, this, SLOT(onJumpKey()),
510             QKeySequence(jumpModifier + Qt::Key_7)))->setProperty("Index", 7);
511     coll->addAction("JumpKey8", new Action(tr("Quick Access #8"), coll, this, SLOT(onJumpKey()),
512             QKeySequence(jumpModifier + Qt::Key_8)))->setProperty("Index", 8);
513     coll->addAction("JumpKey9", new Action(tr("Quick Access #9"), coll, this, SLOT(onJumpKey()),
514             QKeySequence(jumpModifier + Qt::Key_9)))->setProperty("Index", 9);
515
516     // Buffer navigation
517     coll->addAction("NextBufferView", new Action(QIcon::fromTheme("go-next-view"), tr("Activate Next Chat List"), coll,
518             this, SLOT(nextBufferView()), QKeySequence(QKeySequence::Forward)));
519     coll->addAction("PreviousBufferView", new Action(QIcon::fromTheme("go-previous-view"), tr("Activate Previous Chat List"), coll,
520             this, SLOT(previousBufferView()), QKeySequence::Back));
521     coll->addAction("NextBuffer", new Action(QIcon::fromTheme("go-down"), tr("Go to Next Chat"), coll,
522             this, SLOT(nextBuffer()), QKeySequence(Qt::ALT + Qt::Key_Down)));
523     coll->addAction("PreviousBuffer", new Action(QIcon::fromTheme("go-up"), tr("Go to Previous Chat"), coll,
524             this, SLOT(previousBuffer()), QKeySequence(Qt::ALT + Qt::Key_Up)));
525 }
526
527
528 void MainWin::setupMenus()
529 {
530     ActionCollection *coll = QtUi::actionCollection("General");
531
532     _fileMenu = menuBar()->addMenu(tr("&File"));
533
534     static const QStringList coreActions = QStringList()
535         << "ConnectCore" << "DisconnectCore" << "ChangePassword" << "CoreInfo";
536
537     QAction *coreAction;
538     foreach(QString actionName, coreActions) {
539         coreAction = coll->action(actionName);
540         _fileMenu->addAction(coreAction);
541         flagRemoteCoreOnly(coreAction);
542     }
543     flagRemoteCoreOnly(_fileMenu->addSeparator());
544
545     _networksMenu = _fileMenu->addMenu(tr("&Networks"));
546     _networksMenu->addAction(coll->action("ConfigureNetworks"));
547     _networksMenu->addSeparator();
548     _fileMenu->addSeparator();
549     _fileMenu->addAction(coll->action("Quit"));
550
551     _viewMenu = menuBar()->addMenu(tr("&View"));
552     _bufferViewsMenu = _viewMenu->addMenu(tr("&Chat Lists"));
553     _bufferViewsMenu->addAction(coll->action("ConfigureBufferViews"));
554     _toolbarMenu = _viewMenu->addMenu(tr("&Toolbars"));
555     _viewMenu->addSeparator();
556
557     _viewMenu->addAction(coll->action("ToggleMenuBar"));
558     _viewMenu->addAction(coll->action("ToggleStatusBar"));
559     _viewMenu->addAction(coll->action("ToggleSearchBar"));
560
561     coreAction = coll->action("ShowAwayLog");
562     flagRemoteCoreOnly(coreAction);
563     _viewMenu->addAction(coreAction);
564
565     _viewMenu->addSeparator();
566     _viewMenu->addAction(coll->action("LockLayout"));
567
568     _settingsMenu = menuBar()->addMenu(tr("&Settings"));
569 #ifdef HAVE_KDE
570     _settingsMenu->addAction(KStandardAction::configureNotifications(this, SLOT(showNotificationsDlg()), this));
571     _settingsMenu->addAction(KStandardAction::keyBindings(this, SLOT(showShortcutsDlg()), this));
572 #else
573     _settingsMenu->addAction(coll->action("ConfigureShortcuts"));
574 #endif
575     _settingsMenu->addAction(coll->action("ConfigureQuassel"));
576
577
578     _helpMenu = menuBar()->addMenu(tr("&Help"));
579
580     _helpMenu->addAction(coll->action("AboutQuassel"));
581 #ifndef HAVE_KDE
582     _helpMenu->addAction(coll->action("AboutQt"));
583 #else
584     _helpMenu->addAction(KStandardAction::aboutKDE(_kHelpMenu, SLOT(aboutKDE()), this));
585 #endif
586     _helpMenu->addSeparator();
587     _helpDebugMenu = _helpMenu->addMenu(QIcon::fromTheme("tools-report-bug"), tr("Debug"));
588     _helpDebugMenu->addAction(coll->action("DebugNetworkModel"));
589     _helpDebugMenu->addAction(coll->action("DebugBufferViewOverlay"));
590     _helpDebugMenu->addAction(coll->action("DebugMessageModel"));
591     _helpDebugMenu->addAction(coll->action("DebugHotList"));
592     _helpDebugMenu->addAction(coll->action("DebugLog"));
593     _helpDebugMenu->addSeparator();
594     _helpDebugMenu->addAction(coll->action("ReloadStyle"));
595
596     // Toggle visibility
597     QAction *showMenuBar = QtUi::actionCollection("General")->action("ToggleMenuBar");
598
599     QtUiSettings uiSettings;
600     bool enabled = uiSettings.value("ShowMenuBar", QVariant(true)).toBool();
601     showMenuBar->setChecked(enabled);
602     enabled ? menuBar()->show() : menuBar()->hide();
603
604     connect(showMenuBar, SIGNAL(toggled(bool)), menuBar(), SLOT(setVisible(bool)));
605     connect(showMenuBar, SIGNAL(toggled(bool)), this, SLOT(saveMenuBarStatus(bool)));
606 }
607
608
609 void MainWin::setupBufferWidget()
610 {
611     _bufferWidget = new BufferWidget(this);
612     _bufferWidget->setModel(Client::bufferModel());
613     _bufferWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
614     setCentralWidget(_bufferWidget);
615 }
616
617
618 void MainWin::addBufferView(int bufferViewConfigId)
619 {
620     addBufferView(Client::bufferViewManager()->clientBufferViewConfig(bufferViewConfigId));
621 }
622
623
624 void MainWin::addBufferView(ClientBufferViewConfig *config)
625 {
626     if (!config)
627         return;
628
629     config->setLocked(QtUiSettings().value("LockLayout", false).toBool());
630     BufferViewDock *dock = new BufferViewDock(config, this);
631
632     //create the view and initialize it's filter
633     BufferView *view = new BufferView(dock);
634     view->setFilteredModel(Client::bufferModel(), config);
635     view->installEventFilter(_inputWidget); // for key presses
636
637     Client::bufferModel()->synchronizeView(view);
638
639     dock->setWidget(view);
640     dock->setVisible(_layoutLoaded); // don't show before state has been restored
641
642     addDockWidget(Qt::LeftDockWidgetArea, dock);
643     _bufferViewsMenu->addAction(dock->toggleViewAction());
644
645     connect(dock->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(bufferViewToggled(bool)));
646     connect(dock, SIGNAL(visibilityChanged(bool)), SLOT(bufferViewVisibilityChanged(bool)));
647     _bufferViews.append(dock);
648
649     if (!activeBufferView())
650         nextBufferView();
651 }
652
653
654 void MainWin::removeBufferView(int bufferViewConfigId)
655 {
656     QVariant actionData;
657     BufferViewDock *dock;
658     foreach(QAction *action, _bufferViewsMenu->actions()) {
659         actionData = action->data();
660         if (!actionData.isValid())
661             continue;
662
663         dock = qobject_cast<BufferViewDock *>(action->parent());
664         if (dock && actionData.toInt() == bufferViewConfigId) {
665             removeAction(action);
666             Client::bufferViewOverlay()->removeView(dock->bufferViewId());
667             _bufferViews.removeAll(dock);
668
669             if (dock->isActive()) {
670                 dock->setActive(false);
671                 _activeBufferViewIndex = -1;
672                 nextBufferView();
673             }
674
675             dock->deleteLater();
676         }
677     }
678 }
679
680
681 void MainWin::bufferViewToggled(bool enabled)
682 {
683     if (!enabled && !isMinimized()) {
684         // hiding the mainwindow triggers a toggle of the bufferview (which pretty much sucks big time)
685         // since this isn't our fault and we can't do anything about it, we suppress the resulting calls
686         return;
687     }
688     QAction *action = qobject_cast<QAction *>(sender());
689     Q_ASSERT(action);
690     BufferViewDock *dock = qobject_cast<BufferViewDock *>(action->parent());
691     Q_ASSERT(dock);
692
693     // Make sure we don't toggle backlog fetch for a view we've already removed
694     if (!_bufferViews.contains(dock))
695         return;
696
697     if (enabled)
698         Client::bufferViewOverlay()->addView(dock->bufferViewId());
699     else
700         Client::bufferViewOverlay()->removeView(dock->bufferViewId());
701 }
702
703
704 void MainWin::bufferViewVisibilityChanged(bool visible)
705 {
706     Q_UNUSED(visible);
707     BufferViewDock *dock = qobject_cast<BufferViewDock *>(sender());
708     Q_ASSERT(dock);
709     if ((!dock->isHidden() && !activeBufferView()) || (dock->isHidden() && dock->isActive()))
710         nextBufferView();
711 }
712
713
714 BufferView *MainWin::allBuffersView() const
715 {
716     // "All Buffers" is always the first dock created
717     if (_bufferViews.count() > 0)
718         return _bufferViews[0]->bufferView();
719     return 0;
720 }
721
722
723 BufferView *MainWin::activeBufferView() const
724 {
725     if (_activeBufferViewIndex < 0 || _activeBufferViewIndex >= _bufferViews.count())
726         return 0;
727     BufferViewDock *dock = _bufferViews.at(_activeBufferViewIndex);
728     return dock->isActive() ? dock->bufferView() : 0;
729 }
730
731
732 void MainWin::changeActiveBufferView(int bufferViewId)
733 {
734     if (bufferViewId < 0)
735         return;
736
737     if (_activeBufferViewIndex >= 0 && _activeBufferViewIndex < _bufferViews.count()) {
738         _bufferViews[_activeBufferViewIndex]->setActive(false);
739         _activeBufferViewIndex = -1;
740     }
741
742     for (int i = 0; i < _bufferViews.count(); i++) {
743         BufferViewDock *dock = _bufferViews.at(i);
744         if (dock->bufferViewId() == bufferViewId && !dock->isHidden()) {
745             _activeBufferViewIndex = i;
746             dock->setActive(true);
747             return;
748         }
749     }
750
751     nextBufferView(); // fallback
752 }
753
754
755 void MainWin::showPasswordChangeDlg()
756 {
757     if((Client::coreFeatures() & Quassel::PasswordChange)) {
758         PasswordChangeDlg dlg(this);
759         dlg.exec();
760     }
761     else {
762         QMessageBox box(QMessageBox::Warning, tr("Feature Not Supported"),
763                         tr("<b>Your Quassel Core does not support this feature</b>"),
764                         QMessageBox::Ok, this);
765         box.setInformativeText(tr("You need a Quassel Core v0.12.0 or newer in order to be able to remotely change your password."));
766         box.exec();
767     }
768 }
769
770
771 void MainWin::changeActiveBufferView(bool backwards)
772 {
773     if (_activeBufferViewIndex >= 0 && _activeBufferViewIndex < _bufferViews.count()) {
774         _bufferViews[_activeBufferViewIndex]->setActive(false);
775     }
776
777     if (!_bufferViews.count())
778         return;
779
780     int c = _bufferViews.count();
781     while (c--) { // yes, this will reactivate the current active one if all others fail
782         if (backwards) {
783             if (--_activeBufferViewIndex < 0)
784                 _activeBufferViewIndex = _bufferViews.count()-1;
785         }
786         else {
787             if (++_activeBufferViewIndex >= _bufferViews.count())
788                 _activeBufferViewIndex = 0;
789         }
790
791         BufferViewDock *dock = _bufferViews.at(_activeBufferViewIndex);
792         if (dock->isHidden())
793             continue;
794
795         dock->setActive(true);
796         return;
797     }
798
799     _activeBufferViewIndex = -1;
800 }
801
802
803 void MainWin::nextBufferView()
804 {
805     changeActiveBufferView(false);
806 }
807
808
809 void MainWin::previousBufferView()
810 {
811     changeActiveBufferView(true);
812 }
813
814
815 void MainWin::nextBuffer()
816 {
817     BufferView *view = activeBufferView();
818     if (view)
819         view->nextBuffer();
820 }
821
822
823 void MainWin::previousBuffer()
824 {
825     BufferView *view = activeBufferView();
826     if (view)
827         view->previousBuffer();
828 }
829
830
831 void MainWin::hideCurrentBuffer()
832 {
833     BufferView *view = activeBufferView();
834     if (view)
835         view->hideCurrentBuffer();
836 }
837
838
839 void MainWin::showNotificationsDlg()
840 {
841     SettingsPageDlg dlg(new NotificationsSettingsPage(this), this);
842     dlg.exec();
843 }
844
845
846 void MainWin::on_actionConfigureNetworks_triggered()
847 {
848     SettingsPageDlg dlg(new NetworksSettingsPage(this), this);
849     dlg.exec();
850 }
851
852
853 void MainWin::on_actionConfigureViews_triggered()
854 {
855     SettingsPageDlg dlg(new BufferViewSettingsPage(this), this);
856     dlg.exec();
857 }
858
859
860 void MainWin::on_actionLockLayout_toggled(bool lock)
861 {
862     QList<VerticalDock *> docks = findChildren<VerticalDock *>();
863     foreach(VerticalDock *dock, docks) {
864         dock->showTitle(!lock);
865     }
866     if (Client::bufferViewManager()) {
867         foreach(ClientBufferViewConfig *config, Client::bufferViewManager()->clientBufferViewConfigs()) {
868             config->setLocked(lock);
869         }
870     }
871     QtUiSettings().setValue("LockLayout", lock);
872 }
873
874
875 void MainWin::setupNickWidget()
876 {
877     // create nick dock
878     NickListDock *nickDock = new NickListDock(tr("Nicks"), this);
879     nickDock->setObjectName("NickDock");
880     nickDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
881
882     _nickListWidget = new NickListWidget(nickDock);
883     nickDock->setWidget(_nickListWidget);
884
885     addDockWidget(Qt::RightDockWidgetArea, nickDock);
886     _viewMenu->addAction(nickDock->toggleViewAction());
887     nickDock->toggleViewAction()->setText(tr("Show Nick List"));
888
889     // See NickListDock::NickListDock();
890     // connect(nickDock->toggleViewAction(), SIGNAL(triggered(bool)), nickListWidget, SLOT(showWidget(bool)));
891
892     // attach the NickListWidget to the BufferModel and the default selection
893     _nickListWidget->setModel(Client::bufferModel());
894     _nickListWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
895
896     _nickListWidget->setVisible(false);
897 }
898
899
900 void MainWin::setupChatMonitor()
901 {
902     VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this);
903     dock->setObjectName("ChatMonitorDock");
904
905     ChatMonitorFilter *filter = new ChatMonitorFilter(Client::messageModel(), this);
906     _chatMonitorView = new ChatMonitorView(filter, this);
907     _chatMonitorView->setFocusProxy(_inputWidget);
908     _chatMonitorView->show();
909     dock->setWidget(_chatMonitorView);
910     dock->hide();
911
912     addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
913     _viewMenu->addAction(dock->toggleViewAction());
914     dock->toggleViewAction()->setText(tr("Show Chat Monitor"));
915 }
916
917
918 void MainWin::setupInputWidget()
919 {
920     VerticalDock *dock = new VerticalDock(tr("Inputline"), this);
921     dock->setObjectName("InputDock");
922
923     _inputWidget = new InputWidget(dock);
924     dock->setWidget(_inputWidget);
925
926     addDockWidget(Qt::BottomDockWidgetArea, dock);
927
928     _viewMenu->addAction(dock->toggleViewAction());
929     dock->toggleViewAction()->setText(tr("Show Input Line"));
930
931     _inputWidget->setModel(Client::bufferModel());
932     _inputWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
933
934     _bufferWidget->setFocusProxy(_inputWidget);
935
936     _inputWidget->inputLine()->installEventFilter(_bufferWidget);
937
938     connect(_topicWidget, SIGNAL(switchedPlain()), _bufferWidget, SLOT(setFocus()));
939 }
940
941
942 void MainWin::setupTopicWidget()
943 {
944     VerticalDock *dock = new VerticalDock(tr("Topic"), this);
945     dock->setObjectName("TopicDock");
946     _topicWidget = new TopicWidget(dock);
947
948     dock->setWidget(_topicWidget);
949
950     _topicWidget->setModel(Client::bufferModel());
951     _topicWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
952
953     addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
954
955     _viewMenu->addAction(dock->toggleViewAction());
956     dock->toggleViewAction()->setText(tr("Show Topic Line"));
957 }
958
959
960 void MainWin::setupViewMenuTail()
961 {
962     _viewMenu->addSeparator();
963     _viewMenu->addAction(_fullScreenAction);
964 }
965
966
967 void MainWin::setupTitleSetter()
968 {
969     _titleSetter.setModel(Client::bufferModel());
970     _titleSetter.setSelectionModel(Client::bufferModel()->standardSelectionModel());
971 }
972
973
974 void MainWin::setupStatusBar()
975 {
976     // MessageProcessor progress
977     statusBar()->addPermanentWidget(_msgProcessorStatusWidget);
978
979     // Connection state
980     _coreConnectionStatusWidget->update();
981     statusBar()->addPermanentWidget(_coreConnectionStatusWidget);
982
983     QAction *showStatusbar = QtUi::actionCollection("General")->action("ToggleStatusBar");
984
985     QtUiSettings uiSettings;
986
987     bool enabled = uiSettings.value("ShowStatusBar", QVariant(true)).toBool();
988     showStatusbar->setChecked(enabled);
989     enabled ? statusBar()->show() : statusBar()->hide();
990
991     connect(showStatusbar, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool)));
992     connect(showStatusbar, SIGNAL(toggled(bool)), this, SLOT(saveStatusBarStatus(bool)));
993
994     connect(Client::coreConnection(), SIGNAL(connectionMsg(QString)), statusBar(), SLOT(showMessage(QString)));
995 }
996
997
998 void MainWin::setupHotList()
999 {
1000     FlatProxyModel *flatProxy = new FlatProxyModel(this);
1001     flatProxy->setSourceModel(Client::bufferModel());
1002     _bufferHotList = new BufferHotListFilter(flatProxy);
1003 }
1004
1005
1006 void MainWin::saveMenuBarStatus(bool enabled)
1007 {
1008     QtUiSettings uiSettings;
1009     uiSettings.setValue("ShowMenuBar", enabled);
1010 }
1011
1012
1013 void MainWin::saveStatusBarStatus(bool enabled)
1014 {
1015     QtUiSettings uiSettings;
1016     uiSettings.setValue("ShowStatusBar", enabled);
1017 }
1018
1019
1020 void MainWin::setupSystray()
1021 {
1022 #ifdef HAVE_DBUS
1023     _systemTray = new StatusNotifierItem(this);
1024 #elif !defined QT_NO_SYSTEMTRAYICON
1025     _systemTray = new LegacySystemTray(this);
1026 #else
1027     _systemTray = new SystemTray(this); // dummy
1028 #endif
1029     _systemTray->init();
1030 }
1031
1032
1033 void MainWin::setupToolBars()
1034 {
1035     connect(_bufferWidget, SIGNAL(currentChanged(QModelIndex)),
1036         QtUi::toolBarActionProvider(), SLOT(currentBufferChanged(QModelIndex)));
1037     connect(_nickListWidget, SIGNAL(nickSelectionChanged(QModelIndexList)),
1038         QtUi::toolBarActionProvider(), SLOT(nickSelectionChanged(QModelIndexList)));
1039
1040 #ifdef Q_OS_MAC
1041     setUnifiedTitleAndToolBarOnMac(true);
1042 #endif
1043
1044 #ifdef HAVE_KDE
1045     _mainToolBar = new KToolBar("MainToolBar", this, Qt::TopToolBarArea, false, true, true);
1046 #else
1047     _mainToolBar = new QToolBar(this);
1048     _mainToolBar->setObjectName("MainToolBar");
1049 #endif
1050     _mainToolBar->setWindowTitle(tr("Main Toolbar"));
1051     addToolBar(_mainToolBar);
1052
1053     QtUi::toolBarActionProvider()->addActions(_mainToolBar, ToolBarActionProvider::MainToolBar);
1054     _toolbarMenu->addAction(_mainToolBar->toggleViewAction());
1055
1056 #ifdef Q_OS_MAC
1057     QtUiSettings uiSettings;
1058
1059     bool visible = uiSettings.value("ShowMainToolBar", QVariant(true)).toBool();
1060     _mainToolBar->setVisible(visible);
1061     connect(_mainToolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(saveMainToolBarStatus(bool)));
1062 #endif
1063 }
1064
1065 void MainWin::saveMainToolBarStatus(bool enabled)
1066 {
1067 #ifdef Q_OS_MAC
1068     QtUiSettings uiSettings;
1069     uiSettings.setValue("ShowMainToolBar", enabled);
1070 #else
1071     Q_UNUSED(enabled);
1072 #endif
1073 }
1074
1075
1076 void MainWin::connectedToCore()
1077 {
1078     Q_CHECK_PTR(Client::bufferViewManager());
1079     connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigAdded(int)), this, SLOT(addBufferView(int)));
1080     connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigDeleted(int)), this, SLOT(removeBufferView(int)));
1081     connect(Client::bufferViewManager(), SIGNAL(initDone()), this, SLOT(loadLayout()));
1082
1083     connect(Client::transferManager(), SIGNAL(transferAdded(QUuid)), SLOT(showNewTransferDlg(QUuid)));
1084
1085     setConnectedState();
1086 }
1087
1088
1089 void MainWin::setConnectedState()
1090 {
1091     ActionCollection *coll = QtUi::actionCollection("General");
1092
1093     coll->action("ConnectCore")->setEnabled(false);
1094     coll->action("DisconnectCore")->setEnabled(true);
1095     coll->action("ChangePassword")->setEnabled(true);
1096     coll->action("CoreInfo")->setEnabled(true);
1097
1098     foreach(QAction *action, _fileMenu->actions()) {
1099         if (isRemoteCoreOnly(action))
1100             action->setVisible(!Client::internalCore());
1101     }
1102
1103     disconnect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), _msgProcessorStatusWidget, SLOT(setProgress(int, int)));
1104     disconnect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
1105     disconnect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
1106     if (!Client::internalCore()) {
1107         connect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), _msgProcessorStatusWidget, SLOT(setProgress(int, int)));
1108         connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
1109         connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
1110     }
1111
1112     // _viewMenu->setEnabled(true);
1113     if (!Client::internalCore())
1114         statusBar()->showMessage(tr("Connected to core."));
1115     else
1116         statusBar()->clearMessage();
1117
1118     _coreConnectionStatusWidget->setVisible(!Client::internalCore());
1119     updateIcon();
1120     systemTray()->setState(SystemTray::Active);
1121
1122     if (Client::networkIds().isEmpty()) {
1123         IrcConnectionWizard *wizard = new IrcConnectionWizard(this, Qt::Sheet);
1124         wizard->show();
1125     }
1126     else {
1127         // Monolithic always preselects last used buffer - Client only if the connection died
1128         if (Client::coreConnection()->wasReconnect() || Quassel::runMode() == Quassel::Monolithic) {
1129             QtUiSettings s;
1130             BufferId lastUsedBufferId(s.value("LastUsedBufferId").toInt());
1131             if (lastUsedBufferId.isValid())
1132                 Client::bufferModel()->switchToBuffer(lastUsedBufferId);
1133         }
1134     }
1135 }
1136
1137
1138 void MainWin::loadLayout()
1139 {
1140     QtUiSettings s;
1141     int accountId = Client::currentCoreAccount().accountId().toInt();
1142     QByteArray state = s.value(QString("MainWinState-%1").arg(accountId)).toByteArray();
1143     if (state.isEmpty()) {
1144         foreach(BufferViewDock *view, _bufferViews)
1145         view->show();
1146         _layoutLoaded = true;
1147         return;
1148     }
1149     _nickListWidget->setVisible(true);
1150     restoreState(state, accountId);
1151     int bufferViewId = s.value(QString("ActiveBufferView-%1").arg(accountId), -1).toInt();
1152     if (bufferViewId >= 0)
1153         changeActiveBufferView(bufferViewId);
1154
1155     _layoutLoaded = true;
1156 }
1157
1158
1159 void MainWin::saveLayout()
1160 {
1161     QtUiSettings s;
1162     int accountId = _bufferViews.count() ? Client::currentCoreAccount().accountId().toInt() : 0; // only save if we still have a layout!
1163     if (accountId > 0) {
1164         s.setValue(QString("MainWinState-%1").arg(accountId), saveState(accountId));
1165         BufferView *view = activeBufferView();
1166         s.setValue(QString("ActiveBufferView-%1").arg(accountId), view ? view->config()->bufferViewId() : -1);
1167     }
1168 }
1169
1170
1171 void MainWin::disconnectedFromCore()
1172 {
1173     // save core specific layout and remove bufferviews;
1174     saveLayout();
1175     _layoutLoaded = false;
1176
1177     QVariant actionData;
1178     BufferViewDock *dock;
1179     foreach(QAction *action, _bufferViewsMenu->actions()) {
1180         actionData = action->data();
1181         if (!actionData.isValid())
1182             continue;
1183
1184         dock = qobject_cast<BufferViewDock *>(action->parent());
1185         if (dock && actionData.toInt() != -1) {
1186             removeAction(action);
1187             _bufferViews.removeAll(dock);
1188             dock->deleteLater();
1189         }
1190     }
1191
1192     // store last active buffer
1193     QtUiSettings s;
1194     BufferId lastBufId = _bufferWidget->currentBuffer();
1195     if (lastBufId.isValid()) {
1196         s.setValue("LastUsedBufferId", lastBufId.toInt());
1197         // clear the current selection
1198         Client::bufferModel()->standardSelectionModel()->clearSelection();
1199     }
1200     restoreState(s.value("MainWinState").toByteArray());
1201     setDisconnectedState();
1202 }
1203
1204
1205 void MainWin::setDisconnectedState()
1206 {
1207     ActionCollection *coll = QtUi::actionCollection("General");
1208     //ui.menuCore->setEnabled(false);
1209     coll->action("ConnectCore")->setEnabled(true);
1210     coll->action("DisconnectCore")->setEnabled(false);
1211     coll->action("CoreInfo")->setEnabled(false);
1212     coll->action("ChangePassword")->setEnabled(false);
1213     //_viewMenu->setEnabled(false);
1214     statusBar()->showMessage(tr("Not connected to core."));
1215     if (_msgProcessorStatusWidget)
1216         _msgProcessorStatusWidget->setProgress(0, 0);
1217     updateIcon();
1218     systemTray()->setState(SystemTray::Passive);
1219     _nickListWidget->setVisible(false);
1220 }
1221
1222
1223 void MainWin::userAuthenticationRequired(CoreAccount *account, bool *valid, const QString &errorMessage)
1224 {
1225     Q_UNUSED(errorMessage)
1226     CoreConnectAuthDlg dlg(account, this);
1227     *valid = (dlg.exec() == QDialog::Accepted);
1228 }
1229
1230
1231 void MainWin::handleNoSslInClient(bool *accepted)
1232 {
1233     QMessageBox box(QMessageBox::Warning, tr("Unencrypted Connection"), tr("<b>Your client does not support SSL encryption</b>"),
1234         QMessageBox::Ignore|QMessageBox::Cancel, this);
1235     box.setInformativeText(tr("Sensitive data, like passwords, will be transmitted unencrypted to your Quassel core."));
1236     box.setDefaultButton(QMessageBox::Ignore);
1237     *accepted = box.exec() == QMessageBox::Ignore;
1238 }
1239
1240
1241 void MainWin::handleNoSslInCore(bool *accepted)
1242 {
1243     QMessageBox box(QMessageBox::Warning, tr("Unencrypted Connection"), tr("<b>Your core does not support SSL encryption</b>"),
1244         QMessageBox::Ignore|QMessageBox::Cancel, this);
1245     box.setInformativeText(tr("Sensitive data, like passwords, will be transmitted unencrypted to your Quassel core."));
1246     box.setDefaultButton(QMessageBox::Ignore);
1247     *accepted = box.exec() == QMessageBox::Ignore;
1248 }
1249
1250
1251 #ifdef HAVE_SSL
1252
1253 void MainWin::handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently)
1254 {
1255     QString errorString = "<ul>";
1256     foreach(const QSslError error, socket->sslErrors())
1257     errorString += QString("<li>%1</li>").arg(error.errorString());
1258     errorString += "</ul>";
1259
1260     QMessageBox box(QMessageBox::Warning,
1261         tr("Untrusted Security Certificate"),
1262         tr("<b>The SSL certificate provided by the core at %1 is untrusted for the following reasons:</b>").arg(socket->peerName()),
1263         QMessageBox::Cancel, this);
1264     box.setInformativeText(errorString);
1265     box.addButton(tr("Continue"), QMessageBox::AcceptRole);
1266     box.setDefaultButton(box.addButton(tr("Show Certificate"), QMessageBox::HelpRole));
1267
1268     QMessageBox::ButtonRole role;
1269     do {
1270         box.exec();
1271         role = box.buttonRole(box.clickedButton());
1272         if (role == QMessageBox::HelpRole) {
1273             SslInfoDlg dlg(socket, this);
1274             dlg.exec();
1275         }
1276     }
1277     while (role == QMessageBox::HelpRole);
1278
1279     *accepted = role == QMessageBox::AcceptRole;
1280     if (*accepted) {
1281         QMessageBox box2(QMessageBox::Warning,
1282             tr("Untrusted Security Certificate"),
1283             tr("Would you like to accept this certificate forever without being prompted?"),
1284             0, this);
1285         box2.setDefaultButton(box2.addButton(tr("Current Session Only"), QMessageBox::NoRole));
1286         box2.addButton(tr("Forever"), QMessageBox::YesRole);
1287         box2.exec();
1288         *permanently =  box2.buttonRole(box2.clickedButton()) == QMessageBox::YesRole;
1289     }
1290 }
1291
1292
1293 #endif /* HAVE_SSL */
1294
1295 void MainWin::handleCoreConnectionError(const QString &error)
1296 {
1297     QMessageBox::critical(this, tr("Core Connection Error"), error, QMessageBox::Ok);
1298 }
1299
1300
1301 void MainWin::showCoreConnectionDlg()
1302 {
1303     CoreConnectDlg dlg(this);
1304     if (dlg.exec() == QDialog::Accepted) {
1305         AccountId accId = dlg.selectedAccount();
1306         if (accId.isValid())
1307             Client::coreConnection()->connectToCore(accId);
1308     }
1309 }
1310
1311
1312 void MainWin::showCoreConfigWizard(const QVariantList &backends)
1313 {
1314     CoreConfigWizard *wizard = new CoreConfigWizard(Client::coreConnection(), backends, this);
1315
1316     wizard->show();
1317 }
1318
1319
1320 void MainWin::showChannelList(NetworkId netId)
1321 {
1322     ChannelListDlg *channelListDlg = new ChannelListDlg();
1323
1324     if (!netId.isValid()) {
1325         QAction *action = qobject_cast<QAction *>(sender());
1326         if (action)
1327             netId = action->data().value<NetworkId>();
1328     }
1329
1330     channelListDlg->setAttribute(Qt::WA_DeleteOnClose);
1331     channelListDlg->setNetwork(netId);
1332     channelListDlg->show();
1333 }
1334
1335
1336 void MainWin::showIgnoreList(QString newRule)
1337 {
1338     SettingsPageDlg dlg(new IgnoreListSettingsPage(this), this);
1339     // prepare config dialog for new rule
1340     if (!newRule.isEmpty())
1341         qobject_cast<IgnoreListSettingsPage *>(dlg.currentPage())->editIgnoreRule(newRule);
1342     dlg.exec();
1343 }
1344
1345
1346 void MainWin::showCoreInfoDlg()
1347 {
1348     CoreInfoDlg(this).exec();
1349 }
1350
1351
1352 void MainWin::showAwayLog()
1353 {
1354     if (_awayLog)
1355         return;
1356     AwayLogFilter *filter = new AwayLogFilter(Client::messageModel());
1357     _awayLog = new AwayLogView(filter, 0);
1358     filter->setParent(_awayLog);
1359     connect(_awayLog, SIGNAL(destroyed()), this, SLOT(awayLogDestroyed()));
1360     _awayLog->setAttribute(Qt::WA_DeleteOnClose);
1361     _awayLog->show();
1362 }
1363
1364
1365 void MainWin::awayLogDestroyed()
1366 {
1367     _awayLog = 0;
1368 }
1369
1370
1371 void MainWin::showSettingsDlg()
1372 {
1373     SettingsDlg *dlg = new SettingsDlg();
1374
1375     //Category: Interface
1376     dlg->registerSettingsPage(new AppearanceSettingsPage(dlg));
1377     dlg->registerSettingsPage(new ChatViewSettingsPage(dlg));
1378     dlg->registerSettingsPage(new ChatMonitorSettingsPage(dlg));
1379     dlg->registerSettingsPage(new ItemViewSettingsPage(dlg));
1380     dlg->registerSettingsPage(new BufferViewSettingsPage(dlg));
1381     dlg->registerSettingsPage(new InputWidgetSettingsPage(dlg));
1382     dlg->registerSettingsPage(new TopicWidgetSettingsPage(dlg));
1383 #ifdef HAVE_SONNET
1384     dlg->registerSettingsPage(new SonnetSettingsPage(dlg));
1385 #endif
1386     dlg->registerSettingsPage(new HighlightSettingsPage(dlg));
1387     dlg->registerSettingsPage(new NotificationsSettingsPage(dlg));
1388     dlg->registerSettingsPage(new BacklogSettingsPage(dlg));
1389
1390     //Category: IRC
1391     dlg->registerSettingsPage(new ConnectionSettingsPage(dlg));
1392     dlg->registerSettingsPage(new IdentitiesSettingsPage(dlg));
1393     dlg->registerSettingsPage(new NetworksSettingsPage(dlg));
1394     dlg->registerSettingsPage(new AliasesSettingsPage(dlg));
1395     dlg->registerSettingsPage(new IgnoreListSettingsPage(dlg));
1396
1397     // Category: Remote Cores
1398     if (Quassel::runMode() != Quassel::Monolithic) {
1399         dlg->registerSettingsPage(new CoreAccountSettingsPage(dlg));
1400         dlg->registerSettingsPage(new CoreConnectionSettingsPage(dlg));
1401     }
1402
1403     dlg->show();
1404 }
1405
1406
1407 void MainWin::showAboutDlg()
1408 {
1409     AboutDlg(this).exec();
1410 }
1411
1412
1413 void MainWin::showShortcutsDlg()
1414 {
1415 #ifdef HAVE_KDE
1416     KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsDisallowed, this);
1417     foreach(KActionCollection *coll, QtUi::actionCollections())
1418     dlg.addCollection(coll, coll->property("Category").toString());
1419     dlg.configure(true);
1420 #else
1421     SettingsPageDlg dlg(new ShortcutsSettingsPage(QtUi::actionCollections(), this), this);
1422     dlg.exec();
1423 #endif
1424 }
1425
1426
1427 void MainWin::showNewTransferDlg(const QUuid &transferId)
1428 {
1429     auto transfer = Client::transferManager()->transfer(transferId);
1430     if (transfer) {
1431         ReceiveFileDlg *dlg = new ReceiveFileDlg(transfer, this);
1432         dlg->show();
1433     }
1434     else {
1435         qWarning() << "Unknown transfer ID" << transferId;
1436     }
1437 }
1438
1439
1440 void MainWin::onFullScreenToggled()
1441 {
1442     // Relying on QWidget::isFullScreen is discouraged, see the KToggleFullScreenAction docs
1443     // Also, one should not use showFullScreen() or showNormal(), as those reset all other window flags
1444
1445 #ifdef HAVE_KDE
1446     static_cast<KToggleFullScreenAction*>(_fullScreenAction)->setFullScreen(this, _fullScreenAction->isChecked());
1447 #else
1448     if (_fullScreenAction->isChecked())
1449         setWindowState(windowState() | Qt::WindowFullScreen);
1450     else
1451         setWindowState(windowState() & ~Qt::WindowFullScreen);
1452 #endif
1453 }
1454
1455
1456 /********************************************************************************************************/
1457
1458 bool MainWin::event(QEvent *event)
1459 {
1460     switch(event->type()) {
1461     case QEvent::WindowActivate: {
1462         BufferId bufferId = Client::bufferModel()->currentBuffer();
1463         if (bufferId.isValid())
1464             Client::instance()->markBufferAsRead(bufferId);
1465         break;
1466     }
1467     case QEvent::WindowDeactivate:
1468         if (bufferWidget()->autoMarkerLineOnLostFocus())
1469             bufferWidget()->setMarkerLine();
1470         break;
1471     default:
1472         break;
1473     }
1474     return QMainWindow::event(event);
1475 }
1476
1477
1478 void MainWin::moveEvent(QMoveEvent *event)
1479 {
1480     if (!(windowState() & Qt::WindowMaximized))
1481         _normalPos = event->pos();
1482
1483     QMainWindow::moveEvent(event);
1484 }
1485
1486
1487 void MainWin::resizeEvent(QResizeEvent *event)
1488 {
1489     if (!(windowState() & Qt::WindowMaximized))
1490         _normalSize = event->size();
1491
1492     QMainWindow::resizeEvent(event);
1493 }
1494
1495
1496 void MainWin::closeEvent(QCloseEvent *event)
1497 {
1498     QtUiSettings s;
1499     QtUiApplication *app = qobject_cast<QtUiApplication *> qApp;
1500     Q_ASSERT(app);
1501     if (!app->isAboutToQuit() && QtUi::haveSystemTray() && s.value("MinimizeOnClose").toBool()) {
1502         QtUi::hideMainWidget();
1503         event->ignore();
1504     }
1505     else {
1506         event->accept();
1507         quit();
1508     }
1509 }
1510
1511
1512 void MainWin::messagesInserted(const QModelIndex &parent, int start, int end)
1513 {
1514     Q_UNUSED(parent);
1515
1516     bool hasFocus = QApplication::activeWindow() != 0;
1517
1518     for (int i = start; i <= end; i++) {
1519         QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn);
1520         if (!idx.isValid()) {
1521             qDebug() << "MainWin::messagesInserted(): Invalid model index!";
1522             continue;
1523         }
1524         Message::Flags flags = (Message::Flags)idx.data(ChatLineModel::FlagsRole).toInt();
1525         if (flags.testFlag(Message::Backlog) || flags.testFlag(Message::Self))
1526             continue;
1527
1528         BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>();
1529         BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId);
1530
1531         // check if bufferId belongs to the shown chatlists
1532         if (!(Client::bufferViewOverlay()->bufferIds().contains(bufId) ||
1533               Client::bufferViewOverlay()->tempRemovedBufferIds().contains(bufId)))
1534             continue;
1535
1536         // check if it's the buffer currently displayed
1537         if (hasFocus && bufId == Client::bufferModel()->currentBuffer())
1538             continue;
1539
1540         // only show notifications for higlights or queries
1541         if (bufType != BufferInfo::QueryBuffer && !(flags & Message::Highlight))
1542             continue;
1543
1544         // and of course: don't notify for ignored messages
1545         if (Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value<Message>(), Client::networkModel()->networkName(bufId)))
1546             continue;
1547
1548         // seems like we have a legit notification candidate!
1549         QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn);
1550         QString sender = senderIdx.data(ChatLineModel::EditRole).toString();
1551         QString contents = idx.data(ChatLineModel::DisplayRole).toString();
1552         AbstractNotificationBackend::NotificationType type;
1553
1554         if (bufType == BufferInfo::QueryBuffer && !hasFocus)
1555             type = AbstractNotificationBackend::PrivMsg;
1556         else if (bufType == BufferInfo::QueryBuffer && hasFocus)
1557             type = AbstractNotificationBackend::PrivMsgFocused;
1558         else if (flags & Message::Highlight && !hasFocus)
1559             type = AbstractNotificationBackend::Highlight;
1560         else
1561             type = AbstractNotificationBackend::HighlightFocused;
1562
1563         QtUi::instance()->invokeNotification(bufId, type, sender, contents);
1564     }
1565 }
1566
1567
1568 void MainWin::currentBufferChanged(BufferId buffer)
1569 {
1570     if (buffer.isValid())
1571         Client::instance()->markBufferAsRead(buffer);
1572 }
1573
1574
1575 void MainWin::clientNetworkCreated(NetworkId id)
1576 {
1577     const Network *net = Client::network(id);
1578     QAction *act = new QAction(net->networkName(), this);
1579     act->setObjectName(QString("NetworkAction-%1").arg(id.toInt()));
1580     act->setData(QVariant::fromValue<NetworkId>(id));
1581     connect(net, SIGNAL(updatedRemotely()), this, SLOT(clientNetworkUpdated()));
1582     connect(act, SIGNAL(triggered()), this, SLOT(connectOrDisconnectFromNet()));
1583
1584     QAction *beforeAction = 0;
1585     foreach(QAction *action, _networksMenu->actions()) {
1586         if (!action->data().isValid()) // ignore stock actions
1587             continue;
1588         if (net->networkName().localeAwareCompare(action->text()) < 0) {
1589             beforeAction = action;
1590             break;
1591         }
1592     }
1593     _networksMenu->insertAction(beforeAction, act);
1594 }
1595
1596
1597 void MainWin::clientNetworkUpdated()
1598 {
1599     const Network *net = qobject_cast<const Network *>(sender());
1600     if (!net)
1601         return;
1602
1603     QAction *action = findChild<QAction *>(QString("NetworkAction-%1").arg(net->networkId().toInt()));
1604     if (!action)
1605         return;
1606
1607     action->setText(net->networkName());
1608
1609     switch (net->connectionState()) {
1610     case Network::Initialized:
1611         action->setIcon(QIcon::fromTheme("network-connect"));
1612         // if we have no currently selected buffer, jump to the first connecting statusbuffer
1613         if (!bufferWidget()->currentBuffer().isValid()) {
1614             QModelIndex idx = Client::networkModel()->networkIndex(net->networkId());
1615             if (idx.isValid()) {
1616                 BufferId statusBufferId = idx.data(NetworkModel::BufferIdRole).value<BufferId>();
1617                 Client::bufferModel()->switchToBuffer(statusBufferId);
1618             }
1619         }
1620         break;
1621     case Network::Disconnected:
1622         action->setIcon(QIcon::fromTheme("network-disconnect"));
1623         break;
1624     default:
1625         action->setIcon(QIcon::fromTheme("network-wired"));
1626     }
1627 }
1628
1629
1630 void MainWin::clientNetworkRemoved(NetworkId id)
1631 {
1632     QAction *action = findChild<QAction *>(QString("NetworkAction-%1").arg(id.toInt()));
1633     if (!action)
1634         return;
1635
1636     action->deleteLater();
1637 }
1638
1639
1640 void MainWin::connectOrDisconnectFromNet()
1641 {
1642     QAction *act = qobject_cast<QAction *>(sender());
1643     if (!act) return;
1644     const Network *net = Client::network(act->data().value<NetworkId>());
1645     if (!net) return;
1646     if (net->connectionState() == Network::Disconnected) net->requestConnect();
1647     else net->requestDisconnect();
1648 }
1649
1650
1651 void MainWin::on_jumpHotBuffer_triggered()
1652 {
1653     if (!_bufferHotList->rowCount())
1654         return;
1655
1656     Client::bufferModel()->switchToBuffer(_bufferHotList->hottestBuffer());
1657 }
1658
1659 void MainWin::on_bufferSearch_triggered()
1660 {
1661     if (_activeBufferViewIndex < 0 || _activeBufferViewIndex >= _bufferViews.count()) {
1662         qWarning() << "Tried to activate filter on invalid bufferview:" << _activeBufferViewIndex;
1663         return;
1664     }
1665
1666     _bufferViews[_activeBufferViewIndex]->activateFilter();
1667 }
1668
1669
1670 void MainWin::onJumpKey()
1671 {
1672     QAction *action = qobject_cast<QAction *>(sender());
1673     if (!action || !Client::bufferModel())
1674         return;
1675     int idx = action->property("Index").toInt();
1676
1677     if (_jumpKeyMap.isEmpty())
1678         _jumpKeyMap = CoreAccountSettings().jumpKeyMap();
1679
1680     if (!_jumpKeyMap.contains(idx))
1681         return;
1682
1683     BufferId buffer = _jumpKeyMap.value(idx);
1684     if (buffer.isValid())
1685         Client::bufferModel()->switchToBuffer(buffer);
1686 }
1687
1688
1689 void MainWin::bindJumpKey()
1690 {
1691     QAction *action = qobject_cast<QAction *>(sender());
1692     if (!action || !Client::bufferModel())
1693         return;
1694     int idx = action->property("Index").toInt();
1695
1696     _jumpKeyMap[idx] = Client::bufferModel()->currentBuffer();
1697     CoreAccountSettings().setJumpKeyMap(_jumpKeyMap);
1698 }
1699
1700
1701 void MainWin::on_actionDebugNetworkModel_triggered()
1702 {
1703     QTreeView *view = new QTreeView;
1704     view->setAttribute(Qt::WA_DeleteOnClose);
1705     view->setWindowTitle("Debug NetworkModel View");
1706     view->setModel(Client::networkModel());
1707     view->setColumnWidth(0, 250);
1708     view->setColumnWidth(1, 250);
1709     view->setColumnWidth(2, 80);
1710     view->resize(610, 300);
1711     view->show();
1712 }
1713
1714
1715 void MainWin::on_actionDebugHotList_triggered()
1716 {
1717     _bufferHotList->invalidate();
1718     _bufferHotList->sort(0, Qt::DescendingOrder);
1719
1720     QTreeView *view = new QTreeView;
1721     view->setAttribute(Qt::WA_DeleteOnClose);
1722     view->setModel(_bufferHotList);
1723     view->show();
1724 }
1725
1726
1727 void MainWin::on_actionDebugBufferViewOverlay_triggered()
1728 {
1729     DebugBufferViewOverlay *overlay = new DebugBufferViewOverlay(0);
1730     overlay->setAttribute(Qt::WA_DeleteOnClose);
1731     overlay->show();
1732 }
1733
1734
1735 void MainWin::on_actionDebugMessageModel_triggered()
1736 {
1737     QTableView *view = new QTableView(0);
1738     DebugMessageModelFilter *filter = new DebugMessageModelFilter(view);
1739     filter->setSourceModel(Client::messageModel());
1740     view->setModel(filter);
1741     view->setAttribute(Qt::WA_DeleteOnClose, true);
1742     view->verticalHeader()->hide();
1743     view->horizontalHeader()->setStretchLastSection(true);
1744     view->show();
1745 }
1746
1747
1748 void MainWin::on_actionDebugLog_triggered()
1749 {
1750     DebugLogWidget *logWidget = new DebugLogWidget(0);
1751     logWidget->show();
1752 }
1753
1754
1755 void MainWin::showStatusBarMessage(const QString &message)
1756 {
1757     statusBar()->showMessage(message, 10000);
1758 }