X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=10aedfa94b1d312d5018a61af6b26d83b6e19e77;hp=fcd854ed3e82f4f3d796a7215b39f90ea32196d3;hb=b3a8232d4959903591c309d765da9c271d0a761f;hpb=dc9de5af386f61e6dc5537d04ccc8aceb8126b21 diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index fcd854ed..10aedfa9 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -455,16 +455,14 @@ void MainWin::setupTitleSetter() { void MainWin::setupStatusBar() { // MessageProcessor progress statusBar()->addPermanentWidget(msgProcessorStatusWidget); - connect(Client::messageProcessor(), SIGNAL(progressUpdated(int, int)), msgProcessorStatusWidget, SLOT(setProgress(int, int))); // Core Lag: - updateLagIndicator(0); + updateLagIndicator(); statusBar()->addPermanentWidget(coreLagLabel); coreLagLabel->hide(); connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), this, SLOT(updateLagIndicator(int))); // SSL indicator - connect(Client::instance(), SIGNAL(securedConnection()), this, SLOT(securedConnection())); sslLabel->setPixmap(QPixmap()); statusBar()->addPermanentWidget(sslLabel); sslLabel->hide(); @@ -480,9 +478,6 @@ void MainWin::setupStatusBar() { connect(showStatusbar, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool))); connect(showStatusbar, SIGNAL(toggled(bool)), this, SLOT(saveStatusBarStatus(bool))); - - connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &))); - connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &))); } void MainWin::saveStatusBarStatus(bool enabled) { @@ -510,10 +505,8 @@ void MainWin::setupSystray() { } #ifndef Q_WS_MAC - connect(systemTrayIcon(), SIGNAL(activated( QSystemTrayIcon::ActivationReason )), - this, SLOT(systrayActivated( QSystemTrayIcon::ActivationReason ))); + connect(systemTrayIcon(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systrayActivated(QSystemTrayIcon::ActivationReason))); #endif - } void MainWin::changeEvent(QEvent *event) { @@ -521,8 +514,8 @@ void MainWin::changeEvent(QEvent *event) { if(windowState() & Qt::WindowMinimized) { QtUiSettings s; if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnMinimize").toBool()) { - toggleVisibility(); - event->ignore(); + hideToTray(); + event->accept(); } } } @@ -549,12 +542,24 @@ void MainWin::setConnectedState() { 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.")); - if(sslLabel->width() == 0) + if(Client::signalProxy()->isSecure()) { + sslLabel->setPixmap(SmallIcon("security-high")); + } else { sslLabel->setPixmap(SmallIcon("security-low")); + } sslLabel->setVisible(!Client::internalCore()); coreLagLabel->setVisible(!Client::internalCore()); @@ -574,13 +579,12 @@ void MainWin::saveLayout() { } void MainWin::updateLagIndicator(int lag) { - coreLagLabel->setText(QString(tr("Core Lag: %1 msec")).arg(lag)); -} - - -void MainWin::securedConnection() { - // todo: make status bar entry - sslLabel->setPixmap(SmallIcon("security-high")); + QString text = tr("Core Lag: %1"); + if(lag == -1) + text = text.arg('-'); + else + text = text.arg("%1 msec").arg(lag); + coreLagLabel->setText(text); } void MainWin::disconnectedFromCore() { @@ -614,6 +618,7 @@ void MainWin::setDisconnectedState() { statusBar()->showMessage(tr("Not connected to core.")); sslLabel->setPixmap(QPixmap()); sslLabel->hide(); + updateLagIndicator(); coreLagLabel->hide(); updateIcon(); } @@ -681,8 +686,10 @@ void MainWin::showShortcutsDlg() { void MainWin::closeEvent(QCloseEvent *event) { QtUiSettings s; - if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) { - toggleVisibility(); + QtUiApplication* app = qobject_cast qApp; + Q_ASSERT(app); + if(!app->aboutToQuit() && s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) { + toggleMinimizedToTray(); event->ignore(); } else { event->accept(); @@ -690,36 +697,32 @@ void MainWin::closeEvent(QCloseEvent *event) { } } -void MainWin::systrayActivated( QSystemTrayIcon::ActivationReason activationReason) { +void MainWin::systrayActivated(QSystemTrayIcon::ActivationReason activationReason) { if(activationReason == QSystemTrayIcon::Trigger) { - toggleVisibility(); + toggleMinimizedToTray(); } } -void MainWin::toggleVisibility() { - if(isHidden() /*|| !isActiveWindow()*/) { - show(); - if(isMinimized()) { - if(isMaximized()) - showMaximized(); - else - showNormal(); - } +void MainWin::hideToTray() { + if(!systemTrayIcon()->isSystemTrayAvailable()) { + qWarning() << Q_FUNC_INFO << "was called with no SystemTray available!"; + return; + } - raise(); - activateWindow(); - // setFocus(); //Qt::ActiveWindowFocusReason + clearFocus(); + hide(); + systemTrayIcon()->show(); +} +void MainWin::toggleMinimizedToTray() { + if(windowState() & Qt::WindowMinimized) { + // restore + setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); + show(); + raise(); } else { - if(systemTrayIcon()->isSystemTrayAvailable ()) { - clearFocus(); - hide(); - if(!systemTrayIcon()->isVisible()) { - systemTrayIcon()->show(); - } - } else { - lower(); - } + setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized); + hideToTray(); } }