Fix dark mode detection on Linux #895

pull benthecarman wants to merge 1 commits into bitcoin-core:master from benthecarman:fix-dark-mode changing 1 files +12 −0
  1. benthecarman commented at 1:19 AM on September 23, 2025: contributor

    Enable GTK3 platform theme integration on Linux to properly detect system dark/light mode settings. Without this, Qt applications on Linux don't automatically adapt to the system theme, unlike macOS where it works out of the box.

    The fix sets QT_QPA_PLATFORMTHEME to "gtk3" before QApplication initialization, but only if the user hasn't already set a platform theme. This respects existing user configurations while providing better defaults for desktop environments using GTK (GNOME, Unity, XFCE, MATE).

    The change is non-breaking as Qt falls back gracefully if the GTK platform theme plugin is unavailable

    <!-- *** Please remove the following help text before submitting: *** Pull requests without a rationale and clear improvement may be closed immediately. GUI-related pull requests should be opened against https://github.com/bitcoin-core/gui first. See CONTRIBUTING.md -->

    <!-- Please provide clear motivation for your patch and explain how it improves Bitcoin Core user experience or Bitcoin Core developer experience significantly: * Any test improvements or new tests that improve coverage are always welcome. * All other changes should have accompanying unit tests (see `src/test/`) or functional tests (see `test/`). Contributors should note which tests cover modified code. If no tests exist for a region of modified code, new tests should accompany the change. * Bug fixes are most welcome when they come with steps to reproduce or an explanation of the potential issue as well as reasoning for the way the bug was fixed. * Features are welcome, but might be rejected due to design or scope issues. If a feature is based on a lot of dependencies, contributors should first consider building the system outside of Bitcoin Core, if possible. * Refactoring changes are only accepted if they are required for a feature or bug fix or otherwise improve developer experience significantly. For example, most "code style" refactoring changes require a thorough explanation why they are useful, what downsides they have and why they *significantly* improve developer experience or avoid serious programming bugs. Note that code style is often a subjective matter. Unless they are explicitly mentioned to be preferred in the [developer notes](/doc/developer-notes.md), stylistic code changes are usually rejected. -->

    <!-- Bitcoin Core has a thorough review process and even the most trivial change needs to pass a lot of eyes and requires non-zero or even substantial time effort to review. There is a huge lack of active reviewers on the project, so patches often sit for a long time. -->

  2. qt: Fix dark mode detection on Linux
      Enable GTK3 platform theme integration on Linux to properly detect
      system dark/light mode settings. Without this, Qt applications on
      Linux don't automatically adapt to the system theme, unlike macOS
      where it works out of the box.
    
      The fix sets QT_QPA_PLATFORMTHEME to "gtk3" before QApplication
      initialization, but only if the user hasn't already set a platform
      theme. This respects existing user configurations while providing
      better defaults for desktop environments using GTK (GNOME, Unity,
      XFCE, MATE).
    
      The change is non-breaking as Qt falls back gracefully if the GTK
      platform theme plugin is unavailable
    f2cd577b98
  3. DrahtBot commented at 1:19 AM on September 23, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. hebasto commented at 8:07 AM on September 23, 2025: member

    Enable GTK3 platform theme integration on Linux to properly detect system dark/light mode settings. Without this, Qt applications on Linux don't automatically adapt to the system theme, unlike macOS where it works out of the box.

    Could you please clarify which build this change is intended to affect, statically linked or shared?

    If the latter, which system was this tested on (OS, desktop environment, Qt version)?

  5. hebasto renamed this:
    qt: Fix dark mode detection on Linux
    Fix dark mode detection on Linux
    on Sep 23, 2025
  6. hebasto added the label Linux on Sep 23, 2025
  7. luke-jr commented at 9:27 AM on September 23, 2025: member

    Seems like this could make things worse for native (Qt) environments?

  8. benthecarman commented at 4:55 PM on September 23, 2025: contributor

    Could you please clarify which build this change is intended to affect, statically linked or shared?

    If the latter, which system was this tested on (OS, desktop environment, Qt version)?

    this sadly only effects dynamically linked builds.

    I have tested on ubuntu 24.04 with Qt 6.4.2

  9. hebasto commented at 5:38 PM on September 23, 2025: member

    Could you please clarify which build this change is intended to affect, statically linked or shared? If the latter, which system was this tested on (OS, desktop environment, Qt version)?

    this sadly only effects dynamically linked builds.

    Bringing this functionality to statically linked (including release) binaries would require introducing new build dependencies. There is a consensus among Core developers that this should only be considered after separating the GUI build into its own Guix script.

    I have tested on ubuntu 24.04 with Qt 6.4.2

    On the same system, the master branch @ 34fefb633584ecd803b01209756f2bef412f1cb1:

    <img width="827" height="548" alt="image" src="https://github.com/user-attachments/assets/fb5201aa-5777-49ca-8cc0-24f3fe8dfe26" />

    Everything seems to be working correctly.

  10. katesalazar commented at 4:15 PM on September 24, 2025: none

    Ah, nice and small, thanks. I have a couple of questions.

    This is in your code:

    This must be done before creating the QApplication

    Does this mean window won't change live when theme changes, on Linux?

    This is in your post:

    unlike macOS where it works out of the box.

    Does this mean window will change live when theme changes, on macOS?

  11. benthecarman closed this on Oct 4, 2025

  12. benthecarman deleted the branch on Oct 4, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-27 21:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me