[PATCH 5 of 8] (issue41) Add proxsettingsdialog
Wald Commits
scm-commit at wald.intevation.org
Wed Aug 27 16:33:22 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1409149871 -7200
# Node ID 0f7aeb12e5e905938017bb198b0235717ff61a99
# Parent eaea1504f2827cad0ee12db60e07623ae6443c80
(issue41) Add proxsettingsdialog
diff -r eaea1504f282 -r 0f7aeb12e5e9 ui/CMakeLists.txt
--- a/ui/CMakeLists.txt Wed Aug 27 16:29:55 2014 +0200
+++ b/ui/CMakeLists.txt Wed Aug 27 16:31:11 2014 +0200
@@ -52,6 +52,7 @@
${CMAKE_CURRENT_SOURCE_DIR}/textoverlaybutton.cpp
${CMAKE_CURRENT_SOURCE_DIR}/taskscheduler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/trayicon.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/proxysettingsdlg.cpp
${CERTIFICATELIST_SOURCES}
${DOWNLOADER_SOURCES}
)
diff -r eaea1504f282 -r 0f7aeb12e5e9 ui/proxysettingsdlg.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/proxysettingsdlg.cpp Wed Aug 27 16:31:11 2014 +0200
@@ -0,0 +1,80 @@
+/* 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 <QVBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QSettings>
+#include <QPushButton>
+#include <QUrl>
+#include <QDebug>
+#include <QIcon>
+#include <QPixmap>
+
+#include "proxysettingsdlg.h"
+
+ProxySettingsDlg::ProxySettingsDlg(QWidget *parent) :
+ QDialog (parent) {
+ setWindowIcon(QIcon(":/img/preferences-network_16.png"));
+ setWindowTitle(tr("Proxy server settings"));
+ QVBoxLayout *mainLayout = new QVBoxLayout();
+ QHBoxLayout *iconTextLayout = new QHBoxLayout();
+ QHBoxLayout *labelLineLayout = new QHBoxLayout();
+ QHBoxLayout *okCancelLayout = new QHBoxLayout();
+
+ QSettings settings;
+
+ QLabel *iconLabel = new QLabel();
+ iconLabel->setPixmap(QPixmap(":/img/preferences-network_64.png"));
+ iconTextLayout->addWidget(iconLabel);
+
+ QLabel *explanation = new QLabel(tr("Please enter the proxy server to use in the field below.") +
+ "</br>" + tr("The URL can follow the scheme:") + " " +
+ tr("<username>:<password>@<hostname>:<port>") +
+ "</br></br>");
+ explanation->setTextFormat(Qt::RichText);
+ explanation->setWordWrap(true);
+
+ iconTextLayout->addWidget(explanation);
+ mainLayout->addLayout(iconTextLayout);
+
+ mProxyURL = new QLineEdit(settings.value("ProxyURL").toString());
+ QLabel *proxyLabel = new QLabel(tr("Proxy Server:"));
+ proxyLabel->setBuddy(mProxyURL);
+
+ labelLineLayout->addWidget(proxyLabel);
+ labelLineLayout->addWidget(mProxyURL);
+
+ mSaveButton = new QPushButton (tr("&Save"));
+ QPushButton * cancelButton = new QPushButton (tr("&Cancel"));
+ okCancelLayout->addStretch(10);
+ okCancelLayout->addWidget(mSaveButton);
+ okCancelLayout->addWidget(cancelButton);
+
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+ connect(mSaveButton, SIGNAL(clicked()), this, SLOT(save()));
+ connect(mProxyURL, SIGNAL(textChanged(const QString &)),
+ this, SLOT(checkCanSave(const QString&)));
+
+ mainLayout->addLayout(labelLineLayout);
+ mainLayout->addLayout(okCancelLayout);
+
+ setLayout(mainLayout);
+}
+
+void ProxySettingsDlg::checkCanSave(const QString &val) {
+ mSaveButton->setEnabled(val.isEmpty() || QUrl(val).isValid());
+}
+
+void ProxySettingsDlg::save() {
+ QSettings settings;
+ settings.setValue("ProxyURL", mProxyURL->text());
+ settings.sync();
+ accept();
+}
diff -r eaea1504f282 -r 0f7aeb12e5e9 ui/proxysettingsdlg.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/proxysettingsdlg.h Wed Aug 27 16:31:11 2014 +0200
@@ -0,0 +1,37 @@
+/* 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 PROXYSETTINGSDLG_H
+#define PROXYSETTINGSDLG_H
+
+#include <QDialog>
+
+class QLineEdit;
+class QPushButton;
+
+/** @file Small dialog for proxy settings. */
+
+class ProxySettingsDlg : public QDialog {
+
+ Q_OBJECT
+
+public:
+ ProxySettingsDlg(QWidget *parent);
+
+private slots:
+ /** @brief activate the save button depending on the input.*/
+ void checkCanSave(const QString& val);
+
+ /** @brief save the contents of mProxyURL in the settings. */
+ void save();
+
+private:
+ QLineEdit *mProxyURL;
+ QPushButton *mSaveButton;
+};
+
+#endif // PROXYSETTINGSDLG_H
More information about the Trustbridge-commits
mailing list