Merge branch 'find-joinWiFi' into 'dbus-interface'

bug132350修改企业网弹窗界面 与 加入隐藏网络安全页ui调整

See merge request kylin-desktop/kylin-nm!688
This commit is contained in:
赵世旭 2022-08-12 02:41:45 +00:00
commit 3e6e8ef25e
9 changed files with 156 additions and 91 deletions

View File

@ -21,27 +21,37 @@
#include <QApplication>
#include <QDesktopWidget>
#include "xatom-helper.h"
#define MAIN_SIZE_EXPAND 400,500
#define MAIN_SIZE_NARROW 400,400
#define MAIN_SIZE_EXPAND 480,580
#define MAIN_SIZE_NARROW 480,484
#define PEAP_SCRO_HEIGHT 390
#define TLS_SCRO_HEIGHT 590
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define CENTER_LAYOUT_MARGINS 24, 16, 24, 8
#define BUTTON_LAYOUT_MARGINS 24, 24, 24, 24
#define MAIN_LAYOUT_SPACING 0
#define BUTTON_SPACING 16
#define LABEL_MIN_WIDTH 146
#define MEDIUM_WEIGHT_VALUE 57
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
EnterpriseWlanDialog::EnterpriseWlanDialog(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent) : QWidget(parent)
{
//设置窗口无边框,阴影
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
MotifWmHints window_hints;
window_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
window_hints.functions = MWM_FUNC_ALL;
window_hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), window_hints);
#else
this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
#endif
// //设置窗口无边框,阴影
//#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
// MotifWmHints window_hints;
// window_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
// window_hints.functions = MWM_FUNC_ALL;
// window_hints.decorations = MWM_DECOR_BORDER;
// XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), window_hints);
//#else
// this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
//#endif
this->setAttribute(Qt::WA_DeleteOnClose);
this->setWindowFlag(Qt::Window);
this->setWindowTitle(tr("Connect Enterprise WLAN"));
// this->setWindowTitle(tr("Connect Enterprise WLAN"));
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
m_wirelessNetItem = wirelessNetItem;
m_deviceName = device;
@ -70,49 +80,79 @@ void EnterpriseWlanDialog::closeEvent(QCloseEvent *event)
return QWidget::closeEvent(event);
}
void EnterpriseWlanDialog::paintEvent(QPaintEvent *event)
{
QPalette pal = qApp->palette();
QPainter painter(this);
painter.setBrush(pal.color(QPalette::Base));
painter.drawRect(this->rect());
painter.fillRect(rect(), QBrush(pal.color(QPalette::Base)));
return QWidget::paintEvent(event);
}
void EnterpriseWlanDialog::initUI()
{
#define MAIN_LAYOUT_MARGINS 8,8,8,8
#define SSID_LAYOUT_MARGINS 8,8,8,0
#define MAIN_LAYOUT_SPACING 0
#define BUTTON_SPACING 8
m_mainLayout = new QVBoxLayout(this);
this->setLayout(m_mainLayout);
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
m_ssidLayout = new QHBoxLayout();
m_ssidLayout->setContentsMargins(SSID_LAYOUT_MARGINS);
m_ssidTitleLabel = new QLabel(this);
m_ssidTitleLabel->setText("SSID");
m_centerWidget = new QWidget(this);
QVBoxLayout *centerLayout = new QVBoxLayout(m_centerWidget);
centerLayout->setContentsMargins(CENTER_LAYOUT_MARGINS);
centerLayout->setSpacing(MAIN_LAYOUT_SPACING);
m_descriptionLabel = new QLabel(this);
m_descriptionLabel->setText(tr("Wi-Fi network requires authentication")); //Wi-Fi网络要求认证
QFont font = m_descriptionLabel->font();
font.setWeight(MEDIUM_WEIGHT_VALUE);
m_descriptionLabel->setFont(font);
m_ssidLabel = new QLabel(this);
m_ssidLabel->setText(m_wirelessNetItem.m_NetSsid);
m_ssidLayout->addWidget(m_ssidTitleLabel);
m_ssidLayout->addStretch();
m_ssidLayout->addWidget(m_ssidLabel);
m_securityPage = new SecurityPage(this);
QString str = tr("Access to Wi-Fi network \""); //访问Wi-Fi网络
str.append(m_wirelessNetItem.m_NetSsid);
str.append(tr("\" requires a password or encryption key.")); //需要密码或加密秘钥
m_ssidLabel->setText(str);
m_ssidLabel->setWordWrap(true);
m_securityPage = new SecurityPage(false, this);
m_securityPage->setSecurity(KySecuType::WPA_AND_WPA2_ENTERPRISE);
m_securityPage->setSecurityVisible(false);
// m_securityPage->setSecurityVisible(false);
m_btnLayout = new QHBoxLayout();
m_btnLayout->setSpacing(BUTTON_SPACING);
centerLayout->addWidget(m_descriptionLabel);
centerLayout->addSpacing(8);
centerLayout->addWidget(m_ssidLabel);
centerLayout->addSpacing(BUTTON_SPACING);
centerLayout->addWidget(m_securityPage);
centerLayout->addStretch();
m_enterWlanScrollArea = new QScrollArea(this);
m_enterWlanScrollArea->setFrameShape(QFrame::NoFrame);
m_enterWlanScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_enterWlanScrollArea->setWidget(m_centerWidget);
QPalette pal = m_enterWlanScrollArea->palette();
pal.setBrush(QPalette::Window, Qt::transparent);
m_enterWlanScrollArea->setPalette(pal);
m_bottomDivider = new Divider(this);
QWidget *bottomWidget = new QWidget(this);
QHBoxLayout *btnLayout = new QHBoxLayout(bottomWidget);
btnLayout->setContentsMargins(BUTTON_LAYOUT_MARGINS);
btnLayout->setSpacing(BUTTON_SPACING);
m_cancelBtn = new QPushButton(this);
m_connectBtn = new QPushButton(this);
m_cancelBtn->setText(tr("Cancel"));
m_connectBtn->setText(tr("Connect"));
m_connectBtn->setEnabled(false);
m_btnLayout->addStretch();
m_btnLayout->addWidget(m_cancelBtn);
m_btnLayout->addWidget(m_connectBtn);
m_mainLayout->addLayout(m_ssidLayout);
m_mainLayout->addWidget(m_securityPage);
m_mainLayout->addLayout(m_btnLayout);
m_mainLayout->addStretch();
btnLayout->addStretch();
btnLayout->addWidget(m_cancelBtn);
btnLayout->addWidget(m_connectBtn);
m_mainLayout->addWidget(m_enterWlanScrollArea);
m_mainLayout->addWidget(m_bottomDivider);
m_mainLayout->addWidget(bottomWidget);
this->setFixedSize(MAIN_SIZE_EXPAND);
this->setWindowTitle(m_wirelessNetItem.m_NetSsid);
initConnections();
onPaletteChanged();
}
@ -145,15 +185,15 @@ void EnterpriseWlanDialog::onPaletteChanged()
{
QPalette pal = qApp->palette();
QGSettings * styleGsettings = nullptr;
const QByteArray style_id(THEME_SCHAME);
if (QGSettings::isSchemaInstalled(style_id)) {
styleGsettings = new QGSettings(style_id);
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
if(currentTheme == "ukui-default"){
pal = lightPalette(this);
}
}
// QGSettings * styleGsettings = nullptr;
// const QByteArray style_id(THEME_SCHAME);
// if (QGSettings::isSchemaInstalled(style_id)) {
// styleGsettings = new QGSettings(style_id);
// QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
// if(currentTheme == "ukui-default"){
// pal = lightPalette(this);
// }
// }
this->setPalette(pal);
@ -184,7 +224,7 @@ void EnterpriseWlanDialog::onBtnConnectClicked()
KyWirelessConnectSetting connetSetting;
connetSetting.setConnectName(m_wirelessNetItem.m_NetSsid);
connetSetting.setIfaceName(m_deviceName);
connetSetting.isAutoConnect = true; //ZJP_TODO 自动连接选项
// connetSetting.isAutoConnect = true; //ZJP_TODO 自动连接选项
connetSetting.m_type = KyKeyMgmt::WpaEap;
connetSetting.m_ssid = m_wirelessNetItem.m_NetSsid;
connetSetting.m_secretFlag = 0;
@ -214,18 +254,21 @@ 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;
default:
break;

View File

@ -21,7 +21,11 @@
#define ENTERPRISEWLANDIALOG_H
#include <QDialog>
#include <QPushButton>
#include <QScrollArea>
#include <QPainter>
#include "securitypage.h"
#include "divider.h"
#include "kywirelessnetitem.h"
#include "coninfo.h"
@ -34,6 +38,7 @@ public:
protected:
void closeEvent(QCloseEvent *event);
void paintEvent(QPaintEvent *event);
private:
void initUI(); //初始化UI界面
@ -62,13 +67,16 @@ private:
QLabel *m_titleLabel = nullptr;
QPushButton *m_closeBtn = nullptr;
QHBoxLayout *m_ssidLayout = nullptr;
QLabel *m_ssidTitleLabel = nullptr;
QWidget *m_centerWidget = nullptr;
QLabel *m_descriptionLabel = nullptr;
QLabel *m_ssidLabel = nullptr;
SecurityPage *m_securityPage = nullptr;
QHBoxLayout *m_btnLayout = nullptr;
QScrollArea *m_enterWlanScrollArea = nullptr;
Divider *m_bottomDivider = nullptr;
QPushButton *m_cancelBtn = nullptr;
QPushButton *m_connectBtn = nullptr;

View File

@ -24,7 +24,7 @@
#define ITEM_HEIGHT 36
#define ITEM_MARGINS 18,0,16,0
#define MIN_LABEL_WIDTH 150
#define MIN_LABEL_WIDTH 146
#define MAX_LABEL_WIDTH 154
#define MAX_WIDGET_WIDTH 270

View File

@ -33,6 +33,7 @@
#define PSK_SCRO_HEIGHT 182
#define PEAP_SCRO_HEIGHT 340
#define TLS_SCRO_HEIGHT 560
#define MEDIUM_WEIGHT_VALUE 57
JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent)
:m_devName(devName),
@ -73,24 +74,23 @@ void JoinHiddenWiFiPage::initUI()
m_nameLabel->setFixedWidth(LABEL_MIN_WIDTH);
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_hiddenWifiScrollArea = new QScrollArea(this);
m_hiddenWifiScrollArea->setFrameShape(QFrame::NoFrame);
m_hiddenWifiScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QPalette pa = m_hiddenWifiScrollArea->palette();
pa.setBrush(QPalette::Window, Qt::transparent);
m_hiddenWifiScrollArea->setPalette(pa);
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_hiddenWifiScrollArea);
m_pageLayout->addWidget(m_bottomDivider);
m_pageLayout->addWidget(m_bottomWidget);
this->mainWidget()->setLayout(m_pageLayout);
@ -109,26 +109,14 @@ void JoinHiddenWiFiPage::initUI()
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_hiddenWifiScrollArea->setWidget(m_centerWidget);
//底部按钮
m_bottomLayout = new QHBoxLayout(m_bottomWidget);
@ -142,10 +130,10 @@ void JoinHiddenWiFiPage::initUI()
//请输入您想要加入网络的名称和安全类型
m_descriptionLabel->setText(tr("Please enter the network name and security type"));
QFont font = m_descriptionLabel->font();
font.setWeight(75);
font.setWeight(MEDIUM_WEIGHT_VALUE);
m_descriptionLabel->setFont(font);
m_nameLabel->setLabelText(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"));
@ -153,9 +141,6 @@ void JoinHiddenWiFiPage::initUI()
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"));
@ -197,7 +182,6 @@ void JoinHiddenWiFiPage::onBtnJoinClicked()
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;

View File

@ -65,16 +65,12 @@ private:
FixLabel *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;
QScrollArea *m_hiddenWifiScrollArea;
QVBoxLayout *m_pageLayout;
QHBoxLayout *m_topLayout;
QVBoxLayout *m_centerVBoxLayout;

View File

@ -24,8 +24,8 @@
#define DETAIL_MIN_LABEL_WIDTH 80
#define DETAIL_MIN_EDIT_WIDTH 390
#define MIN_LABEL_WIDTH 138
#define MIN_EDIT_WIDTH 286
#define MIN_LABEL_WIDTH 146
#define MIN_EDIT_WIDTH 278
SecurityPage::SecurityPage(bool isNetDetailPage, QWidget *parent) : isDetailPage(isNetDetailPage), QFrame(parent)
{
@ -35,6 +35,7 @@ SecurityPage::SecurityPage(bool isNetDetailPage, QWidget *parent) : isDetailPage
void SecurityPage::initUI()
{
mainLayout = new QVBoxLayout(this);
secuTypeLabel = new QLabel(this);
pwdLabel = new QLabel(this);
//企业wifi共有
@ -87,6 +88,21 @@ void SecurityPage::initUI()
queryLayout->addWidget(userPwdFlagLabel);
queryLayout->addStretch();
//记住该网络复选框
m_emptyLabel = new QLabel(this);
m_emptyLabel->setMinimumWidth(MIN_LABEL_WIDTH - 8);
m_checkLabel = new QLabel(this);
m_checkLabel->setText(tr("Remember the Network")); //记住该网络
m_rememberCheckBox = new QCheckBox(this);
m_rememberCheckBox->setChecked(true);
QWidget *checkWidget = new QWidget(this);
QHBoxLayout *rememberLayout = new QHBoxLayout(checkWidget);
rememberLayout->setContentsMargins(0, 0, 0, 0);
rememberLayout->addWidget(m_emptyLabel);
rememberLayout->addWidget(m_rememberCheckBox);
rememberLayout->addWidget(m_checkLabel);
rememberLayout->addStretch();
// mSecuLayout = new QFormLayout(this);
// mSecuLayout->setContentsMargins(0, 0, 0, 0);
// mSecuLayout->addRow(secuTypeLabel, secuTypeCombox);
@ -104,7 +120,7 @@ void SecurityPage::initUI()
// mSecuLayout->addRow(userPwdLabel, userPwdEdit);
// mSecuLayout->addRow(userPwdFlagBox, userPwdFlagLabel);
topLayout = new QGridLayout(this);
topLayout = new QGridLayout();
topLayout->setContentsMargins(0, 0, 0, 0);
topLayout->setVerticalSpacing(16);
// 安全 Label和选项框 第0行第0列第1列
@ -143,6 +159,7 @@ void SecurityPage::initUI()
bottomLayout = new QGridLayout(tlsWidget);
bottomLayout->setContentsMargins(0, 0, 0, 0);
bottomLayout->setVerticalSpacing(8);
bottomLayout->setHorizontalSpacing(0);
// 域 Label和输入框 第0行第0列第1列
bottomLayout->addWidget(domainLable, 0, 0);
bottomLayout->addWidget(domainEdit, 0, 1);
@ -164,18 +181,24 @@ void SecurityPage::initUI()
bottomLayout->addWidget(pwdOptionLabel, 6, 0);
bottomLayout->addWidget(pwdOptionCombox, 6, 1);
if(isDetailPage) {
if (isDetailPage) {
checkWidget->hide();
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);
bottomLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH - 8);
}
topLayout->addWidget(tlsWidget, 7, 0, 6, 2);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
mainLayout->addLayout(topLayout);
mainLayout->addWidget(checkWidget);
mainLayout->addStretch();
secuTypeLabel->setText(tr("Security"));
pwdLabel->setText(tr("Password"));
@ -672,6 +695,7 @@ void SecurityPage::updateSecurityChange(KyWirelessConnectSetting &setting)
} else if (secuTypeCombox->currentData().toInt() == WPA3_PERSONAL) {
setting.m_type = SAE;
}
setting.isAutoConnect = m_rememberCheckBox->isChecked();
}
bool SecurityPage::checkConnectBtnIsEnabled()
@ -877,7 +901,7 @@ void SecurityPage::changeColumnWidthWithSecuType()
eapMethodCombox->currentData().toInt() == TLS) {
topLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH);
topLayout->setColumnMinimumWidth(1, MIN_EDIT_WIDTH);
bottomLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH);
bottomLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH - 8);
} else {
topLayout->setColumnMinimumWidth(0, DETAIL_MIN_LABEL_WIDTH);

View File

@ -60,6 +60,7 @@ private:
// QFormLayout *mSecuLayout;
QGridLayout *topLayout;
QGridLayout *bottomLayout;
QVBoxLayout *mainLayout;
QLabel *secuTypeLabel;
QLabel *pwdLabel;
@ -101,6 +102,10 @@ private:
KPasswordEdit *userPwdEdit = nullptr;
QCheckBox *userPwdFlagBox;
QLabel *m_emptyLabel = nullptr;
QLabel *m_checkLabel = nullptr;
QCheckBox *m_rememberCheckBox = nullptr;
QString hintRequired = tr("Required"); //必填
QString emptyhint = tr(" ");

Binary file not shown.

View File

@ -1007,6 +1007,11 @@
</context>
<context>
<name>SecurityPage</name>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="90"/>
<source>Remember the Network</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="175"/>
<source>Security</source>