Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt: Support macOS Dark mode #154

Merged
merged 3 commits into from
Mar 29, 2021
Merged

Conversation

goums
Copy link

@goums goums commented Dec 17, 2020

Allow icons to be colorized on macOS to support native Dark mode color scheme.

Rendering on macOS Big Sur before PR:
macos-darkmode-before-pr

Rendering on macOS Big Sur after PR:
macos-darkmode-after-pr

Light mode stay visually unchanged.

Note, that this currently only affect the build from source, as the macos dmg includes an attributes to force light color scheme on macos windows (see bitcoin/bitcoin#14593).
But once all glitches are fixed, we will be able to remove this temporary fix.
Edit: this PR is know including the removal of NSRequiresAquaSystemAppearance on Info.plist file so that the color fix is apply to every build.

Linked issues: #68 #136

@goums
Copy link
Author

goums commented Dec 17, 2020

@laanwj you wrote this code 6 years ago, maybe you could review this PR.
I didn't figure out why the colorizeIcons options was set to false on macosx platform?

@jonasschnelli
Copy link
Contributor

@goums
IIRC, the icon colouring looked bad on MacOS. The discussion is probably somewhere back in 2014: (I think the discussion happened somewhere here: bitcoin/bitcoin#5493).

@jonasschnelli
Copy link
Contributor

I think it would be good to post some screenshots how this looks in non-dark mode.

@goums
Copy link
Author

goums commented Dec 17, 2020

Sure @jonasschnelli

MacOS Big Sur - Light Mode - Before PR:
macos-light-before-pr

MacOS Big Sur - Light Mode - After PR:
macos-light-after-pr

It looks exactly the same to me, with icon colorization active/inactive on light mode.
Maybe older version of MacOs were behaving differently?

@goums
Copy link
Author

goums commented Dec 17, 2020

@goums
IIRC, the icon colouring looked bad on MacOS. The discussion is probably somewhere back in 2014: (I think the discussion happened somewhere here: bitcoin/bitcoin#5493).

Thanks, I've read the discussion, it seems MacOS had no theme styling options at that time, as you mentioned it (bitcoin/bitcoin#5493 (comment)).

That's probably why the colorizeIcons options was set to false for macosx platform on first commit (bitcoin/bitcoin#6487) and never changed since then.

@Sjors
Copy link
Member

Sjors commented Dec 17, 2020

Concept ACK. Just one boolean to fix all the things!

@goums goums mentioned this pull request Dec 18, 2020
2 tasks
@hebasto
Copy link
Member

hebasto commented Dec 26, 2020

@goums IIUC, you use the latest Homebrew's Qt, right?

@hebasto
Copy link
Member

hebasto commented Dec 26, 2020

Note, that this currently only affect the build from source, as the macos dmg includes an attributes to force light color scheme on macos windows (see bitcoin/bitcoin#14593).

I don't think that all macOS users ignore make deploy while building from source. Why make such a difference?

@goums
Copy link
Author

goums commented Jan 4, 2021

@goums IIUC, you use the latest Homebrew's Qt, right?

I installed QT Creator from their website, as mentioned in the readme:
https://github.com/bitcoin-core/gui/tree/master/src/qt#using-qt-creator-as-ide

I don't think that all macOS users ignore make deploy while building from source. Why make such a difference?

Yes sure, my idea was to fix the glitches step by step. Then we could revert the use of NSRequiresAquaSystemAppearance option in the plist file so that everyone can enjoy the Dark Mode in macos.

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

ACK c2db537

The PR Colorizes icons as White on macOS using Dark Mode. Icons are Black when using Light Mode.

Master: Dark Mode Screenshots
master-dark

PR: Dark and Light Mode Screenshots
pr-light-and-dark

@hebasto
Copy link
Member

hebasto commented Feb 22, 2021

I don't think that all macOS users ignore make deploy while building from source. Why make such a difference?

Yes sure, my idea was to fix the glitches step by step.

Both steps could be done in this pr as two different commits, no?

Then we could revert the use of NSRequiresAquaSystemAppearance option in the plist file so that everyone can enjoy the Dark Mode in macos.

For the second commit? Although, it will require to test builds with depends.

@laanwj
Copy link
Member

laanwj commented Feb 23, 2021

@laanwj you wrote this code 6 years ago, maybe you could review this PR.
I didn't figure out why the colorizeIcons options was set to false on macosx platform?

Yes, for the reason @jonasschnelli says. Somehow it didn't look good on MacOS—which was all-white at the time—so black icons looked best.

This may have changed now, thank you for working on dark mode support.

@goums
Copy link
Author

goums commented Feb 25, 2021

@hebasto, as the plist file is not in the src/qt folder, I wasn't sure if it should be updated from this GUI repo or from the main repo.

Anyway, I've updated it so that all deploy can benefit from darkmode now, depending on user "System Preferences".

$ make deploy
$ open Bitcoin-Qt.app
  • When the user has dark mode settings:
    image
  • When the user has light mode settings:
    image

However, there is still some glitches on the TabWidget:
image

I don't know if this is acceptable or not?

This bug is coming directly from QMacStyle, and won't be fixed until QT 6, as discussed here: #136 (comment)
The only workaround I can think of is to force the use fusion QT style on macos.

@goums goums changed the title qt: Colorize icons on macOS for Dark mode support qt: Support macOS Dark mode Feb 25, 2021
@jarolrod
Copy link
Member

However, there is still some glitches on the TabWidget:

The only workaround I can think of is to force the use fusion QT style on macos.

#177 forces Fusion qt style on older versions of Qt. If we are sticking with Qt 5.9.8 as the depends package for the next release, then the next release will use Fusion Qt style.

@hebasto
Copy link
Member

hebasto commented Feb 25, 2021

@hebasto, as the plist file is not in the src/qt folder, I wasn't sure if it should be updated from this GUI repo or from the main repo.

I think this is fine for such a change.

Going to test.

@goums
Do you mind sorting out this PR commits by dropping unrelated one?
DeepinScreenshot_select-area_20210225181710

@hebasto
Copy link
Member

hebasto commented Feb 25, 2021

However, there is still some glitches on the TabWidget:

That is orthogonal to this PR changes.

See QTBUG-86513

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

Tested 92369a1 with depends -- no visual changes as expected.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

Approach ACK 92369a1, tested on macOS Big Sur 11.2.1 (20D74):

  • Homebrew's Qt 5.15.2:
    • running bitcoin-qt -- dark mode works fine
    • installing from Bitcoin-Core.dmg -- dark mode works fine
  • cross-compiling with depends -- no changes, as expected

I think only commits must be sorted out (or squashed) before this PR gets ready to be merged.

@goums goums force-pushed the macos_color_icons branch from 92369a1 to 303cfc6 Compare February 25, 2021 21:24
@goums
Copy link
Author

goums commented Feb 25, 2021

Thanks for the full review @hebasto

I think only commits must be sorted out (or squashed) before this PR gets ready to be merged.

Sorry about that, I've removed the merge commit and rebase the branch instead, should be ok now.
However commit tags have changed:

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

@fanquake
Copy link
Member

Can the commit message in 303cfc6 be rewritten so it explains why this is possible. For release builds we are still using a version of Qt that doesn't properly support dark mode (as far as I'm aware support landed in 5.12.x). It also wasn't really the case that dark mode wasn't allowed before, you just had to build using a newer Qt. i.e this is master using dark mode:

master

If we now properly support dark mode, this note should be removed from doc/release-notes.md as part of this change:

Additionally, Bitcoin Core does not yet change appearance when macOS "dark mode" is activated.

Also, the PR body needs to be updated it's included in the merge), because it's no longer correct. i.e:

Note, that this currently only affect the build from source, as the macos dmg includes an attributes to force light color scheme on macos windows (see bitcoin/bitcoin#14593).

@hebasto
Copy link
Member

hebasto commented Feb 26, 2021

ACK 303cfc6

I retract my ACK.

These changes do not work on macOS Mojave 10.14.6 (18G8022 ) + Homebrew's Qt 5.15.2:

Screenshot from 2021-02-26 22-43-31

UPDATE: probably these changes need to be documented properly?

@goums
Copy link
Author

goums commented Feb 26, 2021

These changes do not work on macOS Mojave 10.14.6 (18G8022 ) + Homebrew's Qt 5.15.2:

@hebasto, I'm running on macOS BigSur, and I'm struggling to find a way to test on macOS Mojave... Do you use VirtualBox to run multiple macOS versions?

UPDATE: probably these changes need to be documented properly?

yes sure

@goums
Copy link
Author

goums commented Feb 26, 2021

Can the commit message in 303cfc6 be rewritten so it explains why this is possible. For release builds we are still using a version of Qt that doesn't properly support dark mode (as far as I'm aware support landed in 5.12.x).

Ok, thanks for your explanations @fanquake .
So theoretically, users downloading release builds will still run QT 5.9.8, right?
As it's the version specified in qt.mk
I'll try to run some tests with QT 5.9.8

If we now properly support dark mode, this note should be removed from doc/release-notes.md as part of this change:

Additionally, Bitcoin Core does not yet change appearance when macOS "dark mode" is activated.

Also, the PR body needs to be updated it's included in the merge), because it's no longer correct. i.e:

Note, that this currently only affect the build from source, as the macos dmg includes an attributes to force light color scheme on macos windows (see bitcoin/bitcoin#14593).

Yes, I'll update that too.

@hebasto
Copy link
Member

hebasto commented Mar 24, 2021

If we now properly support dark mode, this note should be removed from doc/release-notes.md as part of this change:

Additionally, Bitcoin Core does not yet change appearance when macOS "dark mode" is activated.

Maybe document (in release notes?) that switching appearance Light/Dark while Bitcoin Core running is not supported for macOS Mojave?

@fanquake

Will the following work:

--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -51,9 +51,9 @@ Core should also work on most other Unix-like systems but is not as
 frequently tested on them.  It is not recommended to use Bitcoin Core on
 unsupported systems.
 
-From Bitcoin Core 0.22.0 onwards, macOS versions earlier than 10.14 are no
-longer supported. Additionally, Bitcoin Core does not yet change appearance
-when macOS "dark mode" is activated.
+From Bitcoin Core 22.0 onwards, macOS versions earlier than 10.14 are no
+longer supported. Additionally, the appearance switching (light/dark) is
+not supported for maOS 10.14.
 
 Notable changes
 ===============

?

@fanquake
Copy link
Member

So is it just 10.14 it doesn't work on now? Release builds work correctly on 10.15+? I'm not sure what's wrong with "Bitcoin Core does not yet change appearance when macOS "dark mode" is activated.", but I'm happy for this to be rewritten/updated however.

@hebasto
Copy link
Member

hebasto commented Mar 24, 2021

With this PR:

Release builds work correctly on 10.15+?

Yes.

So is it just 10.14 it doesn't work on now?

Partially. Appearance switching while Bitcoin Core is running does not cause automatic switching of icons.

what's wrong with "Bitcoin Core does not yet change appearance when macOS "dark mode" is activated."

On 10.14 only icons do not change appearance.

Being a non-English native speaker, I'll appreciate better wording suggestions to express the ideas above :)

@jarolrod
Copy link
Member

Being a non-English native speaker, I'll appreciate better wording suggestions to express the ideas above :)

@hebasto this is how I would put it, just a suggestion.

-From Bitcoin Core 22.0 onwards, macOS versions earlier than 10.14 are no
-longer supported. Additionally, the appearance switching (light/dark) is
-not supported for maOS 10.14.

+From Bitcoin Core 22.0 onwards, macOS versions earlier than 10.14 are no
+longer supported. Additionally, switching between light and dark mode is
+not supported on macOS 10.14.

@fanquake
Copy link
Member

On 10.14 only icons do not change appearance.

In that case I'd just drop the note entirely. It's no longer worth-while to call out in the release notes.

@hebasto
Copy link
Member

hebasto commented Mar 25, 2021

@goums

Could you implement @fanquake's suggestion to get this PR ready to merge?

@goums
Copy link
Author

goums commented Mar 25, 2021

Thanks @hebasto and @jarolrod for the updates and suggestions.

On 10.14 only icons do not change appearance.

In that case I'd just drop the note entirely. It's no longer worth-while to call out in the release notes.

I agree with @fanquake comment: as user usually don't switch light/dark mode to test the application, it will work just fine for most people by rendering correctly on start time depending on their settings.
I've dropped the line from the release note.

Also, the PR body needs to be updated it's included in the merge), because it's no longer correct. i.e:

Note, that this currently only affect the build from source, as the macos dmg includes an attributes to force light color scheme on macos windows (see bitcoin/bitcoin#14593).

Done

@jarolrod
Copy link
Member

@goums linter is failing: https://cirrus-ci.com/task/4605693853433856?command=lint#L916

diff --git a/doc/release-notes.md b/doc/release-notes.md
@@ -55,2 +55 @@ From Bitcoin Core 0.22.0 onwards, macOS versions earlier than 10.14 are no
+longer supported.
^---- failure generated from test/lint/lint-whitespace.sh

You can just place this warning on one line now. Doesn't have to go on two separate lines just to accommodate longer supported

@@ -52,8 +52,7 @@ frequently tested on them. It is not recommended to use Bitcoin Core on
unsupported systems.

From Bitcoin Core 0.22.0 onwards, macOS versions earlier than 10.14 are no
longer supported. Additionally, Bitcoin Core does not yet change appearance
when macOS "dark mode" is activated.
longer supported.
Copy link
Member

@hebasto hebasto Mar 25, 2021

Choose a reason for hiding this comment

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

removing trailing space is enough :)

Suggested change
longer supported.
longer supported.

@jarolrod
Copy link
Member

Don't want to start with any bikeshedding but 56ed4ce should be squashed onto 02223fc, almost there 🥃

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK 56ed4ce, gitian builds (this pr merged onto the master) tested:

  • macOS Mojave 10.14.6 (18G8022):

Screenshot from 2021-03-25 16-02-54

  • macOS Catalina 10.15.7 (19H524):

Screenshot from 2021-03-25 15-54-22

  • macOS Big Sur 11.2.3 (20D91):

Screenshot from 2021-03-25 15-43-42


@goums
On purpose to get a nice commit history in the git, do you mind squashing your commits, at least the last two ones?

From Bitcoin Core 0.22.0 onwards, macOS versions earlier than 10.14 are no
longer supported. Additionally, Bitcoin Core does not yet change appearance
when macOS "dark mode" is activated.
From Bitcoin Core 0.22.0 onwards, macOS versions earlier than 10.14 are no longer supported.
Copy link
Member

@hebasto hebasto Mar 25, 2021

Choose a reason for hiding this comment

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

(see bitcoin/bitcoin#20223)

Suggested change
From Bitcoin Core 0.22.0 onwards, macOS versions earlier than 10.14 are no longer supported.
From Bitcoin Core 22.0 onwards, macOS versions earlier than 10.14 are no longer supported.

@goums goums force-pushed the macos_color_icons branch from 56ed4ce to dc4551c Compare March 25, 2021 14:31
@goums
Copy link
Author

goums commented Mar 25, 2021

ok, sorry about that ^^
git commits squashed into: dc4551c

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

re-ACK dc4551c

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

ACK dc4551c

@maflcko
Copy link
Contributor

maflcko commented Mar 29, 2021

@fanquake Anything left to do here?

@fanquake
Copy link
Member

Anything left to do here?

I haven't tested this, but I think it can be merged.

@maflcko maflcko merged commit 3bcd278 into bitcoin-core:master Mar 29, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 29, 2021
@hebasto
Copy link
Member

hebasto commented Mar 31, 2021

@goums @jarolrod

Do you mind testing bitcoin/bitcoin#19817 (in context of bitcoin/bitcoin#19817 (comment))?

@hebasto
Copy link
Member

hebasto commented May 27, 2021

@goums

Kindly asking to test #275 as it completes the task you started here.

gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin-core bitcoin-core locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants