Skip to content

feat: make QDeepinTheme follow DConfig settings - #1005

Open
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:fix/qdeepintheme-follow-dconfig
Open

feat: make QDeepinTheme follow DConfig settings#1005
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:fix/qdeepintheme-follow-dconfig

Conversation

@deepin-wm

@deepin-wm deepin-wm commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

增强 QDeepinTheme,让 treeland 自身的光标闪动间隔、双击间隔、系统字体、等宽字体跟随 DConfig 设置。

  1. Override themeHint() to return CursorFlashTime and MouseDoubleClickInterval from TreelandUserConfig
  2. Override font() to return SystemFont and FixedFont based on DConfig font/monoFont/fontSize settings
  3. Add notifyThemeChanged() to trigger Qt theme refresh via QWindowSystemInterface::handleThemeChanged()
  4. Add connectConfigSignals() to bind DConfig change signals to theme refresh, with disconnect on user switch to prevent duplicate connections
  5. Connect Helper::configChanged to reconnect signals when user configuration is rebuilt

WM-25

Summary by Sourcery

Synchronize Treeland’s Qt theme, fonts, input timing, and interaction settings with the active user and seat DConfig configuration.

New Features:

  • Make the application theme follow per-user DConfig settings for cursor behavior, mouse interaction thresholds, cursor theme, and system and monospace fonts.
  • Apply seat-specific keyboard timing settings from DConfig to Qt style hints.

Enhancements:

  • Refresh Qt theme and style settings when user or seat configuration changes, while safely reconnecting when configurations are rebuilt.
  • Preserve system palette integration through the reusable QDeepinTheme implementation.

Build:

  • Add the QDeepinTheme implementation and header to the Treeland executable.

Chores:

  • Expose configuration change notifications needed to keep theme settings synchronized.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @deepin-wm, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-wm
deepin-wm force-pushed the fix/qdeepintheme-follow-dconfig branch 5 times, most recently from 8aa9c67 to 6e93e07 Compare June 18, 2026 06:34
Comment thread src/main.cpp Outdated
Comment thread src/main.cpp Outdated
Comment thread src/main.cpp Outdated
Comment thread src/main.cpp Outdated
Comment thread src/main.cpp Outdated
// Notify all top-level windows about the theme change
for (auto *window : QGuiApplication::topLevelWindows()) {
QEvent event(QEvent::ThemeChange);
QCoreApplication::sendEvent(static_cast<QObject*>(window), &event);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样做意义不大,应该调用 QGuiApplicationPrivate::handleThemeChanged ,而且应该只在theme icon等相关变化时才调用。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QGuiApplicationPrivate::handleThemeChanged() is a protected method and cannot be called from QDeepinTheme (which is not a subclass of QGuiApplicationPrivate). This caused a build failure in CI (Qt 6.11.1). As an alternative, QCoreApplication::postEvent(qGuiApp, new QEvent(QEvent::ThemeChange)) is used, which is functionally equivalent — Qt internally delivers the event and eventually calls handleThemeChanged(), just asynchronously.

Comment thread src/main.cpp Outdated
Comment thread src/main.cpp Outdated
@deepin-wm
deepin-wm force-pushed the fix/qdeepintheme-follow-dconfig branch 7 times, most recently from f9c3c96 to 8aa6adc Compare June 18, 2026 08:52
Comment thread src/deepintheme.cpp
Comment thread src/deepintheme.cpp Outdated
Comment thread src/deepintheme.h Outdated
@deepin-wm
deepin-wm force-pushed the fix/qdeepintheme-follow-dconfig branch 4 times, most recently from cba3420 to ef01bc0 Compare June 18, 2026 10:08
@deepin-bot

deepin-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

TAG Bot

TAG: 0.9.1
EXISTED: no
DISTRIBUTION: unstable

@deepin-bot

deepin-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.13
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1063

deepin-wm pushed a commit to deepin-wm/treeland that referenced this pull request Jul 1, 2026
- Replace QCoreApplication::postEvent(ThemeChange) with
  QGuiApplicationPrivate::handleThemeChanged() in applyThemeSettings()
- Supplement themeHint() with CursorFlashTime, MouseDoubleClickInterval,
  MouseCursorSize, KeyboardAutoRepeatRate, KeyboardInputInterval
- Add bindSeatConfig/applyKeyboardSettings/disconnectSeatConfig for
  keyboard settings via SeatUserDConfig using QStyleHints::setXXX
- Connect cursorSizeChanged to applyThemeSettings() in bindConfig()
- Add InputManager::seatConfigChanged signal emitted from
  setupSeatUserConfig()
- Connect InputManager::seatConfigChanged to QDeepinTheme::bindSeatConfig
  in main.cpp
- Add Helper::inputManager() getter
@deepin-wm
deepin-wm force-pushed the fix/qdeepintheme-follow-dconfig branch 4 times, most recently from dad6f0c to f0deb06 Compare July 1, 2026 11:53
@deepin-bot

deepin-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.14
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1123

@deepin-bot

deepin-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.15
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1163

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-wm

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-wm
deepin-wm force-pushed the fix/qdeepintheme-follow-dconfig branch from 4bfd63b to 83d9859 Compare September 1, 2026 04:27
Implement QDeepinTheme that reads DConfig settings and applies them
to the Qt platform theme, so QPA follows treeland user preferences.

- Split QDeepinTheme to separate deepintheme.h/.cpp files
- Track connections via QMetaObject::Connection for proper cleanup
- Disconnect only own connections from old config on rebind
- Use QStyleHints setters for properties that have them:
  setCursorFlashTime, setMouseDoubleClickInterval,
  setStartDragDistance, setColorScheme
- Set font via QGuiApplication::setFont(), only on font changes
- Use QCoreApplication::postEvent for theme/icon changes
- Support: cursorBlink/cursorBlinkTime, doubleClickTime,
  doubleClickDistance, dndDragThreshold, font/monoFont/fontSize,
  iconThemeName, themeName, preferDark, cursorThemeName,
  keyboardRate/keyboardDelay (via seat config)
- Adapt to treelandinit.cpp refactoring: expose QDeepinTheme via
  Treeland::deepinTheme(), bind config in main.cpp
- Emit seatConfigChanged from InputManager for keyboard settings
- Expose inputManager() accessor on Helper
@deepin-wm
deepin-wm force-pushed the fix/qdeepintheme-follow-dconfig branch from 83d9859 to e289268 Compare September 1, 2026 05:56
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@deepin-wm
deepin-wm changed the base branch from master-backup-20260717 to master September 1, 2026 06:02
@hudeng-go

Copy link
Copy Markdown

/retest

@deepin-bot

deepin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.10.0
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1392

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants