From 8794ff00c8e77e75237e4c0391cffa26830d1122 Mon Sep 17 00:00:00 2001 From: renpeijia Date: Fri, 10 Dec 2021 09:51:44 +0800 Subject: [PATCH 1/2] bug#90711 devicecomboBox color --- src/frontend/tab-pages/tabpage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index aefb306c..f4a1eabd 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -48,6 +48,13 @@ void TabPage::initUI() m_deviceLabel->setText(tr("Current Device")); m_deviceComboBox = new QComboBox(m_deviceFrame); m_deviceComboBox->setFixedWidth(DEVICE_COMBOBOX_WIDTH); + if (m_deviceComboBox->view()) { + QPalette view_pal = m_deviceComboBox->view()->palette(); + QColor view_color = m_deviceComboBox->palette().color(QPalette::Active, QPalette::Button); + view_pal.setColor(QPalette::Base, view_color); + m_deviceComboBox->setPalette(view_pal); + m_deviceComboBox->view()->setPalette(view_pal); + } m_tipsLabel = new QLabel(m_deviceFrame); m_tipsLabel->setText(tr("Devices Closed!")); m_deviceLayout->addWidget(m_deviceLabel); From a0d4d98df6ed42b1d6de0f74b9a81dbcea391179 Mon Sep 17 00:00:00 2001 From: renpeijia Date: Fri, 10 Dec 2021 10:32:17 +0800 Subject: [PATCH 2/2] fix:it will report that the lan is closed, when close wifi-p2p. bug link:https://172.17.50.104/biz/bug-view-91118.html --- src/backend/dbus-interface/dbus-interface.pri | 2 + .../dbus-interface/kylinconnectresource.cpp | 21 +++++----- src/backend/dbus-interface/kylinutil.cpp | 41 +++++++++++++++++++ src/backend/dbus-interface/kylinutil.h | 19 +++++++++ 4 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 src/backend/dbus-interface/kylinutil.cpp create mode 100644 src/backend/dbus-interface/kylinutil.h diff --git a/src/backend/dbus-interface/dbus-interface.pri b/src/backend/dbus-interface/dbus-interface.pri index 70b5b0a8..056901df 100644 --- a/src/backend/dbus-interface/dbus-interface.pri +++ b/src/backend/dbus-interface/dbus-interface.pri @@ -14,6 +14,7 @@ HEADERS += \ $$PWD/kylinconnectsetting.h \ $$PWD/kylinnetworkdeviceresource.h \ $$PWD/kylinnetworkresourcemanager.h \ + $$PWD/kylinutil.h \ $$PWD/kylinvpnconnectitem.h \ $$PWD/kylinvpnrequest.h \ $$PWD/kylinwiredconnectoperation.h \ @@ -35,6 +36,7 @@ SOURCES += \ $$PWD/kylinconnectsetting.cpp \ $$PWD/kylinnetworkdeviceresource.cpp \ $$PWD/kylinnetworkresourcemanager.cpp \ + $$PWD/kylinutil.cpp \ $$PWD/kylinvpnconnectitem.cpp \ $$PWD/kylinvpnrequest.c \ $$PWD/kylinwiredconnectoperation.cpp \ diff --git a/src/backend/dbus-interface/kylinconnectresource.cpp b/src/backend/dbus-interface/kylinconnectresource.cpp index de7b5243..729bebb2 100644 --- a/src/backend/dbus-interface/kylinconnectresource.cpp +++ b/src/backend/dbus-interface/kylinconnectresource.cpp @@ -1,6 +1,7 @@ #include "kylinconnectresource.h" #include "kywirelessconnectoperation.h" +#include "kylinutil.h" #include #include @@ -702,18 +703,16 @@ bool KyConnectResourse::isWiredConnection(QString uuid) return false; } - if (!connectPtr.isNull()) { - NetworkManager::ConnectionSettings::Ptr connectSettingPtr = connectPtr->settings(); + /* + * 由于通过NetworkManager库获取的连接类型,准确的说是判断有线连接类型有时候是不准确的,因为该库 + * 对连接类型支持的不全,对于不支持的类型默认是有线连接类型,比如说wifi-p2p的投屏,所以需要通过 + * networkmanager的dbus接口获取。 + */ - if (connectSettingPtr.isNull()) { - qWarning()<<"[KyConnectResourse]"<<"get connect setting failed, connect uuid"<settings()->connectionType()) { - return true; - } + QString connectPath = connectPtr->path(); + QString connectionType = getConnectTypeByDbus(connectPath); + if (ETHERNET_TYPE == connectionType) { + return true; } return false; diff --git a/src/backend/dbus-interface/kylinutil.cpp b/src/backend/dbus-interface/kylinutil.cpp new file mode 100644 index 00000000..d90dd510 --- /dev/null +++ b/src/backend/dbus-interface/kylinutil.cpp @@ -0,0 +1,41 @@ +#include "kylinutil.h" + +#define LOG_FLAG "kylin-util" + +QString getConnectTypeByDbus(QString &connectPath) +{ + QString connectType = ""; + + if (connectPath.isEmpty()) { + qWarning()<< LOG_FLAG << "connect path is empty, so can not get connect type"; + return connectType; + } + + QDBusInterface dbusInterface("org.freedesktop.NetworkManager", + connectPath, + "org.freedesktop.NetworkManager.Settings.Connection", + QDBusConnection::systemBus()); + + QDBusMessage result = dbusInterface.call("GetSettings"); + const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value(); + QMap> map; + dbusArg1st >> map; + + if (map.isEmpty()) { + qWarning() << LOG_FLAG <<"get connection settings failed."; + return connectType; + } + + QMap connectMap = map.value(KEY_CONNECTION); + if (connectMap.isEmpty()) { + qWarning() << LOG_FLAG <<"threre is not connection settings"; + return connectType; + } + + connectType = connectMap.value(KEY_CONNECT_TYPE).toString(); + + qDebug() << LOG_FLAG << "connection type" << connectType; + + return connectType; + +} diff --git a/src/backend/dbus-interface/kylinutil.h b/src/backend/dbus-interface/kylinutil.h new file mode 100644 index 00000000..027292bd --- /dev/null +++ b/src/backend/dbus-interface/kylinutil.h @@ -0,0 +1,19 @@ +#ifndef KYLINUTIL_H +#define KYLINUTIL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define KEY_CONNECTION "connection" +#define KEY_CONNECT_TYPE "type" +#define ETHERNET_TYPE "802-3-ethernet" + +QString getConnectTypeByDbus(QString &connectPath); + +#endif // KYLINUTIL_H