diff options
author | Kai Koehne <kai.koehne@digia.com> | 2014-07-03 17:16:10 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@digia.com> | 2014-07-10 14:40:07 +0200 |
commit | 6956eea8bfbbc62abb22912200b9c731597cd5ea (patch) | |
tree | db70b2140facac2363fa44910c5f45e46cb72b2b /src | |
parent | 4f4251ba6dbf344c8a4e36272a106a1fedfd143d (diff) | |
download | qt-creator-6956eea8bfbbc62abb22912200b9c731597cd5ea.tar.gz |
Add ProxyCredentialsDialog
Add generic dialog to be shown when a network proxy needs user
credentials.
Change-Id: I6304475171e44ee688ebbe372d14393f45680ad2
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/utils/proxycredentialsdialog.cpp | 81 | ||||
-rw-r--r-- | src/libs/utils/proxycredentialsdialog.h | 63 | ||||
-rw-r--r-- | src/libs/utils/proxycredentialsdialog.ui | 106 | ||||
-rw-r--r-- | src/libs/utils/utils-lib.pri | 9 | ||||
-rw-r--r-- | src/libs/utils/utils.qbs | 3 |
5 files changed, 259 insertions, 3 deletions
diff --git a/src/libs/utils/proxycredentialsdialog.cpp b/src/libs/utils/proxycredentialsdialog.cpp new file mode 100644 index 0000000000..848dc68def --- /dev/null +++ b/src/libs/utils/proxycredentialsdialog.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "proxycredentialsdialog.h" +#include "ui_proxycredentialsdialog.h" + +#include <utils/networkaccessmanager.h> +#include <QNetworkProxy> + +using namespace Utils; + +/*! + \class Utils::ProxyCredentialsDialog + + Dialog for asking the user about proxy credentials (username, password). +*/ + +ProxyCredentialsDialog::ProxyCredentialsDialog(const QNetworkProxy &proxy, QWidget *parent) : + QDialog(parent), + ui(new Ui::ProxyCredentialsDialog) +{ + ui->setupUi(this); + + setUserName(proxy.user()); + setPassword(proxy.password()); + + const QString proxyString = QString::fromLatin1("%1:%2").arg(proxy.hostName()).arg(proxy.port()); + ui->infotext->setText(ui->infotext->text().arg(proxyString)); +} + +ProxyCredentialsDialog::~ProxyCredentialsDialog() +{ + delete ui; +} + +QString ProxyCredentialsDialog::userName() const +{ + return ui->usernameLineEdit->text(); +} + +void ProxyCredentialsDialog::setUserName(const QString &username) +{ + ui->usernameLineEdit->setText(username); +} + +QString ProxyCredentialsDialog::password() const +{ + return ui->passwordLineEdit->text(); +} + +void ProxyCredentialsDialog::setPassword(const QString &passwd) +{ + ui->passwordLineEdit->setText(passwd); +} + diff --git a/src/libs/utils/proxycredentialsdialog.h b/src/libs/utils/proxycredentialsdialog.h new file mode 100644 index 0000000000..cea025888d --- /dev/null +++ b/src/libs/utils/proxycredentialsdialog.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef PROXYCREDENTIALSDIALOG_H +#define PROXYCREDENTIALSDIALOG_H + +#include "utils_global.h" +#include <QDialog> + +QT_FORWARD_DECLARE_CLASS(QNetworkProxy) + +namespace Utils { + +namespace Ui { +class ProxyCredentialsDialog; +} + +class QTCREATOR_UTILS_EXPORT ProxyCredentialsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ProxyCredentialsDialog(const QNetworkProxy &proxy, QWidget *parent = 0); + ~ProxyCredentialsDialog(); + + QString userName() const; + void setUserName(const QString &username); + QString password() const; + void setPassword(const QString &passwd); + +private: + Ui::ProxyCredentialsDialog *ui; +}; + +} // namespace Utils + +#endif // PROXYCREDENTIALSDIALOG_H diff --git a/src/libs/utils/proxycredentialsdialog.ui b/src/libs/utils/proxycredentialsdialog.ui new file mode 100644 index 0000000000..4bf6a17c33 --- /dev/null +++ b/src/libs/utils/proxycredentialsdialog.ui @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Utils::ProxyCredentialsDialog</class> + <widget class="QDialog" name="Utils::ProxyCredentialsDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>279</width> + <height>114</height> + </rect> + </property> + <property name="windowTitle"> + <string>Proxy Credentials</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="infotext"> + <property name="text"> + <string>The proxy %1 requires a username and password.</string> + </property> + </widget> + </item> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="usernameLabel"> + <property name="text"> + <string>Username:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="usernameLineEdit"> + <property name="placeholderText"> + <string>Username</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="passwordLabel"> + <property name="text"> + <string>Password:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="passwordLineEdit"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + <property name="placeholderText"> + <string>Password</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>Utils::ProxyCredentialsDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>Utils::ProxyCredentialsDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index ca6da2708b..630824f98f 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -87,7 +87,8 @@ SOURCES += $$PWD/environment.cpp \ $$PWD/completinglineedit.cpp \ $$PWD/winutils.cpp \ $$PWD/itemviews.cpp \ - $$PWD/treeviewcombobox.cpp + $$PWD/treeviewcombobox.cpp \ + $$PWD/proxycredentialsdialog.cpp win32:SOURCES += $$PWD/consoleprocess_win.cpp else:SOURCES += $$PWD/consoleprocess_unix.cpp @@ -181,10 +182,12 @@ HEADERS += \ $$PWD/treeviewcombobox.h \ $$PWD/scopedswap.h \ $$PWD/algorithm.h \ - $$PWD/QtConcurrentTools + $$PWD/QtConcurrentTools \ + $$PWD/proxycredentialsdialog.h FORMS += $$PWD/filewizardpage.ui \ $$PWD/projectintropage.ui \ - $$PWD/newclasswidget.ui + $$PWD/newclasswidget.ui \ + $$PWD/proxycredentialsdialog.ui RESOURCES += $$PWD/utils.qrc diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 6a17f6bcc9..be6094d1d7 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -136,6 +136,9 @@ QtcLibrary { "projectnamevalidatinglineedit.h", "proxyaction.cpp", "proxyaction.h", + "proxycredentialsdialog.cpp", + "proxycredentialsdialog.h", + "proxycredentialsdialog.ui", "qtcassert.cpp", "qtcassert.h", "qtcolorbutton.cpp", |