新增查找并加入WiFi页面-同步调整安全页ui

This commit is contained in:
zhangyuanyuan1 2022-07-06 16:36:50 +08:00
parent 0153114412
commit 0354bf7d74
9 changed files with 574 additions and 119 deletions

View File

@ -813,6 +813,8 @@ void MainWindow::showAddOtherWlanWidget(QString devName)
return;
}
}
#if 0
NetDetail *netDetail = new NetDetail(devName, "", "", false, true, true, this);
connect(netDetail, &NetDetail::createPageClose, [&](QString interfaceName){
if (m_addOtherPagePtrMap.contains(interfaceName)) {
@ -821,7 +823,17 @@ void MainWindow::showAddOtherWlanWidget(QString devName)
});
m_addOtherPagePtrMap.insert(devName, netDetail);
netDetail->show();
#endif
JoinHiddenWiFiPage *hiddenWiFi =new JoinHiddenWiFiPage(devName);
connect(hiddenWiFi, &JoinHiddenWiFiPage::hiddenWiFiPageClose, [&](QString interfaceName){
if (m_addOtherPagePtrMap.contains(interfaceName)) {
m_addOtherPagePtrMap[interfaceName] = nullptr;
}
});
m_addOtherPagePtrMap.insert(devName, hiddenWiFi);
connect(hiddenWiFi, &JoinHiddenWiFiPage::showWlanList, this, &MainWindow::onShowMainWindow);
hiddenWiFi->show();
}
void MainWindow::getWirelessDeviceCap(QMap<QString, int> &map)

View File

@ -33,6 +33,7 @@
#include "lanpage.h"
#include "wlanpage.h"
#include "netdetails/netdetail.h"
#include "netdetails/joinhiddenwifipage.h"
#include <ukuisdk/kylin-com4cxx.h>
#ifdef WITHKYSEC
@ -189,7 +190,8 @@ private:
IconActiveType iconStatus = IconActiveType::NOT_CONNECTED;
QMap<QString, NetDetail*> m_createPagePtrMap;
QMap<QString, NetDetail*> m_addOtherPagePtrMap;
// QMap<QString, NetDetail*> m_addOtherPagePtrMap;
QMap<QString, JoinHiddenWiFiPage*> m_addOtherPagePtrMap;
public slots:
void onShowMainWindow(int type);

View File

@ -0,0 +1,230 @@
#include "joinhiddenwifipage.h"
#define WINDOW_WIDTH 480
#define MIN_WINDOW_HEIGHT 368
#define PEAP_WINDOW_HEIGHT 524
#define TLS_WINDOW_HEIGHT 580
#define LAYOUT_MARGINS 0, 0, 0, 0
#define TOP_LAYOUT_MARGINS 24, 12, 24, 24
#define CENTER_LAYOUT_MARGINS 24, 0, 24, 8
#define BOTTOM_LAYOUT_MARGINS 24, 24, 24, 24
#define LAYOUT_SPACING 16
#define LABEL_MIN_WIDTH 146
#define MAX_NAME_LENGTH 32
#define PSK_SCRO_HEIGHT 180
#define PEAP_SCRO_HEIGHT 340
#define TLS_SCRO_HEIGHT 560
JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent)
:m_devName(devName),
KDialog(parent)
{
m_wirelessConnOpration = new KyWirelessConnectOperation(this);
initUI();
initComponent();
setFixedWidth(WINDOW_WIDTH);
setAttribute(Qt::WA_DeleteOnClose);
setJoinBtnEnable();
}
JoinHiddenWiFiPage::~JoinHiddenWiFiPage()
{
}
void JoinHiddenWiFiPage::closeEvent(QCloseEvent *event)
{
emit this->hiddenWiFiPageClose(m_devName);
return QWidget::closeEvent(event);
}
void JoinHiddenWiFiPage::initUI()
{
m_topWidget = new QWidget(this);
m_centerWidget = new QWidget(this);
m_bottomWidget = new QWidget(this);
m_secuWidget = new SecurityPage(false, this);
m_secuWidget->setSecurity(KySecuType::WPA_AND_WPA2_PERSONAL);
m_descriptionLabel = new QLabel(this);
m_nameLabel = new QLabel(this);
m_nameEdit =new LineEdit(this);
m_emptyLabel = new QLabel(this);
m_checkLabel = new QLabel(this);
m_rememberCheckBox = new QCheckBox(this);
m_bottomDivider = new Divider(this);
m_showListBtn = new KBorderlessButton(this);
m_cancelBtn =new QPushButton(this);
m_joinBtn =new QPushButton(this);
m_scrollArea = new QScrollArea(this);
m_scrollArea->setFrameShape(QFrame::NoFrame);
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_pageLayout = new QVBoxLayout(this);
m_pageLayout->setContentsMargins(LAYOUT_MARGINS);
m_pageLayout->setSpacing(0);
m_pageLayout->addWidget(m_topWidget);
m_pageLayout->addWidget(m_scrollArea);
m_pageLayout->addWidget(m_bottomDivider);
m_pageLayout->addWidget(m_bottomWidget);
this->mainWidget()->setLayout(m_pageLayout);
m_topLayout = new QHBoxLayout(m_topWidget);
m_topLayout->setContentsMargins(TOP_LAYOUT_MARGINS);
m_topLayout->setSpacing(0);
m_topLayout->addWidget(m_descriptionLabel);
m_topLayout->addStretch();
QWidget *ssidWidget = new QWidget(this);
QHBoxLayout *ssidLayout = new QHBoxLayout(ssidWidget);
ssidLayout->setContentsMargins(LAYOUT_MARGINS);
ssidLayout->setSpacing(0);
m_nameLabel->setMinimumWidth(LABEL_MIN_WIDTH);
ssidLayout->addWidget(m_nameLabel);
ssidLayout->addWidget(m_nameEdit);
//记住该网络复选框
QWidget *checkWidget = new QWidget(this);
QHBoxLayout *checkLayout = new QHBoxLayout(checkWidget);
checkLayout->setContentsMargins(LAYOUT_MARGINS);
m_emptyLabel->setMinimumWidth(LABEL_MIN_WIDTH - 8);
m_rememberCheckBox->setChecked(true);
checkLayout->addWidget(m_emptyLabel);
checkLayout->addWidget(m_rememberCheckBox);
checkLayout->addWidget(m_checkLabel);
checkLayout->addStretch();
m_centerVBoxLayout = new QVBoxLayout(m_centerWidget);
m_centerVBoxLayout->setContentsMargins(CENTER_LAYOUT_MARGINS);
m_centerVBoxLayout->setSpacing(0);
m_centerVBoxLayout->addWidget(ssidWidget);
m_centerVBoxLayout->addSpacing(LAYOUT_SPACING);
m_centerVBoxLayout->addWidget(m_secuWidget);
m_centerVBoxLayout->addWidget(checkWidget);
m_centerVBoxLayout->addStretch();
m_scrollArea->setWidget(m_centerWidget);
//底部按钮
m_bottomLayout = new QHBoxLayout(m_bottomWidget);
m_bottomLayout->setContentsMargins(BOTTOM_LAYOUT_MARGINS);
m_bottomLayout->setSpacing(LAYOUT_SPACING);
m_bottomLayout->addWidget(m_showListBtn);
m_bottomLayout->addStretch();
m_bottomLayout->addWidget(m_cancelBtn);
m_bottomLayout->addWidget(m_joinBtn);
//请输入您想要加入网络的名称和安全类型
m_descriptionLabel->setText(tr("Please enter the network name and security type"));
QFont font = m_descriptionLabel->font();
font.setWeight(75);
m_descriptionLabel->setFont(font);
m_nameLabel->setText(tr("Network name(SSID)")); //网络名(SSID)
m_checkLabel->setText(tr("Remember the Network")); //记住该网络
m_showListBtn->setText(tr("Show Network List")); //显示网络列表
m_cancelBtn->setText(tr("Cancel"));
m_joinBtn->setText(tr("Join"));
m_nameEdit->setMaxLength(MAX_NAME_LENGTH);
m_nameEdit->setPlaceholderText(tr("Required")); //必填
QPalette pa = m_scrollArea->palette();
pa.setBrush(QPalette::Window, Qt::transparent);
m_scrollArea->setPalette(pa);
this->setWindowTitle(tr("Find and Join Wi-Fi"));
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
this->setFixedHeight(MIN_WINDOW_HEIGHT);
}
void JoinHiddenWiFiPage::initComponent()
{
connect(m_cancelBtn, &QPushButton::clicked, this, [=] {
close();
});
connect(m_joinBtn, SIGNAL(clicked()), this, SLOT(onBtnJoinClicked()));
connect(m_showListBtn, SIGNAL(clicked()), this, SLOT(onBtnShowListClicked()));
connect(m_secuWidget, &SecurityPage::secuTypeChanged, this, &JoinHiddenWiFiPage::onSecuTypeChanged);
connect(m_secuWidget, &SecurityPage::eapTypeChanged, this, &JoinHiddenWiFiPage::onEapTypeChanged);
connect(m_secuWidget, &SecurityPage::setSecuPageState, this, [ = ](bool status) {
m_isSecuOk = status;
setJoinBtnEnable();
});
connect(m_nameEdit, &LineEdit::textChanged, this, &JoinHiddenWiFiPage::setJoinBtnEnable);
}
void JoinHiddenWiFiPage::setJoinBtnEnable()
{
if (!m_nameEdit->text().isEmpty() && m_isSecuOk) {
m_isJoinBtnEnable = true;
} else {
m_isJoinBtnEnable = false;
}
m_joinBtn->setEnabled(m_isJoinBtnEnable);
}
void JoinHiddenWiFiPage::onBtnJoinClicked()
{
KyWirelessConnectSetting connSettingInfo;
//基本信息
connSettingInfo.m_ssid = m_nameEdit->text();
connSettingInfo.setConnectName(connSettingInfo.m_ssid);
connSettingInfo.setIfaceName(m_devName);
connSettingInfo.m_isAutoConnect = m_rememberCheckBox->isChecked();
connSettingInfo.m_secretFlag = 0;
KySecuType secuType;
KyEapMethodType eapType;
m_secuWidget->getSecuType(secuType, eapType);
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
if (eapType == TLS) {
m_info.tlsInfo.devIfaceName = m_devName;
m_secuWidget->updateTlsChange(m_info.tlsInfo);
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTlsConnect(m_info.tlsInfo, connSettingInfo, m_devName, true);
} else if (eapType == PEAP) {
m_secuWidget->updatePeapChange(m_info.peapInfo);
m_wirelessConnOpration->addAndActiveWirelessEnterPrisePeapConnect(m_info.peapInfo, connSettingInfo, m_devName, true);
} else if (eapType = TTLS) {
m_secuWidget->updateTtlsChange(m_info.ttlsInfo);
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connSettingInfo, m_devName, true);
}
} else {
m_secuWidget->updateSecurityChange(connSettingInfo);
m_wirelessConnOpration->addAndActiveWirelessConnect(m_devName, connSettingInfo, true);
}
close();
}
void JoinHiddenWiFiPage::onBtnShowListClicked()
{
emit showWlanList(1); //WLAN_PAGE_INDEX
}
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);
}
}
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);
}
}

View File

@ -0,0 +1,79 @@
#ifndef JOINHIDDENWIFIPAGE_H
#define JOINHIDDENWIFIPAGE_H
#include <QScrollArea>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "coninfo.h"
#include "kywirelessconnectoperation.h"
#include "securitypage.h"
#include "divider.h"
#include "kwidget.h"
#include "kdialog.h"
#include "kborderlessbutton.h"
using namespace kdk;
class JoinHiddenWiFiPage : public KDialog
{
Q_OBJECT
public:
JoinHiddenWiFiPage(QString devName, KDialog *parent = nullptr);
~JoinHiddenWiFiPage();
protected:
void closeEvent(QCloseEvent *event);
private:
void initUI();
void initComponent();
void setJoinBtnEnable();
private:
KyWirelessConnectOperation *m_wirelessConnOpration = nullptr;
QString m_devName;
QWidget *m_topWidget;
QWidget *m_centerWidget;
QWidget *m_bottomWidget;
SecurityPage *m_secuWidget;
QLabel *m_descriptionLabel;
QLabel *m_nameLabel;
LineEdit *m_nameEdit;
QLabel *m_emptyLabel;
QLabel *m_checkLabel;
QCheckBox *m_rememberCheckBox = nullptr;
Divider *m_bottomDivider = nullptr;
KBorderlessButton *m_showListBtn;
QPushButton *m_cancelBtn;
QPushButton *m_joinBtn;
QScrollArea *m_scrollArea;
QVBoxLayout *m_pageLayout;
QHBoxLayout *m_topLayout;
QVBoxLayout *m_centerVBoxLayout;
QHBoxLayout *m_bottomLayout;
bool m_isJoinBtnEnable = false;
bool m_isSecuOk = false;
ConInfo m_info;
private slots:
void onBtnJoinClicked();
void onBtnShowListClicked();
void onSecuTypeChanged(const KySecuType &type);
void onEapTypeChanged(const KyEapMethodType &type);
signals:
void hiddenWiFiPageClose(QString);
void showWlanList(int type);
};
#endif // JOINHIDDENWIFIPAGE_H

View File

@ -33,7 +33,7 @@
#include "windowmanager/windowmanager.h"
#define WINDOW_WIDTH 520
#define WINDOW_HEIGHT 562
#define WINDOW_HEIGHT 602
#define ICON_SIZE 22,22
#define TITLE_LAYOUT_MARGINS 9,9,0,0
#define LAYOUT_MARGINS 0,0,0,0

View File

@ -8,6 +8,7 @@ HEADERS += \
$$PWD/detailwidget.h \
$$PWD/ipv4page.h \
$$PWD/ipv6page.h \
$$PWD/joinhiddenwifipage.h \
$$PWD/netdetail.h \
$$PWD/securitypage.h
@ -18,5 +19,6 @@ SOURCES += \
$$PWD/detailwidget.cpp \
$$PWD/ipv4page.cpp \
$$PWD/ipv6page.cpp \
$$PWD/joinhiddenwifipage.cpp \
$$PWD/netdetail.cpp \
$$PWD/securitypage.cpp

View File

@ -22,7 +22,12 @@
#include <QFileDialog>
SecurityPage::SecurityPage(QWidget *parent) : QFrame(parent)
#define DETAIL_MIN_LABEL_WIDTH 80
#define DETAIL_MIN_EDIT_WIDTH 390
#define MIN_LABEL_WIDTH 138
#define MIN_EDIT_WIDTH 286
SecurityPage::SecurityPage(bool isNetDetailPage, QWidget *parent) : isDetailPage(isNetDetailPage), QFrame(parent)
{
initUI();
initConnect();
@ -30,8 +35,6 @@ SecurityPage::SecurityPage(QWidget *parent) : QFrame(parent)
void SecurityPage::initUI()
{
secuTypeLabel = new QLabel(this);
pwdLabel = new QLabel(this);
secuTypeLabel = new QLabel(this);
pwdLabel = new QLabel(this);
//企业wifi共有
@ -44,6 +47,7 @@ void SecurityPage::initUI()
clientCertPathLabel = new QLabel(this);
clientPrivateKeyLabel = new QLabel(this);
clientPrivateKeyPwdLabel = new QLabel(this);
pwdOptionLabel = new QLabel(this);
//PEAP TTLS共有
eapMethodLabel = new QLabel(this);
@ -62,6 +66,8 @@ void SecurityPage::initUI()
clientCertPathCombox = new QComboBox(this);
clientPrivateKeyCombox = new QComboBox(this);
clientPrivateKeyPwdEdit = new KPasswordEdit(this);
pwdOptionCombox = new QComboBox(this);
tlsWidget = new QWidget(this);
//PEAP && TTLS
eapMethodCombox = new QComboBox(this);
@ -69,27 +75,107 @@ void SecurityPage::initUI()
userPwdEdit = new KPasswordEdit(this);
userPwdFlagBox = new QCheckBox(this);
QWidget *queryWidget = new QWidget(this);
QHBoxLayout *queryLayout = new QHBoxLayout(queryWidget);
queryLayout->setContentsMargins(0, 0, 0, 0);
queryLayout->addWidget(userPwdFlagBox);
queryLayout->addWidget(userPwdFlagLabel);
queryLayout->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);
// 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);
topLayout = new QGridLayout(this);
topLayout->setContentsMargins(0, 0, 0, 0);
topLayout->setVerticalSpacing(16);
// 安全 Label和选项框 第0行第0列第1列
topLayout->addWidget(secuTypeLabel, 0, 0);
topLayout->addWidget(secuTypeCombox, 0, 1);
//密码 Label和密码框 第1行第0列第1列
topLayout->addWidget(pwdLabel, 1, 0);
topLayout->addWidget(pwdEdit, 1, 1);
// EAP认证 Label和选项框 第2行第0列第1列
topLayout->addWidget(eapTypeLabel, 2, 0);
topLayout->addWidget(eapTypeCombox, 2, 1);
//内部认证 Label和选项框 第3行第0列第1列
topLayout->addWidget(eapMethodLabel, 3, 0);
topLayout->addWidget(eapMethodCombox, 3, 1);
//用户名 Label和输入框 第4行第0列第1列
topLayout->addWidget(userNameLabel, 4, 0);
topLayout->addWidget(userNameEdit, 4, 1);
//密码 Label和密码框 第5行第0列第1列
topLayout->addWidget(userPwdLabel, 5, 0);
topLayout->addWidget(userPwdEdit, 5, 1);
// 匿名身份 Label和输入框 第6行第0列第1列
topLayout->addWidget(identityLable, 6, 0);
topLayout->addWidget(identityEdit, 6, 1);
// CA证书选项框及CheckBox布局
QWidget *caWidget = new QWidget(this);
QGridLayout *checkLayout = new QGridLayout(caWidget);
checkLayout->setContentsMargins(0, 0, 0, 0);
checkLayout->setVerticalSpacing(0);
checkLayout->setColumnMinimumWidth(0, 16);
checkLayout->addWidget(caCertPathCombox, 0, 0, 1, 2);
checkLayout->addWidget(caNeedBox, 1, 0);
checkLayout->addWidget(caNeedFlagLabel, 1, 1);
bottomLayout = new QGridLayout(tlsWidget);
bottomLayout->setContentsMargins(0, 0, 0, 0);
bottomLayout->setVerticalSpacing(8);
// 域 Label和输入框 第0行第0列第1列
bottomLayout->addWidget(domainLable, 0, 0);
bottomLayout->addWidget(domainEdit, 0, 1);
// CA证书 Label第1行第0列
bottomLayout->addWidget(caCertPathLabel, 1, 0);
// CA证书选项框 不需要CA证书复选框 从第1行第1列开始占2行1列
bottomLayout->addWidget(caWidget, 1, 1, 2, 1);
// 用户证书 Label和选项框 第3行第0列第1列
bottomLayout->addWidget(clientCertPathLabel, 3, 0);
bottomLayout->addWidget(clientCertPathCombox, 3, 1);
// 用户私钥 Label和选项框 第4行第0列第1列
bottomLayout->addWidget(clientPrivateKeyLabel, 4, 0);
bottomLayout->addWidget(clientPrivateKeyCombox, 4, 1);
// 私钥密码 Label和密码框 第5行第0列第1列
bottomLayout->addWidget(clientPrivateKeyPwdLabel, 5, 0);
bottomLayout->addWidget(clientPrivateKeyPwdEdit, 5, 1);
// 密码选项 Label和选项框 第6行第0列第1列
bottomLayout->addWidget(pwdOptionLabel, 6, 0);
bottomLayout->addWidget(pwdOptionCombox, 6, 1);
if(isDetailPage) {
topLayout->addWidget(queryWidget, 7, 1);
changeColumnWidthWithSecuType();
} else {
queryWidget->hide();
topLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH);
topLayout->setColumnMinimumWidth(1, MIN_EDIT_WIDTH);
bottomLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH);
}
topLayout->addWidget(tlsWidget, 7, 0, 6, 2);
secuTypeLabel->setText(tr("Security"));
pwdLabel->setText(tr("Password"));
pwdEdit->setPlaceholderText(hintRequired);
//企业wifi共有
eapTypeLabel->setText(tr("EAP type"));
//TLS
@ -100,12 +186,17 @@ void SecurityPage::initUI()
clientCertPathLabel->setText(tr("User certificate"));
clientPrivateKeyLabel->setText(tr("User private key"));
clientPrivateKeyPwdLabel->setText(tr("User key password"));
pwdOptionLabel->setText(tr("Password options"));
identityEdit->setPlaceholderText(tr("Required"));
clientPrivateKeyPwdEdit->setPlaceholderText(hintRequired);
//PEAP TTLS共有
eapMethodLabel->setText(tr("Ineer authentication"));
userNameLabel->setText(tr("Usename"));
userPwdLabel->setText(tr("Password"));
userPwdFlagLabel->setText(tr("Ask pwd each query"));
userNameEdit->setPlaceholderText(tr("Required"));
userPwdEdit->setPlaceholderText(hintRequired);
secuTypeCombox->addItem(tr("None"),NONE);
secuTypeCombox->addItem(tr("WPA&WPA2 Personal"),WPA_AND_WPA2_PERSONAL);
@ -126,6 +217,14 @@ void SecurityPage::initUI()
clientPrivateKeyCombox->addItem(tr("None"), QString(tr("None"))); //无
clientPrivateKeyCombox->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")));
//存储所有用户的密码
pwdOptionCombox->addItem(tr("Store passwords for all users"), QString(tr("Store password for all users")));
//每次询问这个密码
pwdOptionCombox->addItem(tr("Ask this password every time"), QString(tr("Ask password every time")));
pwdOptionCombox->setCurrentIndex(1);
//禁用ClearBtn按钮
pwdEdit->setClearButtonEnabled(false);
clientPrivateKeyPwdEdit->setClearButtonEnabled(false);
@ -145,6 +244,9 @@ void SecurityPage::initConnect()
//安全类型变化
// connect(secuTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onSecuTypeComboxIndexChanged);
connect(secuTypeCombox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SecurityPage::onSecuTypeComboxIndexChanged);
connect(secuTypeCombox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SecurityPage::changeColumnWidthWithSecuType);
//EAP方式变化
// connect(eapTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onEapTypeComboxIndexChanged);
connect(eapTypeCombox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SecurityPage::onEapTypeComboxIndexChanged);
@ -160,6 +262,9 @@ void SecurityPage::initConnect()
connect(clientPrivateKeyCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &SecurityPage::onClientPrivateKeyComboxIndexChanged);
connect(pwdOptionCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &SecurityPage::onPwdOptionComboxIndexChanged);
connect(secuTypeCombox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(pwdEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(eapTypeCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
@ -215,6 +320,13 @@ void SecurityPage::setTlsInfo(KyEapMethodTlsInfo &info)
clientPrivateKeyPwdEdit->setText(info.clientPrivateKeyPWD);
if (info.m_privateKeyPWDFlag == NetworkManager::Setting::AgentOwned) {
pwdOptionCombox->setCurrentIndex(0);
} else if (info.m_privateKeyPWDFlag == NetworkManager::Setting::None) {
pwdOptionCombox->setCurrentIndex(1);
} else {
pwdOptionCombox->setCurrentIndex(2);
}
}
void SecurityPage::setPeapInfo(KyEapMethodPeapInfo &info)
@ -351,149 +463,101 @@ bool SecurityPage::checkIsChanged(const ConInfo info)
void SecurityPage::showNone()
{
pwdEdit->hide();
eapTypeCombox->hide();
identityEdit->hide();
domainEdit->hide();
caCertPathCombox->hide();
caNeedBox->hide();
clientCertPathCombox->hide();
clientPrivateKeyCombox->hide();
clientPrivateKeyPwdEdit->hide();
eapMethodCombox->hide();
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagBox->hide();
pwdLabel->hide();
pwdEdit->hide();
//企业wifi共有
eapTypeLabel->hide();
eapTypeCombox->hide();
//TLS
identityLable->hide();
domainLable->hide();
caCertPathLabel->hide();
caNeedFlagLabel->hide();
clientCertPathLabel->hide();
clientPrivateKeyLabel->hide();
clientPrivateKeyPwdLabel->hide();
identityEdit->hide();
tlsWidget->hide();
//PEAP TTLS共有
eapMethodLabel->hide();
userNameLabel->hide();
userPwdLabel->hide();
userPwdFlagBox->hide();
eapMethodCombox->hide();
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagLabel->hide();
}
void SecurityPage::showPsk()
{
pwdEdit->show();
eapTypeCombox->hide();
identityEdit->hide();
domainEdit->hide();
caCertPathCombox->hide();
caNeedBox->hide();
clientCertPathCombox->hide();
clientPrivateKeyCombox->hide();
clientPrivateKeyPwdEdit->hide();
eapMethodCombox->hide();
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagBox->hide();
pwdLabel->show();
pwdEdit->show();
//企业wifi共有
eapTypeLabel->hide();
eapTypeCombox->hide();
//TLS
identityLable->hide();
domainLable->hide();
caCertPathLabel->hide();
caNeedFlagLabel->hide();
clientCertPathLabel->hide();
clientPrivateKeyLabel->hide();
clientPrivateKeyPwdLabel->hide();
identityEdit->hide();
tlsWidget->hide();
//PEAP TTLS共有
eapMethodLabel->hide();
userNameLabel->hide();
userPwdLabel->hide();
userPwdFlagBox->hide();
eapMethodCombox->hide();
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagLabel->hide();
}
void SecurityPage::showTls()
{
pwdLabel->hide();
pwdEdit->hide();
eapTypeCombox->show();
identityEdit->show();
domainEdit->show();
caCertPathCombox->show();
caNeedBox->show();
clientCertPathCombox->show();
clientPrivateKeyCombox->show();
clientPrivateKeyPwdEdit->show();
eapMethodCombox->hide();
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagBox->hide();
pwdLabel->hide();
//企业wifi共有
eapTypeLabel->show();
//TLS
identityLable->show();
domainLable->show();
caCertPathLabel->show();
caNeedFlagLabel->show();
clientCertPathLabel->show();
clientPrivateKeyLabel->show();
clientPrivateKeyPwdLabel->show();
identityEdit->show();
tlsWidget->show();
//PEAP TTLS共有
eapMethodLabel->hide();
userNameLabel->hide();
userPwdLabel->hide();
userPwdFlagBox->hide();
eapMethodCombox->hide();
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagLabel->hide();
}
void SecurityPage::showPeapOrTtls()
{
pwdEdit->hide();
eapTypeCombox->show();
identityEdit->hide();
domainEdit->hide();
caCertPathCombox->hide();
caNeedBox->hide();
clientCertPathCombox->hide();
clientPrivateKeyCombox->hide();
clientPrivateKeyPwdEdit->hide();
eapMethodCombox->show();
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();
identityEdit->hide();
tlsWidget->hide();
//PEAP TTLS共有
eapMethodLabel->show();
userNameLabel->show();
userPwdLabel->show();
userPwdFlagBox->show();
eapMethodCombox->show();
userNameEdit->show();
userPwdEdit->show();
userPwdFlagLabel->show();
}
@ -507,8 +571,19 @@ KyEapMethodTlsInfo SecurityPage::assembleTlsInfo()
info.clientCertPath = clientCertPathCombox->currentText();
info.clientPrivateKey = clientPrivateKeyCombox->currentText();
info.clientPrivateKeyPWD = clientPrivateKeyPwdEdit->text();
info.m_privateKeyPWDFlag = NetworkManager::Setting::None;
switch (pwdOptionCombox->currentIndex()) {
case 0:
info.m_privateKeyPWDFlag = NetworkManager::Setting::AgentOwned;
break;
case 1:
info.m_privateKeyPWDFlag = NetworkManager::Setting::None;
break;
case 2:
info.m_privateKeyPWDFlag = NetworkManager::Setting::NotSaved;
break;
default:
break;
}
return info;
}
@ -651,12 +726,19 @@ void SecurityPage::setEnableOfSaveBtn()
void SecurityPage::onSecuTypeComboxIndexChanged()
{
int index = secuTypeCombox->currentData().toInt();
if (index == WPA_AND_WPA2_PERSONAL || index == WPA3_PERSONAL) {
if (index == WPA_AND_WPA2_PERSONAL) {
showPsk();
emit this->secuTypeChanged(WPA_AND_WPA2_PERSONAL);
}
else if (index == WPA3_PERSONAL) {
showPsk();
emit this->secuTypeChanged(WPA3_PERSONAL);
} else if (index == WPA_AND_WPA2_ENTERPRISE) {
onEapTypeComboxIndexChanged();
emit this->secuTypeChanged(WPA_AND_WPA2_ENTERPRISE);
} else if (index == NONE) {
showNone();
emit this->secuTypeChanged(NONE);
}
}
@ -765,3 +847,36 @@ void SecurityPage::onClientPrivateKeyComboxIndexChanged(QString str)
qWarning() << "Choose file is null or unvalible";
}
}
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);
} else {
topLayout->setColumnMinimumWidth(0, DETAIL_MIN_LABEL_WIDTH);
topLayout->setColumnMinimumWidth(1, DETAIL_MIN_EDIT_WIDTH);
}
}

View File

@ -37,7 +37,7 @@ class SecurityPage : public QFrame
{
Q_OBJECT
public:
SecurityPage(QWidget *parent = nullptr);
SecurityPage(bool isNetDetailPage, QWidget *parent = nullptr);
void setSecurity(KySecuType index);
void setPsk(const QString &psk);
@ -55,9 +55,10 @@ public:
void getSecuType(KySecuType &secuType, KyEapMethodType &enterpriseType);
private:
QFormLayout *mSecuLayout;
private:
bool isDetailPage;
// QFormLayout *mSecuLayout;
QGridLayout *topLayout;
QGridLayout *bottomLayout;
QLabel *secuTypeLabel;
QLabel *pwdLabel;
@ -71,6 +72,7 @@ private:
QLabel *clientCertPathLabel;
QLabel *clientPrivateKeyLabel;
QLabel *clientPrivateKeyPwdLabel;
QLabel *pwdOptionLabel;
//PEAP TTLS共有
QLabel *eapMethodLabel;
@ -89,6 +91,8 @@ private:
QComboBox *clientCertPathCombox;
QComboBox *clientPrivateKeyCombox;
KPasswordEdit *clientPrivateKeyPwdEdit = nullptr;
QComboBox *pwdOptionCombox;
QWidget *tlsWidget;
//PEAP && TTLS
QComboBox *eapMethodCombox;
@ -96,6 +100,10 @@ private:
KPasswordEdit *userPwdEdit = nullptr;
QCheckBox *userPwdFlagBox;
QString hintRequired = tr("Required"); //必填
QString emptyhint = tr(" ");
private:
void showNone();
void showPsk();
void showTls();
@ -120,9 +128,12 @@ private slots:
void onCaCertPathComboxIndexChanged(QString str);
void onClientCertPathComboxIndexChanged(QString str);
void onClientPrivateKeyComboxIndexChanged(QString str);
void onPwdOptionComboxIndexChanged(QString str);
void changeColumnWithWithSecuType();
signals:
void setSecuPageState(bool);
void secuTypeChanged(const KySecuType &type);
void eapTypeChanged(const KyEapMethodType &type);
};

View File

@ -19,6 +19,7 @@
*/
#include "wlanpage.h"
#include "kywirelessnetitem.h"
#include "netdetails/joinhiddenwifipage.h"
#include <QEvent>
#include <QDateTime>
#include <QDebug>
@ -1026,9 +1027,12 @@ void WlanPage::requestScan()
void WlanPage::onHiddenWlanClicked()
{
qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ;
NetDetail *netDetail = new NetDetail(m_currentDevice, "", "", false, true, true);
netDetail->show();
// qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ;
// NetDetail *netDetail = new NetDetail(m_currentDevice, "", "", false, true, true);
// netDetail->show();
JoinHiddenWiFiPage *hiddenWiFi =new JoinHiddenWiFiPage(m_currentDevice);
connect(hiddenWiFi, &JoinHiddenWiFiPage::showWlanList, this, &WlanPage::showMainWindow);
hiddenWiFi->show();
}
void WlanPage::showControlCenter()