diff ui/mainwindow.cpp @ 978:d92b1594e974

Merged.
author Emanuel Schuetze <emanuel@intevation.de>
date Fri, 29 Aug 2014 13:10:11 +0200
parents c80777457133
children b8ae69bcc540
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Fri Aug 29 13:09:40 2014 +0200
+++ b/ui/mainwindow.cpp	Fri Aug 29 13:10:11 2014 +0200
@@ -43,6 +43,7 @@
 #include "processhelp.h"
 #include "processwaitdialog.h"
 #include "trayicon.h"
+#include "proxysettingsdlg.h"
 
 // The amount of time in minutes stay silent if we have
 // something to say
@@ -133,10 +134,6 @@
 
 void MainWindow::messageClicked()
 {
-    if (mCurState == NewListAvailable) {
-        show();
-    }
-
     if (mCurState == NewSoftwareAvailable) {
         hide();
         verifySWData();
@@ -148,6 +145,8 @@
         }
         installNewSW(swFileName,
                 mSettings.value("Software/availableDate").toDateTime());
+    } else {
+        show();
     }
 }
 
@@ -156,7 +155,15 @@
     if (mCurMessage.isEmpty()) {
         return;
     }
-    if (mCurState == NewSoftwareAvailable || !isVisible()) {
+
+    if (!mTrayIcon->isVisible() && !mTrayIcon->isAlternative()) {
+        mTrayIcon->show();
+        /* When the message is shown before the tray icon is fully visble
+         * and becoming visible may be delayed on some desktop environments
+         * the message will pop up somehere on the screen and not over
+         * the trayicon. So we delay here.*/
+        QTimer::singleShot(2000, this, SLOT(showMessage()));
+    } else if (mCurState == NewSoftwareAvailable || !isVisible()) {
         mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage,
                                QSystemTrayIcon::Information, 10000);
         mMessageTimer->start(); // Restart the timer so that we don't spam
@@ -445,6 +452,7 @@
     /* TODO logging and handle error according to a plan */
     syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData());
     mCurMessage = message;
+    mTrayIcon->show();
     showMessage();
     setState(TransferError);
 }
@@ -460,6 +468,7 @@
 void MainWindow::createTrayIcon()
 {
     QIcon trayImg(":/img/tray_22.png");
+    trayImg.addFile(":/img/tray_48.png", QSize(48,48));
 
     mTrayMenu = new QMenu(this);
     mTrayMenu->addAction(mCheckUpdates);
@@ -470,7 +479,6 @@
 
     mTrayIcon->setIcon(trayImg);
     setWindowIcon(trayImg);
-    mTrayIcon->show();
     mTrayIcon->setToolTip(tr("TrustBridge"));
 
     connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
@@ -526,8 +534,15 @@
 
     QHBoxLayout *helpButtonLayout = new QHBoxLayout();
     QPushButton *helpButton = new QPushButton(tr("Show Help"));
+    helpButton->setIcon(QIcon(":/img/show-help_16.png"));
     connect(helpButton, SIGNAL(clicked()), this, SLOT(showHelp()));
     helpButtonLayout->addWidget(helpButton);
+#ifdef USE_CURL
+    QPushButton *proxySettingsButton = new QPushButton(tr("Proxy settings"));
+    proxySettingsButton->setIcon(QIcon(":/img/preferences-network_16.png"));
+    connect(proxySettingsButton, SIGNAL(clicked()), this, SLOT(showProxySettings()));
+    helpButtonLayout->addWidget(proxySettingsButton);
+#endif
     helpButtonLayout->addStretch();
     infoCenterLayout->addLayout(helpButtonLayout);
 
@@ -1363,6 +1378,7 @@
     if (getState() == NewListAvailable) {
         /* Only minimize to tray if there is a new list */
         QMainWindow::closeEvent(event);
+        mTrayIcon->show();
         return;
     }
     return closeApp();
@@ -1378,6 +1394,12 @@
         mLastUpdateCheck->show();
         syslog_info_printf(tr("Sucessfully checked for updates.").toUtf8().constData());
     }
+    if (getState() != NewSoftwareAvailable && getState() != NewListAvailable && mTrayMode) {
+        qDebug() << "Shutting down as no list or Software is available.";
+        closeApp();
+    } else {
+        mTrayIcon->show();
+    }
 }
 
 int MainWindow::changeCount()
@@ -1393,6 +1415,12 @@
     }
 }
 
+void MainWindow::showProxySettings()
+{
+    ProxySettingsDlg *dlg = new ProxySettingsDlg(this);
+    dlg->exec();
+}
+
 void MainWindow::showHelp()
 {
     char *inst_dir = get_install_dir();
@@ -1408,7 +1436,11 @@
         QMessageBox::warning(this, tr("Error!"), tr ("Failed to find the manual"));
         return;
     }
+#ifdef Q_OS_WIN
+    QDesktopServices::openUrl(QUrl("file:///" + fiHelp.absoluteFilePath()));
+#else
     QDesktopServices::openUrl(QUrl(fiHelp.absoluteFilePath()));
+#endif
     free (inst_dir);
     return;
 }

http://wald.intevation.org/projects/trustbridge/