+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"));
+}
+
+void MainWin::setupInputWidget() {
+ VerticalDock *dock = new VerticalDock(tr("Inputline"), this);
+ dock->setObjectName("InputDock");
+
+ _inputWidget = new InputWidget(dock);
+ dock->setWidget(_inputWidget);
+
+ addDockWidget(Qt::BottomDockWidgetArea, dock);
+
+ _viewMenu->addAction(dock->toggleViewAction());
+ dock->toggleViewAction()->setText(tr("Show Input Line"));
+
+ _inputWidget->setModel(Client::bufferModel());
+ _inputWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
+
+ _bufferWidget->setFocusProxy(_inputWidget);
+
+ _inputWidget->inputLine()->installEventFilter(_bufferWidget);
+
+ connect(_topicWidget, SIGNAL(switchedPlain()), _bufferWidget, SLOT(setFocus()));
+}
+
+void MainWin::setupTopicWidget() {
+ VerticalDock *dock = new VerticalDock(tr("Topic"), this);
+ dock->setObjectName("TopicDock");
+ _topicWidget = new TopicWidget(dock);
+
+ dock->setWidget(_topicWidget);
+
+ _topicWidget->setModel(Client::bufferModel());
+ _topicWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
+
+ addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
+
+ _viewMenu->addAction(dock->toggleViewAction());
+ dock->toggleViewAction()->setText(tr("Show Topic Line"));
+}
+
+void MainWin::setupTitleSetter() {
+ _titleSetter.setModel(Client::bufferModel());
+ _titleSetter.setSelectionModel(Client::bufferModel()->standardSelectionModel());
+}
+
+void MainWin::setupStatusBar() {
+ // MessageProcessor progress
+ statusBar()->addPermanentWidget(_msgProcessorStatusWidget);
+
+ // Connection state
+ _coreConnectionStatusWidget->update();
+ statusBar()->addPermanentWidget(_coreConnectionStatusWidget);
+
+ QAction *showStatusbar = QtUi::actionCollection("General")->action("ToggleStatusBar");
+
+ QtUiSettings uiSettings;
+
+ bool enabled = uiSettings.value("ShowStatusBar", QVariant(true)).toBool();
+ showStatusbar->setChecked(enabled);
+ enabled ? statusBar()->show() : statusBar()->hide();
+
+ connect(showStatusbar, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool)));
+ connect(showStatusbar, SIGNAL(toggled(bool)), this, SLOT(saveStatusBarStatus(bool)));
+
+ connect(Client::coreConnection(), SIGNAL(connectionMsg(QString)), statusBar(), SLOT(showMessage(QString)));
+}
+
+void MainWin::setupHotList() {
+ FlatProxyModel *flatProxy = new FlatProxyModel(this);
+ flatProxy->setSourceModel(Client::bufferModel());
+ _bufferHotList = new BufferHotListFilter(flatProxy);
+}
+
+void MainWin::saveMenuBarStatus(bool enabled) {
+ QtUiSettings uiSettings;
+ uiSettings.setValue("ShowMenuBar", enabled);
+}
+
+void MainWin::saveStatusBarStatus(bool enabled) {
+ QtUiSettings uiSettings;
+ uiSettings.setValue("ShowStatusBar", enabled);
+}
+
+void MainWin::setupSystray() {
+#ifdef HAVE_DBUS
+ _systemTray = new StatusNotifierItem(this);
+#elif !defined QT_NO_SYSTEMTRAYICON
+ _systemTray = new LegacySystemTray(this);
+#else
+ _systemTray = new SystemTray(this); // dummy
+#endif
+ _systemTray->init();
+}
+
+void MainWin::setupToolBars() {
+ connect(_bufferWidget, SIGNAL(currentChanged(QModelIndex)),
+ QtUi::toolBarActionProvider(), SLOT(currentBufferChanged(QModelIndex)));
+ connect(_nickListWidget, SIGNAL(nickSelectionChanged(QModelIndexList)),
+ QtUi::toolBarActionProvider(), SLOT(nickSelectionChanged(QModelIndexList)));
+
+#ifdef Q_WS_MAC
+ setUnifiedTitleAndToolBarOnMac(true);
+#endif
+
+#ifdef HAVE_KDE
+ _mainToolBar = new KToolBar("MainToolBar", this, Qt::TopToolBarArea, false, true, true);
+#else
+ _mainToolBar = new QToolBar(this);
+ _mainToolBar->setObjectName("MainToolBar");