andre@955: /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik andre@955: * Software engineering by Intevation GmbH andre@955: * andre@955: * This file is Free Software under the GNU GPL (v>=2) andre@955: * and comes with ABSOLUTELY NO WARRANTY! andre@955: * See LICENSE.txt for details. andre@955: */ andre@955: andre@955: #include andre@955: #include andre@955: #include andre@955: #include andre@955: #include andre@955: #include andre@955: #include andre@955: #include andre@955: #include andre@955: #include andre@955: andre@955: #include "proxysettingsdlg.h" andre@955: andre@955: ProxySettingsDlg::ProxySettingsDlg(QWidget *parent) : andre@955: QDialog (parent) { andre@955: setWindowIcon(QIcon(":/img/preferences-network_16.png")); andre@955: setWindowTitle(tr("Proxy server settings")); andre@955: QVBoxLayout *mainLayout = new QVBoxLayout(); andre@955: QHBoxLayout *iconTextLayout = new QHBoxLayout(); andre@955: QHBoxLayout *labelLineLayout = new QHBoxLayout(); andre@955: QHBoxLayout *okCancelLayout = new QHBoxLayout(); andre@955: andre@955: QSettings settings; andre@955: andre@955: QLabel *iconLabel = new QLabel(); andre@955: iconLabel->setPixmap(QPixmap(":/img/preferences-network_64.png")); andre@955: iconTextLayout->addWidget(iconLabel); andre@955: andre@955: QLabel *explanation = new QLabel(tr("Please enter the proxy server to use in the field below.") + andre@955: "
" + tr("The URL can follow the scheme:") + " " + andre@955: tr("<username>:<password>@<hostname>:<port>") + andre@955: "

"); andre@955: explanation->setTextFormat(Qt::RichText); andre@955: explanation->setWordWrap(true); andre@955: andre@955: iconTextLayout->addWidget(explanation); andre@955: mainLayout->addLayout(iconTextLayout); andre@955: andre@955: mProxyURL = new QLineEdit(settings.value("ProxyURL").toString()); andre@955: QLabel *proxyLabel = new QLabel(tr("Proxy Server:")); andre@955: proxyLabel->setBuddy(mProxyURL); andre@955: andre@955: labelLineLayout->addWidget(proxyLabel); andre@955: labelLineLayout->addWidget(mProxyURL); andre@955: andre@955: mSaveButton = new QPushButton (tr("&Save")); andre@955: QPushButton * cancelButton = new QPushButton (tr("&Cancel")); andre@955: okCancelLayout->addStretch(10); andre@955: okCancelLayout->addWidget(mSaveButton); andre@955: okCancelLayout->addWidget(cancelButton); andre@955: andre@955: connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); andre@955: connect(mSaveButton, SIGNAL(clicked()), this, SLOT(save())); andre@955: connect(mProxyURL, SIGNAL(textChanged(const QString &)), andre@955: this, SLOT(checkCanSave(const QString&))); andre@955: andre@955: mainLayout->addLayout(labelLineLayout); andre@955: mainLayout->addLayout(okCancelLayout); andre@955: andre@955: setLayout(mainLayout); andre@955: } andre@955: andre@955: void ProxySettingsDlg::checkCanSave(const QString &val) { andre@955: mSaveButton->setEnabled(val.isEmpty() || QUrl(val).isValid()); andre@955: } andre@955: andre@955: void ProxySettingsDlg::save() { andre@955: QSettings settings; andre@955: settings.setValue("ProxyURL", mProxyURL->text()); andre@955: settings.sync(); andre@955: accept(); andre@955: }