+ Q_UNUSED(enabled);
+#endif
+}
+
+
+void MainWin::doAutoConnect()
+{
+ if (!Client::coreConnection()->connectToCore()) {
+ // No autoconnect selected (or no accounts)
+ showCoreConnectionDlg();
+ }
+}
+
+
+void MainWin::connectedToCore()
+{
+ Q_CHECK_PTR(Client::bufferViewManager());
+ connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigAdded(int)), this, SLOT(addBufferView(int)));
+ connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigDeleted(int)), this, SLOT(removeBufferView(int)));
+ connect(Client::bufferViewManager(), SIGNAL(initDone()), this, SLOT(loadLayout()));
+
+ if (Client::transferManager()) {
+ connect(Client::transferManager(), SIGNAL(transferAdded(QUuid)), SLOT(showNewTransferDlg(QUuid)));
+ }
+
+ setConnectedState();
+}
+
+
+void MainWin::setConnectedState()
+{
+ ActionCollection *coll = QtUi::actionCollection("General");
+
+ coll->action("ConnectCore")->setEnabled(false);
+ coll->action("DisconnectCore")->setEnabled(true);
+ coll->action("ChangePassword")->setEnabled(true);
+ coll->action("CoreInfo")->setEnabled(true);
+
+ foreach(QAction *action, _fileMenu->actions()) {
+ if (isRemoteCoreOnly(action))
+ action->setVisible(!Client::internalCore());
+ }
+
+ disconnect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), _msgProcessorStatusWidget, SLOT(setProgress(int, int)));
+ disconnect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
+ disconnect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
+ if (!Client::internalCore()) {
+ connect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), _msgProcessorStatusWidget, SLOT(setProgress(int, int)));
+ connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
+ connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
+ }
+
+ // _viewMenu->setEnabled(true);
+ if (!Client::internalCore())
+ statusBar()->showMessage(tr("Connected to core."));
+ else
+ statusBar()->clearMessage();
+
+ _coreConnectionStatusWidget->setVisible(!Client::internalCore());
+ updateIcon();
+ systemTray()->setState(SystemTray::Active);
+
+ if (Client::networkIds().isEmpty()) {
+ IrcConnectionWizard *wizard = new IrcConnectionWizard(this, Qt::Sheet);
+ wizard->show();
+ }
+ else {
+ // Monolithic always preselects last used buffer - Client only if the connection died
+ if (Client::coreConnection()->wasReconnect() || Quassel::runMode() == Quassel::Monolithic) {
+ QtUiSettings s;
+ BufferId lastUsedBufferId(s.value("LastUsedBufferId").toInt());
+ if (lastUsedBufferId.isValid())
+ Client::bufferModel()->switchToBuffer(lastUsedBufferId);
+ }
+ }
+}
+
+
+void MainWin::loadLayout()
+{
+ QtUiSettings s;
+ int accountId = Client::currentCoreAccount().accountId().toInt();
+ QByteArray state = s.value(QString("MainWinState-%1").arg(accountId)).toByteArray();
+ if (state.isEmpty()) {
+ foreach(BufferViewDock *view, _bufferViews)
+ view->show();
+ _layoutLoaded = true;
+ return;
+ }
+ _nickListWidget->setVisible(true);
+ restoreState(state, accountId);
+ int bufferViewId = s.value(QString("ActiveBufferView-%1").arg(accountId), -1).toInt();
+ if (bufferViewId >= 0)
+ changeActiveBufferView(bufferViewId);
+
+ _layoutLoaded = true;
+}
+
+
+void MainWin::saveLayout()
+{
+ QtUiSettings s;
+ int accountId = _bufferViews.count() ? Client::currentCoreAccount().accountId().toInt() : 0; // only save if we still have a layout!
+ if (accountId > 0) {
+ s.setValue(QString("MainWinState-%1").arg(accountId), saveState(accountId));
+ BufferView *view = activeBufferView();
+ s.setValue(QString("ActiveBufferView-%1").arg(accountId), view ? view->config()->bufferViewId() : -1);
+ }
+}
+
+
+void MainWin::disconnectedFromCore()
+{
+ // save core specific layout and remove bufferviews;
+ saveLayout();
+ _layoutLoaded = false;
+
+ QVariant actionData;
+ BufferViewDock *dock;
+ foreach(QAction *action, _bufferViewsMenu->actions()) {
+ actionData = action->data();
+ if (!actionData.isValid())
+ continue;
+
+ dock = qobject_cast<BufferViewDock *>(action->parent());
+ if (dock && actionData.toInt() != -1) {
+ removeAction(action);
+ _bufferViews.removeAll(dock);
+ dock->deleteLater();
+ }
+ }
+
+ // store last active buffer
+ QtUiSettings s;
+ BufferId lastBufId = _bufferWidget->currentBuffer();
+ if (lastBufId.isValid()) {
+ s.setValue("LastUsedBufferId", lastBufId.toInt());
+ // clear the current selection
+ Client::bufferModel()->standardSelectionModel()->clearSelection();
+ }
+ restoreState(s.value("MainWinState").toByteArray());
+ setDisconnectedState();
+}
+
+
+void MainWin::setDisconnectedState()
+{
+ ActionCollection *coll = QtUi::actionCollection("General");
+ //ui.menuCore->setEnabled(false);
+ coll->action("ConnectCore")->setEnabled(true);
+ coll->action("DisconnectCore")->setEnabled(false);
+ coll->action("CoreInfo")->setEnabled(false);
+ coll->action("ChangePassword")->setEnabled(false);
+ //_viewMenu->setEnabled(false);
+ statusBar()->showMessage(tr("Not connected to core."));
+ if (_msgProcessorStatusWidget)
+ _msgProcessorStatusWidget->setProgress(0, 0);
+ updateIcon();
+ systemTray()->setState(SystemTray::Passive);
+ _nickListWidget->setVisible(false);
+}
+
+
+void MainWin::userAuthenticationRequired(CoreAccount *account, bool *valid, const QString &errorMessage)
+{
+ Q_UNUSED(errorMessage)
+ CoreConnectAuthDlg dlg(account, this);
+ *valid = (dlg.exec() == QDialog::Accepted);
+}
+
+
+void MainWin::handleNoSslInClient(bool *accepted)
+{
+ QMessageBox box(QMessageBox::Warning, tr("Unencrypted Connection"), tr("<b>Your client does not support SSL encryption</b>"),
+ QMessageBox::Ignore|QMessageBox::Cancel, this);
+ box.setInformativeText(tr("Sensitive data, like passwords, will be transmitted unencrypted to your Quassel core."));
+ box.setDefaultButton(QMessageBox::Ignore);
+ *accepted = box.exec() == QMessageBox::Ignore;
+}
+
+
+void MainWin::handleNoSslInCore(bool *accepted)
+{
+ QMessageBox box(QMessageBox::Warning, tr("Unencrypted Connection"), tr("<b>Your core does not support SSL encryption</b>"),
+ QMessageBox::Ignore|QMessageBox::Cancel, this);
+ box.setInformativeText(tr("Sensitive data, like passwords, will be transmitted unencrypted to your Quassel core."));
+ box.setDefaultButton(QMessageBox::Ignore);
+ *accepted = box.exec() == QMessageBox::Ignore;
+}
+
+
+#ifdef HAVE_SSL
+
+void MainWin::handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently)
+{
+ QString errorString = "<ul>";
+ foreach(const QSslError error, socket->sslErrors())
+ errorString += QString("<li>%1</li>").arg(error.errorString());
+ errorString += "</ul>";
+
+ QMessageBox box(QMessageBox::Warning,
+ tr("Untrusted Security Certificate"),
+ tr("<b>The SSL certificate provided by the core at %1 is untrusted for the following reasons:</b>").arg(socket->peerName()),
+ QMessageBox::Cancel, this);
+ box.setInformativeText(errorString);
+ box.addButton(tr("Continue"), QMessageBox::AcceptRole);
+ box.setDefaultButton(box.addButton(tr("Show Certificate"), QMessageBox::HelpRole));
+
+ QMessageBox::ButtonRole role;
+ do {
+ box.exec();
+ role = box.buttonRole(box.clickedButton());
+ if (role == QMessageBox::HelpRole) {
+ SslInfoDlg dlg(socket, this);
+ dlg.exec();
+ }
+ }
+ while (role == QMessageBox::HelpRole);
+
+ *accepted = role == QMessageBox::AcceptRole;
+ if (*accepted) {
+ QMessageBox box2(QMessageBox::Warning,
+ tr("Untrusted Security Certificate"),
+ tr("Would you like to accept this certificate forever without being prompted?"),
+ 0, this);
+ box2.setDefaultButton(box2.addButton(tr("Current Session Only"), QMessageBox::NoRole));
+ box2.addButton(tr("Forever"), QMessageBox::YesRole);
+ box2.exec();
+ *permanently = box2.buttonRole(box2.clickedButton()) == QMessageBox::YesRole;
+ }
+}
+
+
+#endif /* HAVE_SSL */
+
+void MainWin::handleCoreConnectionError(const QString &error)
+{
+ QMessageBox::critical(this, tr("Core Connection Error"), error, QMessageBox::Ok);
+}
+
+
+void MainWin::showCoreConnectionDlg()
+{
+ CoreConnectDlg dlg(this);
+ if (dlg.exec() == QDialog::Accepted) {
+ AccountId accId = dlg.selectedAccount();
+ if (accId.isValid())
+ Client::coreConnection()->connectToCore(accId);
+ }
+}
+
+
+void MainWin::showCoreConfigWizard(const QVariantList &backends, const QVariantList &authenticators)
+{
+ CoreConfigWizard *wizard = new CoreConfigWizard(Client::coreConnection(), backends, authenticators, this);
+
+ wizard->show();
+}
+
+
+void MainWin::showChannelList(NetworkId netId, const QString &channelFilters, bool listImmediately)
+{
+ if (!netId.isValid()) {
+ QAction *action = qobject_cast<QAction *>(sender());
+ if (action)
+ netId = action->data().value<NetworkId>();
+ if (!netId.isValid()) {
+ // We still haven't found a valid network, probably no network selected, e.g. "/list"
+ // on the client homescreen when no networks are connected.
+ QMessageBox box(QMessageBox::Information, tr("No network selected"),
+ QString("<b>%1</b>").arg(tr("No network selected")),
+ QMessageBox::Ok, this);
+ box.setInformativeText(tr("Select a network before trying to view the channel list."));
+ box.exec();
+ return;
+ }
+ }
+
+ ChannelListDlg *channelListDlg = new ChannelListDlg(this);
+ channelListDlg->setAttribute(Qt::WA_DeleteOnClose);
+ channelListDlg->setNetwork(netId);
+ if (!channelFilters.isEmpty()) {
+ channelListDlg->setChannelFilters(channelFilters);
+ }
+ if (listImmediately) {
+ channelListDlg->requestSearch();
+ }
+ channelListDlg->show();
+}
+
+
+void MainWin::showNetworkConfig(NetworkId netId)
+{
+ SettingsPageDlg dlg(new NetworksSettingsPage(this), this);
+ if (netId.isValid())
+ qobject_cast<NetworksSettingsPage *>(dlg.currentPage())->bufferList_Open(netId);
+ dlg.exec();
+}
+
+
+void MainWin::showIgnoreList(QString newRule)
+{
+ SettingsPageDlg dlg(new IgnoreListSettingsPage(this), this);
+ // prepare config dialog for new rule
+ if (!newRule.isEmpty())
+ qobject_cast<IgnoreListSettingsPage *>(dlg.currentPage())->editIgnoreRule(newRule);
+ dlg.exec();
+}
+
+
+void MainWin::showCoreInfoDlg()
+{
+ CoreInfoDlg(this).exec();
+}
+
+
+void MainWin::showAwayLog()
+{
+ if (_awayLog)
+ return;
+ AwayLogFilter *filter = new AwayLogFilter(Client::messageModel());
+ _awayLog = new AwayLogView(filter, 0);
+ filter->setParent(_awayLog);
+ connect(_awayLog, SIGNAL(destroyed()), this, SLOT(awayLogDestroyed()));
+ _awayLog->setAttribute(Qt::WA_DeleteOnClose);
+ _awayLog->show();
+}
+
+
+void MainWin::awayLogDestroyed()
+{
+ _awayLog = 0;
+}
+
+
+void MainWin::showSettingsDlg()
+{
+ SettingsDlg *dlg = new SettingsDlg();
+
+ //Category: Interface
+ dlg->registerSettingsPage(new AppearanceSettingsPage(dlg));
+ dlg->registerSettingsPage(new ChatViewSettingsPage(dlg));
+ dlg->registerSettingsPage(new ChatViewColorSettingsPage(dlg));
+ dlg->registerSettingsPage(new ChatMonitorSettingsPage(dlg));
+ dlg->registerSettingsPage(new ItemViewSettingsPage(dlg));
+ dlg->registerSettingsPage(new BufferViewSettingsPage(dlg));
+ dlg->registerSettingsPage(new InputWidgetSettingsPage(dlg));
+ dlg->registerSettingsPage(new TopicWidgetSettingsPage(dlg));
+#ifdef HAVE_SONNET
+ dlg->registerSettingsPage(new SonnetSettingsPage(dlg));
+#endif
+ dlg->registerSettingsPage(new HighlightSettingsPage(dlg));
+ dlg->registerSettingsPage(new CoreHighlightSettingsPage(dlg));
+ dlg->registerSettingsPage(new NotificationsSettingsPage(dlg));
+ dlg->registerSettingsPage(new BacklogSettingsPage(dlg));
+
+ //Category: IRC
+ dlg->registerSettingsPage(new ConnectionSettingsPage(dlg));
+ dlg->registerSettingsPage(new IdentitiesSettingsPage(dlg));
+ dlg->registerSettingsPage(new NetworksSettingsPage(dlg));
+ dlg->registerSettingsPage(new AliasesSettingsPage(dlg));
+ dlg->registerSettingsPage(new IgnoreListSettingsPage(dlg));
+ // dlg->registerSettingsPage(new DccSettingsPage(dlg)); not ready yet
+
+ // Category: Remote Cores
+ if (Quassel::runMode() != Quassel::Monolithic) {
+ dlg->registerSettingsPage(new CoreAccountSettingsPage(dlg));
+ dlg->registerSettingsPage(new CoreConnectionSettingsPage(dlg));
+ }
+
+ dlg->show();
+}
+
+
+void MainWin::showAboutDlg()
+{
+ AboutDlg(this).exec();
+}
+
+
+void MainWin::showShortcutsDlg()
+{
+#ifdef HAVE_KDE
+ KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsDisallowed, this);
+ foreach(KActionCollection *coll, QtUi::actionCollections())
+ dlg.addCollection(coll, coll->property("Category").toString());
+ dlg.configure(true);
+#else
+ SettingsPageDlg dlg(new ShortcutsSettingsPage(QtUi::actionCollections(), this), this);
+ dlg.exec();
+#endif
+}
+
+
+void MainWin::showNewTransferDlg(const QUuid &transferId)
+{
+ auto transfer = Client::transferManager()->transfer(transferId);
+ if (transfer) {
+ if (transfer->status() == Transfer::Status::New) {
+ ReceiveFileDlg *dlg = new ReceiveFileDlg(transfer, this);
+ dlg->show();
+ }
+ }
+ else {
+ qWarning() << "Unknown transfer ID" << transferId;
+ }
+}
+
+
+void MainWin::onFullScreenToggled()
+{
+ // Relying on QWidget::isFullScreen is discouraged, see the KToggleFullScreenAction docs
+ // Also, one should not use showFullScreen() or showNormal(), as those reset all other window flags
+
+#ifdef HAVE_KDE
+ static_cast<KToggleFullScreenAction*>(_fullScreenAction)->setFullScreen(this, _fullScreenAction->isChecked());
+#else
+ if (_fullScreenAction->isChecked())
+ setWindowState(windowState() | Qt::WindowFullScreen);
+ else
+ setWindowState(windowState() & ~Qt::WindowFullScreen);
+#endif
+}
+
+
+/********************************************************************************************************/
+
+bool MainWin::event(QEvent *event)
+{
+ switch(event->type()) {
+ case QEvent::WindowActivate: {
+ BufferId bufferId = Client::bufferModel()->currentBuffer();
+ if (bufferId.isValid())
+ Client::instance()->markBufferAsRead(bufferId);
+ break;
+ }
+ case QEvent::WindowDeactivate:
+ if (bufferWidget()->autoMarkerLineOnLostFocus())
+ bufferWidget()->setMarkerLine();
+ break;
+ default:
+ break;
+ }
+ return QMainWindow::event(event);
+}
+
+
+void MainWin::moveEvent(QMoveEvent *event)
+{
+ if (!(windowState() & Qt::WindowMaximized))
+ _normalPos = event->pos();
+
+ QMainWindow::moveEvent(event);
+}
+
+
+void MainWin::resizeEvent(QResizeEvent *event)
+{
+ if (!(windowState() & Qt::WindowMaximized))
+ _normalSize = event->size();
+
+ QMainWindow::resizeEvent(event);
+}
+
+
+void MainWin::closeEvent(QCloseEvent *event)
+{
+ QtUiSettings s;
+ QtUiApplication *app = qobject_cast<QtUiApplication *> qApp;
+ Q_ASSERT(app);
+ // On OSX it can happen that the closeEvent occurs twice. (Especially if packaged with Frameworks)
+ // This messes up MainWinState/MainWinHidden save/restore.
+ // It's a bug in Qt: https://bugreports.qt.io/browse/QTBUG-43344
+ if (!_aboutToQuit && !app->isAboutToQuit() && QtUi::haveSystemTray() && s.value("MinimizeOnClose").toBool()) {
+ QtUi::hideMainWidget();
+ event->ignore();
+ }
+ else if(!_aboutToQuit) {
+ _aboutToQuit = true;
+ event->accept();
+ quit();
+ }
+ else {
+ event->ignore();
+ }
+}
+
+
+void MainWin::messagesInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_UNUSED(parent);
+
+ bool hasFocus = QApplication::activeWindow() != 0;
+
+ for (int i = start; i <= end; i++) {
+ QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn);
+ if (!idx.isValid()) {
+ qDebug() << "MainWin::messagesInserted(): Invalid model index!";
+ continue;
+ }
+ Message::Flags flags = (Message::Flags)idx.data(ChatLineModel::FlagsRole).toInt();
+ if (flags.testFlag(Message::Backlog) || flags.testFlag(Message::Self))
+ continue;
+
+ BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>();
+ BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId);
+
+ // check if bufferId belongs to the shown chatlists
+ if (!(Client::bufferViewOverlay()->bufferIds().contains(bufId) ||
+ Client::bufferViewOverlay()->tempRemovedBufferIds().contains(bufId)))
+ continue;
+
+ // check if it's the buffer currently displayed
+ if (hasFocus && bufId == Client::bufferModel()->currentBuffer())
+ continue;
+
+ // only show notifications for higlights or queries
+ if (bufType != BufferInfo::QueryBuffer && !(flags & Message::Highlight))
+ continue;
+
+ // and of course: don't notify for ignored messages
+ if (Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value<Message>(), Client::networkModel()->networkName(bufId)))
+ continue;
+
+ // seems like we have a legit notification candidate!
+ QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn);
+ QString sender = senderIdx.data(ChatLineModel::EditRole).toString();
+ QString contents = idx.data(ChatLineModel::DisplayRole).toString();
+ AbstractNotificationBackend::NotificationType type;
+
+ if (bufType == BufferInfo::QueryBuffer && !hasFocus)
+ type = AbstractNotificationBackend::PrivMsg;
+ else if (bufType == BufferInfo::QueryBuffer && hasFocus)
+ type = AbstractNotificationBackend::PrivMsgFocused;
+ else if (flags & Message::Highlight && !hasFocus)
+ type = AbstractNotificationBackend::Highlight;
+ else
+ type = AbstractNotificationBackend::HighlightFocused;
+
+ QtUi::instance()->invokeNotification(bufId, type, sender, contents);
+ }
+}
+
+
+void MainWin::currentBufferChanged(BufferId buffer)
+{
+ if (buffer.isValid())
+ Client::instance()->markBufferAsRead(buffer);
+}
+
+
+void MainWin::clientNetworkCreated(NetworkId id)
+{
+ const Network *net = Client::network(id);
+ QAction *act = new QAction(net->networkName(), this);
+ act->setObjectName(QString("NetworkAction-%1").arg(id.toInt()));
+ act->setData(QVariant::fromValue<NetworkId>(id));
+ connect(net, SIGNAL(updatedRemotely()), this, SLOT(clientNetworkUpdated()));
+ connect(act, SIGNAL(triggered()), this, SLOT(connectOrDisconnectFromNet()));
+
+ QAction *beforeAction = 0;
+ foreach(QAction *action, _networksMenu->actions()) {
+ if (!action->data().isValid()) // ignore stock actions
+ continue;
+ if (net->networkName().localeAwareCompare(action->text()) < 0) {
+ beforeAction = action;
+ break;
+ }
+ }
+ _networksMenu->insertAction(beforeAction, act);
+}
+
+
+void MainWin::clientNetworkUpdated()
+{
+ const Network *net = qobject_cast<const Network *>(sender());
+ if (!net)
+ return;
+
+ QAction *action = findChild<QAction *>(QString("NetworkAction-%1").arg(net->networkId().toInt()));
+ if (!action)
+ return;
+
+ action->setText(net->networkName());
+
+ switch (net->connectionState()) {
+ case Network::Initialized:
+ action->setIcon(icon::get("network-connect"));
+ // if we have no currently selected buffer, jump to the first connecting statusbuffer
+ if (!bufferWidget()->currentBuffer().isValid()) {
+ QModelIndex idx = Client::networkModel()->networkIndex(net->networkId());
+ if (idx.isValid()) {
+ BufferId statusBufferId = idx.data(NetworkModel::BufferIdRole).value<BufferId>();
+ Client::bufferModel()->switchToBuffer(statusBufferId);
+ }
+ }
+ break;
+ case Network::Disconnected:
+ action->setIcon(icon::get("network-disconnect"));
+ break;
+ default:
+ action->setIcon(icon::get("network-wired"));
+ }
+}
+
+
+void MainWin::clientNetworkRemoved(NetworkId id)
+{
+ QAction *action = findChild<QAction *>(QString("NetworkAction-%1").arg(id.toInt()));
+ if (!action)
+ return;
+
+ action->deleteLater();
+}
+
+
+void MainWin::connectOrDisconnectFromNet()
+{
+ QAction *act = qobject_cast<QAction *>(sender());
+ if (!act) return;
+ const Network *net = Client::network(act->data().value<NetworkId>());
+ if (!net) return;
+ if (net->connectionState() == Network::Disconnected) net->requestConnect();
+ else net->requestDisconnect();
+}
+
+
+void MainWin::on_inputFormatApplyColor_triggered()
+{
+ if (!_inputWidget)
+ return;
+
+ _inputWidget->applyFormatActiveColor();
+}
+
+
+void MainWin::on_inputFormatApplyColorFill_triggered()
+{
+ if (!_inputWidget)
+ return;
+
+ _inputWidget->applyFormatActiveColorFill();
+}
+
+
+void MainWin::on_inputFormatClear_triggered()
+{
+ if (!_inputWidget)
+ return;
+
+ _inputWidget->clearFormat();
+}
+
+
+void MainWin::on_inputFormatBold_triggered()
+{
+ if (!_inputWidget)
+ return;
+
+ _inputWidget->toggleFormatBold();
+}
+
+
+void MainWin::on_inputFormatItalic_triggered()
+{
+ if (!_inputWidget)
+ return;
+
+ _inputWidget->toggleFormatItalic();
+}
+
+
+void MainWin::on_inputFormatUnderline_triggered()
+{
+ if (!_inputWidget)
+ return;
+
+ _inputWidget->toggleFormatUnderline();
+}
+
+
+void MainWin::on_jumpHotBuffer_triggered()
+{
+ if (!_bufferHotList->rowCount())
+ return;
+
+ Client::bufferModel()->switchToBuffer(_bufferHotList->hottestBuffer());
+}
+
+void MainWin::on_bufferSearch_triggered()
+{
+ if (_activeBufferViewIndex < 0 || _activeBufferViewIndex >= _bufferViews.count()) {
+ qWarning() << "Tried to activate filter on invalid bufferview:" << _activeBufferViewIndex;
+ return;
+ }
+
+ _bufferViews[_activeBufferViewIndex]->activateFilter();
+}
+
+
+void MainWin::onJumpKey()
+{
+ QAction *action = qobject_cast<QAction *>(sender());
+ if (!action || !Client::bufferModel())
+ return;
+ int idx = action->property("Index").toInt();
+
+ if (_jumpKeyMap.isEmpty())
+ _jumpKeyMap = CoreAccountSettings().jumpKeyMap();
+
+ if (!_jumpKeyMap.contains(idx))
+ return;
+
+ BufferId buffer = _jumpKeyMap.value(idx);
+ if (buffer.isValid())
+ Client::bufferModel()->switchToBuffer(buffer);
+}
+
+
+void MainWin::bindJumpKey()
+{
+ QAction *action = qobject_cast<QAction *>(sender());
+ if (!action || !Client::bufferModel())
+ return;
+ int idx = action->property("Index").toInt();
+
+ _jumpKeyMap[idx] = Client::bufferModel()->currentBuffer();
+ CoreAccountSettings().setJumpKeyMap(_jumpKeyMap);
+}
+
+
+void MainWin::on_actionDebugNetworkModel_triggered()
+{
+ QTreeView *view = new QTreeView;
+ view->setAttribute(Qt::WA_DeleteOnClose);
+ view->setWindowTitle("Debug NetworkModel View");
+ view->setModel(Client::networkModel());
+ view->setColumnWidth(0, 250);
+ view->setColumnWidth(1, 250);
+ view->setColumnWidth(2, 80);
+ view->resize(610, 300);
+ view->show();
+}
+
+
+void MainWin::on_actionDebugHotList_triggered()
+{
+ _bufferHotList->invalidate();
+ _bufferHotList->sort(0, Qt::DescendingOrder);
+
+ QTreeView *view = new QTreeView;
+ view->setAttribute(Qt::WA_DeleteOnClose);
+ view->setModel(_bufferHotList);
+ view->show();
+}
+
+
+void MainWin::on_actionDebugBufferViewOverlay_triggered()
+{
+ DebugBufferViewOverlay *overlay = new DebugBufferViewOverlay(0);
+ overlay->setAttribute(Qt::WA_DeleteOnClose);
+ overlay->show();
+}
+
+
+void MainWin::on_actionDebugMessageModel_triggered()
+{
+ QTableView *view = new QTableView(0);
+ DebugMessageModelFilter *filter = new DebugMessageModelFilter(view);
+ filter->setSourceModel(Client::messageModel());
+ view->setModel(filter);
+ view->setAttribute(Qt::WA_DeleteOnClose, true);
+ view->verticalHeader()->hide();
+ view->horizontalHeader()->setStretchLastSection(true);
+ view->show();
+}
+
+
+void MainWin::on_actionDebugLog_triggered()
+{
+ DebugLogWidget *logWidget = new DebugLogWidget(nullptr); // will be deleted on close
+ logWidget->show();
+}
+
+
+void MainWin::showStatusBarMessage(const QString &message)
+{
+ statusBar()->showMessage(message, 10000);