From 08443a1df8df0c539d25b87519f9becb074bed89 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Mon, 7 Nov 2022 16:22:14 +0800 Subject: [PATCH] fix bug 146072 --- src/frontend/tab-pages/lanpage.cpp | 7 +++++++ src/frontend/tab-pages/tabpage.cpp | 13 +++++++++++++ src/frontend/tab-pages/tabpage.h | 1 + 3 files changed, 21 insertions(+) diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 507145e6..da63292d 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -155,6 +155,13 @@ void LanPage::initNetSwitch() m_switchGsettings->set(WIRED_SWITCH, wiredEnable); } + bool oldState; + if (getOldWiredSwitchState(oldState)) { + if (wiredEnable != oldState) { + m_wiredConnectOperation->setWiredEnabled(oldState); + } + } + if (m_devList.count() == 0) { qDebug() << "[wiredSwitch]:init not enable when no device"; m_netSwitch->setChecked(false); diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index b93bebed..d5a9a856 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -301,3 +301,16 @@ void getDeviceEnableState(int type, QMap &map) delete kdr; kdr = nullptr; } + +bool getOldWiredSwitchState(bool state) +{ + QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); + QVariant value = m_settings->value("lan_switch_opened"); + + if (!value.isValid()) + return false; + state = value.toBool(); + m_settings->remove("lan_switch_opened"); + delete m_settings; + return true; +} diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index e66bef22..5bdd8d25 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -81,6 +81,7 @@ bool checkDeviceExist(KyDeviceType deviceType, QString deviceName); QString getDefaultDeviceName(KyDeviceType deviceType); void setDefaultDevice(KyDeviceType deviceType, QString deviceName); void getDeviceEnableState(int type, QMap &map); +bool getOldWiredSwitchState(bool state); class TabPage : public QWidget {