Skip to content

Commit cde5667

Browse files
committed
feat: MI0698-1660 add proxy page ui to installerbase
1 parent 5e2d7d6 commit cde5667

File tree

4 files changed

+332
-7
lines changed

4 files changed

+332
-7
lines changed

src/libs/installer/packagemanagercore.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ class INSTALLER_EXPORT PackageManagerCore : public QObject
9292

9393
enum WizardPage {
9494
Introduction = 0x1000,
95-
TargetDirectory = 0x2000,
96-
ComponentSelection = 0x3000,
97-
LicenseCheck = 0x4000,
98-
StartMenuSelection = 0x5000,
99-
ReadyForInstallation = 0x6000,
100-
PerformInstallation = 0x7000,
101-
InstallationFinished = 0x8000,
95+
ProxySetting = 0x2000,
96+
TargetDirectory = 0x3000,
97+
ComponentSelection = 0x4000,
98+
LicenseCheck = 0x5000,
99+
StartMenuSelection = 0x6000,
100+
ReadyForInstallation = 0x7000,
101+
PerformInstallation = 0x8000,
102+
InstallationFinished = 0x9000,
102103
End = 0xffff
103104
};
104105

src/libs/installer/packagemanagergui.cpp

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#include <QFileDialog>
8282
#include <QGroupBox>
8383
#include <QScreen>
84+
#include <QButtonGroup>
8485

8586
#ifdef Q_OS_WIN
8687
# include <qt_windows.h>
@@ -3260,5 +3261,274 @@ void RestartPage::leaving()
32603261
{
32613262
}
32623263

3264+
ProxySettingPage::ProxySettingPage(PackageManagerCore *core)
3265+
: PackageManagerPage(core)
3266+
, m_noProxy(nullptr)
3267+
, m_systemProxy(nullptr)
3268+
, m_manualProxy(nullptr)
3269+
, m_httpBox(nullptr)
3270+
, m_ftpBox(nullptr)
3271+
, m_labelHttpHostName(nullptr)
3272+
, m_labelHttpPort(nullptr)
3273+
, m_ifHttpAuthenticate(nullptr)
3274+
, m_labelHttpUserName(nullptr)
3275+
, m_labelHttpPassword(nullptr)
3276+
, m_lineHttpHostName(nullptr)
3277+
, m_lineHttpPort(nullptr)
3278+
, m_lineHttpUserName(nullptr)
3279+
, m_lineHttpPassword(nullptr)
3280+
, m_labelFtpHostName(nullptr)
3281+
, m_labelFtpPort(nullptr)
3282+
, m_ifFtpAuthenticate(nullptr)
3283+
, m_labelFtpUserName(nullptr)
3284+
, m_labelFtpPassword(nullptr)
3285+
, m_lineFtpHostName(nullptr)
3286+
, m_lineFtpPort(nullptr)
3287+
, m_lineFtpUserName(nullptr)
3288+
, m_lineFtpPassword(nullptr)
3289+
{
3290+
setPixmap(QWizard::WatermarkPixmap, QPixmap());
3291+
setObjectName(QLatin1String("ProxySettingPage"));
3292+
setColoredTitle(tr("Proxy Setting"));
3293+
3294+
QVBoxLayout *layout = new QVBoxLayout(this);
3295+
setLayout(layout);
3296+
3297+
// proxy type part
3298+
m_noProxy = new QRadioButton(tr("&No Proxy"), this);
3299+
m_noProxy->setObjectName(QLatin1String("NoProxyRadioButton"));
3300+
layout->addWidget(m_noProxy);
3301+
3302+
m_manualProxy = new QRadioButton(tr("&Manual Proxy"), this);
3303+
m_manualProxy->setObjectName(QLatin1String("ManualProxyRadioButton"));
3304+
layout->addWidget(m_manualProxy);
3305+
3306+
m_systemProxy = new QRadioButton(tr("&System Proxy"), this);
3307+
m_systemProxy->setObjectName(QLatin1String("SystemProxyRadioButton"));
3308+
3309+
3310+
3311+
QButtonGroup *BtnGroupProxyType = new QButtonGroup();
3312+
BtnGroupProxyType->addButton(m_noProxy,0);
3313+
BtnGroupProxyType->addButton(m_systemProxy,1);
3314+
BtnGroupProxyType->addButton(m_manualProxy,2);
3315+
BtnGroupProxyType->setExclusive(true);
3316+
3317+
QHBoxLayout *groupBoxLayout = new QHBoxLayout;
3318+
QGridLayout *httpBoxLayout = new QGridLayout;
3319+
QGridLayout *ftpBoxLayout = new QGridLayout;
3320+
3321+
// http para groupbox
3322+
m_labelHttpHostName = new QLabel(this);
3323+
m_labelHttpHostName->setWordWrap(true);
3324+
m_labelHttpHostName->setObjectName(QLatin1String("HttpHostname"));
3325+
m_labelHttpHostName->setText(tr("Hostname"));
3326+
3327+
m_labelHttpPort = new QLabel(this);
3328+
m_labelHttpPort->setWordWrap(true);
3329+
m_labelHttpPort->setObjectName(QLatin1String("HttpPort"));
3330+
m_labelHttpPort->setText(tr("Port"));
3331+
3332+
m_lineHttpHostName = new QLineEdit(this);
3333+
m_lineHttpHostName->setObjectName(QLatin1String("HttpHostNameLineEdit"));
3334+
m_lineHttpPort = new QLineEdit(this);
3335+
m_lineHttpPort->setObjectName(QLatin1String("HttpPortLineEdit"));
3336+
3337+
httpBoxLayout->addWidget(m_labelHttpHostName,0,0,1,1);
3338+
httpBoxLayout->addWidget(m_lineHttpHostName,0,1,1,3);
3339+
httpBoxLayout->addWidget(m_labelHttpPort,1,0,1,1);
3340+
httpBoxLayout->addWidget(m_lineHttpPort,1,1,1,3);
3341+
3342+
m_ifHttpAuthenticate = new QRadioButton(tr("&Use authentication"), this);
3343+
m_ifHttpAuthenticate->setObjectName(QLatin1String("ifHttpAuthenticationRadioButton"));
3344+
3345+
m_labelHttpUserName = new QLabel(this);
3346+
m_labelHttpUserName->setWordWrap(true);
3347+
m_labelHttpUserName->setObjectName(QLatin1String("HttpUsername"));
3348+
m_labelHttpUserName->setText(tr("Username"));
3349+
3350+
m_labelHttpPassword = new QLabel(this);
3351+
m_labelHttpPassword->setWordWrap(true);
3352+
m_labelHttpPassword->setObjectName(QLatin1String("HttpPassword"));
3353+
m_labelHttpPassword->setText(tr("Password"));
3354+
3355+
m_lineHttpUserName = new QLineEdit(this);
3356+
m_lineHttpUserName->setObjectName(QLatin1String("HttpUserNameLineEdit"));
3357+
m_lineHttpPassword = new QLineEdit(this);
3358+
m_lineHttpPassword->setObjectName(QLatin1String("HttpPasswordLineEdit"));
3359+
3360+
httpBoxLayout->addWidget(m_ifHttpAuthenticate,2,1,1,3);
3361+
httpBoxLayout->addWidget(m_labelHttpUserName,3,0,1,1);
3362+
httpBoxLayout->addWidget(m_lineHttpUserName,3,1,1,3);
3363+
httpBoxLayout->addWidget(m_labelHttpPassword,4,0,1,1);
3364+
httpBoxLayout->addWidget(m_lineHttpPassword,4,1,1,3);
3365+
3366+
m_httpBox = new QGroupBox(this);
3367+
m_httpBox->setTitle(QLatin1String("Http"));
3368+
m_httpBox->setLayout(httpBoxLayout);
3369+
3370+
// ftp para groupbox
3371+
m_labelFtpHostName = new QLabel(this);
3372+
m_labelFtpHostName->setWordWrap(true);
3373+
m_labelFtpHostName->setObjectName(QLatin1String("FtpHostname"));
3374+
m_labelFtpHostName->setText(tr("Hostname"));
3375+
3376+
m_labelFtpPort = new QLabel(this);
3377+
m_labelFtpPort->setWordWrap(true);
3378+
m_labelFtpPort->setObjectName(QLatin1String("FtpPort"));
3379+
m_labelFtpPort->setText(tr("Port"));
3380+
3381+
m_lineFtpHostName = new QLineEdit(this);
3382+
m_lineFtpHostName->setObjectName(QLatin1String("FtpHostNameLineEdit"));
3383+
m_lineFtpPort = new QLineEdit(this);
3384+
m_lineFtpPort->setObjectName(QLatin1String("FtpPortLineEdit"));
3385+
3386+
ftpBoxLayout->addWidget(m_labelFtpHostName,0,0,1,1);
3387+
ftpBoxLayout->addWidget(m_lineFtpHostName,0,1,1,3);
3388+
ftpBoxLayout->addWidget(m_labelFtpPort,1,0,1,1);
3389+
ftpBoxLayout->addWidget(m_lineFtpPort,1,1,1,3);
3390+
3391+
m_ifFtpAuthenticate = new QRadioButton(tr("&Use authentication"), this);
3392+
m_ifFtpAuthenticate->setObjectName(QLatin1String("ifHttpAuthenticationRadioButton"));
3393+
3394+
m_labelFtpUserName = new QLabel(this);
3395+
m_labelFtpUserName->setWordWrap(true);
3396+
m_labelFtpUserName->setObjectName(QLatin1String("FtpUsername"));
3397+
m_labelFtpUserName->setText(tr("Username"));
3398+
3399+
m_labelFtpPassword = new QLabel(this);
3400+
m_labelFtpPassword->setWordWrap(true);
3401+
m_labelFtpPassword->setObjectName(QLatin1String("FtpPassword"));
3402+
m_labelFtpPassword->setText(tr("Password"));
3403+
3404+
m_lineFtpUserName = new QLineEdit(this);
3405+
m_lineFtpUserName->setObjectName(QLatin1String("FtpUserNameLineEdit"));
3406+
m_lineFtpPassword = new QLineEdit(this);
3407+
m_lineFtpPassword->setObjectName(QLatin1String("FtpPasswordLineEdit"));
3408+
3409+
ftpBoxLayout->addWidget(m_ifFtpAuthenticate,2,1,1,3);
3410+
ftpBoxLayout->addWidget(m_labelFtpUserName,3,0,1,1);
3411+
ftpBoxLayout->addWidget(m_lineFtpUserName,3,1,1,3);
3412+
ftpBoxLayout->addWidget(m_labelFtpPassword,4,0,1,1);
3413+
ftpBoxLayout->addWidget(m_lineFtpPassword,4,1,1,3);
3414+
3415+
m_ftpBox = new QGroupBox(this);
3416+
m_ftpBox->setTitle(QLatin1String("Ftp"));
3417+
m_ftpBox->setLayout(ftpBoxLayout);
3418+
3419+
//groupbox layout
3420+
groupBoxLayout->addWidget(m_httpBox);
3421+
groupBoxLayout->addWidget(m_ftpBox);
3422+
3423+
layout->addLayout(groupBoxLayout);
3424+
layout->addWidget(m_systemProxy);
3425+
3426+
setNetworkGroupboxVisible(false);
3427+
setHttpAuthenEnabled(false);
3428+
setFtpAuthenEnabled(false);
3429+
connect(m_manualProxy, &QAbstractButton::toggled,
3430+
this, &ProxySettingPage::setNetworkGroupboxVisible);
3431+
connect(m_ifHttpAuthenticate, &QAbstractButton::toggled,
3432+
this, &ProxySettingPage::setHttpAuthenEnabled);
3433+
connect(m_ifFtpAuthenticate, &QAbstractButton::toggled,
3434+
this, &ProxySettingPage::setFtpAuthenEnabled);
3435+
}
3436+
3437+
void ProxySettingPage::setNetworkGroupboxVisible(bool value)
3438+
{
3439+
m_httpBox->setVisible(value);
3440+
m_ftpBox->setVisible(value);
3441+
}
3442+
3443+
void ProxySettingPage::setHttpAuthenEnabled(bool value)
3444+
{
3445+
m_lineHttpUserName->setEnabled(value);
3446+
m_lineHttpPassword->setEnabled(value);
3447+
}
3448+
3449+
void ProxySettingPage::setFtpAuthenEnabled(bool value)
3450+
{
3451+
m_lineFtpUserName->setEnabled(value);
3452+
m_lineFtpPassword->setEnabled(value);
3453+
}
3454+
3455+
void ProxySettingPage::entering()
3456+
{
3457+
PackageManagerCore *core = packageManagerCore();
3458+
const Settings &settings = core->settings();
3459+
switch (settings.proxyType()) {
3460+
case Settings::NoProxy:
3461+
m_noProxy->setChecked(true);
3462+
break;
3463+
case Settings::SystemProxy:
3464+
m_systemProxy->setChecked(true);
3465+
break;
3466+
case Settings::UserDefinedProxy:
3467+
m_manualProxy->setChecked(true);
3468+
break;
3469+
default:
3470+
m_noProxy->setChecked(true);
3471+
Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown proxy type given!");
3472+
}
3473+
const QNetworkProxy &ftpProxy = settings.ftpProxy();
3474+
m_lineFtpHostName->setText(ftpProxy.hostName());
3475+
m_lineFtpPort->setText(QString::number(ftpProxy.port()));
3476+
m_ifFtpAuthenticate->setChecked((!ftpProxy.user().isEmpty()) && (!ftpProxy.password().isEmpty()));
3477+
m_lineFtpUserName->setText(ftpProxy.user());
3478+
m_lineFtpPassword->setText(ftpProxy.password());
3479+
3480+
const QNetworkProxy &httpProxy = settings.httpProxy();
3481+
m_lineHttpHostName->setText(httpProxy.hostName());
3482+
m_lineHttpPort->setText(QString::number(httpProxy.port()));
3483+
m_ifHttpAuthenticate->setChecked((!httpProxy.user().isEmpty()) && (!httpProxy.password().isEmpty()));
3484+
m_lineHttpUserName->setText(httpProxy.user());
3485+
m_lineHttpPassword->setText(httpProxy.password());
3486+
3487+
}
3488+
3489+
void ProxySettingPage::leaving()
3490+
{
3491+
PackageManagerCore *core = packageManagerCore();
3492+
Settings &settings = core->settings();
3493+
3494+
// update proxy type
3495+
settings.setProxyType(Settings::NoProxy);
3496+
if (m_systemProxy->isChecked())
3497+
settings.setProxyType(Settings::SystemProxy);
3498+
else if (m_manualProxy->isChecked())
3499+
settings.setProxyType(Settings::UserDefinedProxy);
3500+
3501+
if (settings.proxyType() == Settings::UserDefinedProxy) {
3502+
// update ftp proxy settings
3503+
if((!m_lineFtpHostName->text().isEmpty()) && (!m_lineFtpPort->text().isEmpty()))
3504+
{
3505+
if(m_ifFtpAuthenticate->isChecked())
3506+
{
3507+
settings.setFtpProxy(QNetworkProxy(QNetworkProxy::HttpProxy, m_lineFtpHostName->text(),
3508+
m_lineFtpPort->text().toInt(),m_lineFtpUserName->text(),m_lineFtpPassword->text()));
3509+
}
3510+
else
3511+
{
3512+
settings.setFtpProxy(QNetworkProxy(QNetworkProxy::HttpProxy, m_lineFtpHostName->text(),
3513+
m_lineFtpPort->text().toInt()));
3514+
}
3515+
}
3516+
// update http proxy settings
3517+
if((!m_lineHttpHostName->text().isEmpty()) && (!m_lineHttpPort->text().isEmpty()))
3518+
{
3519+
if(m_ifHttpAuthenticate->isChecked())
3520+
{
3521+
settings.setHttpProxy(QNetworkProxy(QNetworkProxy::HttpProxy, m_lineHttpHostName->text(),
3522+
m_lineHttpPort->text().toInt(),m_lineHttpUserName->text(),m_lineHttpPassword->text()));
3523+
}
3524+
else
3525+
{
3526+
settings.setHttpProxy(QNetworkProxy(QNetworkProxy::HttpProxy, m_lineHttpHostName->text(),
3527+
m_lineHttpPort->text().toInt()));
3528+
}
3529+
}
3530+
}
3531+
}
3532+
32633533
#include "packagemanagergui.moc"
32643534
#include "moc_packagemanagergui.cpp"

src/libs/installer/packagemanagergui.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class QProgressBar;
5050
class QRadioButton;
5151
class QTextBrowser;
5252
class QWinTaskbarButton;
53+
class QGroupBox;
5354
QT_END_NAMESPACE
5455

5556
namespace QInstaller {
@@ -284,6 +285,58 @@ private Q_SLOTS:
284285
};
285286

286287

288+
// -- ProxySettingPage
289+
class INSTALLER_EXPORT ProxySettingPage : public PackageManagerPage
290+
{
291+
Q_OBJECT
292+
293+
public:
294+
explicit ProxySettingPage(PackageManagerCore *core);
295+
296+
297+
private Q_SLOTS:
298+
void setNetworkGroupboxVisible(bool value);
299+
void setHttpAuthenEnabled(bool value);
300+
void setFtpAuthenEnabled(bool value);
301+
302+
private:
303+
304+
void entering() override;
305+
void leaving() override;
306+
307+
308+
private:
309+
310+
QRadioButton *m_noProxy;
311+
QRadioButton *m_systemProxy;
312+
QRadioButton *m_manualProxy;
313+
314+
QGroupBox *m_httpBox;
315+
QGroupBox *m_ftpBox;
316+
317+
QLabel *m_labelHttpHostName;
318+
QLabel *m_labelHttpPort;
319+
QRadioButton *m_ifHttpAuthenticate;
320+
QLabel *m_labelHttpUserName;
321+
QLabel *m_labelHttpPassword;
322+
QLineEdit *m_lineHttpHostName;
323+
QLineEdit *m_lineHttpPort;
324+
QLineEdit *m_lineHttpUserName;
325+
QLineEdit *m_lineHttpPassword;
326+
327+
QLabel *m_labelFtpHostName;
328+
QLabel *m_labelFtpPort;
329+
QRadioButton *m_ifFtpAuthenticate;
330+
QLabel *m_labelFtpUserName;
331+
QLabel *m_labelFtpPassword;
332+
QLineEdit *m_lineFtpHostName;
333+
QLineEdit *m_lineFtpPort;
334+
QLineEdit *m_lineFtpUserName;
335+
QLineEdit *m_lineFtpPassword;
336+
337+
};
338+
339+
287340
// -- LicenseAgreementPage
288341

289342
class INSTALLER_EXPORT LicenseAgreementPage : public PackageManagerPage

src/sdk/installerbasecommons.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ InstallerGui::InstallerGui(PackageManagerCore *core)
5050
}
5151

5252
setPage(PackageManagerCore::Introduction, new IntroductionPage(core));
53+
setPage(PackageManagerCore::ProxySetting, new ProxySettingPage(core));
5354
setPage(PackageManagerCore::TargetDirectory, new TargetDirectoryPage(core));
5455
setPage(PackageManagerCore::ComponentSelection, new ComponentSelectionPage(core));
5556
setPage(PackageManagerCore::LicenseCheck, new LicenseAgreementPage(core));

0 commit comments

Comments
 (0)