Mercurial > trustbridge
annotate ui/proxysettingsdlg.cpp @ 1059:f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 09 Sep 2014 18:00:37 +0200 |
parents | c1f32c87716a |
children | 515345358b71 |
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> |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
19 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
20 #include "proxysettingsdlg.h" |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
21 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
22 ProxySettingsDlg::ProxySettingsDlg(QWidget *parent) : |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
23 QDialog (parent) { |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
24 setWindowIcon(QIcon(":/img/preferences-network_16.png")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
25 setWindowTitle(tr("Proxy server settings")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
26 QVBoxLayout *mainLayout = new QVBoxLayout(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
27 QHBoxLayout *iconTextLayout = new QHBoxLayout(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
28 QHBoxLayout *labelLineLayout = new QHBoxLayout(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
29 QHBoxLayout *okCancelLayout = new QHBoxLayout(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
30 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
31 QSettings settings; |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
32 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
33 QLabel *iconLabel = new QLabel(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
34 iconLabel->setPixmap(QPixmap(":/img/preferences-network_64.png")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
35 iconTextLayout->addWidget(iconLabel); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
36 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
37 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
|
38 " " + tr("The URL can follow the scheme:") + "<br/>" + |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
39 tr("<username>:<password>@<hostname>:<port>") + |
1009
c1f32c87716a
Fixed label and translation string.
Emanuel Schuetze <emanuel@intevation.de>
parents:
955
diff
changeset
|
40 "<br/></br/>"); |
955
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
41 explanation->setTextFormat(Qt::RichText); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
42 explanation->setWordWrap(true); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
43 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
44 iconTextLayout->addWidget(explanation); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
45 mainLayout->addLayout(iconTextLayout); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
46 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
47 mProxyURL = new QLineEdit(settings.value("ProxyURL").toString()); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
48 QLabel *proxyLabel = new QLabel(tr("Proxy Server:")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
49 proxyLabel->setBuddy(mProxyURL); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
50 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
51 labelLineLayout->addWidget(proxyLabel); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
52 labelLineLayout->addWidget(mProxyURL); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
53 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
54 mSaveButton = new QPushButton (tr("&Save")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
55 QPushButton * cancelButton = new QPushButton (tr("&Cancel")); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
56 okCancelLayout->addStretch(10); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
57 okCancelLayout->addWidget(mSaveButton); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
58 okCancelLayout->addWidget(cancelButton); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
59 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
60 connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
61 connect(mSaveButton, SIGNAL(clicked()), this, SLOT(save())); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
62 connect(mProxyURL, SIGNAL(textChanged(const QString &)), |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
63 this, SLOT(checkCanSave(const QString&))); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
64 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
65 mainLayout->addLayout(labelLineLayout); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
66 mainLayout->addLayout(okCancelLayout); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
67 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
68 setLayout(mainLayout); |
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 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
71 void ProxySettingsDlg::checkCanSave(const QString &val) { |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
72 mSaveButton->setEnabled(val.isEmpty() || QUrl(val).isValid()); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
73 } |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
74 |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
75 void ProxySettingsDlg::save() { |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
76 QSettings settings; |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
77 settings.setValue("ProxyURL", mProxyURL->text()); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
78 settings.sync(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
79 accept(); |
0f7aeb12e5e9
(issue41) Add proxsettingsdialog
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
80 } |