[PATCH 5 of 6] Add warning dialog for running firefox and tunderbird processes
Wald Commits
scm-commit at wald.intevation.org
Wed Jun 18 14:41:33 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1403095206 -7200
# Node ID 292c590ba9cbfb029ff2079706376161cedd0b51
# Parent 81a44b93229e039c87545591d0a7f782d5a1e3fe
Add warning dialog for running firefox and tunderbird processes
diff -r 81a44b93229e -r 292c590ba9cb ui/CMakeLists.txt
--- a/ui/CMakeLists.txt Wed Jun 18 11:22:15 2014 +0200
+++ b/ui/CMakeLists.txt Wed Jun 18 14:40:06 2014 +0200
@@ -20,8 +20,6 @@
${CMAKE_CURRENT_SOURCE_DIR}/downloader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sslconnection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sslhelp.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/processhelp_win.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/processhelp_linux.cpp
)
# Cmake does not correctly identify gcc windres when cross compiling
@@ -37,6 +35,9 @@
${CMAKE_CURRENT_SOURCE_DIR}/separatoritemdelegate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/installwrapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aboutdialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processhelp_win.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processhelp_linux.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processwaitdialog.cpp
${CERTIFICATELIST_SOURCES}
${DOWNLOADER_SOURCES}
)
diff -r 81a44b93229e -r 292c590ba9cb ui/mainwindow.cpp
--- a/ui/mainwindow.cpp Wed Jun 18 11:22:15 2014 +0200
+++ b/ui/mainwindow.cpp Wed Jun 18 14:40:06 2014 +0200
@@ -27,6 +27,19 @@
#include <QImage>
#include <QCheckBox>
+#include "certificatelist.h"
+#include "downloader.h"
+#include "helpdialog.h"
+#include "aboutdialog.h"
+#include "certificateitemdelegate.h"
+#include "separatoritemdelegate.h"
+#include "installwrapper.h"
+#include "util.h"
+#include "logging.h"
+#include "binverify.h"
+#include "processhelp.h"
+#include "processwaitdialog.h"
+
// The amount of time in minutes stay silent if we have
// something to say
#define NAG_INTERVAL_MINUTES 70
@@ -55,17 +68,6 @@
# endif
#endif
-#include "certificatelist.h"
-#include "downloader.h"
-#include "helpdialog.h"
-#include "aboutdialog.h"
-#include "certificateitemdelegate.h"
-#include "separatoritemdelegate.h"
-#include "installwrapper.h"
-#include "util.h"
-#include "logging.h"
-#include "binverify.h"
-
MainWindow::MainWindow(bool trayMode):
mTrayMode(trayMode)
{
@@ -508,7 +510,7 @@
installButton = new QPushButton(tr("Install selected"));
installButton->setFixedHeight(80);
connect(installButton, SIGNAL(clicked()), this, SLOT(resizeButtons()));
- connect(installButton, SIGNAL(clicked()), this, SLOT(installCerts()));
+ connect(installButton, SIGNAL(clicked()), this, SLOT(checkAndInstallCerts()));
quitButton = new QPushButton(tr("Quit"));
quitButton->setFixedHeight(20);
connect(quitButton, SIGNAL(clicked()), this, SLOT(closeApp()));
@@ -855,3 +857,27 @@
saveUnselectedCertificates();
qApp->quit();
}
+
+void MainWindow::checkAndInstallCerts()
+{
+ /* Checking before opening the dialog should be cheaper */
+ QList<int> pids = ProcessHelp::getProcessesIdForName("firefox");
+ pids.append(ProcessHelp::getProcessesIdForName("thunderbird"));
+
+ if (pids.isEmpty()) {
+ installCerts();
+ return;
+ }
+
+ QStringList pNames;
+ pNames << "firefox" << "thunderbird";
+
+ ProcessWaitDialog *waitDialog = new ProcessWaitDialog(this, pNames);
+
+ connect(waitDialog, SIGNAL(accepted()), this, SLOT(installCerts()));
+ connect(waitDialog, SIGNAL(accepted()), waitDialog, SLOT(deleteLater()));
+
+ waitDialog->exec();
+
+ return;
+}
diff -r 81a44b93229e -r 292c590ba9cb ui/mainwindow.h
--- a/ui/mainwindow.h Wed Jun 18 11:22:15 2014 +0200
+++ b/ui/mainwindow.h Wed Jun 18 14:40:06 2014 +0200
@@ -81,6 +81,13 @@
void saveAutoUpdate(int state);
void saveAutoStart(int state);
+ /** @brief check for running software that needs to close before installing
+ *
+ * This function calls installCerts if no software is running otherwise
+ * it informs the user about the software that still needs to be closed.
+ */
+ void checkAndInstallCerts();
+
/** @brief get the last modified date on the download server for
* the current version.
*
diff -r 81a44b93229e -r 292c590ba9cb ui/processwaitdialog.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/processwaitdialog.cpp Wed Jun 18 14:40:06 2014 +0200
@@ -0,0 +1,53 @@
+/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details.
+ */
+#include <QHBoxLayout>
+#include <QListWidget>
+#include <QTimer>
+#include <QList>
+#include <QLabel>
+#include <QApplication>
+
+#include "processwaitdialog.h"
+#include "processhelp.h"
+
+ProcessWaitDialog::ProcessWaitDialog(QWidget *parent, const QStringList& processNames) :
+ QDialog(parent),
+ mProcessNames(processNames) {
+ QHBoxLayout *theLayout = new QHBoxLayout(this);
+
+ setWindowTitle(tr("Applications need to be closed."));
+
+ QLabel *warnLabel = new QLabel(tr("Close all running firefox and thunderbird instances to continue installation"));
+ QLabel *warnIcon = new QLabel();
+ warnIcon->setPixmap(QApplication::style()->standardPixmap(QStyle::SP_MessageBoxWarning));
+
+ theLayout->addWidget(warnIcon);
+ theLayout->addWidget(warnLabel);
+ // mProcessList = new QListWidget();
+// theLayout->addWidget(mProcessList);
+ updateProcesses();
+}
+
+void ProcessWaitDialog::updateProcesses() {
+ QList<int> pids;
+ foreach (const QString& pName, mProcessNames) {
+ pids.append(ProcessHelp::getProcessesIdForName(pName));
+ }
+ if (pids.isEmpty()) {
+ accept();
+ return;
+ }
+
+ /* mProcessList->clear();
+
+ foreach (int pId, pids) {
+ mProcessList->addItem(QString::fromLatin1("Pid ") + pId);
+ }
+*/
+ QTimer::singleShot(500, this, SLOT(updateProcesses()));
+}
diff -r 81a44b93229e -r 292c590ba9cb ui/processwaitdialog.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/processwaitdialog.h Wed Jun 18 14:40:06 2014 +0200
@@ -0,0 +1,45 @@
+/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details. */
+#ifndef PROCESSWAITDIALOG_H
+#define PROCESSWAITDIALOG_H
+
+#include <QDialog>
+#include <QStringList>
+
+/** @file Dialog to show that some processes need to be closed
+ *
+ * This dialog informs about processes that are still running and
+ * need to be closed.
+ */
+
+class ProcessWaitDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ /** @brief create the dialog
+ *
+ * The dialog is modal and will stay open until no more processes
+ * with names from processnames exist.
+ *
+ * @param[in] parent the parent dialog
+ * @param[in] processNames the names of the processes to wait for.
+ */
+ ProcessWaitDialog(QWidget *parent, const QStringList& processNames);
+
+private slots:
+
+ /** @brief update the process list */
+ void updateProcesses();
+
+private:
+
+ QListWidget *mProcessList;
+ const QStringList mProcessNames;
+};
+
+#endif // PROCESSWAITDIALOG_H
More information about the Trustbridge-commits
mailing list