+ _bufferViewsMenu->addAction(dock->toggleViewAction());
+
+ connect(dock->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(bufferViewToggled(bool)));
+ _bufferViews.append(dock);
+}
+
+void MainWin::removeBufferView(int bufferViewConfigId) {
+ 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() == bufferViewConfigId) {
+ removeAction(action);
+ _bufferViews.removeAll(dock);
+ Client::bufferViewOverlay()->removeView(dock->bufferViewId());
+ dock->deleteLater();
+ }
+ }
+}
+
+void MainWin::bufferViewToggled(bool enabled) {
+ if(!enabled && !isVisible()) {
+ // hiding the mainwindow triggers a toggle of the bufferview (which pretty much sucks big time)
+ // since this isn't our fault and we can't do anything about it, we suppress the resulting calls
+ return;
+ }
+ QAction *action = qobject_cast<QAction *>(sender());
+ Q_ASSERT(action);
+ BufferViewDock *dock = qobject_cast<BufferViewDock *>(action->parent());
+ Q_ASSERT(dock);
+
+ // Make sure we don't toggle backlog fetch for a view we've already removed
+ if(!_bufferViews.contains(dock))
+ return;
+
+ if(enabled) {
+ Client::bufferViewOverlay()->addView(dock->bufferViewId());
+ } else {
+ Client::bufferViewOverlay()->removeView(dock->bufferViewId());
+ }
+}
+
+BufferView *MainWin::allBuffersView() const {
+ // "All Buffers" is always the first dock created
+ if(_bufferViews.count() > 0)
+ return _bufferViews[0]->bufferView();
+ return 0;
+}
+
+void MainWin::showNotificationsDlg() {
+ SettingsPageDlg dlg(new NotificationsSettingsPage(this), this);
+ dlg.exec();
+}
+
+void MainWin::on_actionConfigureNetworks_triggered() {
+ SettingsPageDlg dlg(new NetworksSettingsPage(this), this);
+ dlg.exec();
+}
+
+void MainWin::on_actionConfigureViews_triggered() {
+ SettingsPageDlg dlg(new BufferViewSettingsPage(this), this);
+ dlg.exec();
+}
+
+void MainWin::on_actionLockLayout_toggled(bool lock) {
+ QList<VerticalDock *> docks = findChildren<VerticalDock *>();
+ foreach(VerticalDock *dock, docks) {
+ dock->showTitle(!lock);
+ }
+ if(Client::bufferViewManager()) {
+ foreach(ClientBufferViewConfig *config, Client::bufferViewManager()->clientBufferViewConfigs()) {
+ config->setLocked(lock);
+ }
+ }
+ QtUiSettings().setValue("LockLayout", lock);
+}
+
+void MainWin::setupNickWidget() {
+ // create nick dock
+ NickListDock *nickDock = new NickListDock(tr("Nicks"), this);
+ nickDock->setObjectName("NickDock");
+ nickDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+
+ _nickListWidget = new NickListWidget(nickDock);
+ nickDock->setWidget(_nickListWidget);
+
+ addDockWidget(Qt::RightDockWidgetArea, nickDock);
+ _viewMenu->addAction(nickDock->toggleViewAction());
+ nickDock->toggleViewAction()->setText(tr("Show Nick List"));
+
+ // See NickListDock::NickListDock();
+ // connect(nickDock->toggleViewAction(), SIGNAL(triggered(bool)), nickListWidget, SLOT(showWidget(bool)));
+
+ // attach the NickListWidget to the BufferModel and the default selection
+ _nickListWidget->setModel(Client::bufferModel());
+ _nickListWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
+}
+
+void MainWin::setupChatMonitor() {
+ VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this);
+ dock->setObjectName("ChatMonitorDock");
+
+ ChatMonitorFilter *filter = new ChatMonitorFilter(Client::messageModel(), this);
+ _chatMonitorView = new ChatMonitorView(filter, this);
+ _chatMonitorView->setFocusProxy(_inputWidget);
+ _chatMonitorView->show();
+ dock->setWidget(_chatMonitorView);
+ dock->hide();
+
+ addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
+ _viewMenu->addAction(dock->toggleViewAction());
+ dock->toggleViewAction()->setText(tr("Show Chat Monitor"));
+}