From a9a352bfc6a2cb7d212ab8c05db5d50c8c10a620 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Fri, 7 Apr 2023 17:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=89=E5=85=A8=E9=A1=B5ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enterprise-wlan/enterprisewlandialog.cpp | 10 +- .../netdetails/joinhiddenwifipage.cpp | 14 +- src/frontend/netdetails/netdetail.cpp | 111 +++-- src/frontend/netdetails/netdetail.h | 6 +- src/frontend/netdetails/securitypage.cpp | 402 ++++++++---------- 5 files changed, 250 insertions(+), 293 deletions(-) diff --git a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp index 332f45d1..e7e41087 100644 --- a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp +++ b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp @@ -23,8 +23,7 @@ #include "xatom-helper.h" #define MAIN_SIZE_EXPAND 480,580 #define MAIN_SIZE_NARROW 480,484 -#define PEAP_SCRO_HEIGHT 390 -#define TLS_SCRO_HEIGHT 590 +#define SCROAREA_WIDTH 480 #define MAIN_LAYOUT_MARGINS 0,0,0,0 #define CENTER_LAYOUT_MARGINS 24, 16, 24, 8 #define BUTTON_LAYOUT_MARGINS 24, 24, 24, 24 @@ -127,7 +126,11 @@ void EnterpriseWlanDialog::initUI() m_enterWlanScrollArea = new QScrollArea(this); m_enterWlanScrollArea->setFrameShape(QFrame::NoFrame); m_enterWlanScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_centerWidget->setFixedWidth(SCROAREA_WIDTH); + m_enterWlanScrollArea->setFixedWidth(SCROAREA_WIDTH); m_enterWlanScrollArea->setWidget(m_centerWidget); + m_enterWlanScrollArea->setWidgetResizable(true); + QPalette pal = m_enterWlanScrollArea->palette(); pal.setBrush(QPalette::Base, QColor(0,0,0,0)); m_enterWlanScrollArea->setPalette(pal); @@ -279,21 +282,18 @@ void EnterpriseWlanDialog::onEapTypeChanged(const KyEapMethodType &type) m_resource->getEnterPriseInfoTls(m_wirelessNetItem.m_connectUuid, m_info.tlsInfo); } this->setFixedSize(MAIN_SIZE_EXPAND); -// m_centerWidget->setFixedHeight(TLS_SCRO_HEIGHT); break; case KyEapMethodType::PEAP: if (m_wirelessNetItem.m_connectUuid.isEmpty()) { m_resource->getEnterPriseInfoPeap(m_wirelessNetItem.m_connectUuid, m_info.peapInfo); } this->setFixedSize(MAIN_SIZE_NARROW); -// m_centerWidget->setFixedHeight(PEAP_SCRO_HEIGHT); break; case KyEapMethodType::TTLS: if (!m_wirelessNetItem.m_connectUuid.isEmpty()) { m_resource->getEnterPriseInfoTtls(m_wirelessNetItem.m_connectUuid, m_info.ttlsInfo); } this->setFixedSize(MAIN_SIZE_NARROW); -// m_centerWidget->setFixedHeight(PEAP_SCRO_HEIGHT); break; case KyEapMethodType::LEAP: if (!m_wirelessNetItem.m_connectUuid.isEmpty()) { diff --git a/src/frontend/netdetails/joinhiddenwifipage.cpp b/src/frontend/netdetails/joinhiddenwifipage.cpp index 51c0900b..313be9eb 100644 --- a/src/frontend/netdetails/joinhiddenwifipage.cpp +++ b/src/frontend/netdetails/joinhiddenwifipage.cpp @@ -35,9 +35,7 @@ #define LABEL_MIN_WIDTH 146 #define LABEL_MAX_WIDTH 434 #define MAX_NAME_LENGTH 32 -#define PSK_SCRO_HEIGHT 182 -#define PEAP_SCRO_HEIGHT 340 -#define TLS_SCRO_HEIGHT 560 +#define SCROAREA_WIDTH 480 #define MEDIUM_WEIGHT_VALUE 57 JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent) @@ -49,7 +47,6 @@ JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent) initUI(); initComponent(); - setFixedWidth(WINDOW_WIDTH); setAttribute(Qt::WA_DeleteOnClose); setJoinBtnEnable(); @@ -121,8 +118,11 @@ void JoinHiddenWiFiPage::initUI() m_centerVBoxLayout->addWidget(ssidWidget); m_centerVBoxLayout->addSpacing(LAYOUT_SPACING); m_centerVBoxLayout->addWidget(m_secuWidget); - m_centerVBoxLayout->addStretch(); + + m_centerWidget->setFixedWidth(SCROAREA_WIDTH); + m_hiddenWifiScrollArea->setFixedWidth(SCROAREA_WIDTH); m_hiddenWifiScrollArea->setWidget(m_centerWidget); + m_hiddenWifiScrollArea->setWidgetResizable(true); //底部按钮 m_bottomLayout = new QHBoxLayout(m_bottomWidget); @@ -151,6 +151,7 @@ void JoinHiddenWiFiPage::initUI() this->setWindowIcon(QIcon::fromTheme("kylin-network")); this->setFixedHeight(MIN_WINDOW_HEIGHT); + this->setFixedWidth(WINDOW_WIDTH); onPaletteChanged(); } @@ -236,7 +237,6 @@ void JoinHiddenWiFiPage::onSecuTypeChanged(const KySecuType &type) { if (type != KySecuType::WPA_AND_WPA2_ENTERPRISE) { this->setFixedHeight(MIN_WINDOW_HEIGHT); - m_centerWidget->setFixedSize(WINDOW_WIDTH, PSK_SCRO_HEIGHT); } } @@ -244,10 +244,8 @@ void JoinHiddenWiFiPage::onEapTypeChanged(const KyEapMethodType &type) { if (type == KyEapMethodType::TLS) { this->setFixedHeight(TLS_WINDOW_HEIGHT); - m_centerWidget->setFixedSize(WINDOW_WIDTH, TLS_SCRO_HEIGHT); } else if (type == KyEapMethodType::PEAP || type == KyEapMethodType::TTLS) { this->setFixedHeight(PEAP_WINDOW_HEIGHT); - m_centerWidget->setFixedSize(WINDOW_WIDTH, PEAP_SCRO_HEIGHT); } } diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index ec5605fb..32cc3f89 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -47,9 +47,11 @@ #define CONFIG_PAGE_NUM 4 #define CREATE_NET_PAGE_NUM 5 #define PAGE_MIN_HEIGHT 40 +#define PAGE_WIDTH 472 #define LAN_TAB_WIDTH 180 #define WLAN_TAB_WIDTH 240 -#define SCRO_WIDTH 472 +#define SCRO_WIDTH 496 +#define SCRO_HEIGHT 600 #define PEAP_SCRO_HEIGHT 300 #define TLS_SCRO_HEIGHT 480 #define MAX_TAB_TEXT_LENGTH 44 @@ -167,7 +169,6 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv getConInfo(m_info); startObjectThread(); pagePadding(name,isWlan); - setSecuPageHeight(); connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged); isCreateOk = !(m_isCreateNet && !isWlan); @@ -281,52 +282,64 @@ void NetDetail::initUI() { QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0,9,0,24); - mainLayout->setSpacing(24); + mainLayout->setSpacing(22); + + this->installEventFilter(this); + pageFrame = new QFrame(this); + centerWidget = new QWidget(this); + bottomWidget = new QWidget(this); detailPage = new DetailPage(isWlan, m_name.isEmpty(), this); - ipv4Page = new Ipv4Page(this); ipv6Page = new Ipv6Page(this); securityPage = new SecurityPage(this); createNetPage = new CreatNetPage(this); configPage = new ConfigPage(this); - this->installEventFilter(this); + detailPage->setFixedWidth(PAGE_WIDTH); + ipv4Page->setFixedWidth(PAGE_WIDTH); + ipv6Page->setFixedWidth(PAGE_WIDTH); + securityPage->setFixedWidth(PAGE_WIDTH); + createNetPage->setFixedWidth(PAGE_WIDTH); + configPage->setFixedWidth(PAGE_WIDTH); - centerWidget = new QWidget(this); - bottomWidget = new QWidget(this); - - m_secuPageScrollArea = new QScrollArea(this); + m_secuPageScrollArea = new QScrollArea(centerWidget); + m_secuPageScrollArea->setFixedWidth(SCRO_WIDTH); m_secuPageScrollArea->setFrameShape(QFrame::NoFrame); m_secuPageScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_secuPageScrollArea->setWidget(securityPage); + + m_secuPageScrollArea->setWidgetResizable(true); + + m_ipv4ScrollArea = new QScrollArea(centerWidget); + m_ipv4ScrollArea->setFixedWidth(SCRO_WIDTH); + m_ipv4ScrollArea->setFrameShape(QFrame::NoFrame); + m_ipv4ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_ipv4ScrollArea->setWidget(ipv4Page); + m_ipv4ScrollArea->setWidgetResizable(true); + + m_ipv6ScrollArea = new QScrollArea(centerWidget); + m_ipv6ScrollArea->setFixedWidth(SCRO_WIDTH); + m_ipv6ScrollArea->setFrameShape(QFrame::NoFrame); + m_ipv6ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_ipv6ScrollArea->setWidget(ipv6Page); + m_ipv6ScrollArea->setWidgetResizable(true); + QPalette pal = m_secuPageScrollArea->palette(); pal.setBrush(QPalette::Base, QColor(0,0,0,0)); m_secuPageScrollArea->setPalette(pal); + m_ipv4ScrollArea->setPalette(pal); + m_ipv6ScrollArea->setPalette(pal); - detailPage->setFixedWidth(SCRO_WIDTH); - ipv4Page->setFixedWidth(SCRO_WIDTH); - ipv6Page->setFixedWidth(SCRO_WIDTH); - createNetPage->setFixedWidth(SCRO_WIDTH); - configPage->setFixedWidth(SCRO_WIDTH); stackWidget = new QStackedWidget(centerWidget); stackWidget->addWidget(detailPage); - stackWidget->addWidget(ipv4Page); - stackWidget->addWidget(ipv6Page); + stackWidget->addWidget(m_ipv4ScrollArea); + stackWidget->addWidget(m_ipv6ScrollArea); stackWidget->addWidget(m_secuPageScrollArea); stackWidget->addWidget(configPage); stackWidget->addWidget(createNetPage); - mainLayout->addWidget(centerWidget); - mainLayout->addWidget(bottomWidget); - - bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT); - - pageFrame = new QFrame(this); - QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame); -// pageLayout->setSpacing(PAGE_LAYOUT_SPACING); - // TabBar onPaletteChanged(); m_networkMode = NetworkModeType(NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid)); @@ -351,9 +364,6 @@ void NetDetail::initUI() } } - pageLayout->addWidget(m_netTabBar, Qt::AlignCenter); - pageLayout->addSpacing(24); - // TabBar关联选项卡页面 connect(m_netTabBar, SIGNAL(currentChanged(int)), this, SLOT(currentRowChangeSlot(int))); setNetTabToolTip(); @@ -366,10 +376,12 @@ void NetDetail::initUI() forgetBtn = new QPushButton(this); + QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame); + pageLayout->setContentsMargins(0, 0, 0, 0); + pageLayout->addWidget(m_netTabBar, Qt::AlignCenter); + QVBoxLayout *centerlayout = new QVBoxLayout(centerWidget); centerlayout->setContentsMargins(CENTER_LAYOUT_MARGINS); // 右边距为0,为安全页滚动区域留出空间 - centerlayout->addWidget(pageFrame); - centerlayout->addSpacing(4); centerlayout->addWidget(stackWidget); QHBoxLayout *bottomLayout = new QHBoxLayout(bottomWidget); @@ -379,11 +391,13 @@ void NetDetail::initUI() bottomLayout->addStretch(); bottomLayout->addWidget(cancelBtn); bottomLayout->addWidget(confimBtn); + bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT); + + mainLayout->addWidget(pageFrame); + mainLayout->addWidget(centerWidget); + mainLayout->addWidget(bottomWidget); -// QPalette pal(this->palette()); -// pal.setColor(QPalette::Background, qApp->palette().base().color()); this->setAutoFillBackground(true); -// this->setPalette(pal); } void NetDetail::loadPage() @@ -446,13 +460,6 @@ void NetDetail::initComponent() setConfirmEnable(); }); - connect(securityPage, &SecurityPage::secuTypeChanged, this, [=]() { - setSecuPageHeight(); - }); - connect(securityPage, &SecurityPage::eapTypeChanged, this, [=]() { - setSecuPageHeight(); - }); - const QByteArray id(THEME_SCHAME); if(QGSettings::isSchemaInstalled(id)){ QGSettings * fontSetting = new QGSettings(id, QByteArray(), this); @@ -746,22 +753,6 @@ void NetDetail::initSecuData() } } -void NetDetail::setSecuPageHeight() -{ - KySecuType secuType; - KyEapMethodType eapType; - securityPage->getSecuType(secuType, eapType); - if (secuType == WPA_AND_WPA2_ENTERPRISE) { - if (eapType == TLS) { - securityPage->setFixedSize(SCRO_WIDTH, TLS_SCRO_HEIGHT); - } else { - securityPage->setFixedSize(SCRO_WIDTH, PEAP_SCRO_HEIGHT); - } - } else { - securityPage->setFixedSize(SCRO_WIDTH, PEAP_SCRO_HEIGHT); - } -} - void NetDetail::initTlsInfo(ConInfo &conInfo) { m_resource->getEnterPriseInfoTls(m_uuid, conInfo.tlsInfo); @@ -1215,13 +1206,17 @@ NetTabBar::~NetTabBar() QSize NetTabBar::sizeHint() const { - return QSize(TAB_WIDTH, TAB_HEIGHT); + QSize size = KTabBar::sizeHint(); + size.setWidth(TAB_WIDTH); + return size; } QSize NetTabBar::minimumTabSizeHint(int index) const { Q_UNUSED(index) - return QSize(TAB_WIDTH, TAB_HEIGHT); + QSize size = KTabBar::minimumTabSizeHint(index); + size.setWidth(TAB_WIDTH); + return size; } diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h index 13391dfb..1bdaadd4 100644 --- a/src/frontend/netdetails/netdetail.h +++ b/src/frontend/netdetails/netdetail.h @@ -57,6 +57,7 @@ using namespace kdk; #define TAB_WIDTH 60 #define TAB_HEIGHT 36 +#define TAB_HEIGHT_TABLET 48 class NetTabBar : public KTabBar { @@ -64,7 +65,7 @@ class NetTabBar : public KTabBar public: explicit NetTabBar(QWidget *parent = nullptr); ~NetTabBar(); - +protected: QSize sizeHint() const; QSize minimumTabSizeHint(int index) const; }; @@ -109,7 +110,6 @@ private: void loadPage(); void pagePadding(QString netName, bool isWlan); void initSecuData(); - void setSecuPageHeight(); void initTlsInfo(ConInfo &conInfo); void initPeapInfo(ConInfo &conInfo); @@ -166,6 +166,8 @@ private: QWidget * centerWidget; QWidget * bottomWidget; QScrollArea * m_secuPageScrollArea; + QScrollArea * m_ipv4ScrollArea; + QScrollArea * m_ipv6ScrollArea; QPushButton * cancelBtn; QPushButton * forgetBtn; diff --git a/src/frontend/netdetails/securitypage.cpp b/src/frontend/netdetails/securitypage.cpp index 82fabb95..182c06de 100644 --- a/src/frontend/netdetails/securitypage.cpp +++ b/src/frontend/netdetails/securitypage.cpp @@ -25,7 +25,7 @@ #define DETAIL_MIN_LABEL_WIDTH 80 #define DETAIL_MIN_EDIT_WIDTH 390 #define MIN_LABEL_WIDTH 146 -#define MIN_EDIT_WIDTH 278 +#define MIN_EDIT_WIDTH 286 SecurityPage::SecurityPage(bool isNetDetailPage, QWidget *parent) : isDetailPage(isNetDetailPage), QFrame(parent) { @@ -84,14 +84,6 @@ void SecurityPage::initUI() userPwdEdit->setUseCustomPalette(true); userPwdFlagBox = new QCheckBox(this); - //FAST - m_pacCheckBox = new QCheckBox(this); - m_pacProvisionComboBox = new QComboBox(this); - m_pacFilePathComboBox = new QComboBox(this); - m_pacProvisionLabel = new FixLabel(this); - m_pacFlagLabel = new FixLabel(this); - m_pacFileLabel = new QLabel(this); - QWidget *queryWidget = new QWidget(this); QHBoxLayout *queryLayout = new QHBoxLayout(queryWidget); queryLayout->setContentsMargins(0, 0, 0, 0); @@ -99,6 +91,15 @@ void SecurityPage::initUI() queryLayout->addWidget(userPwdFlagLabel); queryLayout->addStretch(); + //FAST + m_pacCheckBox = new QCheckBox(this); + m_pacProvisionComboBox = new QComboBox(this); + m_pacFilePathComboBox = new QComboBox(this); + m_pacProvisionLabel = new FixLabel(this); + m_pacProvisionLabel->setFixedWidth(MIN_LABEL_WIDTH); + m_pacFlagLabel = new FixLabel(this); + m_pacFileLabel = new QLabel(this); + //记住该网络复选框 m_emptyLabel = new QLabel(this); m_emptyLabel->setMinimumWidth(MIN_LABEL_WIDTH - 8); @@ -114,22 +115,15 @@ void SecurityPage::initUI() rememberLayout->addWidget(m_checkLabel); rememberLayout->addStretch(); - // mSecuLayout = new QFormLayout(this); - // mSecuLayout->setContentsMargins(0, 0, 0, 0); - // mSecuLayout->addRow(secuTypeLabel, secuTypeCombox); - // mSecuLayout->addRow(pwdLabel, pwdEdit); - // mSecuLayout->addRow(eapTypeLabel, eapTypeCombox); - // mSecuLayout->addRow(identityLable, identityEdit); - // mSecuLayout->addRow(domainLable, domainEdit); - // mSecuLayout->addRow(caCertPathLabel, caCertPathCombox); - // mSecuLayout->addRow(caNeedBox, caNeedFlagLabel); - // mSecuLayout->addRow(clientCertPathLabel, clientCertPathCombox); - // mSecuLayout->addRow(clientPrivateKeyLabel, clientPrivateKeyCombox); - // mSecuLayout->addRow(clientPrivateKeyPwdLabel,clientPrivateKeyPwdEdit); - // mSecuLayout->addRow(eapMethodLabel, eapMethodCombox); - // mSecuLayout->addRow(userNameLabel, userNameEdit); - // mSecuLayout->addRow(userPwdLabel, userPwdEdit); - // mSecuLayout->addRow(userPwdFlagBox, userPwdFlagLabel); + //允许自动PAC配置复选框 + m_pacCheckWidget = new QWidget(this); + QGridLayout *pacCheckLayout = new QGridLayout(m_pacCheckWidget); + pacCheckLayout->setContentsMargins(0, 0, 0, 0); + pacCheckLayout->setVerticalSpacing(0); + pacCheckLayout->setColumnMinimumWidth(0, 16); + pacCheckLayout->addWidget(m_pacProvisionComboBox, 0, 0, 1, 2); + pacCheckLayout->addWidget(m_pacCheckBox, 1, 0); + pacCheckLayout->addWidget(m_pacFlagLabel, 1, 1); topLayout = new QGridLayout(); topLayout->setContentsMargins(0, 0, 0, 0); @@ -143,27 +137,24 @@ void SecurityPage::initUI() // EAP认证 Label和选项框 第2行,第0列,第1列 topLayout->addWidget(eapTypeLabel, 2, 0); topLayout->addWidget(eapTypeCombox, 2, 1); - // EAP认证 Label和选项框 第3行,第0列,第1列 - topLayout->addWidget(m_pacProvisionLabel, 3, 0); - topLayout->addWidget(m_pacProvisionComboBox, 3, 1); - // pac CheckBox和Label 第4行,第0列,第1列 - topLayout->addWidget(m_pacCheckBox, 4, 0); - topLayout->addWidget(m_pacFlagLabel, 4, 1); - // EAP认证 Label和选项框 第5行,第0列,第1列 - topLayout->addWidget(m_pacFileLabel, 5, 0); - topLayout->addWidget(m_pacFilePathComboBox, 5, 1); - //内部认证 Label和选项框 第6行,第0列,第1列 - topLayout->addWidget(eapMethodLabel, 6, 0); - topLayout->addWidget(eapMethodCombox, 6, 1); - //用户名 Label和输入框 第7行,第0列,第1列 - topLayout->addWidget(userNameLabel, 7, 0); - topLayout->addWidget(userNameEdit, 7, 1); - //密码 Label和密码框 第8行,第0列,第1列 - topLayout->addWidget(userPwdLabel, 8, 0); - topLayout->addWidget(userPwdEdit, 8, 1); - // 匿名身份 Label和输入框 第9行,第0列,第1列 - topLayout->addWidget(identityLable, 9, 0); - topLayout->addWidget(identityEdit, 9, 1); + // 匿名身份 Label和输入框 第3行,第0列,第1列 + topLayout->addWidget(identityLable, 3, 0); + topLayout->addWidget(identityEdit, 3, 1); + //PAC配置 允许自动PAC配置 第4行,第0列;第4行,第1列,占2行1列 + topLayout->addWidget(m_pacProvisionLabel, 4, 0, Qt::AlignTop); + topLayout->addWidget(m_pacCheckWidget, 4, 1); + // PAC文件 + topLayout->addWidget(m_pacFileLabel, 6, 0); + topLayout->addWidget(m_pacFilePathComboBox, 6, 1); + //内部认证 Label和选项框 + topLayout->addWidget(eapMethodLabel, 7, 0); + topLayout->addWidget(eapMethodCombox, 7, 1); + //用户名 Label和输入框 + topLayout->addWidget(userNameLabel, 8, 0); + topLayout->addWidget(userNameEdit, 8, 1); + //密码 Label和密码框 + topLayout->addWidget(userPwdLabel, 9, 0); + topLayout->addWidget(userPwdEdit, 9, 1); // CA证书选项框及CheckBox布局 @@ -205,14 +196,16 @@ void SecurityPage::initUI() checkWidget->hide(); topLayout->addWidget(queryWidget, 10, 1); changeColumnWidthWithSecuType(); + m_pacFlagLabel->setMinimumWidth(MIN_EDIT_WIDTH); } else { queryWidget->hide(); topLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH); topLayout->setColumnMinimumWidth(1, MIN_EDIT_WIDTH); bottomLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH - 8); + m_pacFlagLabel->setMinimumWidth(MIN_EDIT_WIDTH - 36); } - topLayout->addWidget(tlsWidget, 7, 0, 6, 2); + topLayout->addWidget(tlsWidget, 10, 0, 6, 2); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); @@ -268,18 +261,6 @@ void SecurityPage::initUI() clientPrivateKeyCombox->addItem(tr("None"), QString(tr("None"))); //无 clientPrivateKeyCombox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择... - //FAST - m_pacCheckBox->setChecked(true); - m_pacProvisionLabel->setText(tr("PAC provisioning")); //PAC配置 - m_pacFlagLabel->setText(tr("Allow automatic PAC provisioning")); //允许自动PAC配置 - m_pacFileLabel->setText(tr("PAC file")); //PAC文件 - m_pacProvisionComboBox->addItem(tr("Anonymous"), ANON); //匿名 - m_pacProvisionComboBox->addItem(tr("Authenticated"), AUTHEN); //已认证 - m_pacProvisionComboBox->addItem(tr("Both"), BOTH); //两者兼用 - m_pacProvisionComboBox->setCurrentIndex(ANON); - m_pacFilePathComboBox->addItem(tr("None"), QString(tr("None"))); //无 - m_pacFilePathComboBox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择... - //仅为该用户存储密码 pwdOptionCombox->addItem(tr("Store passwords only for this user"), QString(tr("Store password only for this user"))); //存储所有用户的密码 @@ -288,6 +269,18 @@ void SecurityPage::initUI() pwdOptionCombox->addItem(tr("Ask this password every time"), QString(tr("Ask password every time"))); pwdOptionCombox->setCurrentIndex(1); + //FAST + m_pacCheckBox->setChecked(true); + m_pacProvisionLabel->setLabelText(tr("PAC provisioning")); //PAC配置 + m_pacFlagLabel->setLabelText(tr("Allow automatic PAC provisioning")); //允许自动PAC配置 + m_pacFileLabel->setText(tr("PAC file")); //PAC文件 + m_pacProvisionComboBox->addItem(tr("Anonymous"), ANON); //匿名 + m_pacProvisionComboBox->addItem(tr("Authenticated"), AUTHEN); //已认证 + m_pacProvisionComboBox->addItem(tr("Both"), BOTH); //两者兼用 + m_pacProvisionComboBox->setCurrentIndex(ANON); + m_pacFilePathComboBox->addItem(tr("None"), QString(tr("None"))); //无 + m_pacFilePathComboBox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择... + //禁用ClearBtn按钮 pwdEdit->setClearButtonEnabled(false); clientPrivateKeyPwdEdit->setClearButtonEnabled(false); @@ -305,13 +298,13 @@ void SecurityPage::initUI() void SecurityPage::initConnect() { //安全类型变化 - // connect(secuTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onSecuTypeComboxIndexChanged); +// connect(secuTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onSecuTypeComboxIndexChanged); connect(secuTypeCombox, QOverload::of(&QComboBox::currentIndexChanged), this, &SecurityPage::onSecuTypeComboxIndexChanged); connect(secuTypeCombox, QOverload::of(&QComboBox::currentIndexChanged), this, &SecurityPage::changeColumnWidthWithSecuType); //EAP方式变化 - // connect(eapTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onEapTypeComboxIndexChanged); +// connect(eapTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onEapTypeComboxIndexChanged); connect(eapTypeCombox, QOverload::of(&QComboBox::currentIndexChanged), this, &SecurityPage::onEapTypeComboxIndexChanged); connect(caNeedBox, &QCheckBox::clicked, this, &SecurityPage::onCaNeedBoxClicked); @@ -490,22 +483,28 @@ void SecurityPage::setFastInfo(KyEapMethodFastInfo &info) onEapTypeComboxIndexChanged(); identityEdit->setText(info.m_anonIdentity); - if (info.m_pacProvisioning == KyFastProvisioningAllowUnauthenticated) { + m_pacCheckBox->setChecked(false); + m_pacProvisionComboBox->setCurrentIndex(ANON); + if (info.m_pacProvisioning == KyFastProvisioningDisabled) { + m_pacCheckBox->setChecked(false); + m_pacProvisionComboBox->setCurrentIndex(ANON); + m_pacProvisionComboBox->setEnabled(false); + } else if (info.m_pacProvisioning == KyFastProvisioningAllowUnauthenticated) { m_pacProvisionComboBox->setCurrentIndex(ANON); } else if (info.m_pacProvisioning == KyFastProvisioningAllowAuthenticated) { m_pacProvisionComboBox->setCurrentIndex(AUTHEN); } else if (info.m_pacProvisioning == KyFastProvisioningAllowBoth) { m_pacProvisionComboBox->setCurrentIndex(BOTH); + } else { + qWarning() << "Unknown fastProvisioning type" << Q_FUNC_INFO << __LINE__; + m_pacCheckBox->setChecked(false); + m_pacProvisionComboBox->setEnabled(false); } if (info.m_pacFilePath.isEmpty()) { m_pacFilePathComboBox->setItemText(0, QString(tr("None"))); - m_pacCheckBox->setChecked(true); - m_pacFilePathComboBox->setEnabled(false); } else { m_pacFilePathComboBox->setItemText(0, info.m_pacFilePath); - m_pacCheckBox->setChecked(false); - m_pacFilePathComboBox->setEnabled(true); } if (info.m_authMethod == KyAuthMethodGtc) { @@ -611,7 +610,7 @@ bool SecurityPage::checkIsChanged(const ConInfo info) if (info.secType == NONE) { return false; } else if (info.secType == WPA_AND_WPA2_PERSONAL || info.secType == WPA3_PERSONAL) { - return !(info.strPassword == pwdEdit->text()); + return !(info.strPassword == pwdEdit->text()); } else { if (info.enterpriseType != eapTypeCombox->currentData().toInt()) { return true; @@ -659,12 +658,10 @@ void SecurityPage::showNone() userPwdFlagLabel->hide(); //FAST - m_pacCheckBox->hide(); - m_pacProvisionComboBox->hide(); - m_pacFilePathComboBox->hide(); m_pacProvisionLabel->hide(); - m_pacFlagLabel->hide(); + m_pacCheckWidget->hide(); m_pacFileLabel->hide(); + m_pacFilePathComboBox->hide(); } void SecurityPage::showPsk() @@ -692,12 +689,10 @@ void SecurityPage::showPsk() userPwdFlagLabel->hide(); //FAST - m_pacCheckBox->hide(); - m_pacProvisionComboBox->hide(); - m_pacFilePathComboBox->hide(); m_pacProvisionLabel->hide(); - m_pacFlagLabel->hide(); + m_pacCheckWidget->hide(); m_pacFileLabel->hide(); + m_pacFilePathComboBox->hide(); } void SecurityPage::showTls() @@ -724,12 +719,10 @@ void SecurityPage::showTls() userPwdFlagLabel->hide(); //FAST - m_pacCheckBox->hide(); - m_pacProvisionComboBox->hide(); - m_pacFilePathComboBox->hide(); m_pacProvisionLabel->hide(); - m_pacFlagLabel->hide(); + m_pacCheckWidget->hide(); m_pacFileLabel->hide(); + m_pacFilePathComboBox->hide(); } void SecurityPage::showPeapOrTtls() @@ -746,14 +739,6 @@ void SecurityPage::showPeapOrTtls() identityEdit->hide(); tlsWidget->hide(); - //FAST - m_pacCheckBox->hide(); - m_pacProvisionComboBox->hide(); - m_pacFilePathComboBox->hide(); - m_pacProvisionLabel->hide(); - m_pacFlagLabel->hide(); - m_pacFileLabel->hide(); - //PEAP TTLS共有 eapMethodLabel->show(); userNameLabel->show(); @@ -764,96 +749,74 @@ void SecurityPage::showPeapOrTtls() userNameEdit->show(); userPwdEdit->show(); userPwdFlagLabel->show(); + + //FAST + m_pacProvisionLabel->hide(); + m_pacCheckWidget->hide(); + m_pacFileLabel->hide(); + m_pacFilePathComboBox->hide(); } void SecurityPage::showLeapOrPwd() { - pwdEdit->hide(); - eapTypeCombox->show(); - - identityEdit->hide(); - domainEdit->hide(); - caCertPathCombox->hide(); - caNeedBox->hide(); - clientCertPathCombox->hide(); - clientPrivateKeyCombox->hide(); - clientPrivateKeyPwdEdit->hide(); - - eapMethodCombox->hide(); - userNameEdit->show(); - userPwdEdit->show(); - userPwdFlagBox->show(); - pwdLabel->hide(); + pwdEdit->hide(); + //企业wifi共有 eapTypeLabel->show(); + eapTypeCombox->show(); + //TLS identityLable->hide(); - domainLable->hide(); - caCertPathLabel->hide(); - caNeedFlagLabel->hide(); - clientCertPathLabel->hide(); - clientPrivateKeyLabel->hide(); - clientPrivateKeyPwdLabel->hide(); - - //PEAP TTLS共有 - eapMethodLabel->hide(); - userNameLabel->show(); - userPwdLabel->show(); - userPwdFlagLabel->show(); + identityEdit->hide(); + tlsWidget->hide(); //FAST - m_pacCheckBox->hide(); - m_pacProvisionComboBox->hide(); - m_pacFilePathComboBox->hide(); m_pacProvisionLabel->hide(); - m_pacFlagLabel->hide(); + m_pacCheckWidget->hide(); m_pacFileLabel->hide(); + m_pacFilePathComboBox->hide(); + + eapMethodLabel->hide(); + eapMethodCombox->hide(); + userPwdFlagBox->show(); + userPwdFlagLabel->show(); + + userNameLabel->show(); + userNameEdit->show(); + userPwdLabel->show(); + userPwdEdit->show(); } void SecurityPage::showFast() { - pwdEdit->hide(); - eapTypeCombox->show(); - - identityEdit->show(); - domainEdit->hide(); - caCertPathCombox->hide(); - caNeedBox->hide(); - clientCertPathCombox->hide(); - clientPrivateKeyCombox->hide(); - clientPrivateKeyPwdEdit->hide(); - - eapMethodCombox->show(); - userNameEdit->show(); - userPwdEdit->show(); - userPwdFlagBox->hide(); - pwdLabel->hide(); + pwdEdit->hide(); + //企业wifi共有 eapTypeLabel->show(); + eapTypeCombox->show(); + //TLS identityLable->show(); - domainLable->hide(); - caCertPathLabel->hide(); - caNeedFlagLabel->hide(); - clientCertPathLabel->hide(); - clientPrivateKeyLabel->hide(); - clientPrivateKeyPwdLabel->hide(); - - //PEAP TTLS共有 - eapMethodLabel->show(); - userNameLabel->show(); - userPwdLabel->show(); - userPwdFlagLabel->hide(); + identityEdit->show(); + tlsWidget->hide(); //FAST - m_pacCheckBox->show(); - m_pacProvisionComboBox->show(); - m_pacFilePathComboBox->show(); m_pacProvisionLabel->show(); - m_pacFlagLabel->show(); + m_pacCheckWidget->show(); m_pacFileLabel->show(); + m_pacFilePathComboBox->show(); + + eapMethodLabel->show(); + eapMethodCombox->show(); + userPwdFlagBox->show(); + userPwdFlagLabel->show(); + + userNameLabel->show(); + userNameEdit->show(); + userPwdLabel->show(); + userPwdEdit->show(); } KyEapMethodTlsInfo SecurityPage::assembleTlsInfo() @@ -885,7 +848,7 @@ KyEapMethodTlsInfo SecurityPage::assembleTlsInfo() KyEapMethodPeapInfo SecurityPage::assemblePeapInfo() { KyEapMethodPeapInfo info; - // info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt(); +// info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt(); switch (eapMethodCombox->currentIndex()) { case 0: info.phase2AuthMethod = KyAuthMethodMschapv2; @@ -967,37 +930,37 @@ KyEapMethodPwdInfo SecurityPage::assemblePwdInfo() KyEapMethodFastInfo SecurityPage::assembleFastInfo() { KyEapMethodFastInfo info; - info.m_anonIdentity = identityEdit->text(); - switch (m_pacProvisionComboBox->currentIndex()) { - case ANON: - info.m_pacProvisioning = KyFastProvisioningAllowUnauthenticated; - break; - case AUTHEN: - info.m_pacProvisioning = KyFastProvisioningAllowAuthenticated; - break; - case BOTH: - info.m_pacProvisioning = KyFastProvisioningAllowBoth; - break; - default: - break; - } - info.m_allowAutoPacFlag = m_pacCheckBox->isChecked(); - info.m_pacFilePath = m_pacFilePathComboBox->currentText(); + info.m_anonIdentity = identityEdit->text(); + switch (m_pacProvisionComboBox->currentIndex()) { + case ANON: + info.m_pacProvisioning = KyFastProvisioningAllowUnauthenticated; + break; + case AUTHEN: + info.m_pacProvisioning = KyFastProvisioningAllowAuthenticated; + break; + case BOTH: + info.m_pacProvisioning = KyFastProvisioningAllowBoth; + break; + default: + break; + } + info.m_allowAutoPacFlag = m_pacCheckBox->isChecked(); + info.m_pacFilePath = m_pacFilePathComboBox->currentText(); - switch (eapMethodCombox->currentIndex()) { - case GTC_FAST: - info.m_authMethod = KyAuthMethodGtc; - break; - case MSCHAPV2_FAST: - info.m_authMethod = KyAuthMethodMschapv2; - break; - default: - break; - } - info.m_userName = userNameEdit->text(); - info.m_userPwd = userPwdEdit->text(); - info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None); - return info; + switch (eapMethodCombox->currentIndex()) { + case GTC_FAST: + info.m_authMethod = KyAuthMethodGtc; + break; + case MSCHAPV2_FAST: + info.m_authMethod = KyAuthMethodMschapv2; + break; + default: + break; + } + info.m_userName = userNameEdit->text(); + info.m_userPwd = userPwdEdit->text(); + info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None); + return info; } void SecurityPage::updateSecurityChange(KyWirelessConnectSetting &setting) @@ -1064,13 +1027,11 @@ bool SecurityPage::checkConnectBtnIsEnabled() return false; } } else if (type == FAST) { - if (identityEdit->text().isEmpty()) { - qDebug() << "fast anonymous identity is empty"; - return false; - } if(!m_pacCheckBox->isChecked()) { - qDebug() << "Not allow automatic PAC provisioning "; - return false; + if (m_pacFilePathComboBox->currentText() == QString(tr("None"))) { + qDebug() << "Not allow automatic PAC provisioning && pac file is empty"; + return false; + } } if(userNameEdit->text().isEmpty() || userPwdEdit->text().isEmpty()) { qDebug() << "user name or user password is empty"; @@ -1233,6 +1194,39 @@ void SecurityPage::onClientPrivateKeyComboxIndexChanged(QString str) } } +void SecurityPage::onPwdOptionComboxIndexChanged(QString str) +{ + KyEapMethodTlsInfo info; + if (str.contains("Store passwords only for this user") || str.contains("仅为该用户存储密码")) { + info.m_privateKeyPWDFlag = NetworkManager::Setting::AgentOwned; + clientPrivateKeyPwdEdit->setPlaceholderText(emptyhint); + } else if (str.contains("Store passwords for all users") || str.contains("存储所有用户的密码")) { + info.m_privateKeyPWDFlag = NetworkManager::Setting::None; + clientPrivateKeyPwdEdit->setPlaceholderText(hintRequired); + } else { + info.m_privateKeyPWDFlag = NetworkManager::Setting::NotSaved; + clientPrivateKeyPwdEdit->setPlaceholderText(emptyhint); + } +} + +void SecurityPage::changeColumnWidthWithSecuType() +{ + if (!isDetailPage) { + return; + } + if (secuTypeCombox->currentData().toInt() == WPA_AND_WPA2_ENTERPRISE) { + if (eapMethodCombox->currentData().toInt() == TLS || eapMethodCombox->currentData().toInt() == FAST) { + topLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH); + topLayout->setColumnMinimumWidth(1, MIN_EDIT_WIDTH); + bottomLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH - 8); + + } + }else { + topLayout->setColumnMinimumWidth(0, DETAIL_MIN_LABEL_WIDTH); + topLayout->setColumnMinimumWidth(1, DETAIL_MIN_EDIT_WIDTH); + } +} + void SecurityPage::onPacFilePathComboxIndexChanged(QString str) { if (str.contains("Choose from file...") || str.contains("从文件选择...")) @@ -1256,35 +1250,3 @@ void SecurityPage::onPacFilePathComboxIndexChanged(QString str) } } -void SecurityPage::onPwdOptionComboxIndexChanged(QString str) -{ - KyEapMethodTlsInfo info; - if (str.contains("Store passwords only for this user") || str.contains("仅为该用户存储密码")) { - info.m_privateKeyPWDFlag = NetworkManager::Setting::AgentOwned; - clientPrivateKeyPwdEdit->setPlaceholderText(emptyhint); - } else if (str.contains("Store passwords for all users") || str.contains("存储所有用户的密码")) { - info.m_privateKeyPWDFlag = NetworkManager::Setting::None; - clientPrivateKeyPwdEdit->setPlaceholderText(hintRequired); - } else { - info.m_privateKeyPWDFlag = NetworkManager::Setting::NotSaved; - clientPrivateKeyPwdEdit->setPlaceholderText(emptyhint); - } -} - -void SecurityPage::changeColumnWidthWithSecuType() -{ - if (!isDetailPage) { - return; - } - if (secuTypeCombox->currentData().toInt() == WPA_AND_WPA2_ENTERPRISE && - eapMethodCombox->currentData().toInt() == TLS) { - topLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH); - topLayout->setColumnMinimumWidth(1, MIN_EDIT_WIDTH); - bottomLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH - 8); - - } else { - topLayout->setColumnMinimumWidth(0, DETAIL_MIN_LABEL_WIDTH); - topLayout->setColumnMinimumWidth(1, DETAIL_MIN_EDIT_WIDTH); - } -} -