Mercurial > trustbridge
annotate ui/processwaitdialog.cpp @ 1232:f7e890c4dac6
(issue148) Only update list widgets when something new is available.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 24 Sep 2014 15:48:58 +0200 |
parents | 320a64d58e62 |
children |
rev | line source |
---|---|
609
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
3 * |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=2) |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
6 * See LICENSE.txt for details. |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
7 */ |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
8 #include <QHBoxLayout> |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
9 #include <QListWidget> |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
10 #include <QTimer> |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
11 #include <QList> |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
12 #include <QLabel> |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
13 #include <QApplication> |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
14 |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
15 #include "processwaitdialog.h" |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
16 #include "processhelp.h" |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
17 |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
18 ProcessWaitDialog::ProcessWaitDialog(QWidget *parent, const QStringList& processNames) : |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
19 QDialog(parent), |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
20 mProcessNames(processNames) { |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
21 QHBoxLayout *theLayout = new QHBoxLayout(this); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
22 |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
23 setWindowTitle(tr("Applications need to be closed.")); |
613
47235ae3fa9a
Remove close / help button and set fixed size
Andre Heinecke <andre.heinecke@intevation.de>
parents:
611
diff
changeset
|
24 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint); |
609
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
25 |
661
320a64d58e62
(UI) Updated English strings. Removed Issuer fields.
Emanuel Schuetze <emanuel@intevation.de>
parents:
613
diff
changeset
|
26 QLabel *warnLabel = new QLabel(tr("Please close all running Firefox and Thunderbird instances to continue installation!")); |
609
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
27 QLabel *warnIcon = new QLabel(); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
28 warnIcon->setPixmap(QApplication::style()->standardPixmap(QStyle::SP_MessageBoxWarning)); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
29 |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
30 theLayout->addWidget(warnIcon); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
31 theLayout->addWidget(warnLabel); |
613
47235ae3fa9a
Remove close / help button and set fixed size
Andre Heinecke <andre.heinecke@intevation.de>
parents:
611
diff
changeset
|
32 |
47235ae3fa9a
Remove close / help button and set fixed size
Andre Heinecke <andre.heinecke@intevation.de>
parents:
611
diff
changeset
|
33 theLayout->setSizeConstraint(QLayout::SetFixedSize); |
609
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
34 // mProcessList = new QListWidget(); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
35 // theLayout->addWidget(mProcessList); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
36 updateProcesses(); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
37 } |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
38 |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
39 void ProcessWaitDialog::updateProcesses() { |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
40 QList<int> pids; |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
41 foreach (const QString& pName, mProcessNames) { |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
42 pids.append(ProcessHelp::getProcessesIdForName(pName)); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
43 } |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
44 if (pids.isEmpty()) { |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
45 accept(); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
46 return; |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
47 } |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
48 |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
49 /* mProcessList->clear(); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
50 |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
51 foreach (int pId, pids) { |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
52 mProcessList->addItem(QString::fromLatin1("Pid ") + pId); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
53 } |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
54 */ |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
55 QTimer::singleShot(500, this, SLOT(updateProcesses())); |
292c590ba9cb
Add warning dialog for running firefox and tunderbird processes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
56 } |