diff --git a/0001-feature-network-Add-the-conf-file-to-overwrite-the-o.patch b/0001-feature-network-Add-the-conf-file-to-overwrite-the-o.patch new file mode 100644 index 0000000..2df586c --- /dev/null +++ b/0001-feature-network-Add-the-conf-file-to-overwrite-the-o.patch @@ -0,0 +1,59 @@ +From ebd20e32e3f0c0944aebdad0cd5a347694b033e4 Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Fri, 12 Aug 2022 17:27:50 +0800 +Subject: [PATCH 1/7] feature(network):Add the conf file to overwrite the + original configuration of NetworkManager +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 添加conf文件以覆盖NetworkManager原先的配置 +--- + plugins/network/CMakeLists.txt | 4 ++++ + plugins/network/data/00-server.conf.in | 18 ++++++++++++++++++ + 2 files changed, 22 insertions(+) + create mode 100644 plugins/network/data/00-server.conf.in + +diff --git a/plugins/network/CMakeLists.txt b/plugins/network/CMakeLists.txt +index 0bdf4f8..02dbe3a 100644 +--- a/plugins/network/CMakeLists.txt ++++ b/plugins/network/CMakeLists.txt +@@ -115,6 +115,10 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kiran-network-status-icon.desktop DEST + SET(link_source ${PLUGIN_DESKTOP_INSTALL_DIR}/${TARGET_NAME}.desktop) + SET(link_target ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}-link.desktop) + ++set(NETWORK_SERVER_CONF /etc/NetworkManager/conf.d) ++configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/00-server.conf.in ${CMAKE_CURRENT_BINARY_DIR}/00-server.conf @ONLY) ++install(FILES ${CMAKE_CURRENT_BINARY_DIR}/00-server.conf DESTINATION ${NETWORK_SERVER_CONF}/) ++ + #安装插件和二进制文件 + install(TARGETS ${TARGET_NAME} DESTINATION ${PLUGIN_LIBS_INSTALL_DIR}/) + install(TARGETS ${TRAY_PROCESS} DESTINATION ${INSTALL_BINDIR}) +diff --git a/plugins/network/data/00-server.conf.in b/plugins/network/data/00-server.conf.in +new file mode 100644 +index 0000000..e3202b8 +--- /dev/null ++++ b/plugins/network/data/00-server.conf.in +@@ -0,0 +1,18 @@ ++# This configuration file changes NetworkManager's behavior to ++# what's expected on "traditional UNIX server" type deployments. ++# ++# See "man NetworkManager.conf" for more information about these ++# and other keys. ++ ++#NetworkManager会先读取/etc/NetworkManager/NetworkManager.conf,然后是/usr/lib/NetworkManager/conf.d/下的配置 ++#最后读取/etc/NetworkManager/conf.d,后读取的文件将覆盖先读取的同名文件配置 ++#在/etc/NetworkManager/conf.d目录添加该文件,用以覆盖/usr/lib/NetworkManager/conf.d下的同名文件的配置 ++#https://gitee.com/src-openeuler/kiran-desktop/issues/I5I0AA ++[main] ++# Do not do automatic (DHCP/SLAAC) configuration on ethernet devices ++# with no other matching connections. ++no-auto-default=* ++ ++# Ignore the carrier (cable plugged in) state when attempting to ++# activate static-IP connections. ++#ignore-carrier=* +\ No newline at end of file +-- +2.33.0 + diff --git a/0002-fix-network-fix-crash-and-wireless-network-disable-f.patch b/0002-fix-network-fix-crash-and-wireless-network-disable-f.patch new file mode 100644 index 0000000..a178938 --- /dev/null +++ b/0002-fix-network-fix-crash-and-wireless-network-disable-f.patch @@ -0,0 +1,1540 @@ +From 48a78fb158d5f87d123ab8ff0a6358d71aa1eec2 Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Fri, 19 Aug 2022 09:20:18 +0800 +Subject: [PATCH 2/7] fix(network):fix crash and wireless network disable + function defects +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 修复网络页面与其他插件页面快速切换导致崩溃的问题 + 修复无线网络禁用的缺陷 +--- + plugins/network/src/connection-show-page.cpp | 60 +++-- + plugins/network/src/connection-show-page.h | 4 +- + .../src/plugin/cpanel-network-widget.cpp | 150 +++++++----- + .../src/plugin/cpanel-network-widget.h | 11 +- + plugins/network/src/plugin/details-page.cpp | 5 +- + .../src/plugin/manager/vpn-manager.cpp | 134 +++++------ + .../src/plugin/manager/wired-manager.cpp | 11 +- + .../src/plugin/manager/wireless-manager.cpp | 58 +++-- + .../src/plugin/setting-widget/vpn/vpn-ppp.cpp | 6 +- + plugins/network/src/tray/network-tray.cpp | 218 ++++++++++-------- + plugins/network/src/tray/network-tray.h | 2 +- + plugins/network/src/tray/tray-page.cpp | 17 +- + .../network/src/tray/wireless-tray-widget.cpp | 35 ++- + 13 files changed, 392 insertions(+), 319 deletions(-) + +diff --git a/plugins/network/src/connection-show-page.cpp b/plugins/network/src/connection-show-page.cpp +index 71ae95c..ae50b06 100644 +--- a/plugins/network/src/connection-show-page.cpp ++++ b/plugins/network/src/connection-show-page.cpp +@@ -27,13 +27,10 @@ using namespace NetworkManager; + ConnectionShowPage::ConnectionShowPage(QWidget* parent) : QWidget(parent), ui(new Ui::ConnectionShowPage) + { + ui->setupUi(this); +- initUI(); +- initConnect(); + } + + ConnectionShowPage::~ConnectionShowPage() + { +- KLOG_DEBUG() << "ConnectionShowPage::~ConnectionShowPage()"; + delete ui; + } + +@@ -42,14 +39,36 @@ void ConnectionShowPage::setTitle(QString title) + ui->title->setText(title); + } + ++void ConnectionShowPage::init(NetworkManager::ConnectionSettings::ConnectionType connectionType, const QString& devicePath) ++{ ++ m_connectionType = connectionType; ++ m_devicePath = devicePath; ++ ui->connectionLists->setDevicePath(devicePath); ++ ui->connectionLists->setItemWidgetType(ITEM_WIDGET_TYPE_PLUGIN); ++ ++ initUI(); ++ initConnect(); ++} ++ ++// TODO:增加判断设备是否可用的逻辑,unmanager 和 unavalibale的处理 + void ConnectionShowPage::initUI() + { ++ // switchButton Checked 默认为false + m_switchButton = new KiranSwitchButton(this); ++ initSwitchButton(); + + ui->titleLayout->addWidget(m_switchButton); + ui->connectionLists->setMaximumHeight(ui->connectionLists->sizeHintForRow(0) * ui->connectionLists->count() + (2 * ui->connectionLists->frameWidth())); + Kiran::StylePropertyHelper::setButtonType(ui->createConnectionButton, Kiran::BUTTON_Default); + ui->createConnectionButton->setIcon(QIcon(":/kcp-network-images/connection-add.svg")); ++ ++ if (m_connectionType == ConnectionSettings::Wireless) ++ { ++ ui->connectionLists->showWirelessNetworkLists(); ++ ui->connectionLists->setVisible(isWirelessEnabled()); ++ } ++ else ++ ui->connectionLists->showConnectionLists(m_connectionType); + } + + void ConnectionShowPage::initConnect() +@@ -66,31 +85,35 @@ void ConnectionShowPage::initConnect() + + connect(ui->connectionLists, &ConnectionLists::sendSsidToWireless, this, &ConnectionShowPage::sendSsidToWireless); + +- connect(m_switchButton, &KiranSwitchButton::toggled, this, &ConnectionShowPage::handleToggledSwitchButton); ++ connect(m_switchButton, &KiranSwitchButton::toggled, this, &ConnectionShowPage::handleToggledSwitchButton, Qt::UniqueConnection); + + /** + *如果频繁的打开/禁用网络,会频繁发送信号,使用定时器进行处理 + * */ +- m_timer.setInterval(100); +- m_timer.setSingleShot(true); +- connect(notifier(), &Notifier::wirelessEnabledChanged, [=](bool enable) +- { +- m_wirlessNetworkEnable = enable; +- m_timer.start(); }); ++ // m_timer.setInterval(200); ++ // m_timer.setSingleShot(true); ++ // connect(notifier(), &Notifier::wirelessEnabledChanged, this, [this](bool enable) ++ // { ++ // m_wirlessNetworkEnable = enable; ++ // m_timer.start(); }); ++ ++ // connect(&m_timer, &QTimer::timeout, this, [this]() ++ // { handleWirelessEnabledChanged(m_wirlessNetworkEnable); }); + +- connect(&m_timer, &QTimer::timeout, [=]() +- { handleWirelessEnabledChanged(m_wirlessNetworkEnable); }); ++ if (m_connectionType == ConnectionSettings::Wireless) ++ { ++ connect(notifier(), &Notifier::wirelessEnabledChanged, this, &ConnectionShowPage::handleWirelessEnabledChanged, Qt::UniqueConnection); ++ } + +- // connect(notifier(), &Notifier::wirelessEnabledChanged, this, &ConnectionShowPage::handleWirelessEnabledChanged); + connect(notifier(), &Notifier::networkingEnabledChanged, [=]() {}); + } + ++//弃用 + void ConnectionShowPage::setConnectionType(ConnectionSettings::ConnectionType connectionType) + { + m_connectionType = connectionType; + } + +-// XXX:该函数有待修改 + void ConnectionShowPage::initSwitchButton() + { + switch (m_connectionType) +@@ -109,6 +132,7 @@ void ConnectionShowPage::initSwitchButton() + + void ConnectionShowPage::handleToggledSwitchButton(bool toggled) + { ++ KLOG_DEBUG() << "--------------------------------handleToggledSwitchButton:" << toggled; + switch (m_connectionType) + { + case ConnectionSettings::Wired: +@@ -125,14 +149,17 @@ void ConnectionShowPage::handleToggledSwitchButton(bool toggled) + } + } + +-//TODO:控制无线网络设备开关 + void ConnectionShowPage::handleWirelessEnabledChanged(bool enabled) + { ++ KLOG_DEBUG() << "*****************************handleWirelessEnabledChanged:" << enabled; ++ //处理通过命令行等其他方式禁用无线网络的情况 ++ m_switchButton->blockSignals(true); + m_switchButton->setChecked(enabled); ++ m_switchButton->blockSignals(false); + ui->connectionLists->setVisible(enabled); +- // ui->createConnectionButton->setVisible(enabled); + } + ++//弃用 + void ConnectionShowPage::setDevicePath(const QString& devicePath) + { + m_devicePath = devicePath; +@@ -209,6 +236,7 @@ void ConnectionShowPage::updateItemActivatedStatus(const QString& activatedPath) + ui->connectionLists->updateItemActivatedStatus(activatedPath); + } + ++//弃用 + void ConnectionShowPage::setItemWidgetType(ItemWidgetType itemType) + { + ui->connectionLists->setItemWidgetType(itemType); +diff --git a/plugins/network/src/connection-show-page.h b/plugins/network/src/connection-show-page.h +index 9b618c2..308e5dc 100644 +--- a/plugins/network/src/connection-show-page.h ++++ b/plugins/network/src/connection-show-page.h +@@ -19,8 +19,8 @@ + #include + #include + #include +-#include + #include ++#include + + QT_BEGIN_NAMESPACE + namespace Ui +@@ -39,6 +39,8 @@ class ConnectionShowPage : public QWidget + public: + explicit ConnectionShowPage(QWidget *parent = nullptr); + ~ConnectionShowPage() override; ++ ++ void init(NetworkManager::ConnectionSettings::ConnectionType connectionType, const QString &devicePath); + void initUI(); + void initConnect(); + +diff --git a/plugins/network/src/plugin/cpanel-network-widget.cpp b/plugins/network/src/plugin/cpanel-network-widget.cpp +index daf3c33..cb0ec10 100644 +--- a/plugins/network/src/plugin/cpanel-network-widget.cpp ++++ b/plugins/network/src/plugin/cpanel-network-widget.cpp +@@ -13,6 +13,7 @@ + */ + + #include "cpanel-network-widget.h" ++#include + #include + #include "plugin/details-page.h" + #include "ui_cpanel-network-widget.h" +@@ -48,52 +49,63 @@ void CPanelNetworkWidget::init() + initConnect(); + } + +-//TODO:增加sidebarItem与设备的对应关系 ++// TODO:增加sidebarItem与设备的对应关系 + void CPanelNetworkWidget::initPage() + { + getAvailableDeviceList(); + int row = 0; + for (int i = 0; i < m_wiredDeviceList.count(); ++i) + { +- auto device = m_wiredDeviceList.value(i); ++ Device::Ptr device = m_wiredDeviceList.value(i); ++ connect(device.data(), &Device::managedChanged, this, &CPanelNetworkWidget::handleManagedChanged, Qt::UniqueConnection); ++ + QString devicePath = device->uni(); + QString deviceName = device->interfaceName(); + WiredManager *wiredManager = new WiredManager(devicePath, this); +- ui->stackedWidget->insertWidget(row,wiredManager); ++ ui->stackedWidget->insertWidget(row, wiredManager); + + QString subItemName = tr("Wired Network %1"); + QString subItemNameStr = subItemName.arg(i + 1); +- if(m_wiredDeviceList.count() == 1) +- ui->sidebar->insertItem(row, tr("Wired Network")); ++ ++ KiranSidebarItem *sidebarItem = new KiranSidebarItem(); ++ if (m_wiredDeviceList.count() == 1) ++ sidebarItem->setText(tr("Wired Network")); + else +- ui->sidebar->insertItem(row, subItemNameStr); +- ui->sidebar->item(row)->setData(Qt::UserRole, row); +- ui->sidebar->item(row)->setIcon(trayIconColorSwitch(":/kcp-network-images/wired.svg")); ++ sidebarItem->setText(subItemNameStr); ++ ++ ui->sidebar->insertItem(row, sidebarItem); ++ sidebarItem->setData(Qt::UserRole, row); ++ sidebarItem->setIcon(trayIconColorSwitch(":/kcp-network-images/wired.svg")); + row++; + } + + for (int i = 0; i < m_wirelessDeviceList.count(); ++i) + { +- auto device = m_wirelessDeviceList.value(i); ++ Device::Ptr device = m_wirelessDeviceList.value(i); ++ connect(device.data(), &Device::managedChanged, this, &CPanelNetworkWidget::handleManagedChanged, Qt::UniqueConnection); ++ + QString devicePath = device->uni(); + QString deviceName = device->interfaceName(); + WirelessManager *wirelessManager = new WirelessManager(devicePath, this); +- ui->stackedWidget->insertWidget(row,wirelessManager); ++ ui->stackedWidget->insertWidget(row, wirelessManager); + + QString subItemName = tr("Wireless Network %1"); +- QString subItemNameStr = subItemName.arg(i+1); +- if(m_wirelessDeviceList.count() == 1) +- ui->sidebar->insertItem(row, tr("Wireless Network")); ++ QString subItemNameStr = subItemName.arg(i + 1); ++ ++ KiranSidebarItem *sidebarItem = new KiranSidebarItem(); ++ if (m_wirelessDeviceList.count() == 1) ++ sidebarItem->setText(tr("Wireless Network")); + else +- ui->sidebar->insertItem(row, subItemNameStr); ++ sidebarItem->setText(subItemNameStr); + +- ui->sidebar->item(row)->setData(Qt::UserRole, row); +- ui->sidebar->item(row)->setIcon(trayIconColorSwitch(":/kcp-network-images/wireless.svg")); ++ ui->sidebar->insertItem(row, sidebarItem); ++ sidebarItem->setData(Qt::UserRole, row); ++ sidebarItem->setIcon(trayIconColorSwitch(":/kcp-network-images/wireless.svg")); + row++; + } + + VpnManager *vpnManager = new VpnManager(this); +- ui->stackedWidget->insertWidget(row,vpnManager); ++ ui->stackedWidget->insertWidget(row, vpnManager); + + ui->sidebar->insertItem(row, tr("VPN")); + ui->sidebar->item(row)->setData(Qt::UserRole, row); +@@ -101,7 +113,7 @@ void CPanelNetworkWidget::initPage() + row++; + + DetailsPage *networkDetails = new DetailsPage(this); +- ui->stackedWidget->insertWidget(row,networkDetails); ++ ui->stackedWidget->insertWidget(row, networkDetails); + ui->sidebar->insertItem(row, tr("Network Details")); + ui->sidebar->item(row)->setData(Qt::UserRole, row); + ui->sidebar->item(row)->setIcon(trayIconColorSwitch(":/kcp-network-images/network-details.svg")); +@@ -115,7 +127,7 @@ void CPanelNetworkWidget::getAvailableDeviceList() + const Device::List deviceList = networkInterfaces(); + for (Device::Ptr dev : deviceList) + { +- if (dev->state() == Device::Unavailable) ++ if (dev->state() == Device::Unmanaged) + continue; + + switch (dev->type()) +@@ -174,71 +186,89 @@ void CPanelNetworkWidget::initConnect() + { + m_Timer.setInterval(500); + m_Timer.setSingleShot(true); +- waitCounts = 1; +- connect(&m_Timer, &QTimer::timeout, [=]() ++ m_waitCounts = 1; ++ // Note:新设备插入后,需要等待一段时间,Device::List networkInterfaces() 来不及更新 ++ // Note:DeviceAdded signal is emitted when a new network interface is available. ++ ++ // XXX:当发出deviceAdded信号时,应该已经managed,需要修改并重新测试 ++ connect(notifier(), &Notifier::deviceAdded, this, [this](const QString &uni) + { ++ m_addDevicePath = uni; + Device::Ptr device = findNetworkInterface(m_addDevicePath); +- if(device->managed()) ++ if(device.isNull()) ++ { ++ KLOG_DEBUG() << "this device interface is not found"; ++ return; ++ } ++ if(device->isValid()) + { + handleDeviceAdded(m_addDevicePath); +- m_Timer.stop(); + } + else + { +- KLOG_INFO() << "this device interface is not ready"; ++ KLOG_INFO() << "this device interface is invalid!"; + m_Timer.start(); +- } +- waitCounts++; +- if(waitCounts > MAX_WAIT_COUNTS) +- { +- KLOG_INFO() << "This device is not currently managed by NetworkManager"; +- m_Timer.stop(); ++ KLOG_INFO() << "wait counts:" << m_waitCounts; + } }); + +- // Note:新设备插入后,需要等待一段时间,Device::List networkInterfaces() 来不及更新 +- connect(notifier(), &Notifier::deviceAdded, [=](const QString &uni) ++ connect(&m_Timer, &QTimer::timeout, this, [this]() + { +- m_addDevicePath = uni; + Device::Ptr device = findNetworkInterface(m_addDevicePath); +- KLOG_DEBUG() << "device->availableConnections().isEmpty():" << device->availableConnections().isEmpty(); +- KLOG_DEBUG() << "device->managed():" << device->managed(); +- if(!device->isValid()) ++ if(device->isValid()) + { +- KLOG_INFO() << "this device interface is invalid!"; +- return ; +- } +- if(device->managed()) + handleDeviceAdded(m_addDevicePath); ++ m_Timer.stop(); ++ } + else + { +- KLOG_INFO() << "this device interface is not ready"; ++ KLOG_INFO() << "this device interface is invalid!"; + m_Timer.start(); +- KLOG_INFO() << "wait counts:" << waitCounts; ++ } ++ m_waitCounts++; ++ if(m_waitCounts > MAX_WAIT_COUNTS) ++ { ++ KLOG_INFO() << "This device is currently invalid by NetworkManager"; ++ m_Timer.stop(); + } }); + + connect(notifier(), &Notifier::deviceRemoved, this, &CPanelNetworkWidget::handleDeviceRemoved); + +- connect(ui->sidebar, &QListWidget::itemClicked, this,&CPanelNetworkWidget::handleSideBarItemClicked); ++ connect(notifier(), &Notifier::wirelessEnabledChanged, this, &CPanelNetworkWidget::handleWirelessEnabledChanged); ++ connect(notifier(), &Notifier::networkingEnabledChanged, this, &CPanelNetworkWidget::handleNetworkingEnabledChanged); ++ ++ connect(ui->sidebar, &QListWidget::itemClicked, this, &CPanelNetworkWidget::handleSideBarItemClicked); + + connect(Kiran::StylePalette::instance(), &Kiran::StylePalette::themeChanged, this, &CPanelNetworkWidget::handleThemeChanged); + } + +-// XXX:暂时全部item重新加载有待优化 +-void CPanelNetworkWidget::handleDeviceAdded(const QString &devicePath) ++// XXX:需要优化,改成动态增减侧边栏subItems,而不是全部重新加载 ++void CPanelNetworkWidget::handleManagedChanged() + { ++ auto device = qobject_cast(sender()); ++ if (device != nullptr) ++ { ++ if (device->managed()) ++ { ++ } ++ } + reload(); + emit subItemsChanged(); + } + ++// TODO:侧边栏标签显示设备可用或禁用 ++void CPanelNetworkWidget::handleDeviceAdded(const QString &devicePath) ++{ ++ KLOG_DEBUG() << "--------------------DeviceAdded :" << devicePath; ++} ++ + void CPanelNetworkWidget::handleDeviceRemoved(const QString &devicePath) + { +- reload(); +- emit subItemsChanged(); ++ KLOG_DEBUG() << "---------------------DeviceRemoved: " << devicePath; + } + + void CPanelNetworkWidget::reload() + { +- for (int i = 0; i < ui->stackedWidget->count(); ++i) ++ for (int i = 0; i < ui->stackedWidget->count(); i++) + { + auto widget = ui->stackedWidget->widget(i); + ui->stackedWidget->removeWidget(widget); +@@ -255,10 +285,10 @@ void CPanelNetworkWidget::reload() + + QPixmap CPanelNetworkWidget::trayIconColorSwitch(const QString &iconPath) + { +- //icon原本为浅色 ++ // icon原本为浅色 + QIcon icon(iconPath); +- QPixmap pixmap = icon.pixmap(16,16); +- if( Kiran::StylePalette::instance()->paletteType() != Kiran::PALETTE_DARK ) ++ QPixmap pixmap = icon.pixmap(16, 16); ++ if (Kiran::StylePalette::instance()->paletteType() != Kiran::PALETTE_DARK) + { + QImage image = pixmap.toImage(); + image.invertPixels(QImage::InvertRgb); +@@ -272,7 +302,7 @@ void CPanelNetworkWidget::handleThemeChanged(Kiran::PaletteType paletteType) + for (int i = 0; i < ui->sidebar->count(); ++i) + { + auto icon = ui->sidebar->item(i)->icon(); +- QPixmap pixmap = icon.pixmap(16,16); ++ QPixmap pixmap = icon.pixmap(16, 16); + QImage image = pixmap.toImage(); + image.invertPixels(QImage::InvertRgb); + pixmap = QPixmap::fromImage(image); +@@ -283,10 +313,10 @@ void CPanelNetworkWidget::handleThemeChanged(Kiran::PaletteType paletteType) + void CPanelNetworkWidget::handleSideBarItemClicked(QListWidgetItem *item) + { + ui->stackedWidget->setCurrentIndex(item->data(Qt::UserRole).toInt()); +- +- QString itemText = item->text(); +- KLOG_DEBUG() << "item clicked:" << item->text(); +- if(itemText.contains(tr("Wireless Network"))) ++ ++ QString itemText = item->text(); ++ KLOG_DEBUG() << "item clicked:" << item->text(); ++ if (itemText.contains(tr("Wireless Network"))) + { + KLOG_DEBUG() << "item clicked wireless"; + for (auto device : m_wirelessDeviceList) +@@ -305,4 +335,12 @@ void CPanelNetworkWidget::handleSideBarItemClicked(QListWidgetItem *item) + } + } + } ++} ++ ++void CPanelNetworkWidget::handleWirelessEnabledChanged(bool enable) ++{ ++} ++ ++void CPanelNetworkWidget::handleNetworkingEnabledChanged(bool enable) ++{ + } +\ No newline at end of file +diff --git a/plugins/network/src/plugin/cpanel-network-widget.h b/plugins/network/src/plugin/cpanel-network-widget.h +index 112cab8..03c7350 100644 +--- a/plugins/network/src/plugin/cpanel-network-widget.h ++++ b/plugins/network/src/plugin/cpanel-network-widget.h +@@ -15,11 +15,11 @@ + #ifndef KIRAN_CPANEL_NETWORK_CPANEL_NETWORK_WIDGET_H + #define KIRAN_CPANEL_NETWORK_CPANEL_NETWORK_WIDGET_H + +-#include + #include ++#include ++#include + #include "kiran-sidebar-widget.h" + #include "style-palette.h" +-#include + + QT_BEGIN_NAMESPACE + namespace Ui +@@ -51,6 +51,9 @@ public slots: + void handleDeviceRemoved(const QString &devicePath); + void handleThemeChanged(Kiran::PaletteType paletteType); + void handleSideBarItemClicked(QListWidgetItem *item); ++ void handleManagedChanged(); ++ void handleWirelessEnabledChanged(bool enable); ++ void handleNetworkingEnabledChanged(bool enable); + + signals: + void subItemsChanged(); +@@ -63,7 +66,7 @@ private: + + QTimer m_Timer; + QString m_addDevicePath; +- int waitCounts; ++ int m_waitCounts; + }; + +-#endif //KIRAN_CPANEL_NETWORK_CPANEL_NETWORK_WIDGET_H ++#endif // KIRAN_CPANEL_NETWORK_CPANEL_NETWORK_WIDGET_H +diff --git a/plugins/network/src/plugin/details-page.cpp b/plugins/network/src/plugin/details-page.cpp +index a585a68..dfee3f6 100644 +--- a/plugins/network/src/plugin/details-page.cpp ++++ b/plugins/network/src/plugin/details-page.cpp +@@ -58,7 +58,7 @@ void DetailsPage::initUI() + QWidget *widget = new ConnectionDetailsWidget(m_deviceList.at(0), this); + ui->stackedWidget->addWidget(widget); + } +- else if(m_deviceList.count() == 0) ++ else if (m_deviceList.count() == 0) + { + QWidget *widget = new ConnectionDetailsWidget(nullptr, this); + ui->stackedWidget->addWidget(widget); +@@ -105,12 +105,13 @@ void DetailsPage::handleDeviceRemoved(const QString &devicePath) + + void DetailsPage::handleActiveConnectionChanged() + { ++ reload(); + } + + void DetailsPage::handleActiveConnectionAdded(const QString &activeConnectionPath) + { + ActiveConnection::Ptr activeConnection = findActiveConnection(activeConnectionPath); +- connect(activeConnection.data(), &ActiveConnection::stateChanged, this, &DetailsPage::handleActiveConnectionStateChanged); ++ connect(activeConnection.data(), &ActiveConnection::stateChanged, this, &DetailsPage::handleActiveConnectionStateChanged, Qt::UniqueConnection); + } + + void DetailsPage::handleActiveConnectionRemoved(const QString &activeConnectionPath) +diff --git a/plugins/network/src/plugin/manager/vpn-manager.cpp b/plugins/network/src/plugin/manager/vpn-manager.cpp +index 96d6baa..cd858b5 100644 +--- a/plugins/network/src/plugin/manager/vpn-manager.cpp ++++ b/plugins/network/src/plugin/manager/vpn-manager.cpp +@@ -14,17 +14,17 @@ + + #include "vpn-manager.h" + #include ++#include + #include + #include + #include + #include + #include + #include ++#include "connection-name-widget.h" ++#include "status-notification.h" + #include "text-input-dialog.h" + #include "ui_vpn-manager.h" +-#include "status-notification.h" +-#include "connection-name-widget.h" +-#include + using namespace NetworkManager; + + Q_DECLARE_METATYPE(VpnType) +@@ -43,21 +43,20 @@ VpnManager::~VpnManager() + + void VpnManager::initUI() + { +- ui->connectionShowPage->setConnectionType(ConnectionSettings::Vpn); +- ui->connectionShowPage->setItemWidgetType(ITEM_WIDGET_TYPE_PLUGIN); ++ ui->connectionShowPage->init(ConnectionSettings::Vpn, ""); + ui->connectionShowPage->setTitle(tr("VPN")); + ui->connectionShowPage->setSwitchButtonVisible(false); +- ui->connectionShowPage->showConnectionLists(ConnectionSettings::Vpn); + +-// ui->vpnType->addItem(tr("L2TP"), VPN_TYPE_L2TP); ++ // ui->vpnType->addItem(tr("L2TP"), VPN_TYPE_L2TP); + ui->vpnType->addItem(tr("PPTP"), VPN_TYPE_PPTP); +- Kiran::StylePropertyHelper::setButtonType(ui->saveButton,Kiran::BUTTON_Default); ++ Kiran::StylePropertyHelper::setButtonType(ui->saveButton, Kiran::BUTTON_Default); + } + +-//XXX:是否使用模板提升通用性 ++// XXX:是否使用模板提升通用性 + void VpnManager::initConnection() + { +- connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, [=]() { ++ connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, [=]() ++ { + //默认创建vpn类型:L2TP + ui->vpnTypeWidget->setVisible(true); + ui->vpnType->setCurrentIndex(0); +@@ -66,13 +65,13 @@ void VpnManager::initConnection() + + QPointer scrollBar = ui->scrollArea->verticalScrollBar(); + scrollBar->setValue(0); +- ui->stackedWidget->setCurrentIndex(PAGE_SETTING); +- }); ++ ui->stackedWidget->setCurrentIndex(PAGE_SETTING); }); + + connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, this, &VpnManager::handleRequestEditConnection); + connect(ui->connectionShowPage, &ConnectionShowPage::requestActivateCurrentItemConnection, this, &VpnManager::handleRequestActivateConnection); + +- connect(ui->vpnType, QOverload::of(&QComboBox::currentIndexChanged), [=](int index) { ++ connect(ui->vpnType, QOverload::of(&QComboBox::currentIndexChanged), [=](int index) ++ { + VpnType type = ui->vpnType->currentData().value(); + ui->vpnTypeStacked->setCurrentIndex(VPN_TYPE_PPTP); + switch (type) +@@ -85,49 +84,47 @@ void VpnManager::initConnection() + break; + default: + break; +- } +- }); ++ } }); + + connect(ui->returnButton, &QPushButton::clicked, this, &VpnManager::handleReturnPreviousPage); + connect(ui->l2tpSetting, &VpnL2tpSetting::returnPreviousPage, this, &VpnManager::handleReturnPreviousPage); + connect(ui->pptpSetting, &VpnPptpSetting::returnPreviousPage, this, &VpnManager::handleReturnPreviousPage); + +- connect(ui->saveButton, &QPushButton::clicked, [=]() { +- int index = ui->vpnTypeStacked->currentIndex(); +- switch (index) +- { +- case VPN_TYPE_L2TP: +- if(ui->l2tpSetting->isInputValid()) ++ connect(ui->saveButton, &QPushButton::clicked, [=]() + { +- ui->l2tpSetting->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Vpn); +- handleReturnPreviousPage(); +- } +- break; +- case VPN_TYPE_PPTP: +- if(ui->pptpSetting->isInputValid()) ++ int index = ui->vpnTypeStacked->currentIndex(); ++ switch (index) ++ { ++ case VPN_TYPE_L2TP: ++ if(ui->l2tpSetting->isInputValid()) ++ { ++ ui->l2tpSetting->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Vpn); ++ handleReturnPreviousPage(); ++ } ++ break; ++ case VPN_TYPE_PPTP: ++ if(ui->pptpSetting->isInputValid()) ++ { ++ ui->pptpSetting->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Vpn); ++ handleReturnPreviousPage(); ++ } ++ break; ++ default: ++ break; ++ } }); ++ ++ connect(ui->connectionShowPage, &ConnectionShowPage::connectionUpdated, [=](const QString &path) + { +- ui->pptpSetting->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Vpn); +- handleReturnPreviousPage(); +- } +- break; +- default: +- break; +- } +- }); +- +- connect(ui->connectionShowPage,&ConnectionShowPage::connectionUpdated,[=](const QString &path){ +- KLOG_DEBUG() << "Connection::updated:" << path; +- //移除后再加载进来以更新信息 +- ui->connectionShowPage->removeConnectionFromLists(path); +- Connection::Ptr updateConnection = findConnection(path); +- ui->connectionShowPage->addConnectionToLists(updateConnection,""); +- handleReturnPreviousPage(); +- }); ++ KLOG_DEBUG() << "Connection::updated:" << path; ++ //移除后再加载进来以更新信息 ++ ui->connectionShowPage->removeConnectionFromLists(path); ++ Connection::Ptr updateConnection = findConnection(path); ++ ui->connectionShowPage->addConnectionToLists(updateConnection,""); ++ handleReturnPreviousPage(); }); + + initNotifierConnection(); + } + +- + void VpnManager::handleRequestEditConnection(const QString &uuid, QString activeConnectionPath) + { + //隐藏选择VPN类型 +@@ -158,7 +155,7 @@ void VpnManager::handleRequestEditConnection(const QString &uuid, QString active + } + else + { +- //other type ++ // other type + } + + QPointer scrollBar = ui->scrollArea->verticalScrollBar(); +@@ -167,7 +164,7 @@ void VpnManager::handleRequestEditConnection(const QString &uuid, QString active + } + + //考虑弹窗输入密码的情况 +-void VpnManager::handleRequestActivateConnection(const QString &connectionPath,const QString &connectionParameter) ++void VpnManager::handleRequestActivateConnection(const QString &connectionPath, const QString &connectionParameter) + { + Connection::Ptr connection = findConnection(connectionPath); + ConnectionSettings::Ptr settings = connection->settings(); +@@ -190,19 +187,19 @@ void VpnManager::handleRequestActivateConnection(const QString &connectionPath,c + QString tips = QString(tr("Password required to connect to %1.")).arg(settings->id()); + inputDialog.setText(tips); + +- connect(&inputDialog, &TextInputDialog::password, [=](const QString &password) { ++ connect(&inputDialog, &TextInputDialog::password, [=](const QString &password) ++ { + NMStringMap secretsMap = vpnSetting->secrets(); + secretsMap.insert("password", password); + vpnSetting->setSecrets(secretsMap); + activateVPNConnection(connectionPath, connectionParameter); +- connection->clearSecrets(); +- }); ++ connection->clearSecrets(); }); + + inputDialog.exec(); + } + } + +-void VpnManager::activateVPNConnection(const QString &connectionPath,const QString &connectionParameter) ++void VpnManager::activateVPNConnection(const QString &connectionPath, const QString &connectionParameter) + { + QDBusPendingReply reply = + NetworkManager::activateConnection(connectionPath, "", connectionParameter); +@@ -222,11 +219,10 @@ void VpnManager::activateVPNConnection(const QString &connectionPath,const QStri + + void VpnManager::handleNotifierConnectionAdded(const QString &path) + { +- Connection::Ptr connection = findConnection(path); +- if ((connection->settings()->connectionType() == ConnectionSettings::ConnectionType::Vpn) +- && (!connection->name().isEmpty())) ++ Connection::Ptr connection = findConnection(path); ++ if ((connection->settings()->connectionType() == ConnectionSettings::ConnectionType::Vpn) && (!connection->name().isEmpty())) + { +- ui->connectionShowPage->addConnectionToLists(connection,""); ++ ui->connectionShowPage->addConnectionToLists(connection, ""); + } + } + +@@ -238,10 +234,10 @@ void VpnManager::handleNotifierConnectionRemoved(const QString &path) + void VpnManager::handleActiveConnectionAdded(const QString &activePath) + { + ActiveConnection::Ptr activatedConnection = findActiveConnection(activePath); +- if(activatedConnection == nullptr) ++ if (activatedConnection == nullptr) + { + KLOG_DEBUG() << "activatedConnection == nullptr"; +- return ; ++ return; + } + if (activatedConnection->type() == ConnectionSettings::ConnectionType::Vpn) + { +@@ -249,10 +245,9 @@ void VpnManager::handleActiveConnectionAdded(const QString &activePath) + QString uuid = vpnConnection->uuid(); + KLOG_DEBUG() << "vpn uuid:" << uuid; + QListWidgetItem *activeItem = ui->connectionShowPage->findItemByUuid(uuid); +- ui->connectionShowPage->updateItemActivatedPath(activeItem,activePath); +- connect(vpnConnection.data(), &VpnConnection::stateChanged, [=](VpnConnection::State state, VpnConnection::StateChangeReason reason) { +- handleVpnConnectionStateChanged(state, reason, activePath); +- }); ++ ui->connectionShowPage->updateItemActivatedPath(activeItem, activePath); ++ connect(vpnConnection.data(), &VpnConnection::stateChanged, [=](VpnConnection::State state, VpnConnection::StateChangeReason reason) ++ { handleVpnConnectionStateChanged(state, reason, activePath); }); + //加载等待动画 + auto item = ui->connectionShowPage->findItemByActivatedPath(activePath); + ui->connectionShowPage->updateItemActivatingStatus(item); +@@ -263,13 +258,13 @@ void VpnManager::handleActiveConnectionRemoved(const QString &activePath) + { + } + +-//TODO:若没有安装VPN插件则需要提示 ++// TODO:若没有安装VPN插件则需要提示 + void VpnManager::handleVpnConnectionStateChanged(VpnConnection::State state, VpnConnection::StateChangeReason reason, const QString &activePath) + { + auto activeConnection = findActiveConnection(activePath); +- KLOG_DEBUG() << " activeConnection->id():" << activeConnection->id(); ++ KLOG_DEBUG() << " activeConnection->id():" << activeConnection->id(); + QString id = ""; +- if(activeConnection != nullptr) ++ if (activeConnection != nullptr) + id = activeConnection->id(); + switch (state) + { +@@ -294,13 +289,13 @@ void VpnManager::handleVpnConnectionStateChanged(VpnConnection::State state, Vpn + break; + case VpnConnection::State::Failed: + KLOG_DEBUG() << "VpnConnection::State::Failed"; +- if(!id.isEmpty()) ++ if (!id.isEmpty()) + StatusNotification::ActiveConnectionDeactivatedNotify(id); + handleVpnStateFailed(activePath); + break; + case VpnConnection::State::Disconnected: + KLOG_DEBUG() << "VpnConnection::State::Disconnected"; +- if(!id.isEmpty()) ++ if (!id.isEmpty()) + StatusNotification::ActiveConnectionDeactivatedNotify(id); + handleVpnStateDisconnected(activePath); + break; +@@ -354,9 +349,9 @@ void VpnManager::handleVpnConnectionStateChanged(VpnConnection::State state, Vpn + void VpnManager::handleVpnStateActivated(const QString &activePath) + { + ActiveConnection::Ptr activeConnection = findActiveConnection(activePath); +- if(activeConnection.isNull()) +- return ; +- if( activeConnection->type() == ConnectionSettings::Vpn) ++ if (activeConnection.isNull()) ++ return; ++ if (activeConnection->type() == ConnectionSettings::Vpn) + { + ui->connectionShowPage->updateItemActivatedStatus(activePath); + auto item = ui->connectionShowPage->findItemByActivatedPath(activePath); +@@ -398,4 +393,3 @@ void VpnManager::clearVpnSetting() + break; + } + } +- +diff --git a/plugins/network/src/plugin/manager/wired-manager.cpp b/plugins/network/src/plugin/manager/wired-manager.cpp +index dfccd25..cfd11b2 100644 +--- a/plugins/network/src/plugin/manager/wired-manager.cpp ++++ b/plugins/network/src/plugin/manager/wired-manager.cpp +@@ -40,25 +40,22 @@ WiredManager::~WiredManager() + + void WiredManager::initUI() + { +- ui->connectionShowPage->setConnectionType(ConnectionSettings::Wired); +- ui->connectionShowPage->setDevicePath(m_devicePath); +- ui->connectionShowPage->setItemWidgetType(ITEM_WIDGET_TYPE_PLUGIN); ++ ui->connectionShowPage->init(ConnectionSettings::Wired, m_devicePath); + ui->connectionShowPage->setTitle(tr("Wired Network Adapter")); + ui->connectionShowPage->setSwitchButtonVisible(false); +- ui->connectionShowPage->showConnectionLists(ConnectionSettings::ConnectionType::Wired); + Kiran::StylePropertyHelper::setButtonType(ui->saveButton, Kiran::BUTTON_Default); + } + + void WiredManager::initConnection() + { +- connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, [=]() ++ connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, this, [this]() + { + ui->wiredSettingPage->showSettingPage(); + QPointer scrollBar = ui->scrollArea->verticalScrollBar(); + scrollBar->setValue(0); + ui->stackedWidget->setCurrentIndex(PAGE_SETTING); }); + +- connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, [=](const QString &uuid, QString activeConnectionPath) ++ connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, this, [this](const QString &uuid, QString activeConnectionPath) + { + ui->wiredSettingPage->initConnectionSettings(ConnectionSettings::ConnectionType::Wired, uuid); + ui->wiredSettingPage->initSettingPage(); +@@ -73,7 +70,7 @@ void WiredManager::initConnection() + + connect(ui->wiredSettingPage, &WiredSettingPage::returnPreviousPage, this, &WiredManager::handleReturnPreviousPage); + +- connect(ui->connectionShowPage, &ConnectionShowPage::connectionUpdated, this,&WiredManager::handleConnectionUpdated); ++ connect(ui->connectionShowPage, &ConnectionShowPage::connectionUpdated, this, &WiredManager::handleConnectionUpdated); + + connect(ui->connectionShowPage, &ConnectionShowPage::requestActivateCurrentItemConnection, + this, &WiredManager::handleRequestActivateConnection); +diff --git a/plugins/network/src/plugin/manager/wireless-manager.cpp b/plugins/network/src/plugin/manager/wireless-manager.cpp +index 7c2eabb..2596c39 100644 +--- a/plugins/network/src/plugin/manager/wireless-manager.cpp ++++ b/plugins/network/src/plugin/manager/wireless-manager.cpp +@@ -11,6 +11,7 @@ + * + * Author: luoqing + */ ++#include "wireless-manager.h" + #include + #include + #include +@@ -20,7 +21,6 @@ + #include + #include "text-input-dialog.h" + #include "ui_wireless-manager.h" +-#include "wireless-manager.h" + + using namespace NetworkManager; + +@@ -41,14 +41,10 @@ WirelessManager::~WirelessManager() + + void WirelessManager::initUI() + { +- ui->connectionShowPage->setConnectionType(ConnectionSettings::Wireless); +- ui->connectionShowPage->setDevicePath(m_devicePath); +- ui->connectionShowPage->setItemWidgetType(ITEM_WIDGET_TYPE_PLUGIN); ++ ui->connectionShowPage->init(ConnectionSettings::Wireless, m_devicePath); + ui->connectionShowPage->setTitle(tr("Wireless Network Adapter")); +- ui->connectionShowPage->initSwitchButton(); + ui->connectionShowPage->setSwitchButtonVisible(true); + ui->connectionShowPage->setCreateButtonVisible(false); +- ui->connectionShowPage->showWirelessNetworkLists(); + Kiran::StylePropertyHelper::setButtonType(ui->saveButton, Kiran::BUTTON_Default); + + // XXX:由于存在switchButton,所以特别修改一下topMargin +@@ -57,38 +53,38 @@ void WirelessManager::initUI() + + void WirelessManager::initConnection() + { +- connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, [=]() ++ connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, this, [this]() + { +- ui->wirelessSettingPage->showSettingPage(); +- QPointer scrollBar = ui->scrollArea->verticalScrollBar(); +- scrollBar->setValue(0); +- ui->stackedWidget->setCurrentIndex(PAGE_SETTING); }); ++ ui->wirelessSettingPage->showSettingPage(); ++ QPointer scrollBar = ui->scrollArea->verticalScrollBar(); ++ scrollBar->setValue(0); ++ ui->stackedWidget->setCurrentIndex(PAGE_SETTING); }); + +- connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, [=](const QString &uuid, QString activeConnectionPath) ++ connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, this, [this](const QString &uuid, QString activeConnectionPath) + { +- ActiveConnection::Ptr activeConnection = findActiveConnection(activeConnectionPath); +- ConnectionSettings::Ptr connectionSettings = activeConnection->connection()->settings(); +- ui->wirelessSettingPage->setConnection(activeConnection->connection()); +- ui->wirelessSettingPage->setConnectionSettings(connectionSettings); +- ui->wirelessSettingPage->initSettingPage(); +- ui->wirelessSettingPage->showSettingPage(activeConnectionPath); +- QPointer scrollBar = ui->scrollArea->verticalScrollBar(); +- scrollBar->setValue(0); +- ui->stackedWidget->setCurrentIndex(PAGE_SETTING); }); ++ ActiveConnection::Ptr activeConnection = findActiveConnection(activeConnectionPath); ++ ConnectionSettings::Ptr connectionSettings = activeConnection->connection()->settings(); ++ ui->wirelessSettingPage->setConnection(activeConnection->connection()); ++ ui->wirelessSettingPage->setConnectionSettings(connectionSettings); ++ ui->wirelessSettingPage->initSettingPage(); ++ ui->wirelessSettingPage->showSettingPage(activeConnectionPath); ++ QPointer scrollBar = ui->scrollArea->verticalScrollBar(); ++ scrollBar->setValue(0); ++ ui->stackedWidget->setCurrentIndex(PAGE_SETTING); }); + + connect(ui->returnButton, &QPushButton::clicked, this, &WirelessManager::handleReturnPreviousPage); +- connect(ui->saveButton, &QPushButton::clicked, [=]() ++ connect(ui->saveButton, &QPushButton::clicked, this, [this]() + { +- ui->wirelessSettingPage->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Wireless); +- handleReturnPreviousPage(); }); ++ ui->wirelessSettingPage->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Wireless); ++ handleReturnPreviousPage(); }); + + connect(ui->wirelessSettingPage, &WirelessSettingPage::returnPreviousPage, this, &WirelessManager::handleReturnPreviousPage); + // XXX:更改信号 +- connect(ui->wirelessSettingPage, &WirelessSettingPage::settingUpdated, [=]() ++ connect(ui->wirelessSettingPage, &WirelessSettingPage::settingUpdated, this, [this]() + { +- KLOG_DEBUG() << "WiredSettingPage::settingUpdated"; +- handleReturnPreviousPage(); +- refreshConnectionLists(); }); ++ KLOG_DEBUG() << "WiredSettingPage::settingUpdated"; ++ handleReturnPreviousPage(); ++ refreshConnectionLists(); }); + + connect(ui->connectionShowPage, &ConnectionShowPage::requestConnectWirelessNetwork, + this, &WirelessManager::handleRequestConnectWirelessNetwork); +@@ -99,8 +95,8 @@ void WirelessManager::initConnection() + connect(m_wirelessDevice.data(), &WirelessDevice::networkDisappeared, this, &WirelessManager::handleNetworkDisappeared, Qt::QueuedConnection); + connect(m_wirelessDevice.data(), &WirelessDevice::networkAppeared, this, &WirelessManager::handleNetworkAppeared); + +- //Note:插件与托盘都对该设备的信号进行了连接,容易干扰重复,因此,插件暂未实现该函数 +- connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessManager::handleDeviceStateChanged,Qt::UniqueConnection); ++ // Note:插件与托盘都对该设备的信号进行了连接,容易干扰重复,因此,插件暂未实现该函数 ++ connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessManager::handleDeviceStateChanged, Qt::UniqueConnection); + } + + //在已存在WirelessSetting配置的情况下,激活连接.(连接过一次后会创建WirelessSetting配置) +@@ -203,7 +199,7 @@ void WirelessManager::handleActiveConnectionAdded(const QString &path) + auto item = ui->connectionShowPage->item(row); + ui->connectionShowPage->itemSimpleStatus(item); + } +- connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WirelessManager::handleActiveConnectionStateChanged,Qt::UniqueConnection); ++ connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WirelessManager::handleActiveConnectionStateChanged, Qt::UniqueConnection); + } + } + +diff --git a/plugins/network/src/plugin/setting-widget/vpn/vpn-ppp.cpp b/plugins/network/src/plugin/setting-widget/vpn/vpn-ppp.cpp +index c195235..383d3e4 100644 +--- a/plugins/network/src/plugin/setting-widget/vpn/vpn-ppp.cpp ++++ b/plugins/network/src/plugin/setting-widget/vpn/vpn-ppp.cpp +@@ -63,11 +63,11 @@ void VpnPpp::initOptionsButton(const QStringList &supportOptions) + switchButton->setProperty("option", option); + m_optionsButtonMap[option] = switchButton; + +- QHBoxLayout *horizontalLayout = new QHBoxLayout(this); ++ QHBoxLayout *horizontalLayout = new QHBoxLayout(); + horizontalLayout->addWidget(strLabel); + horizontalLayout->addStretch(); + horizontalLayout->addWidget(switchButton); +- horizontalLayout->setContentsMargins(0,0,0,0); ++ horizontalLayout->setContentsMargins(0, 0, 0, 0); + ui->optionsLayout->addLayout(horizontalLayout); + } + else +@@ -156,7 +156,7 @@ void VpnPpp::saveSettings() + m_vpnSetting->setInitialized(true); + } + +-//XXX:优化流程 ++// XXX:优化流程 + void VpnPpp::showSettings() + { + if (m_vpnSetting != nullptr) +diff --git a/plugins/network/src/tray/network-tray.cpp b/plugins/network/src/tray/network-tray.cpp +index 5aeb35d..232882b 100644 +--- a/plugins/network/src/tray/network-tray.cpp ++++ b/plugins/network/src/tray/network-tray.cpp +@@ -74,7 +74,7 @@ void NetworkTray::initConnect() + + // TODO:优化deviceAdded的逻辑 + // 需要等待一段时间,Device::List networkInterfaces() 来不及更新 +- connect(notifier(), &Notifier::deviceAdded, [this](const QString &uni) ++ connect(notifier(), &Notifier::deviceAdded, this, [this](const QString &uni) + { + m_addDevicePath = uni; + Device::Ptr device = findNetworkInterface(m_addDevicePath); +@@ -83,18 +83,17 @@ void NetworkTray::initConnect() + KLOG_DEBUG() << "this device interface is not found"; + return; + } +- +- KLOG_DEBUG() << "device->managed():" << device->managed(); +- if(!device->isValid()) ++ KLOG_DEBUG() << "device->uni():" << device->uni(); ++ KLOG_DEBUG() << "device->interfaceName():" << device->interfaceName(); ++ KLOG_DEBUG() << "device->state():" << device->state(); ++ KLOG_DEBUG() << "device->isValid():" << device->isValid(); ++ if(device->isValid()) + { +- KLOG_INFO() << "this device interface is invalid!"; +- return ; +- } +- if(device->managed()) + handleDeviceAdded(m_addDevicePath); ++ } + else + { +- KLOG_INFO() << "this device interface is not ready"; ++ KLOG_INFO() << "this device interface is invalid!"; + m_Timer.start(); + KLOG_INFO() << "wait counts:" << m_waitCounts; + } }); +@@ -102,7 +101,7 @@ void NetworkTray::initConnect() + m_Timer.setInterval(500); + m_Timer.setSingleShot(true); + m_waitCounts = 1; +- connect(&m_Timer, &QTimer::timeout, [this]() ++ connect(&m_Timer, &QTimer::timeout, this, [this]() + { + Device::Ptr device = findNetworkInterface(m_addDevicePath); + if(device.isNull()) +@@ -132,6 +131,8 @@ void NetworkTray::initConnect() + + connect(notifier(), &Notifier::primaryConnectionChanged, this, &NetworkTray::handlePrimaryConnectionChanged); + ++ connect(notifier(), &Notifier::wirelessEnabledChanged, this, &NetworkTray::handleWirelessEnabledChanged, Qt::UniqueConnection); ++ + // 无线网络如果一下消失多个网络,短时间会触发多次SizeHint变更的信号 + m_wirelessTimer.setInterval(100); + m_wirelessTimer.setSingleShot(true); +@@ -184,8 +185,8 @@ void NetworkTray::getAvailableDeviceList() + for (Device::Ptr dev : deviceList) + { + KLOG_DEBUG() << "dev->interfaceName():" << dev->interfaceName(); +- KLOG_DEBUG() << "dev->availableConnections():" << dev->availableConnections(); + KLOG_DEBUG() << "dev->state():" << dev->state(); ++ KLOG_DEBUG() << "dev->isValid():" << dev->isValid(); + + if (dev->state() == Device::Unavailable) + continue; +@@ -295,103 +296,50 @@ void NetworkTray::getTrayGeometry() + // TODO:增加其他状态图标 + void NetworkTray::setTrayIcon(NetworkManager::Status status) + { +- // 判断主连接类型,托盘网络图标以主连接类型为准 +- // NetworkManager::primaryConnectionType() 更新不及时,暂时不用 +- ActiveConnection::Ptr primaryActiveConnection = primaryConnection(); +- if (primaryActiveConnection != nullptr) ++ if (status == NetworkManager::Status::Connected) + { +- auto primaryConnectionType = primaryActiveConnection->connection()->settings()->connectionType(); +- if (primaryConnectionType == ConnectionSettings::Wireless) ++ // 判断主连接类型,托盘网络图标以主连接类型为准 ++ // NetworkManager::primaryConnectionType() 更新不及时,暂时不用 ++ ActiveConnection::Ptr primaryActiveConnection = primaryConnection(); ++ if (primaryActiveConnection != nullptr) + { +- // ActiveConnection::Ptr primaryActiveConnection = primaryConnection(); +- // WirelessSetting::Ptr wirelessSetting = primaryActiveConnection->connection()->settings()->setting(Setting::Wireless).dynamicCast(); +- // QString ssid = QString(wirelessSetting->ssid()); ++ auto primaryConnectionType = primaryActiveConnection->connection()->settings()->connectionType(); ++ if (primaryConnectionType == ConnectionSettings::Wireless) ++ { ++ // ActiveConnection::Ptr primaryActiveConnection = primaryConnection(); ++ // WirelessSetting::Ptr wirelessSetting = primaryActiveConnection->connection()->settings()->setting(Setting::Wireless).dynamicCast(); ++ // QString ssid = QString(wirelessSetting->ssid()); + +- // QString devicePath = primaryActiveConnection->devices().value(0); +- // Device::Ptr device = findNetworkInterface(devicePath); +- // WirelessDevice::Ptr wirelessDevice = qobject_cast(device); +- // WirelessNetwork::Ptr wirelessNetwork = wirelessDevice->findNetwork(ssid); +- // int signalStrength = wirelessNetwork->signalStrength(); ++ // QString devicePath = primaryActiveConnection->devices().value(0); ++ // Device::Ptr device = findNetworkInterface(devicePath); ++ // WirelessDevice::Ptr wirelessDevice = qobject_cast(device); ++ // WirelessNetwork::Ptr wirelessNetwork = wirelessDevice->findNetwork(ssid); ++ // int signalStrength = wirelessNetwork->signalStrength(); + +- switch (status) +- { +- case NetworkManager::Status::Unknown: +- // 未知 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- break; +- case NetworkManager::Status::Asleep: +- // 不可用 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- break; +- case NetworkManager::Status::Disconnected: +- // 不可用 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- break; +- case NetworkManager::Status::Disconnecting: +- break; +- case NetworkManager::Status::Connecting: +- // 加载动画 +- break; +- case NetworkManager::Status::ConnectedLinkLocal: +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- // 不可用 +- break; +- case NetworkManager::Status::ConnectedSiteOnly: +- // 未知 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- break; +- case NetworkManager::Status::Connected: +- // 可用 + m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wireless-4.svg")); +- break; +- default: +- break; + } + } + else + { +- switch (status) +- { +- case NetworkManager::Status::Unknown: +- // 未知 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- break; +- case NetworkManager::Status::Asleep: +- // 不可用 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- break; +- case NetworkManager::Status::Disconnected: +- // 不可用 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- break; +- case NetworkManager::Status::Disconnecting: +- break; +- case NetworkManager::Status::Connecting: +- // 加载动画 +- break; +- case NetworkManager::Status::ConnectedLinkLocal: +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- // 不可用 +- break; +- case NetworkManager::Status::ConnectedSiteOnly: +- // 未知 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); +- break; +- case NetworkManager::Status::Connected: +- // 可用 +- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-connection.svg")); +- break; +- default: +- break; +- } ++ // 可用 ++ m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-connection.svg")); + } + } ++ else if (status == NetworkManager::Status::Disconnecting || NetworkManager::Status::Connecting) ++ { ++ // TODO:加载动画 ++ } ++ else ++ { ++ m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg")); ++ } + } + + // 重新获取device、初始化,刷新 + // XXX:可以优化 + void NetworkTray::handleDeviceAdded(const QString &devicePath) + { ++ KLOG_DEBUG() << "---------------------handleDeviceAdded:" << devicePath; + Device::Ptr device = findNetworkInterface(devicePath); + if (device->type() == Device::Ethernet) + { +@@ -406,6 +354,7 @@ void NetworkTray::handleDeviceAdded(const QString &devicePath) + // XXX:当device被移除时,由于设备对象可能已经被删除,所以并不能通过findNetworkInterface(path)找到该设备接口,进而知道被删除的设备类型 + void NetworkTray::handleDeviceRemoved(const QString &devicePath) + { ++ KLOG_DEBUG() << "handle Device Removed :" << devicePath; + if (m_wiredTrayPage != nullptr) + { + if (m_wiredTrayPage->devicePathList().contains(devicePath)) +@@ -424,12 +373,76 @@ void NetworkTray::handleDeviceStateChanged(NetworkManager::Device::State newstat + NetworkManager::Device::State oldstate, + NetworkManager::Device::StateChangeReason reason) + { ++ if ((oldstate == Device::Unavailable) && ++ (newstate != Device::Unmanaged && newstate != Device::UnknownState)) ++ { ++ } ++ ++ if (newstate == Device::State::Unavailable) ++ { ++ Device *device = qobject_cast(sender()); ++ // KLOG_DEBUG() << "Device::State::Unavailable"; ++ // KLOG_DEBUG() << "device->uni():" << device->uni(); ++ // KLOG_DEBUG() << "device->interfaceName():" << device->interfaceName(); ++ } + } + + void NetworkTray::handleDeviceManagedChanged() + { + } + ++// TODO:托盘对不可用状态进行提示 ++/** ++ * XXX:由于在禁用和开启wifi时,并没有发出Wireless设备的deviceRemoved和deviceAdded信号 ++ * 并且当WirelessEnabledChanged信号发送时,device state 还处在unavailbel 不可用状态,需要处理 ++ */ ++ ++// TODO:托盘对不可用状态进行提示 ++void NetworkTray::handleWirelessEnabledChanged(bool enable) ++{ ++ KLOG_DEBUG() << "-----------------------handleWirelessEnabledChanged:" << enable; ++ ++ if (m_wirelessTrayPage != nullptr) ++ { ++ m_verticalLayout->removeWidget(m_wirelessTrayPage); ++ delete m_wirelessTrayPage; ++ m_wirelessTrayPage = nullptr; ++ } ++ m_wirelessDeviceList.clear(); ++ ++ if (enable) ++ { ++ // networkInterfaces() 是否及时更新,需验证 ++ const Device::List deviceList = networkInterfaces(); ++ for (Device::Ptr dev : deviceList) ++ { ++ KLOG_DEBUG() << "dev->interfaceName():" << dev->interfaceName(); ++ KLOG_DEBUG() << "dev->state():" << dev->state(); ++ KLOG_DEBUG() << "dev->isValid():" << dev->isValid(); ++ ++ if ((dev->state() == Device::Unmanaged) || (dev->state() == Device::UnknownState)) ++ continue; ++ ++ if (dev->type() == Device::Wifi) ++ { ++ // Note:此时WirelessDevice状态还处在Unavailable,但还是将该设备加载 ++ if (dev->state() == Device::Unavailable) ++ { ++ } ++ m_wirelessDeviceList << dev; ++ } ++ } ++ ++ if (m_wirelessDeviceList.count() != 0) ++ { ++ m_wirelessTrayPage = new TrayPage(m_wirelessDeviceList, this); ++ m_verticalLayout->insertWidget(-1, m_wirelessTrayPage); ++ m_verticalLayout->setMargin(0); ++ update(); ++ } ++ } ++} ++ + void NetworkTray::handleNetworkManagerStatusChanged(NetworkManager::Status status) + { + setTrayIcon(status); +@@ -446,14 +459,15 @@ void NetworkTray::reloadWiredTrayPage() + delete m_wiredTrayPage; + m_wiredTrayPage = nullptr; + m_wiredDeviceList.clear(); ++ + getAvailableDeviceList(); + if (m_wiredDeviceList.count() != 0) ++ { + m_wiredTrayPage = new TrayPage(m_wiredDeviceList, this); +- +- // XXX:待修改,使有线widget一直在最上层 +- m_verticalLayout->insertWidget(0, m_wiredTrayPage); +- m_verticalLayout->setMargin(0); +- update(); ++ m_verticalLayout->insertWidget(0, m_wiredTrayPage); ++ m_verticalLayout->setMargin(0); ++ update(); ++ } + } + + void NetworkTray::reloadWirelessTrayPage() +@@ -465,10 +479,12 @@ void NetworkTray::reloadWirelessTrayPage() + + getAvailableDeviceList(); + if (m_wirelessDeviceList.count() != 0) ++ { + m_wirelessTrayPage = new TrayPage(m_wirelessDeviceList, this); +- m_verticalLayout->insertWidget(-1, m_wirelessTrayPage); +- m_verticalLayout->setMargin(0); +- update(); ++ m_verticalLayout->insertWidget(-1, m_wirelessTrayPage); ++ m_verticalLayout->setMargin(0); ++ update(); ++ } + } + + void NetworkTray::handleAdjustedTraySize(QSize sizeHint) +@@ -476,8 +492,8 @@ void NetworkTray::handleAdjustedTraySize(QSize sizeHint) + // this->sizeHint() 更新不及时,需要等一段时间 + QTimer::singleShot(100, this, [=]() + { +- adjustSize(); +- setTrayPagePos(); }); ++ adjustSize(); ++ setTrayPagePos(); }); + } + + void NetworkTray::handleThemeChanged(Kiran::PaletteType paletteType) +diff --git a/plugins/network/src/tray/network-tray.h b/plugins/network/src/tray/network-tray.h +index 7601e4f..23a0a9b 100644 +--- a/plugins/network/src/tray/network-tray.h ++++ b/plugins/network/src/tray/network-tray.h +@@ -23,7 +23,6 @@ + #include + #include "kiran-rounded-tray-popup/kiran-rounded-tray-popup.h" + +- + class WiredTrayWidget; + class WirelessTrayWidget; + class StatusNotifierManagerInterface; +@@ -65,6 +64,7 @@ public slots: + NetworkManager::Device::State oldstate, + NetworkManager::Device::StateChangeReason reason); + void handleDeviceManagedChanged(); ++ void handleWirelessEnabledChanged(bool enable); + + void handleAdjustedTraySize(QSize sizeHint); + +diff --git a/plugins/network/src/tray/tray-page.cpp b/plugins/network/src/tray/tray-page.cpp +index 7415dc8..c854d36 100644 +--- a/plugins/network/src/tray/tray-page.cpp ++++ b/plugins/network/src/tray/tray-page.cpp +@@ -33,11 +33,15 @@ TrayPage::~TrayPage() + + void TrayPage::init() + { +- Device::Type deviceType = m_deviceList.at(0)->type(); +- initUI(deviceType); +- initConnection(); ++ if (m_deviceList.count() != 0) ++ { ++ Device::Type deviceType = m_deviceList.value(0)->type(); ++ initUI(deviceType); ++ initConnection(); ++ } + } + ++// XXX:修改初始化 + void TrayPage::initUI(Device::Type deviceType) + { + setFixedWidth(240); +@@ -50,7 +54,7 @@ void TrayPage::initUI(Device::Type deviceType) + // { + // setSingleDeviceWidget(deviceType); + // } +- if(m_deviceList.count() != 0) ++ if (m_deviceList.count() != 0) + { + setMultiDeviceWidget(deviceType); + } +@@ -133,12 +137,9 @@ void TrayPage::handleDeviceComboBoxChanged(int index) + QStringList TrayPage::devicePathList() + { + QStringList devicePathList; +- KLOG_DEBUG() << "m_deviceList:" << m_deviceList; + for (Device::Ptr device : m_deviceList) + { +- if (device == nullptr) +- KLOG_DEBUG() << "device == nullptr"; +- else ++ if (device != nullptr) + devicePathList << device->uni(); + } + KLOG_DEBUG() << "devicePathList:" << devicePathList; +diff --git a/plugins/network/src/tray/wireless-tray-widget.cpp b/plugins/network/src/tray/wireless-tray-widget.cpp +index 2a480b1..32a9791 100644 +--- a/plugins/network/src/tray/wireless-tray-widget.cpp ++++ b/plugins/network/src/tray/wireless-tray-widget.cpp +@@ -43,10 +43,9 @@ void WirelessTrayWidget::init() + initUI(); + initConnection(); + +- ActiveConnection::Ptr activatedConnection = m_wirelessDevice->activeConnection(); +- if(!activatedConnection.isNull()) ++ ActiveConnection::Ptr activatedConnection = m_wirelessDevice->activeConnection(); ++ if (!activatedConnection.isNull()) + connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WirelessTrayWidget::handleActiveConnectionStateChanged, Qt::UniqueConnection); +- + } + + void WirelessTrayWidget::initUI() +@@ -70,7 +69,7 @@ void WirelessTrayWidget::initConnection() + connect(m_connectionLists, &ConnectionLists::sendPasswordToWirelessSetting, this, &WirelessTrayWidget::setSecurityPskAndActivateWirelessConnection); + connect(m_connectionLists, &ConnectionLists::sendSsidToWireless, this, &WirelessTrayWidget::handleRequestConnectHiddenNetwork); + +- connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessTrayWidget::handleDeviceStateChanged,Qt::UniqueConnection); ++ connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessTrayWidget::handleDeviceStateChanged, Qt::UniqueConnection); + connect(m_connectionLists, &ConnectionLists::adjustedTraySize, this, &WirelessTrayWidget::adjustedTraySize); + } + +@@ -110,7 +109,7 @@ void WirelessTrayWidget::handleRequestConnectHiddenNetwork(const QString &ssid) + { + KLOG_DEBUG() << "Hidden networks have been explicitly detected,return"; + StatusNotification::connectitonHiddenNetworkFailedNotify(ssid); +- ++ + QListWidgetItem *item = m_connectionLists->getHiddenNetworkItem(); + m_connectionLists->itemSimpleStatus(item); + return; +@@ -148,7 +147,7 @@ void WirelessTrayWidget::getWirelessAvailableConnections(const QString &devicePa + } + + // 在已存在WirelessSetting配置的情况下,激活连接.(连接过一次后会创建WirelessSetting配置) +-//Note:不存在的无线网络或者配置,能activate成功,但是返回的ActivateConnection可能会空,从而导致错误 ++// Note:不存在的无线网络或者配置,能activate成功,但是返回的ActivateConnection可能会空,从而导致错误 + void WirelessTrayWidget::activateWirelessConnection(const QString &connectionPath, const QString &devicePath, const QString &accessPointPath) + { + if (!connectionPath.isEmpty()) +@@ -164,7 +163,7 @@ void WirelessTrayWidget::activateWirelessConnection(const QString &connectionPat + StatusNotification::connectitonFailedNotify(connectionPath); + } + else +- KLOG_DEBUG() << "reply.reply():" << reply.reply(); ++ KLOG_DEBUG() << "reply.reply():" << reply.reply(); + } + } + +@@ -226,13 +225,13 @@ void WirelessTrayWidget::createConnectionSettings(const QString &ssid, const QSt + } + } + +-//Note:不存在的无线网络或者配置,activate成功,但是返回的ActivateConnection可能会空,从而导致错误 ++// Note:不存在的无线网络或者配置,activate成功,但是返回的ActivateConnection可能会空,从而导致错误 + void WirelessTrayWidget::addAndActivateWirelessConnection(ConnectionSettings::Ptr connectionSettings) + { + const QString ssid = m_connectionInfo.wirelessInfo.ssid; + const QString accessPointPath = m_connectionInfo.wirelessInfo.accessPointPath; + KLOG_DEBUG() << "accessPointPath" << accessPointPath; +- KLOG_DEBUG() << "wireless device path:" << m_devicePath; ++ KLOG_DEBUG() << "wireless device path:" << m_devicePath; + QDBusPendingReply reply = + NetworkManager::addAndActivateConnection(connectionSettings->toMap(), m_devicePath, accessPointPath); + +@@ -260,9 +259,9 @@ void WirelessTrayWidget::handleRequestDisconnect(const QString &activatedConnect + } + + /*FIX: +-*由于ActiveConnection为空,暂时无法获得有效的连接信息 +-*存在多个网卡时,由于无法确定是那个该ActiveConnection来自那个设备,则多个设备都会发送通知 +-*/ ++ *由于ActiveConnection为空,暂时无法获得有效的连接信息 ++ *存在多个网卡时,由于无法确定是那个该ActiveConnection来自那个设备,则多个设备都会发送通知 ++ */ + void WirelessTrayWidget::handleActiveConnectionAdded(const QString &path) + { + //多个网卡,还需要判断设备 +@@ -270,12 +269,12 @@ void WirelessTrayWidget::handleActiveConnectionAdded(const QString &path) + ActiveConnection::Ptr activatedConnection = findActiveConnection(path); + if (activatedConnection == nullptr) + { +- //Note:目前已知连接一个不存在的无线网络时,activatedConnection为空 ++ // Note:目前已知连接一个不存在的无线网络时,activatedConnection为空 + StatusNotification::connectitonFailedNotify(); + KLOG_DEBUG() << "new add activatedConnection is nullptr"; + return; + } +- ++ + QStringList deviceList = activatedConnection->devices(); + if ((activatedConnection->type() == ConnectionSettings::ConnectionType::Wireless) && deviceList.contains(m_devicePath)) + { +@@ -296,7 +295,7 @@ void WirelessTrayWidget::handleActiveConnectionAdded(const QString &path) + m_connectionLists->itemSimpleStatus(item); + } + connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WirelessTrayWidget::handleActiveConnectionStateChanged, Qt::UniqueConnection); +- } ++ } + } + + void WirelessTrayWidget::handleActiveConnectionRemoved(const QString &path) +@@ -310,7 +309,7 @@ void WirelessTrayWidget::handleStateActivating(const QString &activatedPath) + ActiveConnection::Ptr activatedConnection = findActiveConnection(activatedPath); + if (activatedConnection == nullptr) + { +- //Note:目前已知连接一个不存在的无线网络时,activatedConnection为空 ++ // Note:目前已知连接一个不存在的无线网络时,activatedConnection为空 + StatusNotification::connectitonFailedNotify(); + KLOG_DEBUG() << "activatedConnection == nullptr"; + return; +@@ -357,7 +356,6 @@ void WirelessTrayWidget::handleStateActivated(const QString &activatedPath) + //连接成功后手动rescan + QDBusPendingReply<> replyRequestScan = m_wirelessDevice->requestScan(); + replyRequestScan.waitForFinished(); +- KLOG_DEBUG() << "--------------------------StateActivated requestScan"; + if (replyRequestScan.isError()) + { + KLOG_DEBUG() << "StateActivated requestScan error:" << replyRequestScan.error(); +@@ -447,8 +445,7 @@ void WirelessTrayWidget::handleRequestIgnore(const QString &activatedConnectionP + QDBusPendingReply<> replyRemove = connection->remove(); + replyRemove.waitForFinished(); + if (replyRemove.isError()) +- KLOG_INFO() << "Remove connection failed:" << replyRemove.error(); +- }); ++ KLOG_INFO() << "Remove connection failed:" << replyRemove.error(); }); + } + + void WirelessTrayWidget::setSecurityPskAndActivateWirelessConnection(const QString &password) +-- +2.33.0 + diff --git a/0003-fix-network-fix-the-problem-of-network-and-details-c.patch b/0003-fix-network-fix-the-problem-of-network-and-details-c.patch new file mode 100644 index 0000000..8e6cf40 --- /dev/null +++ b/0003-fix-network-fix-the-problem-of-network-and-details-c.patch @@ -0,0 +1,66 @@ +From 50c2ccba7af88dfe335a5dfdeff54e4371238316 Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Fri, 19 Aug 2022 15:24:13 +0800 +Subject: [PATCH 3/7] fix(network):fix the problem of network and details + corresponding error +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 修复网络详情页面中网络与详情对应错误 + +Close #I5M0L9 +--- + plugins/network/src/plugin/details-page.cpp | 10 ++++++---- + plugins/network/src/plugin/details-page.h | 2 +- + 2 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/plugins/network/src/plugin/details-page.cpp b/plugins/network/src/plugin/details-page.cpp +index dfee3f6..5ba4d12 100644 +--- a/plugins/network/src/plugin/details-page.cpp ++++ b/plugins/network/src/plugin/details-page.cpp +@@ -75,11 +75,11 @@ void DetailsPage::initMultiConnectionDetailsWidget() + QWidget *widget = new ConnectionDetailsWidget(device, this); + ui->stackedWidget->addWidget(widget); + } +- connect(ui->activatedConnectionComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, +- &DetailsPage::handleActivatedConnectionComboBoxChanged); ++ connect(ui->activatedConnectionComboBox, QOverload::of(&QComboBox::activated), this, ++ &DetailsPage::handleActivatedConnectionComboBoxActivated, Qt::UniqueConnection); + } + +-void DetailsPage::handleActivatedConnectionComboBoxChanged(int index) ++void DetailsPage::handleActivatedConnectionComboBoxActivated(int index) + { + ui->stackedWidget->setCurrentIndex(index); + } +@@ -131,10 +131,12 @@ void DetailsPage::clear() + { + m_deviceList.clear(); + ui->activatedConnectionComboBox->clear(); +- for (int i = 0; i < ui->stackedWidget->count(); ++i) ++ int count = ui->stackedWidget->count(); ++ for (int i = 0; i < count; i++) + { + QWidget *widget = ui->stackedWidget->currentWidget(); + ui->stackedWidget->removeWidget(widget); ++ widget->deleteLater(); + } + } + +diff --git a/plugins/network/src/plugin/details-page.h b/plugins/network/src/plugin/details-page.h +index e7cb744..f0cceb1 100644 +--- a/plugins/network/src/plugin/details-page.h ++++ b/plugins/network/src/plugin/details-page.h +@@ -39,7 +39,7 @@ public: + void reload(); + + public slots: +- void handleActivatedConnectionComboBoxChanged(int index); ++ void handleActivatedConnectionComboBoxActivated(int index); + void handleDeviceAdded(const QString &devicePath); + void handleDeviceRemoved(const QString &devicePath); + void handleActiveConnectionAdded(const QString &activeConnectionPath); +-- +2.33.0 + diff --git a/0004-fix-network-Add-error-prompt-box-when-saving-configu.patch b/0004-fix-network-Add-error-prompt-box-when-saving-configu.patch new file mode 100644 index 0000000..823d6ff --- /dev/null +++ b/0004-fix-network-Add-error-prompt-box-when-saving-configu.patch @@ -0,0 +1,532 @@ +From 4b63a44d04c18418076fe7570887e601b499671c Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Tue, 23 Aug 2022 09:19:05 +0800 +Subject: [PATCH 4/7] fix(network):Add error prompt box when saving + configuration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 保存配置时,增加错误提示框 + +Close #I5GYQD +--- + .../src/plugin/manager/wired-manager.cpp | 2 + + .../setting-widget/connection-name-widget.cpp | 16 ++- + .../plugin/setting-widget/ethernet-widget.cpp | 27 +++-- + .../src/plugin/setting-widget/ipv4-widget.cpp | 105 ++++++++++++++---- + .../src/plugin/setting-widget/ipv6-widget.cpp | 62 +++++++++-- + .../src/plugin/settings/setting-page.cpp | 10 +- + .../plugin/settings/wired-setting-page.cpp | 7 +- + 7 files changed, 180 insertions(+), 49 deletions(-) + +diff --git a/plugins/network/src/plugin/manager/wired-manager.cpp b/plugins/network/src/plugin/manager/wired-manager.cpp +index cfd11b2..9ceeb89 100644 +--- a/plugins/network/src/plugin/manager/wired-manager.cpp ++++ b/plugins/network/src/plugin/manager/wired-manager.cpp +@@ -180,7 +180,9 @@ void WiredManager::handleSaveButtonClicked() + handleReturnPreviousPage(); + } + else ++ { + KLOG_DEBUG() << "Invalid input exists"; ++ } + } + + void WiredManager::handleConnectionUpdated(const QString &path) +diff --git a/plugins/network/src/plugin/setting-widget/connection-name-widget.cpp b/plugins/network/src/plugin/setting-widget/connection-name-widget.cpp +index 71b3626..5ee8b62 100644 +--- a/plugins/network/src/plugin/setting-widget/connection-name-widget.cpp ++++ b/plugins/network/src/plugin/setting-widget/connection-name-widget.cpp +@@ -13,6 +13,7 @@ + */ + + #include "connection-name-widget.h" ++#include + #include + #include + #include +@@ -82,7 +83,7 @@ void ConnectionNameWidget::showSettings(ConnectionSettings::ConnectionType conne + } + else if (m_connectionType == ConnectionSettings::Wireless) + { +- if(m_connectionSettings != nullptr) ++ if (m_connectionSettings != nullptr) + { + WirelessSetting::Ptr wirelessSetting = m_connectionSettings->setting(Setting::Wireless).dynamicCast(); + ui->connectionName->setText(wirelessSetting->ssid()); +@@ -91,8 +92,8 @@ void ConnectionNameWidget::showSettings(ConnectionSettings::ConnectionType conne + } + else + { +-// ui->connectionName->setEnabled(true); +-// m_autoConnection->setChecked(true); ++ // ui->connectionName->setEnabled(true); ++ // m_autoConnection->setChecked(true); + } + } + } +@@ -173,11 +174,16 @@ void ConnectionNameWidget::clearPtr() + + bool ConnectionNameWidget::isInputValid() + { +- bool valid = true; + QString nameStr = ui->connectionName->text(); + if (nameStr.isEmpty()) + { ++ QString error = QString(tr("Connection name can not be empty")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ ++ KLOG_DEBUG() << "Connection name cannot be empty"; + return false; + } +- return valid; ++ return true; + } +\ No newline at end of file +diff --git a/plugins/network/src/plugin/setting-widget/ethernet-widget.cpp b/plugins/network/src/plugin/setting-widget/ethernet-widget.cpp +index 55c5cd8..ae43125 100644 +--- a/plugins/network/src/plugin/setting-widget/ethernet-widget.cpp ++++ b/plugins/network/src/plugin/setting-widget/ethernet-widget.cpp +@@ -13,11 +13,13 @@ + */ + + #include "ethernet-widget.h" ++#include + #include + #include + #include + #include + #include "ui_ethernet-widget.h" ++ + using namespace NetworkManager; + + EthernetWidget::EthernetWidget(QWidget *parent) : QWidget(parent), ui(new Ui::EthernetWidget) +@@ -38,7 +40,7 @@ void EthernetWidget::initUI() + ui->customMTU->setVisible(false); + ui->customMTU->setMinimum(0); + ui->customMTU->setMaximum(10000); +- //UserData设为空"",为了匹配Mac地址为空的情况 ++ // UserData设为空"",为了匹配Mac地址为空的情况 + ui->deviceMac->addItem(tr("No device specified"), ""); + initEthernetMacComboBox(); + } +@@ -75,7 +77,7 @@ void EthernetWidget::setWiredSetting(const WiredSetting::Ptr &wiredSetting) + + void EthernetWidget::saveSettings() + { +- if(m_wiredSetting != nullptr) ++ if (m_wiredSetting != nullptr) + { + QString macAddress = ui->deviceMac->currentData().toString(); + QString cloneMac = ui->cloneDeviceMac->text(); +@@ -89,7 +91,7 @@ void EthernetWidget::saveSettings() + + void EthernetWidget::showSettings() + { +- if(m_wiredSetting != nullptr) ++ if (m_wiredSetting != nullptr) + { + QString deviceMac = m_wiredSetting->macAddress().toHex(':').toUpper(); + QString cloneDeviceMac = m_wiredSetting->clonedMacAddress().toHex(':').toUpper(); +@@ -132,15 +134,26 @@ void EthernetWidget::clearPtr() + + bool EthernetWidget::isInputValid() + { +- isCloneMacValid(ui->cloneDeviceMac->text()); +- return false; ++ if (!isCloneMacValid(ui->cloneDeviceMac->text())) ++ { ++ QString error = QString(tr("Clone Mac invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ ++ KLOG_DEBUG() << "Clone Mac invalid"; ++ return false; ++ } ++ return true; + } + + bool EthernetWidget::isCloneMacValid(const QString &cloneMac) + { +- if (cloneMac.isEmpty()) { ++ if (cloneMac.isEmpty()) ++ { + return true; + } +- bool matched = QRegExp("^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$").exactMatch(cloneMac); ++ bool matched = QRegExp("^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$").exactMatch(cloneMac); ++ + return matched; + } +diff --git a/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp b/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp +index 30f7844..7f28576 100644 +--- a/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp ++++ b/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp +@@ -13,6 +13,7 @@ + */ + + #include "ipv4-widget.h" ++#include + #include + #include + #include "ui_ipv4-widget.h" +@@ -65,7 +66,6 @@ void Ipv4Widget::setIpv4Setting(const Ipv4Setting::Ptr &ipv4Setting) + m_ipv4Setting = ipv4Setting; + } + +-// TODO:错误提示弹窗 + void Ipv4Widget::saveSettings() + { + if (m_ipv4Setting != nullptr) +@@ -85,7 +85,6 @@ void Ipv4Widget::saveSettings() + m_ipv4Setting->setMethod(method); + + ipv4Address.setIp(QHostAddress(ui->ipv4Address->text())); +- // XXX:输入合法性检测 + QString netMask = ui->ipv4Netmask->text(); + if (!netMask.contains(".")) + { +@@ -134,8 +133,11 @@ void Ipv4Widget::showSettings() + { + if (m_ipv4Setting != nullptr) + { ++ KLOG_DEBUG() << "m_ipv4Setting->method():" << m_ipv4Setting->method(); ++ + if (m_ipv4Setting->method() == Ipv4Setting::ConfigMethod::Automatic) + { ++ KLOG_DEBUG() << "Ipv4Setting::ConfigMethod::Automatic"; + resetSettings(); + } + else if (m_ipv4Setting->method() == Ipv4Setting::ConfigMethod::Manual) +@@ -143,11 +145,15 @@ void Ipv4Widget::showSettings() + int ipv4MethodIndex = ui->ipv4Method->findData(m_ipv4Setting->method()); + ui->ipv4Method->setCurrentIndex(ipv4MethodIndex); + // xxx:取addresses的方式有待改进 +- IpAddress ipv4Address = m_ipv4Setting->addresses().at(0); ++ IpAddress ipv4Address = m_ipv4Setting->addresses().value(0); + QString address = ipv4Address.ip().toString(); + QString netmask = ipv4Address.netmask().toString(); + QString gateway = ipv4Address.gateway().toString(); + ++ KLOG_DEBUG() << "address:" << address; ++ KLOG_DEBUG() << "netmask:" << netmask; ++ KLOG_DEBUG() << "gateway:" << gateway; ++ + ui->ipv4Address->setText(address); + ui->ipv4Netmask->setText(netmask); + ui->ipv4Gateway->setText(gateway); +@@ -188,57 +194,108 @@ void Ipv4Widget::clearPtr() + } + + // TODO:验证功能待完善 ++// XXX:输入验证提示暂时先用弹框,之后修改 + bool Ipv4Widget::isInputValid() + { + Ipv4Setting::ConfigMethod configMethod = ui->ipv4Method->currentData().value(); +- bool valid = true; ++ + if (configMethod == Ipv4Setting::ConfigMethod::Automatic) + { +- isIpv4AddressValid(ui->ipv4PreferredDNS->text()); +- isIpv4AddressValid(ui->ipv4AlternateDNS->text()); + } + else if (configMethod == Ipv4Setting::ConfigMethod::Manual) + { +- QString ipv4 = ui->ipv4Address->text(); +- QString netMask = ui->ipv4Netmask->text(); ++ QString ipv4 = ui->ipv4Address->text(); ++ QString netMask = ui->ipv4Netmask->text(); ++ QString ipv4Gateway = ui->ipv4Gateway->text(); + + if (ipv4.isEmpty()) + { +- valid = false; +- KLOG_DEBUG() << "Ipv4 address cannot be empty"; ++ QString error = QString(tr("Ipv4 address can not be empty")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ ++ KLOG_DEBUG() << "Ipv4 address can not be empty"; ++ return false; + } + else + { +- if(!isIpv4AddressValid(ipv4)) ++ if (!isIpv4AddressValid(ipv4)) + { +- valid = false; +- KLOG_DEBUG() << "Ipv4Address invalid"; ++ QString error = QString(tr("Ipv4 Address invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Ipv4 Address invalid"; ++ return false; + } + } +- ++ + if (netMask.isEmpty()) + { +- valid = false; ++ QString error = QString(tr("NetMask can not be empty")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); + KLOG_DEBUG() << "NetMask cannot be empty"; ++ return false; + } + else + { +- if(!isIpv4NetmaskValid(netMask)) ++ if (!isIpv4NetmaskValid(netMask)) + { +- valid = false; ++ QString error = QString(tr("Netmask invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); + KLOG_DEBUG() << "Netmask invalid"; ++ return false; + } + } + +- ui->ipv4Gateway->text(); +- ui->ipv4PreferredDNS->text(); +- ui->ipv4AlternateDNS->text(); +- isIpv4AddressValid(ui->ipv4Gateway->text()); +- isIpv4AddressValid(ui->ipv4PreferredDNS->text()); +- isIpv4AddressValid(ui->ipv4AlternateDNS->text()); ++ if (!ipv4Gateway.isEmpty()) ++ { ++ if (!isIpv4AddressValid(ipv4Gateway)) ++ { ++ QString error = QString(tr("Ipv4 Gateway invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Ipv4 Netmask invalid"; ++ return false; ++ } ++ } ++ } + ++ QString preferredDNS = ui->ipv4PreferredDNS->text(); ++ if (!preferredDNS.isEmpty()) ++ { ++ if (!isIpv4AddressValid(preferredDNS)) ++ { ++ QString error = QString(tr("Ipv4 Preferred DNS invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Ipv4 Preferred DNS invalid"; ++ return false; ++ } + } +- return valid; ++ ++ QString alternateDNS = ui->ipv4AlternateDNS->text(); ++ if (!alternateDNS.isEmpty()) ++ { ++ if (!isIpv4AddressValid(alternateDNS)) ++ { ++ QString error = QString(tr("Ipv4 Alternate DNS invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Ipv4 Alternate DNS invalid"; ++ return false; ++ } ++ } ++ ++ return true; + } + + bool Ipv4Widget::isIpv4AddressValid(const QString &address) +diff --git a/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp b/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp +index a703f95..a9f1676 100644 +--- a/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp ++++ b/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp +@@ -13,6 +13,7 @@ + */ + + #include "ipv6-widget.h" ++#include + #include + #include "ui_ipv6-widget.h" + using namespace NetworkManager; +@@ -177,7 +178,7 @@ void Ipv6Widget::clearPtr() + bool Ipv6Widget::isInputValid() + { + Ipv6Setting::ConfigMethod configMethod = ui->ipv6Method->currentData().value(); +- bool valid = true; ++ + if (configMethod == Ipv6Setting::ConfigMethod::Ignored) + { + } +@@ -189,24 +190,71 @@ bool Ipv6Widget::isInputValid() + QString ipv6 = ui->ipv6Address->text(); + if (ipv6.isEmpty()) + { +- valid = false; ++ QString error = QString(tr("Ipv6 address can not be empty")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ + KLOG_DEBUG() << "Ipv6 Address cannot be empty"; ++ return false; + } + else + { + if (!isIpv6AddressValid(ipv6)) + { +- valid = false; ++ QString error = QString(tr("Ipv6 address invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); + KLOG_DEBUG() << "Ipv6Address invalid"; ++ return false; + } + } + +- isIpv6AddressValid(ui->ipv6Gateway->text()); +- isIpv6AddressValid(ui->ipv6AlternateDNS->text()); +- isIpv6AddressValid(ui->ipv6PreferredDNS->text()); ++ QString ipv6Gateway = ui->ipv6Gateway->text(); ++ if (!ipv6Gateway.isEmpty()) ++ { ++ if (!isIpv6AddressValid(ipv6Gateway)) ++ { ++ QString error = QString(tr("Ipv6 Gateway invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Ipv6 Netmask invalid"; ++ return false; ++ } ++ } + } + +- return valid; ++ QString preferredDNS = ui->ipv6PreferredDNS->text(); ++ if (!preferredDNS.isEmpty()) ++ { ++ if (!isIpv6AddressValid(preferredDNS)) ++ { ++ QString error = QString(tr("Ipv6 Preferred DNS invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Ipv6 Preferred DNS invalid"; ++ return false; ++ } ++ } ++ ++ QString alternateDNS = ui->ipv6AlternateDNS->text(); ++ if (!alternateDNS.isEmpty()) ++ { ++ if (!isIpv6AddressValid(alternateDNS)) ++ { ++ QString error = QString(tr("Ipv6 Alternate DNS invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Ipv6 Alternate DNS invalid"; ++ return false; ++ } ++ } ++ ++ return true; + } + + bool Ipv6Widget::isIpv6AddressValid(const QString &address) +diff --git a/plugins/network/src/plugin/settings/setting-page.cpp b/plugins/network/src/plugin/settings/setting-page.cpp +index 241f46c..dd84209 100644 +--- a/plugins/network/src/plugin/settings/setting-page.cpp ++++ b/plugins/network/src/plugin/settings/setting-page.cpp +@@ -76,11 +76,12 @@ void SettingPage::setConnectionSettings(const ConnectionSettings::Ptr& other) + + void SettingPage::handleSaveButtonClicked(ConnectionSettings::ConnectionType connectionType) + { +- if(m_connectionSettings == nullptr) ++ if (m_connectionSettings == nullptr) + { + initConnectionSettings(connectionType); + initSettingPage(); + saveSettingPage(); ++ KLOG_DEBUG() << " m_connectionSettings->toMap():" << m_connectionSettings->toMap(); + QDBusPendingReply replyAdd = NetworkManager::addConnection(m_connectionSettings->toMap()); + replyAdd.waitForFinished(); + if (replyAdd.isError()) +@@ -88,13 +89,16 @@ void SettingPage::handleSaveButtonClicked(ConnectionSettings::ConnectionType con + KLOG_DEBUG() << "add connection failed," << replyAdd.error(); + } + else +- KLOG_DEBUG() << "add new connection"; ++ { ++ KLOG_DEBUG() << "add new connection reply:" << replyAdd.reply(); ++ } + } + else + { + saveSettingPage(); + //只有无线网络使用自定义settingUpdated信号,因为未连接无线网络前不存在本地Setting,无法在初始化时监听信号 +- connect(m_connection.data(),&NetworkManager::Connection::updated,this,&SettingPage::settingUpdated,Qt::UniqueConnection); ++ connect(m_connection.data(), &NetworkManager::Connection::updated, this, &SettingPage::settingUpdated, Qt::UniqueConnection); ++ KLOG_DEBUG() << "m_connectionSettings->toMap():" << m_connectionSettings->toMap(); + QDBusPendingReply<> replyUpdate = m_connection->update(m_connectionSettings->toMap()); + replyUpdate.waitForFinished(); + if (replyUpdate.isError()) +diff --git a/plugins/network/src/plugin/settings/wired-setting-page.cpp b/plugins/network/src/plugin/settings/wired-setting-page.cpp +index 86ec372..4466468 100644 +--- a/plugins/network/src/plugin/settings/wired-setting-page.cpp ++++ b/plugins/network/src/plugin/settings/wired-setting-page.cpp +@@ -20,18 +20,17 @@ + #include + #include + #include "ui_wired-setting-page.h" ++ + using namespace NetworkManager; + + WiredSettingPage::WiredSettingPage(QWidget *parent) : SettingPage(parent), ui(new Ui::WiredSettingPage) + { + ui->setupUi(this); + initConnecton(); +- KLOG_DEBUG() << "WiredSettingPage::WiredSettingPage(QWidget *parent)"; + } + + WiredSettingPage::~WiredSettingPage() + { +- KLOG_DEBUG() << "WiredSettingPage::~WiredSettingPage()"; + delete ui; + } + +@@ -54,6 +53,7 @@ void WiredSettingPage::initSpecificSettings() + m_wiredSetting = m_connectionSettings->setting(Setting::SettingType::Wired).dynamicCast(); + } + ++// TODO:修改命名 + void WiredSettingPage::initWidgets() + { + ui->connectionNameWidget->setConnectionSettings(m_connectionSettings); +@@ -109,7 +109,8 @@ void WiredSettingPage::clearPtr() + + bool WiredSettingPage::isInputValid() + { +- if (ui->ipv4Widget->isInputValid() && ui->ipv6Widget->isInputValid() && ui->connectionNameWidget->isInputValid()) ++ if (ui->ipv4Widget->isInputValid() && ui->ipv6Widget->isInputValid() && ++ ui->connectionNameWidget->isInputValid() && ui->ethernetWidget->isInputValid()) + return true; + else + return false; +-- +2.33.0 + diff --git a/0005-fix-network-fix-invalid-configuration-created-for-th.patch b/0005-fix-network-fix-invalid-configuration-created-for-th.patch new file mode 100644 index 0000000..f7bce0c --- /dev/null +++ b/0005-fix-network-fix-invalid-configuration-created-for-th.patch @@ -0,0 +1,466 @@ +From 78bd84e3e5f9626e363e295a1f175c6f2f816ffe Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Tue, 23 Aug 2022 11:45:12 +0800 +Subject: [PATCH 5/7] fix(network):fix invalid configuration created for the + first time +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 修复初次创建配置失效的问题 +--- + .../src/plugin/setting-widget/ipv6-widget.cpp | 27 ++++++++++--------- + .../src/plugin/settings/setting-page.cpp | 4 +-- + .../src/plugin/settings/setting-page.h | 4 +-- + .../plugin/settings/vpn/vpn-l2tp-setting.cpp | 17 ++++++------ + .../plugin/settings/vpn/vpn-l2tp-setting.h | 5 ++-- + .../plugin/settings/vpn/vpn-pptp-setting.cpp | 18 ++++++------- + .../plugin/settings/vpn/vpn-pptp-setting.h | 5 ++-- + .../plugin/settings/wired-setting-page.cpp | 9 +++---- + .../src/plugin/settings/wired-setting-page.h | 3 +-- + .../plugin/settings/wireless-setting-page.cpp | 19 +++++++------ + .../plugin/settings/wireless-setting-page.h | 8 +++--- + 11 files changed, 54 insertions(+), 65 deletions(-) + +diff --git a/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp b/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp +index a9f1676..a16bff5 100644 +--- a/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp ++++ b/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp +@@ -81,7 +81,6 @@ void Ipv6Widget::saveSettings() + { + m_ipv6Setting->setMethod(method); + m_ipv6Setting->setAddresses(QList()); +- return; + } + else if (method == Ipv6Setting::ConfigMethod::Automatic) + { +@@ -119,11 +118,13 @@ void Ipv6Widget::showSettings() + { + if (m_ipv6Setting->method() == Ipv6Setting::ConfigMethod::Ignored) + { +- resetSettings(); ++ int ipv6MethodIndex = ui->ipv6Method->findData(Ipv6Setting::ConfigMethod::Ignored); ++ ui->ipv6Method->setCurrentIndex(ipv6MethodIndex); + } + else if (m_ipv6Setting->method() == Ipv6Setting::ConfigMethod::Automatic) + { +- resetSettings(); ++ int ipv6MethodIndex = ui->ipv6Method->findData(Ipv6Setting::ConfigMethod::Automatic); ++ ui->ipv6Method->setCurrentIndex(ipv6MethodIndex); + } + else if (m_ipv6Setting->method() == Ipv6Setting::ConfigMethod::Manual) + { +@@ -135,24 +136,24 @@ void Ipv6Widget::showSettings() + QString ip = ipv6Address.ip().toString(); + int prefix = ipv6Address.prefixLength(); + QString gateway = ipv6Address.gateway().toString(); +- QString preferredDNS = ""; +- QString alternateDNS = ""; + + ui->ipv6Address->setText(ip); + ui->ipv6Prefix->setValue(prefix); + ui->ipv6Gateway->setText(gateway); ++ } + +- if (!m_ipv6Setting->dns().isEmpty()) ++ QString preferredDNS = ""; ++ QString alternateDNS = ""; ++ if (!m_ipv6Setting->dns().isEmpty()) ++ { ++ preferredDNS = m_ipv6Setting->dns().at(0).toString(); ++ if (m_ipv6Setting->dns().count() >= 2) + { +- preferredDNS = m_ipv6Setting->dns().at(0).toString(); +- if (m_ipv6Setting->dns().count() >= 2) +- { +- alternateDNS = m_ipv6Setting->dns().at(1).toString(); +- } ++ alternateDNS = m_ipv6Setting->dns().at(1).toString(); + } +- ui->ipv6PreferredDNS->setText(preferredDNS); +- ui->ipv6AlternateDNS->setText(alternateDNS); + } ++ ui->ipv6PreferredDNS->setText(preferredDNS); ++ ui->ipv6AlternateDNS->setText(alternateDNS); + } + else + resetSettings(); +diff --git a/plugins/network/src/plugin/settings/setting-page.cpp b/plugins/network/src/plugin/settings/setting-page.cpp +index dd84209..512b263 100644 +--- a/plugins/network/src/plugin/settings/setting-page.cpp ++++ b/plugins/network/src/plugin/settings/setting-page.cpp +@@ -81,7 +81,7 @@ void SettingPage::handleSaveButtonClicked(ConnectionSettings::ConnectionType con + initConnectionSettings(connectionType); + initSettingPage(); + saveSettingPage(); +- KLOG_DEBUG() << " m_connectionSettings->toMap():" << m_connectionSettings->toMap(); ++ + QDBusPendingReply replyAdd = NetworkManager::addConnection(m_connectionSettings->toMap()); + replyAdd.waitForFinished(); + if (replyAdd.isError()) +@@ -98,7 +98,6 @@ void SettingPage::handleSaveButtonClicked(ConnectionSettings::ConnectionType con + saveSettingPage(); + //只有无线网络使用自定义settingUpdated信号,因为未连接无线网络前不存在本地Setting,无法在初始化时监听信号 + connect(m_connection.data(), &NetworkManager::Connection::updated, this, &SettingPage::settingUpdated, Qt::UniqueConnection); +- KLOG_DEBUG() << "m_connectionSettings->toMap():" << m_connectionSettings->toMap(); + QDBusPendingReply<> replyUpdate = m_connection->update(m_connectionSettings->toMap()); + replyUpdate.waitForFinished(); + if (replyUpdate.isError()) +@@ -111,7 +110,6 @@ void SettingPage::handleSaveButtonClicked(ConnectionSettings::ConnectionType con + void SettingPage::initSettingPage() + { + initSpecificSettings(); +- initWidgets(); + } + + bool SettingPage::isInputValid() +diff --git a/plugins/network/src/plugin/settings/setting-page.h b/plugins/network/src/plugin/settings/setting-page.h +index ef5a8a7..474751a 100644 +--- a/plugins/network/src/plugin/settings/setting-page.h ++++ b/plugins/network/src/plugin/settings/setting-page.h +@@ -39,7 +39,6 @@ public: + + virtual void initSettingPage(); + virtual void initSpecificSettings() = 0; +- virtual void initWidgets() = 0; + virtual void saveSettingPage() = 0; + virtual bool isInputValid(); + +@@ -53,7 +52,6 @@ signals: + void settingChanged(); + void settingUpdated(); + +- + protected: + NetworkManager::Connection::Ptr m_connection = nullptr; + NetworkManager::ConnectionSettings::Ptr m_connectionSettings = nullptr; +@@ -68,4 +66,4 @@ private: + bool m_isNewConnection; + }; + +-#endif //KIRAN_CPANEL_NETWORK_SETTINGPAGE_H ++#endif // KIRAN_CPANEL_NETWORK_SETTINGPAGE_H +diff --git a/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.cpp b/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.cpp +index b9c7e84..dc9e4d2 100644 +--- a/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.cpp ++++ b/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.cpp +@@ -13,9 +13,9 @@ + */ + + #include "vpn-l2tp-setting.h" +-#include "ui_vpn-l2tp-setting.h" +-#include + #include ++#include ++#include "ui_vpn-l2tp-setting.h" + #define ServiceTypeL2TP "org.freedesktop.NetworkManager.l2tp" + using namespace NetworkManager; + +@@ -33,25 +33,24 @@ VpnL2tpSetting::~VpnL2tpSetting() + + void VpnL2tpSetting::initConnection() + { +- connect(ui->disconnectAndDeleteWidget,&DisconnectAndDeleteButton::disconnectButtonClicked,this,&VpnL2tpSetting::returnPreviousPage); +- connect(ui->disconnectAndDeleteWidget,&DisconnectAndDeleteButton::deleteButtonClicked,this,&VpnL2tpSetting::returnPreviousPage); ++ connect(ui->disconnectAndDeleteWidget, &DisconnectAndDeleteButton::disconnectButtonClicked, this, &VpnL2tpSetting::returnPreviousPage); ++ connect(ui->disconnectAndDeleteWidget, &DisconnectAndDeleteButton::deleteButtonClicked, this, &VpnL2tpSetting::returnPreviousPage); + } + + void VpnL2tpSetting::initSettingPage() + { + initSpecificSettings(); +- initWidgets(); + } + + void VpnL2tpSetting::initSpecificSettings() + { + m_vpnSetting = m_connectionSettings->setting(Setting::SettingType::Vpn).dynamicCast(); + m_ipv4Setting = m_connectionSettings->setting(Setting::SettingType::Ipv4).dynamicCast(); ++ + m_vpnSetting->setServiceType(ServiceTypeL2TP); +-} ++ m_vpnSetting->setInitialized(true); ++ m_ipv4Setting->setInitialized(true); + +-void VpnL2tpSetting::initWidgets() +-{ + ui->connectioNameWidget->setConnectionSettings(m_connectionSettings); + ui->vpnWidget->setVpnSetting(m_vpnSetting); + ui->vpnPpp->setVpnSetting(m_vpnSetting); +@@ -80,7 +79,7 @@ void VpnL2tpSetting::showSettingPage(QString activeConnectionPath) + if (activeConnectionPath.isEmpty()) + ui->disconnectAndDeleteWidget->initButton(SETTING_CONNECTION_STATUS_DEACTIVATED); + else +- ui->disconnectAndDeleteWidget->initButton(SETTING_CONNECTION_STATUS_ACTIVATED,activeConnectionPath); ++ ui->disconnectAndDeleteWidget->initButton(SETTING_CONNECTION_STATUS_ACTIVATED, activeConnectionPath); + } + } + +diff --git a/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.h b/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.h +index cda99b6..daefdb8 100644 +--- a/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.h ++++ b/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.h +@@ -15,8 +15,8 @@ + #ifndef KIRAN_CPANEL_NETWORK_VPN_L2TP_SETTING_H + #define KIRAN_CPANEL_NETWORK_VPN_L2TP_SETTING_H + +-#include + #include ++#include + #include "setting-page.h" + QT_BEGIN_NAMESPACE + namespace Ui +@@ -36,7 +36,6 @@ public: + void initConnection(); + void initSettingPage() override; + void initSpecificSettings() override; +- void initWidgets() override; + void clearPtr() override; + + public slots: +@@ -49,4 +48,4 @@ private: + NetworkManager::VpnSetting::Ptr m_vpnSetting; + }; + +-#endif //KIRAN_CPANEL_NETWORK_VPN_L2TP_SETTING_H ++#endif // KIRAN_CPANEL_NETWORK_VPN_L2TP_SETTING_H +diff --git a/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.cpp b/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.cpp +index c09b2aa..260ae22 100644 +--- a/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.cpp ++++ b/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.cpp +@@ -13,8 +13,8 @@ + */ + + #include "vpn-pptp-setting.h" +-#include "ui_vpn-pptp-setting.h" + #include ++#include "ui_vpn-pptp-setting.h" + #define ServiceTypePPTP "org.freedesktop.NetworkManager.pptp" + using namespace NetworkManager; + +@@ -22,8 +22,8 @@ VpnPptpSetting::VpnPptpSetting(QWidget *parent) : SettingPage(parent), ui(new Ui + { + ui->setupUi(this); + ui->generalWidget->setNameLabel(tr("VPN name")); +- connect(ui->generalButton,&DisconnectAndDeleteButton::disconnectButtonClicked,this,&VpnPptpSetting::returnPreviousPage); +- connect(ui->generalButton,&DisconnectAndDeleteButton::deleteButtonClicked,this,&VpnPptpSetting::returnPreviousPage); ++ connect(ui->generalButton, &DisconnectAndDeleteButton::disconnectButtonClicked, this, &VpnPptpSetting::returnPreviousPage); ++ connect(ui->generalButton, &DisconnectAndDeleteButton::deleteButtonClicked, this, &VpnPptpSetting::returnPreviousPage); + } + + VpnPptpSetting::~VpnPptpSetting() +@@ -34,19 +34,17 @@ VpnPptpSetting::~VpnPptpSetting() + void VpnPptpSetting::initSettingPage() + { + initSpecificSettings(); +- initWidgets(); + } + +- + void VpnPptpSetting::initSpecificSettings() + { + m_vpnSetting = m_connectionSettings->setting(Setting::SettingType::Vpn).dynamicCast(); + m_ipv4Setting = m_connectionSettings->setting(Setting::SettingType::Ipv4).dynamicCast(); ++ + m_vpnSetting->setServiceType(ServiceTypePPTP); +-} ++ m_vpnSetting->setInitialized(true); ++ m_ipv4Setting->setInitialized(true); + +-void VpnPptpSetting::initWidgets() +-{ + ui->generalWidget->setConnectionSettings(m_connectionSettings); + ui->vpnWidget->setVpnSetting(m_vpnSetting); + ui->vpnPpp->setVpnSetting(m_vpnSetting); +@@ -81,13 +79,13 @@ void VpnPptpSetting::showSettingPage(QString activeConnectionPath) + if (activeConnectionPath.isEmpty()) + ui->generalButton->initButton(SETTING_CONNECTION_STATUS_DEACTIVATED); + else +- ui->generalButton->initButton(SETTING_CONNECTION_STATUS_ACTIVATED,activeConnectionPath); ++ ui->generalButton->initButton(SETTING_CONNECTION_STATUS_ACTIVATED, activeConnectionPath); + } + } + + void VpnPptpSetting::clearPtr() + { +- KLOG_DEBUG() << "VpnPptpSetting::clearPtr" ; ++ KLOG_DEBUG() << "VpnPptpSetting::clearPtr"; + m_vpnSetting.clear(); + SettingPage::clearPtr(); + +diff --git a/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.h b/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.h +index 729d1da..fa179a1 100644 +--- a/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.h ++++ b/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.h +@@ -15,9 +15,9 @@ + #ifndef KIRAN_CPANEL_NETWORK_VPN_PPTP_SETTING_H + #define KIRAN_CPANEL_NETWORK_VPN_PPTP_SETTING_H + ++#include + #include + #include "setting-page.h" +-#include + QT_BEGIN_NAMESPACE + namespace Ui + { +@@ -34,7 +34,6 @@ public: + ~VpnPptpSetting() override; + void initSettingPage() override; + void initSpecificSettings() override; +- void initWidgets() override; + void clearPtr() override; + + public slots: +@@ -47,4 +46,4 @@ private: + NetworkManager::VpnSetting::Ptr m_vpnSetting; + }; + +-#endif //KIRAN_CPANEL_NETWORK_VPN_PPTP_SETTING_H ++#endif // KIRAN_CPANEL_NETWORK_VPN_PPTP_SETTING_H +diff --git a/plugins/network/src/plugin/settings/wired-setting-page.cpp b/plugins/network/src/plugin/settings/wired-setting-page.cpp +index 4466468..507aee5 100644 +--- a/plugins/network/src/plugin/settings/wired-setting-page.cpp ++++ b/plugins/network/src/plugin/settings/wired-setting-page.cpp +@@ -37,7 +37,6 @@ WiredSettingPage::~WiredSettingPage() + void WiredSettingPage::initSettingPage() + { + initSpecificSettings(); +- initWidgets(); + } + + void WiredSettingPage::initConnecton() +@@ -51,11 +50,11 @@ void WiredSettingPage::initSpecificSettings() + m_ipv4Setting = m_connectionSettings->setting(Setting::SettingType::Ipv4).dynamicCast(); + m_ipv6Setting = m_connectionSettings->setting(Setting::SettingType::Ipv6).dynamicCast(); + m_wiredSetting = m_connectionSettings->setting(Setting::SettingType::Wired).dynamicCast(); +-} + +-// TODO:修改命名 +-void WiredSettingPage::initWidgets() +-{ ++ m_ipv4Setting->setInitialized(true); ++ m_ipv6Setting->setInitialized(true); ++ m_wiredSetting->setInitialized(true); ++ + ui->connectionNameWidget->setConnectionSettings(m_connectionSettings); + ui->ipv4Widget->setIpv4Setting(m_ipv4Setting); + ui->ipv6Widget->setIpv6Setting(m_ipv6Setting); +diff --git a/plugins/network/src/plugin/settings/wired-setting-page.h b/plugins/network/src/plugin/settings/wired-setting-page.h +index f90c8a7..335d7a4 100644 +--- a/plugins/network/src/plugin/settings/wired-setting-page.h ++++ b/plugins/network/src/plugin/settings/wired-setting-page.h +@@ -37,7 +37,6 @@ public: + void initConnecton(); + void initSettingPage() override; + void initSpecificSettings() override; +- void initWidgets() override; + void clearPtr() override; + + public slots: +@@ -50,4 +49,4 @@ private: + KiranSwitchButton *m_security; + }; + +-#endif //KIRAN_CPANEL_NETWORK_WIRED_SETTING_PAGE_H ++#endif // KIRAN_CPANEL_NETWORK_WIRED_SETTING_PAGE_H +diff --git a/plugins/network/src/plugin/settings/wireless-setting-page.cpp b/plugins/network/src/plugin/settings/wireless-setting-page.cpp +index efcdbe1..b0d5877 100644 +--- a/plugins/network/src/plugin/settings/wireless-setting-page.cpp ++++ b/plugins/network/src/plugin/settings/wireless-setting-page.cpp +@@ -13,8 +13,8 @@ + */ + + #include "wireless-setting-page.h" +-#include "ui_wireless-setting-page.h" + #include ++#include "ui_wireless-setting-page.h" + using namespace NetworkManager; + + WirelessSettingPage::WirelessSettingPage(QWidget *parent) : SettingPage(parent), ui(new Ui::WirelessSettingPage) +@@ -32,14 +32,13 @@ WirelessSettingPage::~WirelessSettingPage() + + void WirelessSettingPage::initConnection() + { +- connect(ui->disconnectAndDeleteButton,&DisconnectAndDeleteButton::disconnectButtonClicked,this,&WirelessSettingPage::returnPreviousPage); +- connect(ui->disconnectAndDeleteButton,&DisconnectAndDeleteButton::deleteButtonClicked,this,&WirelessSettingPage::returnPreviousPage); ++ connect(ui->disconnectAndDeleteButton, &DisconnectAndDeleteButton::disconnectButtonClicked, this, &WirelessSettingPage::returnPreviousPage); ++ connect(ui->disconnectAndDeleteButton, &DisconnectAndDeleteButton::deleteButtonClicked, this, &WirelessSettingPage::returnPreviousPage); + } + + void WirelessSettingPage::initSettingPage() + { + initSpecificSettings(); +- initWidgets(); + } + + void WirelessSettingPage::initSpecificSettings() +@@ -48,10 +47,12 @@ void WirelessSettingPage::initSpecificSettings() + m_ipv6Setting = m_connectionSettings->setting(Setting::SettingType::Ipv6).dynamicCast(); + m_wirelessSetting = m_connectionSettings->setting(Setting::SettingType::Wireless).dynamicCast(); + m_wirelessSecuritySetting = m_connectionSettings->setting(Setting::SettingType::WirelessSecurity).dynamicCast(); +-} + +-void WirelessSettingPage::initWidgets() +-{ ++ m_ipv4Setting->setInitialized(true); ++ m_ipv6Setting->setInitialized(true); ++ m_wirelessSetting->setInitialized(true); ++ m_wirelessSecuritySetting->setInitialized(true); ++ + ui->generalWidget->setConnectionSettings(m_connectionSettings); + ui->ipv4Widget->setIpv4Setting(m_ipv4Setting); + ui->ipv6Widget->setIpv6Setting(m_ipv6Setting); +@@ -81,7 +82,7 @@ void WirelessSettingPage::showSettingPage(QString activeConnectionPath) + if (activeConnectionPath.isEmpty()) + ui->disconnectAndDeleteButton->initButton(SETTING_CONNECTION_STATUS_DEACTIVATED); + else +- ui->disconnectAndDeleteButton->initButton(SETTING_CONNECTION_STATUS_ACTIVATED,activeConnectionPath); ++ ui->disconnectAndDeleteButton->initButton(SETTING_CONNECTION_STATUS_ACTIVATED, activeConnectionPath); + } + } + +@@ -109,5 +110,3 @@ void WirelessSettingPage::clearPtr() + ui->wirelessSecurity->clearPtr(); + ui->wireless->clearPtr(); + } +- +- +diff --git a/plugins/network/src/plugin/settings/wireless-setting-page.h b/plugins/network/src/plugin/settings/wireless-setting-page.h +index d0cf97b..bb963fe 100644 +--- a/plugins/network/src/plugin/settings/wireless-setting-page.h ++++ b/plugins/network/src/plugin/settings/wireless-setting-page.h +@@ -15,10 +15,10 @@ + #ifndef KIRAN_CPANEL_NETWORK_WIRELESS_SETTING_PAGE_H + #define KIRAN_CPANEL_NETWORK_WIRELESS_SETTING_PAGE_H + ++#include ++#include + #include + #include "setting-page.h" +-#include +-#include + QT_BEGIN_NAMESPACE + namespace Ui + { +@@ -36,16 +36,16 @@ public: + void initConnection(); + void initSettingPage() override; + void initSpecificSettings() override; +- void initWidgets() override; + void clearPtr() override; + + public slots: + void saveSettingPage() override; + void showSettingPage(QString activeConnectionPath = ""); ++ + private: + Ui::WirelessSettingPage *ui; + NetworkManager::WirelessSetting::Ptr m_wirelessSetting; + NetworkManager::WirelessSecuritySetting::Ptr m_wirelessSecuritySetting; + }; + +-#endif //KIRAN_CPANEL_NETWORK_WIRELESS_SETTING_PAGE_H ++#endif // KIRAN_CPANEL_NETWORK_WIRELESS_SETTING_PAGE_H +-- +2.33.0 + diff --git a/0006-fix-network-only-L2TP-type-is-supported-temporary-an.patch b/0006-fix-network-only-L2TP-type-is-supported-temporary-an.patch new file mode 100644 index 0000000..bea3376 --- /dev/null +++ b/0006-fix-network-only-L2TP-type-is-supported-temporary-an.patch @@ -0,0 +1,211 @@ +From 963d10274ea3f9bf5321755a9f6f9b21ca98206d Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Tue, 23 Aug 2022 15:20:59 +0800 +Subject: [PATCH 6/7] fix(network):only L2TP type is supported temporary, and + fix input defect +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 暂时只支持l2tp类型,修复输入缺陷 +--- + .../src/plugin/manager/vpn-manager.cpp | 27 +++++------ + .../network/src/plugin/manager/vpn-manager.h | 9 ++-- + .../plugin/setting-widget/vpn/vpn-widget.cpp | 46 +++++++++++++++---- + .../plugin/settings/vpn/vpn-l2tp-setting.cpp | 2 +- + .../plugin/settings/vpn/vpn-pptp-setting.cpp | 1 - + 5 files changed, 58 insertions(+), 27 deletions(-) + +diff --git a/plugins/network/src/plugin/manager/vpn-manager.cpp b/plugins/network/src/plugin/manager/vpn-manager.cpp +index cd858b5..e4aecaf 100644 +--- a/plugins/network/src/plugin/manager/vpn-manager.cpp ++++ b/plugins/network/src/plugin/manager/vpn-manager.cpp +@@ -47,8 +47,8 @@ void VpnManager::initUI() + ui->connectionShowPage->setTitle(tr("VPN")); + ui->connectionShowPage->setSwitchButtonVisible(false); + +- // ui->vpnType->addItem(tr("L2TP"), VPN_TYPE_L2TP); +- ui->vpnType->addItem(tr("PPTP"), VPN_TYPE_PPTP); ++ ui->vpnType->addItem(tr("L2TP"), VPN_TYPE_L2TP); ++ // ui->vpnType->addItem(tr("PPTP"), VPN_TYPE_PPTP); + Kiran::StylePropertyHelper::setButtonType(ui->saveButton, Kiran::BUTTON_Default); + } + +@@ -59,9 +59,10 @@ void VpnManager::initConnection() + { + //默认创建vpn类型:L2TP + ui->vpnTypeWidget->setVisible(true); +- ui->vpnType->setCurrentIndex(0); +- ui->vpnTypeStacked->setCurrentIndex(VPN_TYPE_PPTP); +- ui->pptpSetting->showSettingPage(); ++ ui->vpnType->setCurrentIndex(VPN_TYPE_L2TP); ++ ui->vpnTypeStacked->setCurrentIndex(VPN_TYPE_L2TP); ++ ui->l2tpSetting->showSettingPage(); ++ // ui->vpnType->setCurrentIndex(0); + + QPointer scrollBar = ui->scrollArea->verticalScrollBar(); + scrollBar->setValue(0); +@@ -73,7 +74,7 @@ void VpnManager::initConnection() + connect(ui->vpnType, QOverload::of(&QComboBox::currentIndexChanged), [=](int index) + { + VpnType type = ui->vpnType->currentData().value(); +- ui->vpnTypeStacked->setCurrentIndex(VPN_TYPE_PPTP); ++ ui->vpnTypeStacked->setCurrentIndex(type); + switch (type) + { + case VPN_TYPE_L2TP: +@@ -186,14 +187,14 @@ void VpnManager::handleRequestActivateConnection(const QString &connectionPath, + inputDialog.setTitle(tr("Tips")); + QString tips = QString(tr("Password required to connect to %1.")).arg(settings->id()); + inputDialog.setText(tips); +- +- connect(&inputDialog, &TextInputDialog::password, [=](const QString &password) ++ inputDialog.setlineEditEchoMode(QLineEdit::Password); ++ connect(&inputDialog, &TextInputDialog::password, this, [=](const QString &password) + { +- NMStringMap secretsMap = vpnSetting->secrets(); +- secretsMap.insert("password", password); +- vpnSetting->setSecrets(secretsMap); +- activateVPNConnection(connectionPath, connectionParameter); +- connection->clearSecrets(); }); ++ NMStringMap secretsMap = vpnSetting->secrets(); ++ secretsMap.insert("password", password); ++ vpnSetting->setSecrets(secretsMap); ++ activateVPNConnection(connectionPath, connectionParameter); ++ connection->clearSecrets(); }); + + inputDialog.exec(); + } +diff --git a/plugins/network/src/plugin/manager/vpn-manager.h b/plugins/network/src/plugin/manager/vpn-manager.h +index 81233ab..e3fd096 100644 +--- a/plugins/network/src/plugin/manager/vpn-manager.h ++++ b/plugins/network/src/plugin/manager/vpn-manager.h +@@ -39,23 +39,24 @@ public: + public slots: + void clearVpnSetting(); + void handleRequestEditConnection(const QString &uuid, QString activeConnectionPath); +- void handleRequestActivateConnection(const QString &connectionPath,const QString &connectionParameter); ++ void handleRequestActivateConnection(const QString &connectionPath, const QString &connectionParameter); + + void handleNotifierConnectionAdded(const QString &path) override; + void handleNotifierConnectionRemoved(const QString &path) override; +- void activateVPNConnection(const QString &connectionPath,const QString &connectionParameter); ++ void activateVPNConnection(const QString &connectionPath, const QString &connectionParameter); + + void handleActiveConnectionAdded(const QString &activePath) override; + void handleActiveConnectionRemoved(const QString &activePath) override; + +- void handleVpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason,const QString &activePath); ++ void handleVpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason, const QString &activePath); + void handleVpnStateActivated(const QString &activePath); + void handleVpnStateDisconnected(const QString &activePath); + void handleVpnStateFailed(const QString &activePath); + + void handleReturnPreviousPage(); ++ + private: + Ui::VpnManager *ui; + }; + +-#endif //KIRAN_CPANEL_NETWORK_VPN_MANAGER_H ++#endif // KIRAN_CPANEL_NETWORK_VPN_MANAGER_H +diff --git a/plugins/network/src/plugin/setting-widget/vpn/vpn-widget.cpp b/plugins/network/src/plugin/setting-widget/vpn/vpn-widget.cpp +index 2439947..27de2af 100644 +--- a/plugins/network/src/plugin/setting-widget/vpn/vpn-widget.cpp ++++ b/plugins/network/src/plugin/setting-widget/vpn/vpn-widget.cpp +@@ -13,6 +13,7 @@ + */ + + #include "vpn-widget.h" ++#include + #include + #include + #include "ui_vpn-widget.h" +@@ -150,24 +151,53 @@ void VpnWidget::clearPtr() + + bool VpnWidget::isInputValid() + { +- bool valid = true; + QString gatewayStr = ui->gateway->text(); + if (gatewayStr.isEmpty()) +- valid = false; ++ { ++ QString error = QString(tr("Gateway can not be empty")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Gateway cannot be empty"; ++ return false; ++ } + else + { + if (!isIpv4AddressValid(gatewayStr)) +- valid = false; ++ { ++ QString error = QString(tr("Gateway invalid")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ KLOG_DEBUG() << "Gateway invalid"; ++ return false; ++ } + } + + if (ui->userName->text().isEmpty()) +- valid = false; ++ { ++ QString error = QString(tr("user name can not be empty")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); + +- if ((ui->passwordOptions->currentData().value() == NetworkManager::Setting::SecretFlagType::None) +- && ui->password->text().isEmpty()) +- valid = false; ++ KLOG_DEBUG() << "user name can not be empty"; ++ return false; ++ } ++ ++ if ((ui->passwordOptions->currentData().value() == Setting::SecretFlagType::None) && ++ ui->password->text().isEmpty()) ++ { ++ QString error = QString(tr("password can not be empty")); ++ KiranMessageBox::KiranStandardButton btn = KiranMessageBox::message(this, tr("Error"), ++ error, ++ KiranMessageBox::Yes | KiranMessageBox::No); ++ ++ KLOG_DEBUG() << "password can not be empty"; ++ return false; ++ } + +- return valid; ++ return true; + } + + bool VpnWidget::isIpv4AddressValid(const QString &address) +diff --git a/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.cpp b/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.cpp +index dc9e4d2..09a7109 100644 +--- a/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.cpp ++++ b/plugins/network/src/plugin/settings/vpn/vpn-l2tp-setting.cpp +@@ -107,5 +107,5 @@ void VpnL2tpSetting::clearPtr() + + bool VpnL2tpSetting::isInputValid() + { +- return ui->vpnWidget->isInputValid() || ui->connectioNameWidget->isInputValid(); ++ return ui->vpnWidget->isInputValid() && ui->connectioNameWidget->isInputValid(); + } +diff --git a/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.cpp b/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.cpp +index 260ae22..817171c 100644 +--- a/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.cpp ++++ b/plugins/network/src/plugin/settings/vpn/vpn-pptp-setting.cpp +@@ -85,7 +85,6 @@ void VpnPptpSetting::showSettingPage(QString activeConnectionPath) + + void VpnPptpSetting::clearPtr() + { +- KLOG_DEBUG() << "VpnPptpSetting::clearPtr"; + m_vpnSetting.clear(); + SettingPage::clearPtr(); + +-- +2.33.0 + diff --git a/0007-feature-network-update-translations.patch b/0007-feature-network-update-translations.patch new file mode 100644 index 0000000..ab7f243 --- /dev/null +++ b/0007-feature-network-update-translations.patch @@ -0,0 +1,460 @@ +From e25198845ff304e2a968f6d01b557acc15ba2821 Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Tue, 23 Aug 2022 16:14:27 +0800 +Subject: [PATCH 7/7] feature(network):update translations +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 更新翻译 +--- + .../kiran-cpanel-network.zh_CN.ts | 223 ++++++++++++++---- + 1 file changed, 176 insertions(+), 47 deletions(-) + +diff --git a/plugins/network/translations/kiran-cpanel-network.zh_CN.ts b/plugins/network/translations/kiran-cpanel-network.zh_CN.ts +index 10521ae..0a1f191 100644 +--- a/plugins/network/translations/kiran-cpanel-network.zh_CN.ts ++++ b/plugins/network/translations/kiran-cpanel-network.zh_CN.ts +@@ -25,38 +25,39 @@ + 无线连接 + + +- +- ++ ++ + Wired Network %1 + 有线网络 %1 + + +- +- ++ ++ + Wired Network + 有线网络 + + +- +- ++ ++ + Wireless Network %1 + 无线网络 %1 + + +- +- ++ ++ ++ + Wireless Network + 无线网络 + + +- +- ++ ++ + VPN + VPN + + +- +- ++ ++ + Network Details + 网络详情 + +@@ -184,25 +185,35 @@ + 自动连接 + + +- ++ + Required + 必填 + + +- ++ + Wired Connection %1 + 有线网络%1 + + +- ++ + VPN L2TP %1 + + + +- ++ + VPN PPTP %1 + + ++ ++ ++ Connection name can not be empty ++ 网络名称不能为空 ++ ++ ++ ++ Error ++ 错误 ++ + + + ConnectionShowPage +@@ -262,12 +273,12 @@ + 忽略 + + +- ++ + Are you sure you want to delete the connection %1 + 您是否确定要删除连接 "%1" + + +- ++ + Warning + 警告 + +@@ -344,10 +355,20 @@ + 自定义MTU + + +- ++ + No device specified + 不指定设备 + ++ ++ ++ Clone Mac invalid ++ 无效的克隆MAC地址 ++ ++ ++ ++ Error ++ 错误 ++ + + + Ipv4Widget +@@ -387,21 +408,67 @@ + 备选DNS + + +- ++ + Auto + 自动 + + +- ++ + Manual + 手动 + + +- + ++ + Required + 必填 + ++ ++ ++ Ipv4 address can not be empty ++ Ipv4地址不能为空 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Error ++ 错误 ++ ++ ++ ++ Ipv4 Address invalid ++ 无效的Ipv4地址 ++ ++ ++ ++ NetMask can not be empty ++ 子网掩码不能为空 ++ ++ ++ ++ Netmask invalid ++ 无效的子网掩码 ++ ++ ++ ++ Ipv4 Gateway invalid ++ 无效的Ipv4网关 ++ ++ ++ ++ Ipv4 Preferred DNS invalid ++ 无效的Ipv4首选DNS ++ ++ ++ ++ Ipv4 Alternate DNS invalid ++ 无效的Ipv4备选DNS ++ + + + Ipv6Widget +@@ -441,25 +508,59 @@ + 备选DNS + + +- ++ + Auto + 自动 + + +- ++ + Manual + 手动 + + +- ++ + Ignored + 忽略 + + +- ++ + Required + 必填 + ++ ++ ++ Ipv6 address can not be empty ++ Ipv6地址不能为空 ++ ++ ++ ++ ++ ++ ++ ++ Error ++ 错误 ++ ++ ++ ++ Ipv6 address invalid ++ 无效的Ipv6地址 ++ ++ ++ ++ Ipv6 Gateway invalid ++ 无效的Ipv6网关 ++ ++ ++ ++ Ipv6 Preferred DNS invalid ++ 无效的Ipv6首选DNS ++ ++ ++ ++ Ipv6 Alternate DNS invalid ++ 无效的Ipv6备选DNS ++ + + + ManagerTray +@@ -471,7 +572,7 @@ + + NetworkTray + +- ++ + Network settings + 网络设置 + +@@ -629,17 +730,17 @@ + + + +- ++ + TextLabel + + + +- ++ + Select wired network card +- 请选择 有线网卡 ++ 请选择有线网卡 + + +- ++ + Select wireless network card + 请选择无线网卡 + +@@ -751,22 +852,22 @@ + 返回 + + +- ++ + VPN + VPN + + +- +- PPTP ++ ++ L2TP + + + +- ++ + Tips + 提示 + + +- ++ + Password required to connect to %1. + 连接网络 "%1" 需要密码 + +@@ -915,27 +1016,55 @@ + NT域 + + +- + + ++ + Required + 必填 + + +- ++ + Saved + 已保存的 + + +- ++ + Ask + 总是询问 + + +- ++ + Not required + 不要求 + ++ ++ ++ Gateway can not be empty ++ 网关不能为空 ++ ++ ++ ++ ++ ++ ++ Error ++ 错误 ++ ++ ++ ++ Gateway invalid ++ 无效的网关 ++ ++ ++ ++ user name can not be empty ++ 用户名不能为空 ++ ++ ++ ++ password can not be empty ++ 密码不能为空 ++ + + + WiredManager +@@ -955,7 +1084,7 @@ + 返回 + + +- ++ + Wired Network Adapter + 有线网卡 + +@@ -968,7 +1097,7 @@ + + + +- ++ + Network name + 网络名称 + +@@ -991,17 +1120,17 @@ + 返回 + + +- ++ + Wireless Network Adapter + 无线网卡 + + +- ++ + Tips + 提示 + + +- ++ + Password required to connect to %1. + 连接网络 "%1" 需要密码 + +@@ -1076,7 +1205,7 @@ + + + +- ++ + Wireless name + 无线网络名称 + +@@ -1084,7 +1213,7 @@ + + WirelessTrayWidget + +- ++ + the network "%1" not found + 未找到网络 "%1" + +-- +2.33.0 + diff --git a/kiran-control-panel.spec b/kiran-control-panel.spec index 8daa5b7..619f1dd 100644 --- a/kiran-control-panel.spec +++ b/kiran-control-panel.spec @@ -1,6 +1,6 @@ Name: kiran-control-panel Version: 2.3.4 -Release: 6 +Release: 7 Summary: Kiran Control Panel Summary(zh_CN): Kiran桌面控制面板 @@ -15,6 +15,14 @@ Patch0005: 0001-fix-search-when-the-relevant-setting-interface-canno.patch Patch0006: 0002-fix-account-error-prompt-box-is-added-with-the-defau.patch Patch0007: 0001-fix-battery-idle-remove-invalid-idle-shutdown-displa.patch Patch0008: 0002-fix-account-The-connection-singleton-in-the-signal-s.patch +Patch0009: 0001-feature-network-Add-the-conf-file-to-overwrite-the-o.patch +Patch0010: 0002-fix-network-fix-crash-and-wireless-network-disable-f.patch +Patch0011: 0003-fix-network-fix-the-problem-of-network-and-details-c.patch +Patch0012: 0004-fix-network-Add-error-prompt-box-when-saving-configu.patch +Patch0013: 0005-fix-network-fix-invalid-configuration-created-for-th.patch +Patch0014: 0006-fix-network-only-L2TP-type-is-supported-temporary-an.patch +Patch0015: 0007-feature-network-update-translations.patch + BuildRequires: gcc-c++ BuildRequires: cmake >= 3.2 @@ -136,6 +144,7 @@ make %{?_smp_mflags} #network %{_sysconfdir}/xdg/autostart/kiran-network-status-icon.desktop %{_bindir}/kiran-network-status-icon +/etc/NetworkManager/conf.d/00-server.conf #display %{_datadir}/kiran-cpanel-display/translations/* @@ -173,6 +182,12 @@ make %{?_smp_mflags} rm -rf %{buildroot} %changelog +* Tue Aug 23 2022 luoqing - 2.3.4-7 +- KYOS-F: fix the problem of network and details corresponding error(#I5M0L9) +- KYOS-F: Add error prompt box when saving configuration(#I5GYQD) +- KYOS-F: fix invalid configuration created for the first time +- KYOS-F: fix crash and wireless network disable function defects + * Thu Aug 18 2022 liuxinhao - 2.3.4-6 - KYOS-F: account the connection singleton in the signal slot is not automatically disconnected because the receiver parameter is not added, resulting in a crash(#I5HRYF) - KYOS-F: power ,remove invalid idle shutdown display option(#I5M336)