diff --git a/0014-fix-tray-Fixed-the-tray-menu-using-the-X11-platform-.patch b/0014-fix-tray-Fixed-the-tray-menu-using-the-X11-platform-.patch new file mode 100644 index 0000000000000000000000000000000000000000..0b3bb355a7cae4e8f9a6ebe45a15ce12b699de4c --- /dev/null +++ b/0014-fix-tray-Fixed-the-tray-menu-using-the-X11-platform-.patch @@ -0,0 +1,288 @@ +From 60cfb83ae452e20c1d974eb431b2be551db3432e Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Thu, 21 Sep 2023 10:21:23 +0800 +Subject: [PATCH 1/2] fix(tray):Fixed the tray menu using the X11 platform, + which caused the missing voice and network icon in the lower right corner, + and the network icon in the taskbar was formatted incorrectly +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 修复托盘菜单使用X11平台,从而导致的右下角缺少声音和网络图标,以及任务栏网络图标格式不对的问题 + +Closes #13353,#11856,#14006 +--- + CMakeLists.txt | 1 + + include/dbus-tray-monitor.h | 111 +++++++++++++++++++++++++ + plugins/audio/CMakeLists.txt | 3 +- + plugins/audio/src/system-tray/main.cpp | 28 +++---- + plugins/network/CMakeLists.txt | 1 + + plugins/network/src/tray/main.cpp | 29 +++---- + 6 files changed, 141 insertions(+), 32 deletions(-) + create mode 100644 include/dbus-tray-monitor.h + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bdffa50..210c938 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -77,6 +77,7 @@ target_link_libraries(${PROJECT_NAME} + ${KIRAN_STYLE_LIBRARIES} + ${GLIB_2_LIBRARIES}) + ++list(FILTER INCLUDE_SRC EXCLUDE REGEX ".*bus-tray-monitor.h$") + install(FILES "${CMAKE_SOURCE_DIR}/data/kiran-control-panel.svg" DESTINATION ${INSTALL_DATADIR}/icons/hicolor/) + install(FILES ${INCLUDE_SRC} DESTINATION ${KCP_INSTALL_INCLUDE}/) + install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop" DESTINATION "${INSTALL_DATADIR}/applications/") +diff --git a/include/dbus-tray-monitor.h b/include/dbus-tray-monitor.h +new file mode 100644 +index 0000000..652e7b1 +--- /dev/null ++++ b/include/dbus-tray-monitor.h +@@ -0,0 +1,111 @@ ++/** ++ * Copyright (c) 2022 KylinSec Co., Ltd. ++ * kiran-control-panel is licensed under Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ * ++ * Author: luoqing ++ */ ++ ++#pragma once ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define KDE_STATUS_NOTIFIER_WATCHER_SERVICE "org.kde.StatusNotifierWatcher" ++#define KDE_STATUS_NOTIFIER_WATCHER_PATH "/StatusNotifierWatcher" ++#define FREEDESKTOP_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties" ++#define FREEDESKTOP_DBUS_PROPERTIES_CHANGED_METHOD "PropertiesChanged" ++ ++#define KDE_STATUS_NOTIFIER_HOST "org.kde.StatusNotifierHost" ++ ++namespace KiranControlPanel ++{ ++class DBusTrayMonitor : public QObject ++{ ++ Q_OBJECT ++public: ++ DBusTrayMonitor(QObject *parent = nullptr) ++ : QObject(parent), ++ m_connection(QDBusConnection::sessionBus()), ++ m_statusNotifierHostRegistered(false) ++ { ++ ++ QDBusInterface trayWatcherInterface(KDE_STATUS_NOTIFIER_WATCHER_SERVICE, KDE_STATUS_NOTIFIER_WATCHER_PATH, ++ KDE_STATUS_NOTIFIER_WATCHER_SERVICE, QDBusConnection::sessionBus()); ++ ++ // 确认托盘服务Watcher是否存在,检测Watcher IsStatusNotifierHostRegistered是否为true(满足QDBusTray可用的条件,具体可参考Qt代码) ++ if (trayWatcherInterface.isValid() && trayWatcherInterface.property("IsStatusNotifierHostRegistered").toBool()) ++ { ++ m_statusNotifierHostRegistered = true; ++ } ++ else ++ { ++ // 托盘服务Watcher不存在/Host未注册/IsStatusNotifierHostRegistered属性未更新 ++ // 连接到DBus Daemon,处理Watcher属性变化信号 ++ m_connection.connect(KDE_STATUS_NOTIFIER_WATCHER_SERVICE, ++ KDE_STATUS_NOTIFIER_WATCHER_PATH, ++ FREEDESKTOP_DBUS_PROPERTIES_INTERFACE, ++ FREEDESKTOP_DBUS_PROPERTIES_CHANGED_METHOD, ++ this, SLOT(onWatcherServicePropertyChanged(QDBusMessage))); ++ } ++ } ++ ++ ~DBusTrayMonitor() {} ++ ++ bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; } ++ ++private slots: ++ void onWatcherServicePropertyChanged(QDBusMessage msg) ++ { ++ // 若Host已注册过,无需判断 ++ if (m_statusNotifierHostRegistered) ++ return; ++ ++ QList args = msg.arguments(); ++ QVariantMap changedProps = qdbus_cast(args.at(1).value()); ++ for (auto iter = changedProps.begin(); iter != changedProps.end(); iter++) ++ { ++ if (iter.key() != "IsStatusNotifierHostRegistered") ++ continue; ++ ++ // IsStatusNotifierHostRegistered,属性变为true ++ // 发出DBus托盘服务可用信号(只在托盘初始化时发出) ++ // 后续属性变化不关注 ++ if (iter.value().toBool()) ++ { ++ m_statusNotifierHostRegistered = true; ++ KLOG_DEBUG() << "notifier host registered,dbus tray available!"; ++ emit dbusTrayAvailable(); ++ } ++ break; ++ } ++ } ++ ++signals: ++ void dbusTrayAvailable(); ++ ++private: ++ QDBusConnection m_connection; ++ bool m_statusNotifierHostRegistered; ++}; ++ ++static bool isDBusTrayAvailable() ++{ ++ bool dbusTrayAvailable = false; ++ DBusTrayMonitor conn; ++ if (conn.isStatusNotifierHostRegistered()) ++ dbusTrayAvailable = true; ++ return dbusTrayAvailable; ++} ++ ++} // namespace KiranControlPanel +diff --git a/plugins/audio/CMakeLists.txt b/plugins/audio/CMakeLists.txt +index ea568f1..55b07b2 100644 +--- a/plugins/audio/CMakeLists.txt ++++ b/plugins/audio/CMakeLists.txt +@@ -44,7 +44,8 @@ add_executable(${TRAY_PROCESS} + ${DBUS_SRC} + ${SYSTEM_TRAY_SRC} + ${AUDIO_QM_FILES} +- ${QRC}) ++ ${QRC} ++ ${PROJECT_SOURCE_DIR}/include/dbus-tray-monitor.h) + + target_include_directories(${TRAY_PROCESS} PRIVATE + ${CMAKE_BINARY_DIR} +diff --git a/plugins/audio/src/system-tray/main.cpp b/plugins/audio/src/system-tray/main.cpp +index 431e6c9..8c36383 100644 +--- a/plugins/audio/src/system-tray/main.cpp ++++ b/plugins/audio/src/system-tray/main.cpp +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include "dbus-tray-monitor.h" + + #define DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER "org.kde.StatusNotifierWatcher" + +@@ -47,27 +48,24 @@ int main(int argc, char *argv[]) + } + + AudioSystemTray *audioSystemTray = nullptr; +- +- if (QDBusConnection::sessionBus().interface()->isServiceRegistered(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER)) ++ if (KiranControlPanel::isDBusTrayAvailable()) + { +- KLOG_DEBUG() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create audio tray icon"; ++ KLOG_DEBUG() << KDE_STATUS_NOTIFIER_HOST << "is registered,create network tray icon"; + audioSystemTray = new AudioSystemTray; + } + else + { +- KLOG_WARNING() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is not registered,wait"; +- QDBusServiceWatcher* dbusServiceWatcher = new QDBusServiceWatcher; +- dbusServiceWatcher->setConnection(QDBusConnection::sessionBus()); +- dbusServiceWatcher->addWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER); +- QObject::connect(dbusServiceWatcher, &QDBusServiceWatcher::serviceRegistered, +- [&dbusServiceWatcher, &audioSystemTray](const QString& service) ++ KLOG_WARNING() << KDE_STATUS_NOTIFIER_HOST << "is not registered,wait"; ++ ++ auto dBusTrayMonitor = new KiranControlPanel::DBusTrayMonitor(); ++ QObject::connect(dBusTrayMonitor, &KiranControlPanel::DBusTrayMonitor::dbusTrayAvailable, [&audioSystemTray]() + { +- if (service != DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER) +- return; +- KLOG_INFO() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create audio tray icon"; +- audioSystemTray = new AudioSystemTray; +- dbusServiceWatcher->removeWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER); +- }); ++ if(audioSystemTray == nullptr) ++ { ++ KLOG_DEBUG() << KDE_STATUS_NOTIFIER_HOST << "is registered,create network tray icon"; ++ audioSystemTray = new AudioSystemTray; ++ } ++ }); + } + return QApplication::exec(); + } +diff --git a/plugins/network/CMakeLists.txt b/plugins/network/CMakeLists.txt +index 7ea6479..94de67a 100644 +--- a/plugins/network/CMakeLists.txt ++++ b/plugins/network/CMakeLists.txt +@@ -55,6 +55,7 @@ add_executable(${TRAY_PROCESS} + ${COMMON_SRC} + ${QRC} + ${NETWORK_QM_FILES} ++ ${PROJECT_SOURCE_DIR}/include/dbus-tray-monitor.h + ) + + target_include_directories(${TRAY_PROCESS} PRIVATE +diff --git a/plugins/network/src/tray/main.cpp b/plugins/network/src/tray/main.cpp +index 2a62bf1..5c4bb65 100644 +--- a/plugins/network/src/tray/main.cpp ++++ b/plugins/network/src/tray/main.cpp +@@ -20,10 +20,9 @@ + #include + #include + #include "config.h" ++#include "dbus-tray-monitor.h" + #include "network-tray.h" + +-#define DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER "org.kde.StatusNotifierWatcher" +- + int main(int argc, char* argv[]) + { + KiranApplication a(argc, argv); +@@ -43,26 +42,24 @@ int main(int argc, char* argv[]) + } + + NetworkTray* tray = nullptr; +- if (QDBusConnection::sessionBus().interface()->isServiceRegistered(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER)) ++ if (KiranControlPanel::isDBusTrayAvailable()) + { +- KLOG_DEBUG() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create network tray icon"; ++ KLOG_DEBUG() << KDE_STATUS_NOTIFIER_HOST << "is registered,create network tray icon"; + tray = new NetworkTray; + } + else + { +- KLOG_WARNING() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is not registered,wait"; +- QDBusServiceWatcher* dbusServiceWatcher = new QDBusServiceWatcher; +- dbusServiceWatcher->setConnection(QDBusConnection::sessionBus()); +- dbusServiceWatcher->addWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER); +- QObject::connect(dbusServiceWatcher, &QDBusServiceWatcher::serviceRegistered, +- [&dbusServiceWatcher, &tray](const QString& service) ++ KLOG_WARNING() << KDE_STATUS_NOTIFIER_HOST << "is not registered,wait"; ++ ++ auto dBusTrayMonitor = new KiranControlPanel::DBusTrayMonitor(); ++ QObject::connect(dBusTrayMonitor, &KiranControlPanel::DBusTrayMonitor::dbusTrayAvailable, [&tray]() + { +- if (service != DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER) +- return; +- KLOG_INFO() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create network tray icon"; +- tray = new NetworkTray; +- dbusServiceWatcher->removeWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER); +- }); ++ if(tray == nullptr) ++ { ++ KLOG_DEBUG() << KDE_STATUS_NOTIFIER_HOST << "is registered,create network tray icon"; ++ tray = new NetworkTray; ++ } ++ }); + } + + return QApplication::exec(); +-- +2.33.0 + diff --git a/0015-fix-network-tray-Fixed-an-issue-where-the-size-Setti.patch b/0015-fix-network-tray-Fixed-an-issue-where-the-size-Setti.patch new file mode 100644 index 0000000000000000000000000000000000000000..b777357ea6747664269808ab7cbf13fd526d44a4 --- /dev/null +++ b/0015-fix-network-tray-Fixed-an-issue-where-the-size-Setti.patch @@ -0,0 +1,81 @@ +From c385edb7f7babef4d46ca77f1a979dd9f139b16e Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Thu, 21 Sep 2023 10:33:42 +0800 +Subject: [PATCH 2/2] fix(network-tray):Fixed an issue where the size Settings + of widgets that are not currently displaying pages in the stackwidget did not + take effect when multiple nics were present during tray initialization +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 修复在托盘初始化时,存在多个网卡时,stackwidget中当前未显示页面的widget的设置大小未生效的问题 + +Close #13862 +--- + plugins/network/src/tray/tray-page.cpp | 35 ++++++++++++++++++++++++++ + plugins/network/src/tray/tray-page.h | 3 +++ + 2 files changed, 38 insertions(+) + +diff --git a/plugins/network/src/tray/tray-page.cpp b/plugins/network/src/tray/tray-page.cpp +index 753abc4..2e50f22 100644 +--- a/plugins/network/src/tray/tray-page.cpp ++++ b/plugins/network/src/tray/tray-page.cpp +@@ -53,6 +53,41 @@ void TrayPage::initUI() + { + setSingleDeviceWidget(); + } ++ ++ /** ++ * NOTE: ++ * 此处是修复当存在多个网卡时,stackwidget中当前未显示页面的widget的大小有问题 ++ * 推测原因在于,在初始化时,在页面未show的状态下,设置widget的尺寸不生效存在问题。 ++ */ ++ repolish(this); ++} ++ ++void TrayPage::repolish(QWidget *w) ++{ ++ QList children; ++ children.reserve(w->children().size() + 1); ++ for (auto child: qAsConst(w->children())) ++ children.append(child); ++ children.append(w); ++ updateObjects(children); ++} ++ ++void TrayPage::updateObjects(const QList& objects) ++{ ++ QEvent event(QEvent::StyleChange); ++ for (const QObject *object : objects) ++ { ++ if (auto widget = qobject_cast(const_cast(object))) ++ { ++ widget->style()->polish(widget); ++ QCoreApplication::sendEvent(widget, &event); ++ QList children; ++ children.reserve(widget->children().size() + 1); ++ for (auto child: qAsConst(widget->children())) ++ children.append(child); ++ updateObjects(children); ++ } ++ } + } + + void TrayPage::initConnection() +diff --git a/plugins/network/src/tray/tray-page.h b/plugins/network/src/tray/tray-page.h +index 28948a4..66a84f2 100644 +--- a/plugins/network/src/tray/tray-page.h ++++ b/plugins/network/src/tray/tray-page.h +@@ -44,6 +44,9 @@ public: + + QSize trayPageSize(); + ++ void repolish(QWidget *w); ++ void updateObjects(const QList& objects); ++ + public slots: + void handleDeviceComboBoxChanged(int index); + void handleAdjustedTraySize(QSize sizeHint); +-- +2.33.0 + diff --git a/kiran-control-panel.spec b/kiran-control-panel.spec index fe509f5348fdf29d803e44e09b312c6b8da5eb81..c46c4956c05d6767bcd1396d1a6a158772f0e0e6 100644 --- a/kiran-control-panel.spec +++ b/kiran-control-panel.spec @@ -1,6 +1,6 @@ Name: kiran-control-panel Version: 2.5.5 -Release: 10%{?dist} +Release: 11%{?dist} Summary: Kiran Control Panel Summary(zh_CN): Kiran桌面控制面板 @@ -20,6 +20,8 @@ Patch0010: 0010-fix-kiran-control-panel-fits-the-Qt5.9.7-interface.patch Patch0011: 0011-fix-tray-icon-Fixed-an-issue-where-the-tray-icon-was.patch Patch0012: 0012-fix-network-tray-Improved-the-notification-logic.-Wi.patch Patch0013: 0013-fix-network-Modify-DNS-Settings-and-display-DNS-deta.patch +Patch0014: 0014-fix-tray-Fixed-the-tray-menu-using-the-X11-platform-.patch +Patch0015: 0015-fix-network-tray-Fixed-an-issue-where-the-size-Setti.patch BuildRequires: gcc-c++ BuildRequires: cmake >= 3.2 @@ -176,6 +178,10 @@ make %{?_smp_mflags} rm -rf %{buildroot} %changelog +* Thu Sep 21 2023 luoqing - 2.5.5-11 +- KYOS-F: Fixed an issue where the size Settings of widgets that are not currently displaying pages in the stackwidget did not take effect when multiple nics were present during tray initialization(#13862) +- KYOS-F: Fixed the tray menu using the X11 platform, which caused the missing voice and network icon in the lower right corner, and the network icon in the taskbar was formatted incorrectly(#13353,#11856,#14006) + * Mon Sep 18 2023 luoqing - 2.5.5-10 - KYOS-F: Modify DNS Settings and display DNS details(#14000) - KYOS-F: Improved the notification logic. "Wired NIC: xxx is unavailable" and "Network is Unavailable" are no longer displayed during sleep recovery.(#15619)