From a25a87275cb39aff1d8e2993e90af7ccff92ad47 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Fri, 24 Sep 2021 15:52:51 +0800 Subject: [PATCH] Feature:Add enterprise wlan connection. --- debian/control | 1 + kylin-nm.pro | 6 +- .../enterprise-wlan/enterprise-wlan.pri | 9 + .../enterprise-wlan/enterprisewlandialog.cpp | 205 ++++++++++++++++++ .../enterprise-wlan/enterprisewlandialog.h | 58 +++++ src/frontend/frontend.pri | 3 +- src/frontend/list-items/wlanlistitem.cpp | 12 +- src/frontend/netdetails.pri | 18 -- src/frontend/netdetails/netdetail.cpp | 73 ++----- src/frontend/netdetails/netdetails.pri | 20 ++ src/frontend/netdetails/securitypage.cpp | 17 ++ src/frontend/netdetails/securitypage.h | 2 + src/frontend/new-mainwindow.cpp | 19 +- src/frontend/tab-pages/lanpage.cpp | 17 ++ src/frontend/tab-pages/lanpage.h | 4 + src/frontend/tab-pages/tabpage.cpp | 3 +- src/frontend/tab-pages/wlanpage.cpp | 6 +- src/frontend/tab-pages/wlanpage.h | 1 - src/src.pro | 7 +- 19 files changed, 388 insertions(+), 93 deletions(-) create mode 100644 src/frontend/enterprise-wlan/enterprise-wlan.pri create mode 100644 src/frontend/enterprise-wlan/enterprisewlandialog.cpp create mode 100644 src/frontend/enterprise-wlan/enterprisewlandialog.h delete mode 100644 src/frontend/netdetails.pri create mode 100644 src/frontend/netdetails/netdetails.pri diff --git a/debian/control b/debian/control index 7e333361..0dec5721 100644 --- a/debian/control +++ b/debian/control @@ -17,6 +17,7 @@ Build-Depends: debhelper (>=9), libqt5svg5-dev, libkf5networkmanagerqt-dev (>= 5.36.0), libnm-dev, + libcap-dev, Standards-Version: 4.5.0 Rules-Requires-Root: no Homepage: https://github.com/ukui/kylin-nm diff --git a/kylin-nm.pro b/kylin-nm.pro index 9c890810..45470913 100644 --- a/kylin-nm.pro +++ b/kylin-nm.pro @@ -7,8 +7,6 @@ SUBDIRS = \ src \ TRANSLATIONS += \ - translations/kylin-nm_zh_CN.ts \ + translations/kylin-nm_zh_CN.ts \ translations/kylin-nm_tr.ts \ - translations/kylin-nm_bo.ts - -QT += widgets + translations/kylin-nm_bo.ts diff --git a/src/frontend/enterprise-wlan/enterprise-wlan.pri b/src/frontend/enterprise-wlan/enterprise-wlan.pri new file mode 100644 index 00000000..c4571359 --- /dev/null +++ b/src/frontend/enterprise-wlan/enterprise-wlan.pri @@ -0,0 +1,9 @@ +INCLUDEPATH += $$PWD + +FORMS += \ + +HEADERS += \ + $$PWD/enterprisewlandialog.h \ + +SOURCES += \ + $$PWD/enterprisewlandialog.cpp \ diff --git a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp new file mode 100644 index 00000000..bcf3c02b --- /dev/null +++ b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp @@ -0,0 +1,205 @@ +#include "enterprisewlandialog.h" +#include +#include +#include "xatom-helper.h" +#define MAIN_SIZE_EXPAND 400,500 +#define MAIN_SIZE_NARROW 400,400 + +EnterpriseWlanDialog::EnterpriseWlanDialog(KyWirelessNetItem *data, QString device, QWidget *parent) : QDialog(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 + this->setAttribute(Qt::WA_DeleteOnClose); + + m_data = data; + m_deviceName = device; + m_connectOperation = new KyWirelessConnectOperation(); + m_resource = new KyWirelessNetResource(); + + initUI(); + initData(); + centerToScreen(); +} + +EnterpriseWlanDialog::~EnterpriseWlanDialog() { + if (m_securityPage) { + delete m_securityPage; + m_securityPage = nullptr; + } + if (m_connectOperation) { + delete m_connectOperation; + m_connectOperation = nullptr; + } +} + +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 +#define CLOSE_BUTTON_SIZE 24,24 + + m_mainLayout = new QVBoxLayout(this); + this->setLayout(m_mainLayout); + m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS); + m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING); + + m_titleLayout = new QHBoxLayout(); + m_titleLabel = new QLabel(this); + m_titleLabel->setText(tr("Connect Enterprise WLAN")); + m_closeBtn = new QPushButton(this); + m_closeBtn->setFixedSize(CLOSE_BUTTON_SIZE); + m_closeBtn->setToolTip(tr("Close")); + m_closeBtn->setProperty("isWindowButton", 0x02); + m_closeBtn->setProperty("useIconHighlightEffect", 0x08); + m_closeBtn->setFlat(true); + m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic")); + m_titleLayout->addWidget(m_titleLabel); + m_titleLayout->addStretch(); + m_titleLayout->addWidget(m_closeBtn); + + m_ssidLayout = new QHBoxLayout(); + m_ssidLayout->setContentsMargins(SSID_LAYOUT_MARGINS); + m_ssidTitleLabel = new QLabel(this); + m_ssidTitleLabel->setText("SSID"); + m_ssidLabel = new QLabel(this); + if (m_data) { + m_ssidLabel->setText(m_data->m_NetSsid); + } else { + qWarning() << "Get SSID failed because of null pointer!" << Q_FUNC_INFO << __LINE__; + } + m_ssidLayout->addWidget(m_ssidTitleLabel); + m_ssidLayout->addStretch(); + m_ssidLayout->addWidget(m_ssidLabel); + + m_securityPage = new SecurityPage(this); + m_securityPage->setSecurity(KySecuType::WPA_AND_WPA2_ENTERPRISE); + m_securityPage->setSecurityVisible(false); + + m_btnLayout = new QHBoxLayout(); + m_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_titleLayout); + m_mainLayout->addLayout(m_ssidLayout); + m_mainLayout->addWidget(m_securityPage); + m_mainLayout->addLayout(m_btnLayout); + m_mainLayout->addStretch(); + + this->setFixedSize(MAIN_SIZE_EXPAND); + initConnections(); +} + +void EnterpriseWlanDialog::centerToScreen() +{ + QDesktopWidget* m = QApplication::desktop(); + QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos())); + int desk_x = desk_rect.width(); + int desk_y = desk_rect.height(); + int x = this->width(); + int y = this->height(); + this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); +} + +void EnterpriseWlanDialog::initConnections() +{ + connect(m_closeBtn, &QPushButton::clicked, this, &EnterpriseWlanDialog::close); + connect(m_cancelBtn, &QPushButton::clicked, this, &EnterpriseWlanDialog::close); + connect(m_connectBtn, &QPushButton::clicked, this, &EnterpriseWlanDialog::onBtnConnectClicked); + connect(m_securityPage, &SecurityPage::eapTypeChanged, this, &EnterpriseWlanDialog::onEapTypeChanged); + connect(m_securityPage, &SecurityPage::setSecuPageState, this, [ = ](bool status) { + m_connectBtn->setEnabled(status); + }); +} + +void EnterpriseWlanDialog::initData() +{ + if (m_data && m_data->m_isConfigured) { + KyEapMethodType type; + m_connectOperation->getEnterpiseEapMethod(m_data->m_connectUuid, type); + if (type) { + onEapTypeChanged(type); + } else { + qWarning() << "Get eap type failed!" << Q_FUNC_INFO << __LINE__; + } + } +} + +void EnterpriseWlanDialog::onBtnConnectClicked() +{ + if (!m_data) { + qWarning() << "Connect enterprise WLAN failed because of null pointer m_data!" << Q_FUNC_INFO << __LINE__; + } + qDebug() << "Clicked connectBtn, will connect enterprise WLAN, ssid = " << m_data->m_NetSsid << "." << Q_FUNC_INFO << __LINE__; + KySecuType secuType; + KyEapMethodType eapType; + m_securityPage->getSecuType(secuType, eapType); + + KyWirelessConnectSetting connetSetting; + connetSetting.setConnectName(m_data->m_NetSsid); + connetSetting.setIfaceName(m_deviceName); + connetSetting.isAutoConnect = true; //ZJP_TODO 自动连接选项 + connetSetting.m_type = KyKeyMgmt::WpaEap; + connetSetting.m_ssid = m_data->m_NetSsid; + connetSetting.m_secretFlag = 0; + connetSetting.dumpInfo(); + + if (eapType == KyEapMethodType::TLS) { + m_info.tlsInfo.devIfaceName = m_deviceName; + m_securityPage->updateTlsChange(m_info.tlsInfo); + m_connectOperation->addAndActiveWirelessEnterPriseTlsConnect(m_info.tlsInfo, connetSetting, m_deviceName, true); + } else if (eapType == KyEapMethodType::PEAP) { + m_securityPage->updatePeapChange(m_info.peapInfo); + m_connectOperation->addAndActiveWirelessEnterPrisePeapConnect(m_info.peapInfo, connetSetting, m_deviceName, true); + } else if (eapType == KyEapMethodType::TTLS) { + m_securityPage->updateTtlsChange(m_info.ttlsInfo); + m_connectOperation->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, true); + } else { + qWarning() << "Connect enterprise wlan failed!(Unknown eap type)" << Q_FUNC_INFO << __LINE__; + } +} + +void EnterpriseWlanDialog::onEapTypeChanged(const KyEapMethodType &type) +{ + switch (type) { + case KyEapMethodType::TLS: + if (m_data && !m_data->m_connectUuid.isEmpty()) { + m_resource->getEnterPriseInfoTls(m_data->m_connectUuid, m_info.tlsInfo); + m_securityPage->setTlsInfo(m_info.tlsInfo); + } + this->setFixedSize(MAIN_SIZE_EXPAND); + break; + case KyEapMethodType::PEAP: + if (m_data && !m_data->m_connectUuid.isEmpty()) { + m_resource->getEnterPriseInfoPeap(m_data->m_connectUuid, m_info.peapInfo); + m_securityPage->setPeapInfo(m_info.peapInfo); + } + this->setFixedSize(MAIN_SIZE_NARROW); + break; + case KyEapMethodType::TTLS: + if (m_data && !m_data->m_connectUuid.isEmpty()) { + m_resource->getEnterPriseInfoTtls(m_data->m_connectUuid, m_info.ttlsInfo); + m_securityPage->setTtlsInfo(m_info.ttlsInfo); + } + this->setFixedSize(MAIN_SIZE_NARROW); + break; + default: + break; + } +} diff --git a/src/frontend/enterprise-wlan/enterprisewlandialog.h b/src/frontend/enterprise-wlan/enterprisewlandialog.h new file mode 100644 index 00000000..a3260944 --- /dev/null +++ b/src/frontend/enterprise-wlan/enterprisewlandialog.h @@ -0,0 +1,58 @@ +#ifndef ENTERPRISEWLANDIALOG_H +#define ENTERPRISEWLANDIALOG_H +#include +#include +#include "securitypage.h" +#include "kywirelessnetitem.h" +#include "coninfo.h" + +class EnterpriseWlanDialog : public QDialog +{ + Q_OBJECT +public: + EnterpriseWlanDialog(KyWirelessNetItem *data, QString device, QWidget *parent = nullptr); + ~EnterpriseWlanDialog(); + +private: + void initUI(); //初始化UI界面 + void centerToScreen(); + void initConnections(); + void initData(); + +private: + KyWirelessNetItem *m_data = nullptr; + ConInfo m_info; + QString m_deviceName; + KyWirelessConnectOperation *m_connectOperation = nullptr; + KyWirelessNetResource *m_resource = nullptr; + + /* 弹窗布局 + * Connect Enterprise WLAN············X + * SSID··························[SSID] + * -----------SecurityPage------------- + * | | + * ------------------------------------ + * ····················CANCEL···CONNECT + */ + QVBoxLayout *m_mainLayout = nullptr; + + QHBoxLayout *m_titleLayout = nullptr; + QLabel *m_titleLabel = nullptr; + QPushButton *m_closeBtn = nullptr; + + QHBoxLayout *m_ssidLayout = nullptr; + QLabel *m_ssidTitleLabel = nullptr; + QLabel *m_ssidLabel = nullptr; + + SecurityPage *m_securityPage = nullptr; + + QHBoxLayout *m_btnLayout = nullptr; + QPushButton *m_cancelBtn = nullptr; + QPushButton *m_connectBtn = nullptr; + +private slots: + void onBtnConnectClicked(); + void onEapTypeChanged(const KyEapMethodType &type); +}; + +#endif // ENTERPRISEWLANDIALOG_H diff --git a/src/frontend/frontend.pri b/src/frontend/frontend.pri index 475c30e6..6b0c3d0e 100644 --- a/src/frontend/frontend.pri +++ b/src/frontend/frontend.pri @@ -4,7 +4,8 @@ include(wireless-security/wireless-security.pri) include(xatom/xatom.pri) include(tab-pages/tab-pages.pri) include(list-items/list-items.pri) -include(netdetails.pri) +include(netdetails/netdetails.pri) +include(enterprise-wlan/enterprise-wlan.pri) FORMS += \ $$PWD/confform.ui \ diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 7c42e596..b933dfec 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -1,5 +1,6 @@ #include "wlanlistitem.h" #include +#include "enterprisewlandialog.h" WlanListItem::WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *data, QString device, QWidget *parent) : ListItem(parent) { @@ -266,18 +267,23 @@ void WlanListItem::onNetButtonClicked() //执行连接或断开 if (m_isActive) { - m_connoperation->deActivateWirelessConnection(m_wlanDevice,m_data->m_connectUuid); + m_connoperation->deActivateWirelessConnection(m_wlanDevice, m_data->m_connectUuid); qDebug()<<"Clicked on connected wifi, it will be inactivated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__; return; } //有配置或者无密码的wifi直接连接 if (m_data->m_isConfigured || m_hasPwd == false) { - m_connoperation->activeWirelessConnect(m_wlanDevice,m_data->m_connectUuid); + m_connoperation->activeWirelessConnect(m_wlanDevice, m_data->m_connectUuid); qDebug()<<"Has configuration, will be activated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__; return; } if (!this->m_connectButton->isVisible() && m_data->m_secuType != "") { - this->setExpanded(true); + if (m_data->m_secuType.contains("wpa", Qt::CaseInsensitive)) { + EnterpriseWlanDialog *enterpriseWlanDialog = new EnterpriseWlanDialog(m_data, m_wlanDevice, this); + enterpriseWlanDialog->show(); + } else { + this->setExpanded(true); + } } else { onConnectButtonClicked(); } diff --git a/src/frontend/netdetails.pri b/src/frontend/netdetails.pri deleted file mode 100644 index 10b5c1e7..00000000 --- a/src/frontend/netdetails.pri +++ /dev/null @@ -1,18 +0,0 @@ -HEADERS += \ - $$PWD/netdetails/coninfo.h \ - $$PWD/netdetails/creatnetpage.h \ - $$PWD/netdetails/customtabstyle.h \ - $$PWD/netdetails/detailpage.h \ - $$PWD/netdetails/ipv4page.h \ - $$PWD/netdetails/ipv6page.h \ - $$PWD/netdetails/netdetail.h \ - $$PWD/netdetails/securitypage.h - -SOURCES += \ - $$PWD/netdetails/creatnetpage.cpp \ - $$PWD/netdetails/customtabstyle.cpp \ - $$PWD/netdetails/detailpage.cpp \ - $$PWD/netdetails/ipv4page.cpp \ - $$PWD/netdetails/ipv6page.cpp \ - $$PWD/netdetails/netdetail.cpp \ - $$PWD/netdetails/securitypage.cpp diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 329116db..7b38eb3b 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -1,6 +1,7 @@ #include "netdetail.h" #include "backend/kylinipv4arping.h" #include "backend/kylinipv6arping.h" +#include "xatom/xatom-helper.h" #define WINDOW_WIDTH 540 #define WINDOW_HEIGHT 574 @@ -17,7 +18,7 @@ #define CREATE_NET_PAGE_NUM 4 #define PAGE_MIN_HEIGHT 40 -extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); +//extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent) :m_deviceName(interface), @@ -28,8 +29,19 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv isCreateNet(isCreateNet), QDialog(parent) { - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint ); - setAttribute(Qt::WA_TranslucentBackground); + //设置窗口无边框,阴影 +#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->setProperty("useStyleWindowManager", false); //禁用拖动 +// setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint ); +// setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_DeleteOnClose); setFixedSize(WINDOW_WIDTH,WINDOW_HEIGHT); centerToScreen(); @@ -62,6 +74,11 @@ NetDetail::~NetDetail() } +void NetDetail::paintEvent(QPaintEvent *event) +{ + return QDialog::paintEvent(event); +} + void NetDetail::centerToScreen() { QDesktopWidget* m = QApplication::desktop(); @@ -607,50 +624,6 @@ void NetDetail::updateWirelessEnterPriseConnect(KyEapMethodType enterpriseType) } } - - -void NetDetail::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - QPainterPath rectPath; - rectPath.addRoundedRect(this->rect().adjusted(12, 12, -12, -12), 12, 12); - - // 画一个黑底 - QPixmap pixmap(this->rect().size()); - pixmap.fill(Qt::transparent); - QPainter pixmapPainter(&pixmap); - pixmapPainter.setRenderHint(QPainter::Antialiasing); - pixmapPainter.setPen(Qt::transparent); - pixmapPainter.setBrush(Qt::black); - pixmapPainter.setOpacity(0.65); - pixmapPainter.drawPath(rectPath); - pixmapPainter.end(); - - // 模糊这个黑底 - QImage img = pixmap.toImage(); - qt_blurImage(img, 10, false, false); - - // 挖掉中心 - pixmap = QPixmap::fromImage(img); - QPainter pixmapPainter2(&pixmap); - pixmapPainter2.setRenderHint(QPainter::Antialiasing); - pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear); - pixmapPainter2.setPen(Qt::transparent); - pixmapPainter2.setBrush(Qt::transparent); - pixmapPainter2.drawPath(rectPath); - - // 绘制阴影 - p.drawPixmap(this->rect(), pixmap, pixmap.rect()); - - // 绘制一个背景 - p.save(); - p.fillPath(rectPath, palette().color(QPalette::Base)); - p.restore(); -} - bool NetDetail::createWiredConnect() { KyWirelessConnectSetting connetSetting; @@ -682,7 +655,9 @@ bool NetDetail::createWirelessConnect() } qDebug() << "isAutoConnect" << connetSetting.isAutoConnect; connetSetting.m_ssid = ssid; - connetSetting.m_secretFlag = NetworkManager::Setting::None; +// connetSetting.m_secretFlag = NetworkManager::Setting::None; + //由于X.h的None与此处的None有歧义,此处直接使用值 + connetSetting.m_secretFlag = 0; //ipv4 & ipv6 bool ipv4Change = ipv4Page->checkIsChanged(m_info, connetSetting); @@ -711,7 +686,7 @@ bool NetDetail::createWirelessConnect() KyEapMethodType enterpriseType; securityPage->getSecuType(secuType, enterpriseType); if (secuType == WPA_AND_WPA2_ENTERPRISE) { - connetSetting.m_type = SAE; + connetSetting.m_type = WpaEap; if (enterpriseType == TLS) { m_info.tlsInfo.devIfaceName = m_deviceName; securityPage->updateTlsChange(m_info.tlsInfo); diff --git a/src/frontend/netdetails/netdetails.pri b/src/frontend/netdetails/netdetails.pri new file mode 100644 index 00000000..206899b9 --- /dev/null +++ b/src/frontend/netdetails/netdetails.pri @@ -0,0 +1,20 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/coninfo.h \ + $$PWD/creatnetpage.h \ + $$PWD/customtabstyle.h \ + $$PWD/detailpage.h \ + $$PWD/ipv4page.h \ + $$PWD/ipv6page.h \ + $$PWD/netdetail.h \ + $$PWD/securitypage.h + +SOURCES += \ + $$PWD/creatnetpage.cpp \ + $$PWD/customtabstyle.cpp \ + $$PWD/detailpage.cpp \ + $$PWD/ipv4page.cpp \ + $$PWD/ipv6page.cpp \ + $$PWD/netdetail.cpp \ + $$PWD/securitypage.cpp diff --git a/src/frontend/netdetails/securitypage.cpp b/src/frontend/netdetails/securitypage.cpp index f6447b3a..bac45d63 100644 --- a/src/frontend/netdetails/securitypage.cpp +++ b/src/frontend/netdetails/securitypage.cpp @@ -288,6 +288,20 @@ void SecurityPage::setTtlsInfo(KyEapMethodTtlsInfo &info) } } +void SecurityPage::setSecurityVisible(const bool &visible) +{ + if (secuTypeLabel) { + secuTypeLabel->setVisible(visible); + } else { + qWarning() << "Set visible of secuTypeLabel failed because of null pointer" << Q_FUNC_INFO << __LINE__; + } + if (secuTypeCombox) { + secuTypeCombox->setVisible(visible); + } else { + qWarning() << "Set visible of secuTypeCombox failed because of null pointer" << Q_FUNC_INFO << __LINE__; + } +} + void SecurityPage::updateTlsChange(KyEapMethodTlsInfo &info) { KyEapMethodTlsInfo tlsInfo = assembleTlsInfo(); @@ -630,12 +644,14 @@ void SecurityPage::onEapTypeComboxIndexChanged() int index = eapTypeCombox->currentData().toInt(); if (index == TLS) { showTls(); + emit this->eapTypeChanged(TLS); } else if (index == PEAP) { showPeapOrTtls(); eapMethodCombox->clear(); eapMethodCombox->addItem("MSCHAPv2", KyAuthMethodMschapv2); eapMethodCombox->addItem("MD5", KyAuthMethodMd5); eapMethodCombox->addItem("GTC", KyAuthMethodGtc); + emit this->eapTypeChanged(PEAP); } else if (index == TTLS) { showPeapOrTtls(); eapMethodCombox->clear(); @@ -646,6 +662,7 @@ void SecurityPage::onEapTypeComboxIndexChanged() eapMethodCombox->addItem("chap", CHAP); eapMethodCombox->addItem("md5(eap)", MD5_EAP); eapMethodCombox->addItem("gtc(eap)", GTC_EAP); + emit this->eapTypeChanged(TTLS); } } diff --git a/src/frontend/netdetails/securitypage.h b/src/frontend/netdetails/securitypage.h index 34669022..aec1504b 100644 --- a/src/frontend/netdetails/securitypage.h +++ b/src/frontend/netdetails/securitypage.h @@ -22,6 +22,7 @@ public: void setTlsInfo(KyEapMethodTlsInfo &info); void setPeapInfo(KyEapMethodPeapInfo &info); void setTtlsInfo(KyEapMethodTtlsInfo &info); + void setSecurityVisible(const bool &visible); bool checkIsChanged(const ConInfo info); void updateSecurityChange(KyWirelessConnectSetting &setting); @@ -107,6 +108,7 @@ private slots: signals: void setSecuPageState(bool); + void eapTypeChanged(const KyEapMethodType &type); }; #endif // SECURITYWIDGET_H diff --git a/src/frontend/new-mainwindow.cpp b/src/frontend/new-mainwindow.cpp index 53f0f40c..66e7324b 100644 --- a/src/frontend/new-mainwindow.cpp +++ b/src/frontend/new-mainwindow.cpp @@ -94,15 +94,15 @@ void MainWindow::secondaryStart() */ void MainWindow::initWindowProperties() { - this->setAttribute(Qt::WA_TranslucentBackground, true); this->setWindowTitle(tr("kylin-nm")); this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png"))); - //绘制毛玻璃特效 this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT); - QPainterPath path; - auto rect = this->rect(); - path.addRoundedRect(rect, 6, 6); - KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); +// //绘制毛玻璃特效 +// this->setAttribute(Qt::WA_TranslucentBackground, true); +// QPainterPath path; +// auto rect = this->rect(); +// path.addRoundedRect(rect, 6, 6); +// KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); } /** @@ -270,7 +270,7 @@ void MainWindow::initWindowTheme() const QByteArray style_id(THEME_SCHAME); if (QGSettings::isSchemaInstalled(style_id)) { m_styleGsettings = new QGSettings(style_id); - resetWindowTheme(); +// resetWindowTheme(); connect(m_styleGsettings, &QGSettings::changed, this, &MainWindow::onThemeChanged); } else { qWarning() << "Gsettings interface \"org.ukui.style\" is not exist!" << Q_FUNC_INFO << __LINE__; @@ -292,7 +292,7 @@ void MainWindow::resetWindowTheme() return; } app->setStyle(new CustomStyle("ukui-light")); - qDebug() << "Has set color theme to ukui-light." << Q_FUNC_INFO << __LINE__; + qDebug() << "Has set color theme to " << currentTheme << Q_FUNC_INFO << __LINE__; emit qApp->paletteChanged(qApp->palette()); return; } @@ -338,7 +338,8 @@ void MainWindow::onThemeChanged(const QString &key) { if (key == COLOR_THEME) { qDebug() << "Received signal of theme changed, will reset theme." << Q_FUNC_INFO << __LINE__; - resetWindowTheme(); +// resetWindowTheme(); + emit qApp->paletteChanged(qApp->palette()); } else { qDebug() << "Received signal of theme changed, key=" << key << " will do nothing." << Q_FUNC_INFO << __LINE__; } diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 339cd9d9..cfb57b5b 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -335,6 +335,12 @@ void LanPage::onDeviceComboxIndexChanged(int currentIndex) } } +void LanPage::showControlCenter() +{ + QProcess process; + process.startDetached("ukui-control-center --wiredconnect"); +} + void LanPage::initUI() { m_titleLabel->setText(tr("LAN")); @@ -366,6 +372,7 @@ void LanPage::initUI() // m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条 inactiveLanListLayout->addWidget(m_inactivatedLanListWidget); + m_settingsLabel->installEventFilter(this); // emit this->lanConnectChanged(); } @@ -710,6 +717,16 @@ void LanPage::setWiredDeviceEnable(const QString& devName, bool enable) initDeviceCombox(); } +bool LanPage::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == m_settingsLabel) { + if (event->type() == QEvent::MouseButtonPress) { + showControlCenter(); + } + } + return QWidget::eventFilter(watched, event); +} + void LanPage::activateWired(const QString& devName, const QString& connUuid) { qDebug() << "activateWired" << devName << connUuid; diff --git a/src/frontend/tab-pages/lanpage.h b/src/frontend/tab-pages/lanpage.h index 31e99f1d..2ff8b861 100644 --- a/src/frontend/tab-pages/lanpage.h +++ b/src/frontend/tab-pages/lanpage.h @@ -30,6 +30,9 @@ public: void showDetailPage(QString devName, QString uuid); void setWiredDeviceEnable(const QString& devName, bool enable); +protected: + bool eventFilter(QObject *watched, QEvent *event); + signals: void lanAdd(QString devName, QStringList info); void lanRemove(QString dbusPath); @@ -86,6 +89,7 @@ private slots: void onDeviceRemove(QString deviceName); void onDeviceNameUpdate(QString oldName, QString newName); void onDeviceComboxIndexChanged(int currentIndex); + void showControlCenter(); // void onLanDataChange(QString uuid); }; diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index 7e5e9312..cf071387 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -62,7 +62,7 @@ void TabPage::initUI() m_activatedNetDivider = new Divider(this); m_inactivatedNetFrame = new QFrame(this); -// m_inactivatedNetFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT); + m_inactivatedNetFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT); m_inactivatedNetLayout = new QVBoxLayout(m_inactivatedNetFrame); m_inactivatedNetLayout->setContentsMargins(NET_LAYOUT_MARGINS); m_inactivatedNetLayout->setSpacing(NET_LAYOUT_SPACING); @@ -81,6 +81,7 @@ void TabPage::initUI() m_settingsLayout = new QHBoxLayout(m_settingsFrame); m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS); m_settingsLabel = new QLabel(m_settingsFrame); + m_settingsLabel->setCursor(Qt::PointingHandCursor); m_settingsLabel->setText(tr("Settings")); m_settingsLayout->addWidget(m_settingsLabel); m_settingsFrame->setLayout(m_settingsLayout); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index c9c9e94d..29fe3f4c 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -35,7 +35,6 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::deactivateConnectionError, this, &WlanPage::deactivateFailed); connect(this, &WlanPage::hiddenWlanClicked, this, &WlanPage::onHiddenWlanClicked); - connect(this, &WlanPage::settingsClicked, this, &WlanPage::showControlCenter); connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::wifinEnabledChanged, this, &WlanPage::onWifiEnabledChanged); } @@ -52,7 +51,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e) emit this->hiddenWlanClicked(); } else if (w == m_settingsLabel) { //ZJP_TODO 打开控制面板 - emit this->settingsClicked(); + showControlCenter(); } } return QWidget::eventFilter(w,e); @@ -188,6 +187,9 @@ void WlanPage::initDeviceCombox() disconnect(m_deviceComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &WlanPage::onDeviceComboxIndexChanged); if (m_devList.length() <= 1) { m_deviceFrame->hide(); + foreach (QString device, m_devList) { + m_deviceComboBox->addItem(device, device); + } } else { m_deviceFrame->show(); foreach (QString device, m_devList) { diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index 47cad272..522a2901 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -48,7 +48,6 @@ signals: void signalStrengthChange(QString devName, QString ssid, int strength); void secuTypeChange(QString devName, QString ssid, QString secuType); void hiddenWlanClicked(); - void settingsClicked(); void wlanConnectChanged(); public slots: diff --git a/src/src.pro b/src/src.pro index 0c34e67c..559c13df 100644 --- a/src/src.pro +++ b/src/src.pro @@ -8,14 +8,11 @@ QT += core gui x11extras dbus KWindowSystem svg concurrent network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -TARGET = kylin-nm +TARGET = kylin-network-manager TEMPLATE = app -LANGUAGE = C++ -CONFIG += c++14 -CONFIG += qt warn_on +CONFIG += c++14 qt warn_on link_pkgconfig #CONFIG += release -CONFIG += link_pkgconfig PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt libcap