kiran-control-panel/0015-fix-network-tray-Fixed-an-issue-where-the-size-Setti.patch
luoqing 803a350b0c fix(tray):Fixed an issue with some widgets being incorrectly sized during tray initialization and the tray application using the X11 platform
- 修复在托盘初始化时,存在多个网卡时,stackwidget中当前未显示页面的widget的设置大小未生效的问题
  修复托盘菜单使用X11平台,从而导致的右下角缺少声音和网络图标,以及任务栏网络图标格式不对的问题

Closes #13862,#13353,#11856,#14006
2023-09-21 16:34:24 +08:00

82 lines
2.7 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From c385edb7f7babef4d46ca77f1a979dd9f139b16e Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
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<const QObject *> 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<const QObject *>& objects)
+{
+ QEvent event(QEvent::StyleChange);
+ for (const QObject *object : objects)
+ {
+ if (auto widget = qobject_cast<QWidget*>(const_cast<QObject*>(object)))
+ {
+ widget->style()->polish(widget);
+ QCoreApplication::sendEvent(widget, &event);
+ QList<const QObject *> 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<const QObject *>& objects);
+
public slots:
void handleDeviceComboBoxChanged(int index);
void handleAdjustedTraySize(QSize sizeHint);
--
2.33.0