X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=ebd83f6cdb94b5683fe05306eff25b82b5b9519c;hb=823477acf579a0c3333d61fbf6400ad49155da5c;hp=cf283e485380276821bfda37d78d9aae33d84acc;hpb=f2e4609f070221a010eef8be98524c5ce88d228b;p=quassel.git diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index cf283e48..ebd83f6c 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -61,10 +61,12 @@ #include "global.h" #include "qtuistyle.h" + MainWin::MainWin(QtUi *_gui, QWidget *parent) : QMainWindow(parent), gui(_gui), sslLabel(new QLabel()), + _titleSetter(this), systray(new QSystemTrayIcon(this)), activeTrayIcon(":/icons/quassel-icon-active.png"), onlineTrayIcon(":/icons/quassel-icon.png"), @@ -77,6 +79,7 @@ MainWin::MainWin(QtUi *_gui, QWidget *parent) ui.setupUi(this); setWindowTitle("Quassel IRC"); setWindowIcon(offlineTrayIcon); + qApp->setWindowIcon(offlineTrayIcon); systray->setIcon(offlineTrayIcon); setWindowIconText("Quassel IRC"); @@ -100,6 +103,8 @@ void MainWin::init() { Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferInfo, QVariant, QVariant))); + connect(QApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(saveLayout())); + connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(clientNetworkCreated(NetworkId))); connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), this, SLOT(clientNetworkRemoved(NetworkId))); //ui.bufferWidget->init(); @@ -131,13 +136,15 @@ void MainWin::init() { // restore mainwin state restoreState(s.value("MainWinState").toByteArray()); - disconnectedFromCore(); // Disable menus and stuff + setDisconnectedState(); // Disable menus and stuff showCoreConnectionDlg(true); // autoconnect if appropriate // attach the BufferWidget to the BufferModel and the default selection ui.bufferWidget->setModel(Client::bufferModel()); ui.bufferWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel()); + _titleSetter.setModel(Client::bufferModel()); + _titleSetter.setSelectionModel(Client::bufferModel()->standardSelectionModel()); } MainWin::~MainWin() { @@ -217,7 +224,7 @@ void MainWin::removeBufferView(int bufferViewConfigId) { break; dock = qobject_cast(action->parent()); - if(dock && actionData.toInt() != bufferViewConfigId) { + if(dock && actionData.toInt() == bufferViewConfigId) { removeAction(action); dock->deleteLater(); } @@ -259,7 +266,8 @@ void MainWin::setupNickWidget() { addDockWidget(Qt::RightDockWidgetArea, nickDock); ui.menuViews->addAction(nickDock->toggleViewAction()); - connect(nickDock->toggleViewAction(), SIGNAL(triggered(bool)), nickListWidget, SLOT(showWidget(bool))); + // 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()); @@ -399,7 +407,10 @@ void MainWin::connectedToCore() { foreach(BufferInfo id, Client::allBufferInfos()) { Client::backlogManager()->requestBacklog(id.bufferId(), 500, -1); } + setConnectedState(); +} +void MainWin::setConnectedState() { ui.menuViews->setEnabled(true); //ui.menuCore->setEnabled(true); ui.actionConnectCore->setEnabled(false); @@ -408,6 +419,7 @@ void MainWin::connectedToCore() { ui.bufferWidget->show(); statusBar()->showMessage(tr("Connected to core.")); setWindowIcon(onlineTrayIcon); + qApp->setWindowIcon(onlineTrayIcon); systray->setIcon(onlineTrayIcon); if(sslLabel->width() == 0) sslLabel->setPixmap(QPixmap::fromImage(QImage(":/16x16/status/no-ssl"))); @@ -419,6 +431,12 @@ void MainWin::loadLayout() { restoreState(s.value(QString("MainWinState-%1").arg(accountId)).toByteArray(), accountId); } +void MainWin::saveLayout() { + QtUiSettings s; + int accountId = Client::currentCoreAccount().toInt(); + if(accountId > 0) s.setValue(QString("MainWinState-%1").arg(accountId) , saveState(accountId)); +} + void MainWin::securedConnection() { // todo: make status bar entry qDebug() << "secured the connection"; @@ -428,9 +446,7 @@ void MainWin::securedConnection() { void MainWin::disconnectedFromCore() { // save core specific layout and remove bufferviews; - QtUiSettings s; - int accountId = Client::currentCoreAccount().toInt(); - s.setValue(QString("MainWinState-%1").arg(accountId) , saveState(accountId)); + saveLayout(); QVariant actionData; BufferViewDock *dock; foreach(QAction *action, ui.menuViews->actions()) { @@ -447,7 +463,12 @@ void MainWin::disconnectedFromCore() { dock->deleteLater(); } } + QtUiSettings s; + restoreState(s.value("MainWinState").toByteArray()); + setDisconnectedState(); +} +void MainWin::setDisconnectedState() { ui.menuViews->setEnabled(false); //ui.menuCore->setEnabled(false); ui.actionDisconnectCore->setEnabled(false); @@ -457,6 +478,7 @@ void MainWin::disconnectedFromCore() { // nickListWidget->reset(); statusBar()->showMessage(tr("Not connected to core.")); setWindowIcon(offlineTrayIcon); + qApp->setWindowIcon(offlineTrayIcon); systray->setIcon(offlineTrayIcon); sslLabel->setPixmap(QPixmap()); } @@ -592,6 +614,7 @@ void MainWin::makeTrayIconBlink() { } + void MainWin::clientNetworkCreated(NetworkId id) { const Network *net = Client::network(id); QAction *act = new QAction(net->networkName(), this);