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

Dark reader mode: welcome page's text also get dark when turning on. #1450

Open
atauzki opened this issue Mar 31, 2024 · 11 comments
Open

Dark reader mode: welcome page's text also get dark when turning on. #1450

atauzki opened this issue Mar 31, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@atauzki
Copy link
Collaborator

atauzki commented Mar 31, 2024

The version I used is compiled with qt6.7.0:
https://cloud.freemdict.com/index.php/s/psF3GZstsYZ3JZc

step:

  1. open goldendict
  2. set "Dark reader mode" to "ON"
  3. text are getting black.

This is the screenshort:
https://github.com/xiaoyifang/goldendict-ng/assets/19769843/26695d63-5a8d-4855-9d90-96970d2b8927

@atauzki
Copy link
Collaborator Author

atauzki commented Mar 31, 2024

And I also tried the latest version on Github, it takes no effect before relaunching the program or make a word query.

@atauzki atauzki changed the title Dark reader mode: text also get dark when turning on. Dark reader mode: welcome page's text also get dark when turning on. Mar 31, 2024
@shenlebantongying
Copy link
Collaborator

shenlebantongying commented Mar 31, 2024

I don't have time right now due to exams in the following weeks.

However, these are my guesses:

  1. This change is problematic fix: reduce darkreader mode white flash further by using QWebEnginePage::setBackgroundColor() (for Qt6.6.3+) #1406
  2. Various code were added to Qt6.7 that enables Chrome's built-in dark mode. Qt6.7 has this new ForceDarkMode (which is an exp experimental feature flag chrome://flags/#enable-force-dark)
  3. We need to bump dark-reader.js which is almost 2 years behind
    1. https://github.com/xiaoyifang/goldendict-ng/blob/staged/src/scripts/darkreader.js
    2. https://github.com/darkreader/darkreader/blob/main/CHANGELOG.md#4958-sep-22-2022

@xiaoyifang xiaoyifang added the bug Something isn't working label Apr 1, 2024
@xiaoyifang
Copy link
Owner

#1452

@atauzki can you help to try this PR?

@atauzki
Copy link
Collaborator Author

atauzki commented Apr 1, 2024

background and text in welcome page dont change to black before query or restart just like before.

@xiaoyifang
Copy link
Owner

I guess the reason is that the welcome page does not refresh when the dark mode setting changes

@shenlebantongying
Copy link
Collaborator

I tried all configurations other than on Windows. I cannot reproduce in any way.

Maybe you have local article-style.css affecting it?

@atauzki
Copy link
Collaborator Author

atauzki commented May 5, 2024

article-style.css

.mdict + .mdict {
    margin-top: 20px
}

.mwiki {
    font-size: 14px
}

compiled last code, and comment these code, still reproducable.

@shenlebantongying
Copy link
Collaborator

shenlebantongying commented May 5, 2024

Don't screenshot code my friend, just copy and paste 🫠🫠🫠🫠🫠

I will check it when I can access a Windows machine today.

@shenlebantongying
Copy link
Collaborator

I still cannot reproduce, the article-style.css is inserted.

Maybe a bug of re-release Qt6.7? This issue was opened when Qt6.7 was not yet released.

image

@atauzki
Copy link
Collaborator Author

atauzki commented May 5, 2024

I tried 6.6.2 build on github action build on Mar 31, the day I proposed this issue. And qt 6.7.0 action is not completed that time.
In 6.6.2, the welcome page has no change at all after turn on the dark reader mode until restart. (not portable mode, so no extra config takes effect)
Maybe the background change affected 6.7.0 but doesn't affect 6.6.2.
Then I inspected the page shows darkreader.js doesn't loads until restart in both version.

@shenlebantongying
Copy link
Collaborator

shenlebantongying commented May 8, 2024

This problem is super weird.

Set a breakpoint here:

ArticleView & view = dynamic_cast< ArticleView & >( *( ui.tabWidget->widget( x ) ) );
view.setSelectionBySingleClick( p.selectWordBySingleClick );
view.syncBackgroundColorWithCfgDarkReader();
if ( needReload ) {
view.reload();
}

view.currentWord is "welcome!", so the right widget got picked up.

needReload is true, the webview's reload is called.

Manually calling view.reload(); is debugger -> won't trigger reload. The reload is called, but LocalSchemeHandler::requestStarted will not be triggered (????)

However, when switching dark mode on and off, you can rigger reload inside the browser's inspector by calling location.reload() in JavaScript and the welcome page will successfully reload and dark theme will be correctly set. (????)

All other pages other than welcome are OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants