When the cursor theme changes, let the Qt application cursor reload(#11637)
This commit is contained in:
parent
3386933cab
commit
4525341e6b
140
0006-feat-cursor-theme-When-the-cursor-theme-changes-let-.patch
Normal file
140
0006-feat-cursor-theme-When-the-cursor-theme-changes-let-.patch
Normal file
@ -0,0 +1,140 @@
|
||||
From 48fbb1db8230eb551e5be92e3b75a3d3e71b3a46 Mon Sep 17 00:00:00 2001
|
||||
From: liuxinhao <liuxinhao@kylinsec.com.cn>
|
||||
Date: Mon, 7 Aug 2023 18:54:31 +0800
|
||||
Subject: [PATCH] feat(cursor theme): When the cursor theme changes, let the Qt
|
||||
application cursor reload
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 当光标主题变更时,让Qt应用重新加载光标主题
|
||||
|
||||
Related #11637
|
||||
---
|
||||
common/src/kiran-appearance-monitor.cpp | 15 +++++++++++++++
|
||||
common/src/kiran-appearance-monitor.h | 5 +++++
|
||||
platformtheme/kiran-theme.cpp | 10 +++++++++-
|
||||
platformtheme/kiran-theme.h | 1 +
|
||||
4 files changed, 30 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/common/src/kiran-appearance-monitor.cpp b/common/src/kiran-appearance-monitor.cpp
|
||||
index 7af4f9d..b279d55 100644
|
||||
--- a/common/src/kiran-appearance-monitor.cpp
|
||||
+++ b/common/src/kiran-appearance-monitor.cpp
|
||||
@@ -118,6 +118,10 @@ KiranAppearanceMonitor::KiranAppearanceMonitor(QObject *parent)
|
||||
|
||||
connect(m_displayIface, &KiranDisplayProxy::window_scaling_factorChanged,
|
||||
this, &KiranAppearanceMonitor::handleWindowScaleFactorChanged);
|
||||
+ m_polishCursorTimer.setInterval(500);
|
||||
+ m_polishCursorTimer.setSingleShot(true);
|
||||
+
|
||||
+ connect(&m_polishCursorTimer,&QTimer::timeout,this,&KiranAppearanceMonitor::handleCursorThemeChanged);
|
||||
}
|
||||
|
||||
KiranAppearanceMonitor *KiranAppearanceMonitor::instance()
|
||||
@@ -257,6 +261,17 @@ void KiranAppearanceMonitor::handleThemeSettingChanged(int type, const QString &
|
||||
emit gtkThemeChanged(m_gtkThemeName);
|
||||
}
|
||||
}
|
||||
+ else if(type==APPEARANCE_THEME_TYPE_CURSOR)
|
||||
+ {
|
||||
+ // 延迟通知,让QXcbCursor更新主题
|
||||
+ // 若未变化光标,qt5.15之前都需要合入修复补丁
|
||||
+ m_polishCursorTimer.start();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void KiranAppearanceMonitor::handleCursorThemeChanged()
|
||||
+{
|
||||
+ emit cursorThemeChanged();
|
||||
}
|
||||
|
||||
QString KiranAppearanceMonitor::gtkTheme() const
|
||||
diff --git a/common/src/kiran-appearance-monitor.h b/common/src/kiran-appearance-monitor.h
|
||||
index 54b3a97..8d7033f 100644
|
||||
--- a/common/src/kiran-appearance-monitor.h
|
||||
+++ b/common/src/kiran-appearance-monitor.h
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QFont>
|
||||
+#include <QTimer>
|
||||
|
||||
class KiranDisplayProxy;
|
||||
class KiranAppearanceProxy;
|
||||
@@ -39,6 +40,7 @@ signals:
|
||||
void scaleFactorChanged(int factor);
|
||||
void iconThemeChanged(QString iconTheme);
|
||||
void gtkThemeChanged(QString gtkTheme);
|
||||
+ void cursorThemeChanged();
|
||||
|
||||
private:
|
||||
static bool parseFontValue(const QString& font,QString& fontName,int& fontSize);
|
||||
@@ -47,6 +49,7 @@ private slots:
|
||||
void handleFontSettingChanged(int type,const QString& fontValue);
|
||||
void handleWindowScaleFactorChanged(int scaleFactor);
|
||||
void handleThemeSettingChanged(int type,const QString& themeName);
|
||||
+ void handleCursorThemeChanged();
|
||||
|
||||
private:
|
||||
QString m_appFontName = "Noto Sans CJK";
|
||||
@@ -59,6 +62,8 @@ private:
|
||||
|
||||
QString m_iconTheme = "hicolor";
|
||||
QString m_gtkThemeName = "kiran";
|
||||
+
|
||||
+ QTimer m_polishCursorTimer;
|
||||
KiranDisplayProxy* m_displayIface;
|
||||
KiranAppearanceProxy* m_appearanceIface;
|
||||
};
|
||||
\ No newline at end of file
|
||||
diff --git a/platformtheme/kiran-theme.cpp b/platformtheme/kiran-theme.cpp
|
||||
index 9fec043..86eb2e1 100644
|
||||
--- a/platformtheme/kiran-theme.cpp
|
||||
+++ b/platformtheme/kiran-theme.cpp
|
||||
@@ -132,6 +132,7 @@ void KiranTheme::init()
|
||||
QObject::connect(m_settingsMonitor, &KiranAppearanceMonitor::titleBarFontChanged, this, &KiranTheme::handleTitleBarFontChanged);
|
||||
QObject::connect(m_settingsMonitor, &KiranAppearanceMonitor::iconThemeChanged, this, &KiranTheme::handleIconThemeChanged);
|
||||
QObject::connect(m_settingsMonitor, &KiranAppearanceMonitor::scaleFactorChanged, this, &KiranTheme::handleScaleFactorChanged);
|
||||
+ QObject::connect(m_settingsMonitor, &KiranAppearanceMonitor::cursorThemeChanged, this, &KiranTheme::handleCursorThemeChanged);
|
||||
|
||||
// 不从KiranAppearanceMonitor接受主题变更事件,修改为接受KiranPalette的主题变更信号,能监听到系统主题变更以及应用程序手动指定主题
|
||||
//QObject::connect(m_settingsMonitor, &KiranAppearanceMonitor::gtkThemeChanged, this, &KiranTheme::handleThemeChanged);
|
||||
@@ -291,6 +292,13 @@ void KiranTheme::handleScaleFactorChanged(int factor)
|
||||
}
|
||||
}
|
||||
|
||||
+void KiranTheme::handleCursorThemeChanged()
|
||||
+{
|
||||
+ // 强制让窗口更新光标
|
||||
+ QApplication::setOverrideCursor(QCursor());
|
||||
+ QApplication::restoreOverrideCursor();
|
||||
+}
|
||||
+
|
||||
bool KiranTheme::enableRealTimeScaling()
|
||||
{
|
||||
static bool enable = !qEnvironmentVariableIsSet("QT_DEVICE_PIXEL_RATIO") &&
|
||||
@@ -335,7 +343,7 @@ void KiranTheme::handleThemeChanged()
|
||||
{
|
||||
// NOTE: SchemeLoader会接收KiranAppearanceMonitor的GTK主题改变信号,重新加载配色方案
|
||||
// 此处只需等到下一个事件循环,通知QGuiApplication重新更新palette
|
||||
-
|
||||
+
|
||||
// clang-format off
|
||||
QTimer::singleShot(0, [this] {
|
||||
// 此事件会促使QGuiApplication重新从QPlatformTheme中获取系统级别的QPalette
|
||||
diff --git a/platformtheme/kiran-theme.h b/platformtheme/kiran-theme.h
|
||||
index e7ebe94..243789c 100644
|
||||
--- a/platformtheme/kiran-theme.h
|
||||
+++ b/platformtheme/kiran-theme.h
|
||||
@@ -50,6 +50,7 @@ private slots:
|
||||
void handleScaleFactorChanged(int factor);
|
||||
void handleScreenAdded(QScreen* screen);
|
||||
void handleThemeChanged();
|
||||
+ void handleCursorThemeChanged();
|
||||
|
||||
private:
|
||||
KiranAppearanceMonitor* m_settingsMonitor;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: kiran-qt5-integration
|
||||
Version: 2.4.0
|
||||
Release: 7
|
||||
Release: 8
|
||||
Summary: Kiran desktop platform integration plugin.
|
||||
|
||||
License: MulanPSL-2.0
|
||||
@ -11,6 +11,7 @@ Patch0002: 0002-fix-arrow-Adjust-the-theme-drawing-arrow.patch
|
||||
Patch0003: 0003-build-qt5.11.1-Adaptation-Qt5.11.1.patch
|
||||
Patch0004: 0004-feat-style-app-Adjust-the-topic-configuration-to-whi.patch
|
||||
Patch0005: 0005-fix-style-add-ksl-os-gui-to-the-Style-whitelist.patch
|
||||
Patch0006: 0006-feat-cursor-theme-When-the-cursor-theme-changes-let-.patch
|
||||
|
||||
BuildRequires: cmake >= 3.2
|
||||
BuildRequires: gcc-c++
|
||||
@ -66,6 +67,9 @@ make %{?_smp_mflags}
|
||||
%{_libdir}/pkgconfig/kiran-style-helper.pc
|
||||
|
||||
%changelog
|
||||
* Mon Aug 07 2023 liuxinhao <liuxinhao@kylinsec.com.cn> - 2.4.0-8
|
||||
- KYOS-F: When the cursor theme changes, let the Qt application cursor reload(#11637)
|
||||
|
||||
* Mon Jul 03 2023 liuxinhao <liuxinhao@kylinsec.com.cn> - 2.4.0-7
|
||||
- KYOS-F: add ksl-os-gui to kiran style white list
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user