X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=e3dece21a585eadd6029840186139a4c6942a038;hb=d42123b2f56292e10bf4ad4a710950149af824d0;hp=52699e93cc134a4bb7f18492731291fec8f5390b;hpb=25eb89768427a8c62f0ea776d05407db3aec2f97;p=quassel.git diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 52699e93..e3dece21 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -28,6 +28,7 @@ #include "channellistdlg.h" #include "client.h" #include "clientbacklogmanager.h" +#include "coreinfodlg.h" #include "coreconnectdlg.h" #include "networkmodel.h" #include "buffermodel.h" @@ -109,7 +110,6 @@ void MainWin::init() { connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(clientNetworkCreated(NetworkId))); connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), this, SLOT(clientNetworkRemoved(NetworkId))); - //ui.bufferWidget->init(); show(); @@ -130,12 +130,6 @@ void MainWin::init() { setupTopicWidget(); setupChatMonitor(); setupInputWidget(); - - QAction *toggleLockDocksAction = ui.menuViews->addAction(tr("Lock dock positions")); - toggleLockDocksAction->setCheckable(true); - connect(toggleLockDocksAction, SIGNAL(toggled(bool)), this, SLOT(lockVerticalDocks(bool))); - toggleLockDocksAction->setChecked(s.value("LockDocks", false).toBool()); - setupStatusBar(); setupSystray(); @@ -144,6 +138,10 @@ void MainWin::init() { // restore mainwin state restoreState(s.value("MainWinState").toByteArray()); + // restore locked state of docks + ui.actionLockDockPositions->setChecked(s.value("LockDocks", false).toBool()); + + setDisconnectedState(); // Disable menus and stuff showCoreConnectionDlg(true); // autoconnect if appropriate @@ -165,22 +163,15 @@ MainWin::~MainWin() { void MainWin::setupMenus() { connect(ui.actionConnectCore, SIGNAL(triggered()), this, SLOT(showCoreConnectionDlg())); connect(ui.actionDisconnectCore, SIGNAL(triggered()), Client::instance(), SLOT(disconnectFromCore())); + connect(ui.actionCoreInfo, SIGNAL(triggered()), this, SLOT(showCoreInfoDlg())); connect(ui.actionQuit, SIGNAL(triggered()), QCoreApplication::instance(), SLOT(quit())); - //connect(ui.actionNetworkList, SIGNAL(triggered()), this, SLOT(showServerList())); connect(ui.actionSettingsDlg, SIGNAL(triggered()), this, SLOT(showSettingsDlg())); // connect(ui.actionDebug_Console, SIGNAL(triggered()), this, SLOT(showDebugConsole())); connect(ui.actionAboutQuassel, SIGNAL(triggered()), this, SLOT(showAboutDlg())); connect(ui.actionAboutQt, SIGNAL(triggered()), QApplication::instance(), SLOT(aboutQt())); - - actionEditNetworks = new QAction(QIcon(":/22x22/actions/configure"), tr("Edit &Networks..."), this); - ui.menuNetworks->addAction(actionEditNetworks); - connect(actionEditNetworks, SIGNAL(triggered()), this, SLOT(showNetworkDlg())); - connect(ui.actionManageViews, SIGNAL(triggered()), this, SLOT(showManageViewsDlg())); } void MainWin::setupViews() { - QAction *separator = ui.menuViews->addSeparator(); - separator->setData("__EOBV__"); addBufferView(); } @@ -208,16 +199,7 @@ void MainWin::addBufferView(BufferViewConfig *config) { dock->show(); addDockWidget(Qt::LeftDockWidgetArea, dock); - - QAction *endOfBufferViews = 0; - foreach(QAction *action, ui.menuViews->actions()) { - if(action->data().toString() == "__EOBV__") { - endOfBufferViews = action; - break; - } - } - Q_CHECK_PTR(endOfBufferViews); - ui.menuViews->insertAction(endOfBufferViews, dock->toggleViewAction()); + ui.menuBufferViews->addAction(dock->toggleViewAction()); _netViews.append(dock); } @@ -225,13 +207,10 @@ void MainWin::addBufferView(BufferViewConfig *config) { void MainWin::removeBufferView(int bufferViewConfigId) { QVariant actionData; BufferViewDock *dock; - foreach(QAction *action, ui.menuViews->actions()) { + foreach(QAction *action, ui.menuBufferViews->actions()) { actionData = action->data(); if(!actionData.isValid()) continue; - - if(actionData.toString() == "__EOBV__") - break; dock = qobject_cast(action->parent()); if(dock && actionData.toInt() == bufferViewConfigId) { @@ -255,17 +234,17 @@ void MainWin::setupSettingsDlg() { settingsDlg->registerSettingsPage(new BufferViewSettingsPage(settingsDlg)); } -void MainWin::showNetworkDlg() { +void MainWin::on_actionEditNetworks_triggered() { SettingsPageDlg dlg(new NetworksSettingsPage(this), this); dlg.exec(); } -void MainWin::showManageViewsDlg() { +void MainWin::on_actionManageViews_triggered() { SettingsPageDlg dlg(new BufferViewSettingsPage(this), this); dlg.exec(); } -void MainWin::lockVerticalDocks(bool lock) { +void MainWin::on_actionLockDockPositions_toggled(bool lock) { QList docks = findChildren(); foreach(VerticalDock *dock, docks) { dock->showTitle(!lock); @@ -435,7 +414,6 @@ void MainWin::setConnectedState() { //ui.menuCore->setEnabled(true); ui.actionConnectCore->setEnabled(false); ui.actionDisconnectCore->setEnabled(true); - //ui.actionNetworkList->setEnabled(true); ui.bufferWidget->show(); statusBar()->showMessage(tr("Connected to core.")); setWindowIcon(onlineTrayIcon); @@ -459,8 +437,6 @@ void MainWin::saveLayout() { void MainWin::securedConnection() { // todo: make status bar entry - qDebug() << "secured the connection"; - sslLabel->setPixmap(QPixmap::fromImage(QImage(":/16x16/status/ssl"))); } @@ -469,13 +445,10 @@ void MainWin::disconnectedFromCore() { saveLayout(); QVariant actionData; BufferViewDock *dock; - foreach(QAction *action, ui.menuViews->actions()) { + foreach(QAction *action, ui.menuBufferViews->actions()) { actionData = action->data(); if(!actionData.isValid()) continue; - - if(actionData.toString() == "__EOBV__") - break; dock = qobject_cast(action->parent()); if(dock && actionData.toInt() != -1) { @@ -492,10 +465,8 @@ void MainWin::setDisconnectedState() { ui.menuViews->setEnabled(false); //ui.menuCore->setEnabled(false); ui.actionDisconnectCore->setEnabled(false); - //ui.actionNetworkList->setEnabled(false); ui.bufferWidget->hide(); ui.actionConnectCore->setEnabled(true); - // nickListWidget->reset(); statusBar()->showMessage(tr("Not connected to core.")); setWindowIcon(offlineTrayIcon); qApp->setWindowIcon(offlineTrayIcon); @@ -525,6 +496,11 @@ void MainWin::showChannelList(NetworkId netId) { channelListDlg->show(); } +void MainWin::showCoreInfoDlg() { + CoreInfoDlg dlg(this); + dlg.exec(); +} + void MainWin::showSettingsDlg() { settingsDlg->show(); } @@ -641,61 +617,58 @@ void MainWin::makeTrayIconBlink() { } } - - 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(id)); connect(net, SIGNAL(updatedRemotely()), this, SLOT(clientNetworkUpdated())); connect(act, SIGNAL(triggered()), this, SLOT(connectOrDisconnectFromNet())); - bool inserted = false; - for(int i = 0; i < networkActions.count(); i++) { - if(net->networkName().localeAwareCompare(networkActions[i]->text()) < 0) { - networkActions.insert(i, act); - inserted = true; + + QAction *beforeAction = 0; + foreach(QAction *action, ui.menuNetworks->actions()) { + if(action->isSeparator()) { + beforeAction = action; + break; + } + if(net->networkName().localeAwareCompare(action->text()) < 0) { + beforeAction = action; break; } } - if(!inserted) networkActions.append(act); - ui.menuNetworks->clear(); // why the f*** isn't there a QMenu::insertAction()??? - foreach(QAction *a, networkActions) ui.menuNetworks->addAction(a); - ui.menuNetworks->addSeparator(); - ui.menuNetworks->addAction(actionEditNetworks); + Q_CHECK_PTR(beforeAction); + ui.menuNetworks->insertAction(beforeAction, act); } void MainWin::clientNetworkUpdated() { const Network *net = qobject_cast(sender()); - if(!net) return; - foreach(QAction *a, networkActions) { - if(a->data().value() == net->networkId()) { - a->setText(net->networkName()); - if(net->connectionState() == Network::Initialized) { - a->setIcon(QIcon(":/16x16/actions/network-connect")); - //a->setEnabled(true); - } else if(net->connectionState() == Network::Disconnected) { - a->setIcon(QIcon(":/16x16/actions/network-disconnect")); - //a->setEnabled(true); - } else { - a->setIcon(QIcon(":/16x16/actions/gear")); - //a->setEnabled(false); - } - return; - } + if(!net) + return; + + QAction *action = findChild(QString("NetworkAction-%1").arg(net->networkId().toInt())); + if(!action) + return; + + action->setText(net->networkName()); + + switch(net->connectionState()) { + case Network::Initialized: + action->setIcon(QIcon(":/16x16/actions/network-connect")); + break; + case Network::Disconnected: + action->setIcon(QIcon(":/16x16/actions/network-disconnect")); + break; + default: + action->setIcon(QIcon(":/16x16/actions/gear")); } } void MainWin::clientNetworkRemoved(NetworkId id) { - QList::iterator actionIter = networkActions.begin();; - QAction *action; - while(actionIter != networkActions.end()) { - action = *actionIter; - if(action->data().value() == id) { - action->deleteLater(); - actionIter = networkActions.erase(actionIter); - } else - actionIter++; - } + QAction *action = findChild(QString("NetworkAction-%1").arg(id.toInt())); + if(!action) + return; + + action->deleteLater(); } void MainWin::connectOrDisconnectFromNet() {