comparison ui/mainwindow.cpp @ 609:292c590ba9cb

Add warning dialog for running firefox and tunderbird processes
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 18 Jun 2014 14:40:06 +0200
parents e83589f1fd7f
children 129e611eaf50
comparison
equal deleted inserted replaced
608:81a44b93229e 609:292c590ba9cb
25 #include <QSplitter> 25 #include <QSplitter>
26 #include <QLabel> 26 #include <QLabel>
27 #include <QImage> 27 #include <QImage>
28 #include <QCheckBox> 28 #include <QCheckBox>
29 29
30 #include "certificatelist.h"
31 #include "downloader.h"
32 #include "helpdialog.h"
33 #include "aboutdialog.h"
34 #include "certificateitemdelegate.h"
35 #include "separatoritemdelegate.h"
36 #include "installwrapper.h"
37 #include "util.h"
38 #include "logging.h"
39 #include "binverify.h"
40 #include "processhelp.h"
41 #include "processwaitdialog.h"
42
30 // The amount of time in minutes stay silent if we have 43 // The amount of time in minutes stay silent if we have
31 // something to say 44 // something to say
32 #define NAG_INTERVAL_MINUTES 70 45 #define NAG_INTERVAL_MINUTES 70
33 46
34 #ifndef APPNAME 47 #ifndef APPNAME
53 # else 66 # else
54 # define SW_RESOURCE_VERSION "/users/aheinecke/development/TrustBridge-development.sh" 67 # define SW_RESOURCE_VERSION "/users/aheinecke/development/TrustBridge-development.sh"
55 # endif 68 # endif
56 #endif 69 #endif
57 70
58 #include "certificatelist.h"
59 #include "downloader.h"
60 #include "helpdialog.h"
61 #include "aboutdialog.h"
62 #include "certificateitemdelegate.h"
63 #include "separatoritemdelegate.h"
64 #include "installwrapper.h"
65 #include "util.h"
66 #include "logging.h"
67 #include "binverify.h"
68
69 MainWindow::MainWindow(bool trayMode): 71 MainWindow::MainWindow(bool trayMode):
70 mTrayMode(trayMode) 72 mTrayMode(trayMode)
71 { 73 {
72 createActions(); 74 createActions();
73 createTrayIcon(); 75 createTrayIcon();
506 // The buttons. 508 // The buttons.
507 bottomLayout->setAlignment(Qt::AlignBottom); 509 bottomLayout->setAlignment(Qt::AlignBottom);
508 installButton = new QPushButton(tr("Install selected")); 510 installButton = new QPushButton(tr("Install selected"));
509 installButton->setFixedHeight(80); 511 installButton->setFixedHeight(80);
510 connect(installButton, SIGNAL(clicked()), this, SLOT(resizeButtons())); 512 connect(installButton, SIGNAL(clicked()), this, SLOT(resizeButtons()));
511 connect(installButton, SIGNAL(clicked()), this, SLOT(installCerts())); 513 connect(installButton, SIGNAL(clicked()), this, SLOT(checkAndInstallCerts()));
512 quitButton = new QPushButton(tr("Quit")); 514 quitButton = new QPushButton(tr("Quit"));
513 quitButton->setFixedHeight(20); 515 quitButton->setFixedHeight(20);
514 connect(quitButton, SIGNAL(clicked()), this, SLOT(closeApp())); 516 connect(quitButton, SIGNAL(clicked()), this, SLOT(closeApp()));
515 bottomLayout->insertStretch(0, 10); 517 bottomLayout->insertStretch(0, 10);
516 bottomLayout->addWidget(installButton); 518 bottomLayout->addWidget(installButton);
853 void MainWindow::closeApp() 855 void MainWindow::closeApp()
854 { 856 {
855 saveUnselectedCertificates(); 857 saveUnselectedCertificates();
856 qApp->quit(); 858 qApp->quit();
857 } 859 }
860
861 void MainWindow::checkAndInstallCerts()
862 {
863 /* Checking before opening the dialog should be cheaper */
864 QList<int> pids = ProcessHelp::getProcessesIdForName("firefox");
865 pids.append(ProcessHelp::getProcessesIdForName("thunderbird"));
866
867 if (pids.isEmpty()) {
868 installCerts();
869 return;
870 }
871
872 QStringList pNames;
873 pNames << "firefox" << "thunderbird";
874
875 ProcessWaitDialog *waitDialog = new ProcessWaitDialog(this, pNames);
876
877 connect(waitDialog, SIGNAL(accepted()), this, SLOT(installCerts()));
878 connect(waitDialog, SIGNAL(accepted()), waitDialog, SLOT(deleteLater()));
879
880 waitDialog->exec();
881
882 return;
883 }

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