Skip to content

MI0698-1660: Add poxy page UI #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/libs/installer/packagemanagercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ class INSTALLER_EXPORT PackageManagerCore : public QObject

enum WizardPage {
Introduction = 0x1000,
TargetDirectory = 0x2000,
ComponentSelection = 0x3000,
LicenseCheck = 0x4000,
StartMenuSelection = 0x5000,
ReadyForInstallation = 0x6000,
PerformInstallation = 0x7000,
InstallationFinished = 0x8000,
ProxySetting = 0x2000,
TargetDirectory = 0x3000,
ComponentSelection = 0x4000,
LicenseCheck = 0x5000,
StartMenuSelection = 0x6000,
ReadyForInstallation = 0x7000,
PerformInstallation = 0x8000,
InstallationFinished = 0x9000,
End = 0xffff
};

Expand Down
178 changes: 178 additions & 0 deletions src/libs/installer/packagemanagergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#include <QFileDialog>
#include <QGroupBox>
#include <QScreen>
#include <QButtonGroup>

#ifdef Q_OS_WIN
# include <qt_windows.h>
Expand Down Expand Up @@ -3260,5 +3261,182 @@ void RestartPage::leaving()
{
}

ProxySettingPage::ProxySettingPage(PackageManagerCore *core)
: PackageManagerPage(core)
, m_noProxy(nullptr)
, m_systemProxy(nullptr)
, m_manualProxy(nullptr)
, m_httpBox(nullptr)
, m_labelHttpHostName(nullptr)
, m_labelHttpPort(nullptr)
, m_ifHttpAuthenticate(nullptr)
, m_labelHttpUserName(nullptr)
, m_labelHttpPassword(nullptr)
, m_lineHttpHostName(nullptr)
, m_lineHttpPort(nullptr)
, m_lineHttpUserName(nullptr)
, m_lineHttpPassword(nullptr)
{
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("ProxySettingPage"));
setColoredTitle(tr("Proxy Setting"));

QVBoxLayout *layout = new QVBoxLayout(this);
setLayout(layout);

// proxy type part
m_noProxy = new QRadioButton(tr("&No Proxy"), this);
m_noProxy->setObjectName(QLatin1String("NoProxyRadioButton"));
layout->addWidget(m_noProxy);

m_manualProxy = new QRadioButton(tr("&Manual Proxy"), this);
m_manualProxy->setObjectName(QLatin1String("ManualProxyRadioButton"));
layout->addWidget(m_manualProxy);

m_systemProxy = new QRadioButton(tr("&System Proxy"), this);
m_systemProxy->setObjectName(QLatin1String("SystemProxyRadioButton"));



QButtonGroup *BtnGroupProxyType = new QButtonGroup();
BtnGroupProxyType->addButton(m_noProxy,0);
BtnGroupProxyType->addButton(m_systemProxy,1);
BtnGroupProxyType->addButton(m_manualProxy,2);
BtnGroupProxyType->setExclusive(true);

QHBoxLayout *groupBoxLayout = new QHBoxLayout;
QGridLayout *httpBoxLayout = new QGridLayout;

// http para groupbox
m_labelHttpHostName = new QLabel(this);
m_labelHttpHostName->setWordWrap(true);
m_labelHttpHostName->setObjectName(QLatin1String("HttpHostname"));
m_labelHttpHostName->setText(tr("Hostname"));

m_labelHttpPort = new QLabel(this);
m_labelHttpPort->setWordWrap(true);
m_labelHttpPort->setObjectName(QLatin1String("HttpPort"));
m_labelHttpPort->setText(tr("Port"));

m_lineHttpHostName = new QLineEdit(this);
m_lineHttpHostName->setObjectName(QLatin1String("HttpHostNameLineEdit"));
m_lineHttpPort = new QLineEdit(this);
m_lineHttpPort->setObjectName(QLatin1String("HttpPortLineEdit"));

httpBoxLayout->addWidget(m_labelHttpHostName,0,0,1,1);
httpBoxLayout->addWidget(m_lineHttpHostName,0,1,1,3);
httpBoxLayout->addWidget(m_labelHttpPort,1,0,1,1);
httpBoxLayout->addWidget(m_lineHttpPort,1,1,1,3);

m_ifHttpAuthenticate = new QRadioButton(tr("&Use authentication"), this);
m_ifHttpAuthenticate->setObjectName(QLatin1String("ifHttpAuthenticationRadioButton"));

m_labelHttpUserName = new QLabel(this);
m_labelHttpUserName->setWordWrap(true);
m_labelHttpUserName->setObjectName(QLatin1String("HttpUsername"));
m_labelHttpUserName->setText(tr("Username"));

m_labelHttpPassword = new QLabel(this);
m_labelHttpPassword->setWordWrap(true);
m_labelHttpPassword->setObjectName(QLatin1String("HttpPassword"));
m_labelHttpPassword->setText(tr("Password"));

m_lineHttpUserName = new QLineEdit(this);
m_lineHttpUserName->setObjectName(QLatin1String("HttpUserNameLineEdit"));
m_lineHttpPassword = new QLineEdit(this);
m_lineHttpPassword->setObjectName(QLatin1String("HttpPasswordLineEdit"));

httpBoxLayout->addWidget(m_ifHttpAuthenticate,2,1,1,3);
httpBoxLayout->addWidget(m_labelHttpUserName,3,0,1,1);
httpBoxLayout->addWidget(m_lineHttpUserName,3,1,1,3);
httpBoxLayout->addWidget(m_labelHttpPassword,4,0,1,1);
httpBoxLayout->addWidget(m_lineHttpPassword,4,1,1,3);

m_httpBox = new QGroupBox(this);
m_httpBox->setTitle(QLatin1String("Http"));
m_httpBox->setLayout(httpBoxLayout);

//groupbox layout
groupBoxLayout->addWidget(m_httpBox);

layout->addLayout(groupBoxLayout);
layout->addWidget(m_systemProxy);

setNetworkGroupboxVisible(false);
setHttpAuthenEnabled(false);
connect(m_manualProxy, &QAbstractButton::toggled,
this, &ProxySettingPage::setNetworkGroupboxVisible);
connect(m_ifHttpAuthenticate, &QAbstractButton::toggled,
this, &ProxySettingPage::setHttpAuthenEnabled);
}

void ProxySettingPage::setNetworkGroupboxVisible(bool value)
{
m_httpBox->setVisible(value);
}

void ProxySettingPage::setHttpAuthenEnabled(bool value)
{
m_lineHttpUserName->setEnabled(value);
m_lineHttpPassword->setEnabled(value);
}

void ProxySettingPage::entering()
{
PackageManagerCore *core = packageManagerCore();
const Settings &settings = core->settings();
switch (settings.proxyType()) {
case Settings::NoProxy:
m_noProxy->setChecked(true);
break;
case Settings::SystemProxy:
m_systemProxy->setChecked(true);
break;
case Settings::UserDefinedProxy:
m_manualProxy->setChecked(true);
break;
default:
m_noProxy->setChecked(true);
Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown proxy type given!");
}

const QNetworkProxy &httpProxy = settings.httpProxy();
m_lineHttpHostName->setText(httpProxy.hostName());
m_lineHttpPort->setText(QString::number(httpProxy.port()));
m_ifHttpAuthenticate->setChecked((!httpProxy.user().isEmpty()) && (!httpProxy.password().isEmpty()));
m_lineHttpUserName->setText(httpProxy.user());
m_lineHttpPassword->setText(httpProxy.password());

}

void ProxySettingPage::leaving()
{
PackageManagerCore *core = packageManagerCore();
Settings &settings = core->settings();

// update proxy type
settings.setProxyType(Settings::NoProxy);
if (m_systemProxy->isChecked())
settings.setProxyType(Settings::SystemProxy);
else if (m_manualProxy->isChecked())
settings.setProxyType(Settings::UserDefinedProxy);

if (settings.proxyType() == Settings::UserDefinedProxy) {
if((!m_lineHttpHostName->text().isEmpty()) && (!m_lineHttpPort->text().isEmpty()))
{
if(m_ifHttpAuthenticate->isChecked())
{
settings.setHttpProxy(QNetworkProxy(QNetworkProxy::HttpProxy, m_lineHttpHostName->text(),
m_lineHttpPort->text().toInt(),m_lineHttpUserName->text(),m_lineHttpPassword->text()));
}
else
{
settings.setHttpProxy(QNetworkProxy(QNetworkProxy::HttpProxy, m_lineHttpHostName->text(),
m_lineHttpPort->text().toInt()));
}
}
}
}

#include "packagemanagergui.moc"
#include "moc_packagemanagergui.cpp"
41 changes: 41 additions & 0 deletions src/libs/installer/packagemanagergui.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class QProgressBar;
class QRadioButton;
class QTextBrowser;
class QWinTaskbarButton;
class QGroupBox;
QT_END_NAMESPACE

namespace QInstaller {
Expand Down Expand Up @@ -284,6 +285,46 @@ private Q_SLOTS:
};


// -- ProxySettingPage
class INSTALLER_EXPORT ProxySettingPage : public PackageManagerPage
{
Q_OBJECT

public:
explicit ProxySettingPage(PackageManagerCore *core);


private Q_SLOTS:
void setNetworkGroupboxVisible(bool value);
void setHttpAuthenEnabled(bool value);

private:

void entering() override;
void leaving() override;


private:

QRadioButton *m_noProxy;
QRadioButton *m_systemProxy;
QRadioButton *m_manualProxy;

QGroupBox *m_httpBox;

QLabel *m_labelHttpHostName;
QLabel *m_labelHttpPort;
QRadioButton *m_ifHttpAuthenticate;
QLabel *m_labelHttpUserName;
QLabel *m_labelHttpPassword;
QLineEdit *m_lineHttpHostName;
QLineEdit *m_lineHttpPort;
QLineEdit *m_lineHttpUserName;
QLineEdit *m_lineHttpPassword;

};


// -- LicenseAgreementPage

class INSTALLER_EXPORT LicenseAgreementPage : public PackageManagerPage
Expand Down
1 change: 1 addition & 0 deletions src/sdk/installerbasecommons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ InstallerGui::InstallerGui(PackageManagerCore *core)
}

setPage(PackageManagerCore::Introduction, new IntroductionPage(core));
setPage(PackageManagerCore::ProxySetting, new ProxySettingPage(core));
setPage(PackageManagerCore::TargetDirectory, new TargetDirectoryPage(core));
setPage(PackageManagerCore::ComponentSelection, new ComponentSelectionPage(core));
setPage(PackageManagerCore::LicenseCheck, new LicenseAgreementPage(core));
Expand Down