-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add option to use OS specific colour theme #9263
Conversation
…her based on system settings
…as 'Automatic detection' as the AppearancePreference and so needs to hold this state
@@ -2067,7 +2067,8 @@ public AppearancePreferences getAppearancePreferences() { | |||
appearancePreferences = new AppearancePreferences( | |||
getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), | |||
getInt(MAIN_FONT_SIZE), | |||
new Theme(get(FX_THEME)) | |||
new Theme(get(FX_THEME)), | |||
false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need to add a new constant for the new flag and get the value here : sth like getBoolean(AUTOMATIC_THEME_DETECTION) and then add a new listener so that the value gets stored and read on change
To ease organizational workflows I have linked the pull-request to the issue with syntax as described in https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
|
…actoring + commenting
Bumps [gittools/actions](https://github.com/gittools/actions) from 0.9.13 to 0.9.14. - [Release notes](https://github.com/gittools/actions/releases) - [Commits](GitTools/actions@v0.9.13...v0.9.14) --- updated-dependencies: - dependency-name: gittools/actions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [hmarr/auto-approve-action](https://github.com/hmarr/auto-approve-action) from 2.4.0 to 3.0.0. - [Release notes](https://github.com/hmarr/auto-approve-action/releases) - [Commits](hmarr/auto-approve-action@v2.4.0...v3.0.0) --- updated-dependencies: - dependency-name: hmarr/auto-approve-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/configure-pages](https://github.com/actions/configure-pages) from 1 to 2. - [Release notes](https://github.com/actions/configure-pages/releases) - [Commits](actions/configure-pages@v1...v2) --- updated-dependencies: - dependency-name: actions/configure-pages dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [controlsfx](https://github.com/controlsfx/controlsfx) from 11.1.1 to 11.1.2. - [Release notes](https://github.com/controlsfx/controlsfx/releases) - [Commits](controlsfx/controlsfx@11.1.1...11.1.2) --- updated-dependencies: - dependency-name: org.controlsfx:controlsfx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Save files again relative to bib file * Reworded * Reintroduced default file chooser directory without swing * Update CHANGELOG.md * Update CHANGELOG.md * Update NativeDesktop.java * Reworked ADR * Added mac directory * Removed comments * Added linux support * Revert "Save files again relative to bib file" This reverts commit 3e640f5. # Conflicts: # CHANGELOG.md # src/main/java/org/jabref/preferences/FilePreferences.java # src/main/java/org/jabref/preferences/JabRefPreferences.java # src/test/java/org/jabref/model/database/BibDatabaseContextTest.java * Update src/main/java/org/jabref/gui/desktop/os/Windows.java * fix merge errors * fix wrong method call * remove defautl fix checkstyle * reintroduce method to avoid calling get two times * Introduced getPath method * Update src/main/java/org/jabref/gui/desktop/os/Linux.java fix env var Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>
…her based on system settings
I've just noticed that I (at some point) pulled from upstream when in my remote branch accidentally which is why there are other people's contributions in this PR. Will this cause a problem? If so, let me know and I'll fix it up tomorrow. Thanks (sorry about that) |
@shafinkamal That's no problem, but you will probably need to sync your fork's main branch so that github correclty detecs the changes again On your fork in github just use the sync fork e.g. Thanks for your PR so far, it's overall looking good. But unfortunately the new dependency is blocked by https://bugs.openjdk.org/browse/JDK-8240567 |
Anything I can do to fix the failing tests or is it all good on my end? the fails seem to be related to servers and what not... Anyways, let me know. Thanks! |
Thanks it looks good, the failing tests are related to some jitpack error not resolving the dependency correctly. |
U sure this works with modern verions of windows too, because it looks like microsoft removed some registry keys: |
I'm not too sure about the modern versions of Windows as I have geared this towards MacOS, because the issue (#8729) is specific to MacOS and I have MacOS so I can manually test it on modern versions of that. I had included some Windows operations for the sake of coverage but perhaps another issue can be made to ensure further coverage of Windows (and other OS's). In the issue discussion, @Siedlerchr also mentions that a complete implementation would have to be done individually for each OS. If we're worried about the code breaking the application on the more recent versions of Windows, we can comment out the Windows section and make this a purely MacOS specific feature (for the time being). |
public final boolean isDarkMode() { | ||
switch (getOperatingSystem()) { | ||
case WINDOWS: return isWindowsDarkMode(); | ||
case MACOS: return isMacOsDarkMode(); | ||
// currently theme detection not implemented for Linux and Solaris | ||
case LINUX: return false; | ||
case SOLARIS: return false; | ||
default: return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please split up this class and use the existing OS package and classes to provide a method isDarkMode instead of introducing some code duplication to test for which os is runnning here?
Process process = Runtime.getRuntime().exec(DARK_THEME_CMD); | ||
StreamReader reader = new StreamReader(process.getInputStream()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You really should use JNA here, we already use it in other occasions and its a way cleaner solution.
this.shouldOverrideDefaultFontSize = new SimpleBooleanProperty(shouldOverrideDefaultFontSize); | ||
this.mainFontSize = new SimpleIntegerProperty(mainFontSize); | ||
this.theme = new SimpleObjectProperty<>(theme); | ||
this.automaticThemeDetectionFlag = new SimpleBooleanProperty(automaticThemeDetectionFlag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(should)AutoDetectTheme(Property)
<Label fx:id="restartJabRefHint" styleClass="text" text="${'\nRestarting JabRef may be required to display changes in theme preferences.'}"> | ||
<font> | ||
<Font name="Italic" size="13.0"/> | ||
</font> | ||
</Label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why just fixed the restart for theme change issue a few months back. This would be a major regression.
Thanks for your interest in JabRef programming. I like the idea, yet there are some issues with you changes that should be adressed... |
* upstream/main: (55 commits) Update guidelines-for-setting-up-a-local-workspace.md Add link to good first issues (and fix link) Refine guidelines (and fix .md file linking) Extend ArXiv fetcher results by using data from related DOIs (JabRef#9170) New Crowdin updates (JabRef#9366) Fix token New translations JabRef_en.properties (Chinese Simplified) (JabRef#9364) Fix date field change causes an uncaught exception (JabRef#9365) Add date format and respective test case (JabRef#9310) Bump jackson-datatype-jsr310 from 2.13.4 to 2.14.0 (JabRef#9357) Bump jackson-dataformat-yaml from 2.13.4 to 2.14.0 (JabRef#9356) Bump tika-core from 2.5.0 to 2.6.0 (JabRef#9358) Refine guideline "Set up a local workspace" (JabRef#9355) Adds missing "requires" statement (JabRef#9354) Bind "Find unlinked files" default directory to the current library (JabRef#9290) Rename "Remote" to "Tele" (JabRef#9270) Fixed display of file field adjusting for the dark theme (JabRef#9343) Update sorting of entries in maintable by special fields immediately (JabRef#9338) New translations JabRef_en.properties (German) (JabRef#9336) Fix Abbreviation for Escaped Ampersand (JabRef#9288) ... # Conflicts: # CHANGELOG.md # src/main/java/org/jabref/preferences/AppearancePreferences.java # src/main/java/org/jabref/preferences/JabRefPreferences.java # src/test/java/org/jabref/gui/theme/ThemeManagerTest.java
Hey @shafinkamal. Do you plan to continue working on this? |
* upstream/main: (145 commits) Enable groups drag'n'drop to new library (JabRef#9460) Update MacOS jabrefHost.py to find local installs (JabRef#9487) Fix remember last open valid library with empty new one (JabRef#9489) Observable Preferences R (CitationKeyPatternPreferences) (JabRef#9486) Fixed ZBMathTest and extracted keyWordSeparator (JabRef#9485) New Crowdin updates (JabRef#9483) Add log for ignored excepton (JabRef#9302) Select Library to import into (JabRef#9402) Bump org.eclipse.jgit from 6.3.0.202209071007-r to 6.4.0.202211300538-r (JabRef#9476) Bump com.github.andygoossens.modernizer from 1.6.2 to 1.7.0 (JabRef#9478) Bump mockito-core from 4.9.0 to 4.10.0 (JabRef#9479) Bump checkstyle from 10.4 to 10.5.0 (JabRef#9477) Bump slf4j-api from 2.0.5 to 2.0.6 in /buildSrc (JabRef#9480) Bibtex month not deprecated (JabRef#9404) Show development information\n\n+semver: major Release v5.8 Update external libraries add afterburner fx jabref add jakarta inject fix display name for artifact store Prepare CHANGELOG for release Also trigger on branch arm64mac-release ... # Conflicts: # CHANGELOG.md # src/main/java/org/jabref/preferences/JabRefPreferences.java
Closing this issue due to inactivity 💤 |
- Add "Use System Preference" option under General -> Appearance -> Visual Theme - Add flags to store whether user chose this option - Add SystemThemeDetector.java for auto detect system theme(to do)
* Add basic files and settings followed by PR #9263 - Add "Use System Preference" option under General -> Appearance -> Visual Theme - Add flags to store whether user chose this option - Add SystemThemeDetector.java for auto detect system theme(to do) * Using jSystemThemeDetector to detect system theme - Add jSystemThemeDetector dependency in build.gradle - Implemented detector into codebase - Delete unnecessary java file * Add the "Use System Preference" to the English translation file * Add library document and licence * Add update to CHANGELOG.md * Update checkstyle * Update checkstyle * Update CHANGELOG.md. Former log was put in a released part. * Applied review notes and cleaned up * Update JabRefGUI.java Removed whitespace --------- Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Resolves #8729.
Currently, I have added a new Radio Button (see below) which the user would select so that their JabRef theme corresponds to the theme that their OS is currently. I have achieved that by referencing the jSystemThemeDetector library
However, I am currently at a roadblock and would greatly appreciate some help. If my MacOS Theme is 'Light', I can change it to 'Dark' and within JabRef if I select 'Automatic detection' and then 'Save', JabRef will change from Light to Dark. However when going back the JabRef Preferences, the setting has not stayed at 'Automatic detection' and instead has moved to 'Dark theme'. This means that next time I change from Dark to Light on my MacOS System Preferences, this change won't be reflected in JabRef. I've attached a demo to visually show the behaviour.
Any pointers please? Thank you!!!
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)