Mercurial > trustbridge
annotate ui/proxysettingsdlg.cpp @ 1222:0c73c9b1cd57
(issue147) do-changes button icon now a yellow flash.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Wed, 24 Sep 2014 14:43:36 +0200 |
parents | 8a1071fee883 |
children |
rev | line source |
---|---|
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
3 * |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=2) |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
6 * See LICENSE.txt for details. |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
7 */ |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
8 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
9 #include <QHBoxLayout> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
10 #include <QVBoxLayout> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
11 #include <QLabel> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
12 #include <QLineEdit> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
13 #include <QSettings> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
14 #include <QPushButton> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
15 #include <QUrl> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
16 #include <QDebug> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
17 #include <QIcon> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
18 #include <QPixmap> |
1062
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
19 #include <QCheckBox> |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
20 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
21 #include "proxysettingsdlg.h" |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
22 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
23 ProxySettingsDlg::ProxySettingsDlg(QWidget *parent) : |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
24 QDialog (parent) { |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
25 setWindowIcon(QIcon(":/img/preferences-network_16.png")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
26 setWindowTitle(tr("Proxy server settings")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
27 QVBoxLayout *mainLayout = new QVBoxLayout(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
28 QHBoxLayout *iconTextLayout = new QHBoxLayout(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
29 QHBoxLayout *labelLineLayout = new QHBoxLayout(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
30 QHBoxLayout *okCancelLayout = new QHBoxLayout(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
31 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
32 QSettings settings; |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
33 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
34 QLabel *iconLabel = new QLabel(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
35 iconLabel->setPixmap(QPixmap(":/img/preferences-network_64.png")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
36 iconTextLayout->addWidget(iconLabel); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
37 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
38 QLabel *explanation = new QLabel(tr("Please enter the proxy server to use in the field below.") + |
1009
c1f32c87716a
Fixed label and translation string.
Emanuel Schuetze <emanuel@intevation.de>
parents:
955
diff
changeset
|
39 " " + tr("The URL can follow the scheme:") + "<br/>" + |
1063
8a1071fee883
Fixed proxy server label.
Emanuel Schuetze <emanuel@intevation.de>
parents:
1062
diff
changeset
|
40 tr("[<username>:<password>@]<hostname>[:<port>]") + |
1009
c1f32c87716a
Fixed label and translation string.
Emanuel Schuetze <emanuel@intevation.de>
parents:
955
diff
changeset
|
41 "<br/></br/>"); |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
42 explanation->setTextFormat(Qt::RichText); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
43 explanation->setWordWrap(true); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
44 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
45 iconTextLayout->addWidget(explanation); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
46 mainLayout->addLayout(iconTextLayout); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
47 |
1062
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
48 bool useProxy = settings.value("UseProxy", false).toBool(); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
49 mCheckBox = new QCheckBox(tr("Use Proxy Server")); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
50 mCheckBox->setTristate(false); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
51 mCheckBox->setCheckState(useProxy ? Qt::Checked : Qt::Unchecked); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
52 |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
53 mainLayout->addWidget(mCheckBox); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
54 |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
55 mProxyURL = new QLineEdit(settings.value("ProxyURL").toString()); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
56 QLabel *proxyLabel = new QLabel(tr("Proxy Server:")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
57 proxyLabel->setBuddy(mProxyURL); |
1062
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
58 mProxyURL->setReadOnly(!useProxy); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
59 mProxyURL->setEnabled(useProxy); |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
60 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
61 labelLineLayout->addWidget(proxyLabel); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
62 labelLineLayout->addWidget(mProxyURL); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
63 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
64 mSaveButton = new QPushButton (tr("&Save")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
65 QPushButton * cancelButton = new QPushButton (tr("&Cancel")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
66 okCancelLayout->addStretch(10); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
67 okCancelLayout->addWidget(mSaveButton); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
68 okCancelLayout->addWidget(cancelButton); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
69 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
70 connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
71 connect(mSaveButton, SIGNAL(clicked()), this, SLOT(save())); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
72 connect(mProxyURL, SIGNAL(textChanged(const QString &)), |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
73 this, SLOT(checkCanSave(const QString&))); |
1062
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
74 connect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(checkCanEdit(int))); |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
75 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
76 mainLayout->addLayout(labelLineLayout); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
77 mainLayout->addLayout(okCancelLayout); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
78 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
79 setLayout(mainLayout); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
80 } |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
81 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
82 void ProxySettingsDlg::checkCanSave(const QString &val) { |
1062
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
83 mSaveButton->setEnabled(mCheckBox->checkState() == Qt::Unchecked || |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
84 QUrl(val).isValid()); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
85 } |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
86 |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
87 void ProxySettingsDlg::checkCanEdit(int state) { |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
88 mProxyURL->setReadOnly(state != Qt::Checked); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
89 mProxyURL->setEnabled(state == Qt::Checked); |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
90 } |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
91 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
92 void ProxySettingsDlg::save() { |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
93 QSettings settings; |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
94 settings.setValue("ProxyURL", mProxyURL->text()); |
1062
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1009
diff
changeset
|
95 settings.setValue("UseProxy", mCheckBox->checkState() == Qt::Checked); |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
96 settings.sync(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
97 accept(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
98 } |