diff --git a/src/frontend/netdetails/ipv4page.h b/src/frontend/netdetails/ipv4page.h index f25148fd..fbb5422e 100644 --- a/src/frontend/netdetails/ipv4page.h +++ b/src/frontend/netdetails/ipv4page.h @@ -46,6 +46,8 @@ public: void setMulDns(const QList &dns); void setGateWay(const QString &gateWay); + QString getNetMaskText(QString text); + bool checkIsChanged(const ConInfo info, KyConnectSetting &setting); void startLoading(); @@ -87,7 +89,7 @@ private: void configSave(); bool getTextEditState(QString text); bool netMaskIsValide(QString text); - QString getNetMaskText(QString text); + bool checkConnectBtnIsEnabled(); void initConflictHintLable(); void initLoadingIcon(); diff --git a/src/frontend/netdetails/joinhiddenwifipage.cpp b/src/frontend/netdetails/joinhiddenwifipage.cpp index 03315782..9363dd45 100644 --- a/src/frontend/netdetails/joinhiddenwifipage.cpp +++ b/src/frontend/netdetails/joinhiddenwifipage.cpp @@ -19,6 +19,10 @@ */ #include "joinhiddenwifipage.h" +#include + +#define THEME_SCHAME "org.ukui.style" +#define COLOR_THEME "styleName" #define WINDOW_WIDTH 480 #define MIN_WINDOW_HEIGHT 368 #define PEAP_WINDOW_HEIGHT 524 @@ -253,3 +257,25 @@ void JoinHiddenWiFiPage::onEapTypeChanged(const KyEapMethodType &type) } } +void JoinHiddenWiFiPage::onPaletteChanged() +{ + QPalette pal = qApp->palette(); + + QGSettings * styleGsettings = nullptr; +// const QByteArray style_id(THEME_SCHAME); +// if (QGSettings::isSchemaInstalled(style_id)) { +// styleGsettings = new QGSettings(style_id); +// QString currentTheme = styleGsettings->get(COLOR_THEME).toString(); +// if(currentTheme == "ukui-default"){ +// pal = lightPalette(this); +// } +// } + this->setPalette(pal); + setFramePalette(m_secuWidget, pal); + setFramePalette(m_hiddenWifiScrollArea, pal); + + if (styleGsettings != nullptr) { + delete styleGsettings; + styleGsettings = nullptr; + } +} diff --git a/src/frontend/netdetails/joinhiddenwifipage.h b/src/frontend/netdetails/joinhiddenwifipage.h index 23d14328..bea8be80 100644 --- a/src/frontend/netdetails/joinhiddenwifipage.h +++ b/src/frontend/netdetails/joinhiddenwifipage.h @@ -88,6 +88,7 @@ private Q_SLOTS: void onBtnShowListClicked(); void onSecuTypeChanged(const KySecuType &type); void onEapTypeChanged(const KyEapMethodType &type); + void onPaletteChanged(); Q_SIGNALS: void hiddenWiFiPageClose(QString); diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 53df88a1..fa12a26b 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -689,26 +689,16 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived) kyConnectResourse->getConnectionSetting(m_uuid,connetSetting); connetSetting.dumpInfo(); - conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType; +// conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType; conInfo.ipv6ConfigType = connetSetting.m_ipv6ConfigIpType; conInfo.isAutoConnect = connetSetting.m_isAutoConnect; - if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) { - if (connetSetting.m_ipv4Address.size() > 0) { - conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString(); - conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString(); - conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString(); - } - #if 0 - if (connetSetting.m_ipv4Dns.size() == 1) { - conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString(); - } else if (connetSetting.m_ipv4Dns.size() > 1) { - conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString(); - conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString(); - } - #endif - - conInfo.ipv4DnsList = connetSetting.m_ipv4Dns; + //openkylin从第三方库读取有问题 改为ipv4信息直接通过dbus获取 + KyConnectItem* item = kyConnectResourse->getConnectionItemByUuidWithoutActivateChecking(m_uuid); + if (item == nullptr) { + conInfo.ipv4ConfigType = CONFIG_IP_DHCP; + } else { + getIpv4Info(item->m_connectPath, conInfo); } if (connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) { @@ -732,7 +722,14 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived) if (!bActived) { conInfo.strDynamicIpv4 = conInfo.strIPV4Address.isEmpty() ? tr("Auto") : conInfo.strIPV4Address; conInfo.strDynamicIpv6 = conInfo.strIPV6Address.isEmpty() ? tr("Auto") : conInfo.strIPV6Address; - conInfo.strDynamicIpv4Dns = conInfo.strIPV4FirDns.isEmpty() ? tr("Auto") : conInfo.strIPV4FirDns; + QString dns(" "); + for (int i = 0; i < conInfo.ipv4DnsList.size(); ++i) { + dns.append(conInfo.ipv4DnsList.at(i).toString()); + if (i != conInfo.ipv4DnsList.size()-1) { + dns.append(" "); + } + } + conInfo.strDynamicIpv4Dns = dns.isEmpty() ? tr("Auto") : dns; } } @@ -1272,3 +1269,88 @@ void ThreadObject::checkIpv6ConflictThread(const QString &ipv6Address) ipv6rping = nullptr; Q_EMIT ipv6IsConflict(isConflict); } + +void NetDetail::getIpv4Info(QString objPath, ConInfo &conInfo) +{ + QDBusInterface m_interface("org.freedesktop.NetworkManager", + objPath, + "org.freedesktop.NetworkManager.Settings.Connection", + QDBusConnection::systemBus()); + QDBusMessage result = m_interface.call("GetSettings"); + + if (result.arguments().isEmpty()) { return; } + const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value(); + QMap> map; + dbusArg1st >> map; + + for (QString key : map.keys() ) { + QMap innerMap = map.value(key); + if (key == "ipv4") { + for (QString inner_key : innerMap.keys()) { + if (inner_key == "address-data") { + //ipv4地址 ipv4子网掩码 + const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); + QVector> addressVector; + + dbusArg2nd.beginArray(); + + while (!dbusArg2nd.atEnd()) { + QMap tempMap; + dbusArg2nd >> tempMap; + addressVector.append(tempMap); + } + dbusArg2nd.endArray(); + if (addressVector.size() >= 1) { + conInfo.strIPV4Address = addressVector.at(0).value("address").toString(); + conInfo.strIPV4NetMask = ipv4Page->getNetMaskText(addressVector.at(0).value("prefix").toString()); + } + } else if (inner_key == "method") { + //ipv4 method + if (innerMap.value(inner_key).toString() == "auto") + conInfo.ipv4ConfigType = CONFIG_IP_DHCP; + else { + conInfo.ipv4ConfigType = CONFIG_IP_MANUAL; + } + } else if (inner_key == "dns") { + //dns + const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); + QList addressVector; + + dbusArg2nd.beginArray(); + while (!dbusArg2nd.atEnd()) { + uint tempMap; + dbusArg2nd >> tempMap; + addressVector.append(tempMap); + } + dbusArg2nd.endArray(); + for (int i = 0; i < addressVector.size(); ++i) { + QString dns(inet_ntoa(*(struct in_addr *)&addressVector.at(i))); + conInfo.ipv4DnsList << QHostAddress(dns); + } + + } else if (inner_key == "gateway") { + //gateway + conInfo.strIPV4GateWay = innerMap.value(inner_key).toString(); + } + } + } + // if (key == "ipv6") { + // for (QString inner_key : innerMap.keys()) { + // if (inner_key == "address-data"){ + // const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); + // QMap m_map; + + // dbusArg2nd.beginArray(); + // while (!dbusArg2nd.atEnd()) { + // dbusArg2nd >> m_map;// append map to a vector here if you want to keep it + // } + // dbusArg2nd.endArray(); + + // dbusWifiIpv6 = m_map.value("address").toString(); + // } else if (inner_key == "method") { + // dbusWifiIpv6Method = innerMap.value(inner_key).toString(); + // } + // } + // } + } +} diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h index 085f11af..6e6b2d32 100644 --- a/src/frontend/netdetails/netdetail.h +++ b/src/frontend/netdetails/netdetail.h @@ -51,6 +51,7 @@ #include "kwidget.h" #include "ktabbar.h" +#include using namespace kdk; #define TAB_WIDTH 60 @@ -146,6 +147,7 @@ private: void startObjectThread(); void setNetTabToolTip(); + void getIpv4Info(QString objPath, ConInfo &conInfo); private: KyNetworkDeviceResourse *m_netDeviceResource = nullptr; KyConnectOperation* m_connectOperation = nullptr; diff --git a/src/frontend/single-pages/vpnpage.cpp b/src/frontend/single-pages/vpnpage.cpp index d594a35c..36d21c69 100644 --- a/src/frontend/single-pages/vpnpage.cpp +++ b/src/frontend/single-pages/vpnpage.cpp @@ -108,8 +108,10 @@ void VpnPage::constructActiveConnectionArea() { QList activedList; QList netList; - QGSettings vpnGsettings(GSETTINGS_VPNICON_VISIBLE); - + QGSettings* vpnGsettings = nullptr; + if (QGSettings::isSchemaInstalled(GSETTINGS_VPNICON_VISIBLE)) { + vpnGsettings = new QGSettings(GSETTINGS_VPNICON_VISIBLE); + } activedList.clear(); netList.clear(); clearConnectionMap(m_activeConnectionMap, m_vpnListWidget); @@ -137,12 +139,14 @@ void VpnPage::constructActiveConnectionArea() delete p_netConnectionItem; p_netConnectionItem = nullptr; } - if (vpnGsettings.keys().contains(QString(VISIBLE))) { - vpnGsettings.set(VISIBLE, true); + if (vpnGsettings != nullptr + && vpnGsettings->keys().contains(QString(VISIBLE))) { + vpnGsettings->set(VISIBLE, true); } } else { - if (vpnGsettings.keys().contains(QString(VISIBLE))) { - vpnGsettings.set(VISIBLE, false); + if (vpnGsettings != nullptr + && vpnGsettings->keys().contains(QString(VISIBLE))) { + vpnGsettings->set(VISIBLE, false); } } @@ -154,6 +158,9 @@ void VpnPage::constructActiveConnectionArea() m_netListArea->setFixedHeight(MAX_ITEMS * ITEM_HEIGHT); } m_netFrame->setFixedHeight(37 + m_netListArea->height()); + + delete vpnGsettings; + vpnGsettings = nullptr; } void VpnPage::initVpnArea() diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index a5a04a7a..39b4225a 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -151,7 +151,8 @@ void LanPage::initNetSwitch() qDebug()<<"[LanPage] org.ukui.kylin-nm.switch is not installed!"; } - if (wiredSwitch != wiredEnable) { + if (m_switchGsettings != nullptr + &&wiredSwitch != wiredEnable) { m_switchGsettings->set(WIRED_SWITCH, wiredEnable); }