Merge branch 'dbus-interface' into '0922'

# Conflicts:
#   src/frontend/tab-pages/lanpage.cpp
This commit is contained in:
Zhang Jiaping 2021-09-24 09:46:45 +00:00
commit 9292060929
21 changed files with 417 additions and 99 deletions

1
debian/control vendored
View File

@ -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

2
debian/kylin-nm.postinst vendored Normal file → Executable file
View File

@ -10,5 +10,5 @@ fi
echo "kylin nm set cap success"
exit(0)
exit 0

View File

@ -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

View File

@ -0,0 +1,9 @@
INCLUDEPATH += $$PWD
FORMS += \
HEADERS += \
$$PWD/enterprisewlandialog.h \
SOURCES += \
$$PWD/enterprisewlandialog.cpp \

View File

@ -0,0 +1,205 @@
#include "enterprisewlandialog.h"
#include <QApplication>
#include <QDesktopWidget>
#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;
}
}

View File

@ -0,0 +1,58 @@
#ifndef ENTERPRISEWLANDIALOG_H
#define ENTERPRISEWLANDIALOG_H
#include <QDialog>
#include <QPushButton>
#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

View File

@ -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 \

View File

@ -1,5 +1,6 @@
#include "wlanlistitem.h"
#include <QResizeEvent>
#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("802.1x", Qt::CaseInsensitive)) {
EnterpriseWlanDialog *enterpriseWlanDialog = new EnterpriseWlanDialog(m_data, m_wlanDevice, this);
enterpriseWlanDialog->show();
} else {
this->setExpanded(true);
}
} else {
onConnectButtonClicked();
}

View File

@ -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

View File

@ -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,25 @@
#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);
void NetDetail::showDesktopNotify(const QString &message)
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(tr("Kylin NM"))
<<((unsigned int) 0)
<<QString("/usr/share/icons/ukui-icon-theme-default/24x24/devices/gnome-dev-ethernet.png")
<<tr("kylin network desktop message") //显示的是什么类型的信息
<<message //显示的具体信息
<<QStringList()
<<QVariantMap()
<<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
}
NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent)
:m_deviceName(interface),
@ -28,8 +47,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 +92,11 @@ NetDetail::~NetDetail()
}
void NetDetail::paintEvent(QPaintEvent *event)
{
return QDialog::paintEvent(event);
}
void NetDetail::centerToScreen()
{
QDesktopWidget* m = QApplication::desktop();
@ -554,6 +589,7 @@ void NetDetail::setConfirmEnable()
bool NetDetail::checkIpv4Conflict(QString ipv4Address)
{
showDesktopNotify(tr("start check ipv4 address conflict"));
bool isConflict = false;
KyIpv4Arping* ipv4Arping = new KyIpv4Arping(m_deviceName, ipv4Address);
@ -570,6 +606,7 @@ bool NetDetail::checkIpv4Conflict(QString ipv4Address)
bool NetDetail::checkIpv6Conflict(QString ipv6address)
{
showDesktopNotify(tr("start check ipv6 address conflict"));
bool isConflict = false;
KyIpv6Arping* ipv46rping = new KyIpv6Arping(m_deviceName, ipv6address);
@ -607,50 +644,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;
@ -659,7 +652,7 @@ bool NetDetail::createWiredConnect()
if (connetSetting.m_ipv4ConfigIpType != CONFIG_IP_DHCP) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv4 address conflict!"));
return false;
}
}
@ -682,7 +675,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);
@ -694,7 +689,7 @@ bool NetDetail::createWirelessConnect()
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv4 address conflict!"));
return false;
}
}
@ -702,7 +697,7 @@ bool NetDetail::createWirelessConnect()
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
qDebug() << "ipv6 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv6 address conflict!"));
return false;
}
}
@ -711,7 +706,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);
@ -772,7 +767,7 @@ bool NetDetail::updateConnect()
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv4 address conflict!"));
return false;
}
}
@ -780,7 +775,7 @@ bool NetDetail::updateConnect()
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
qDebug() << "ipv6 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv6 address conflict!"));
return false;
}
}

View File

@ -69,6 +69,8 @@ private:
bool createWiredConnect();
bool createWirelessConnect();
bool updateConnect();
void showDesktopNotify(const QString &message);
private:
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
KyConnectOperation* m_connectOperation = nullptr;

View File

@ -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

View File

@ -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);
}
}

View File

@ -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

View File

@ -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__;
}

View File

@ -331,6 +331,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"));
@ -362,6 +368,8 @@ void LanPage::initUI()
// m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条
inactiveLanListLayout->addWidget(m_inactivatedLanListWidget);
m_settingsLabel->installEventFilter(this);
// emit this->lanConnectChanged();
}
void LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
@ -686,6 +694,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;

View File

@ -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);
};

View File

@ -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);

View File

@ -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<int>::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) {

View File

@ -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:

View File

@ -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