From b5a8442ed28a709dbc3065dfabb5bbcdf694b2a1 Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Fri, 6 Mar 2020 12:20:33 +0100 Subject: [PATCH] added "unlock themes" hyperlink in general preferences if no valid license has been found --- .../GeneralPreferencesController.java | 11 ++++++++++- .../ui/preferences/PreferencesController.java | 17 +++++++++++++++-- main/ui/src/main/resources/css/dark_theme.css | 4 ++++ main/ui/src/main/resources/css/light_theme.css | 4 ++++ .../ui/src/main/resources/fxml/preferences.fxml | 8 ++++---- .../resources/fxml/preferences_general.fxml | 8 +++++--- .../src/main/resources/i18n/strings.properties | 1 + 7 files changed, 43 insertions(+), 10 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java index ae18dbd3f..85c8630b0 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.preferences; import javafx.application.Platform; +import javafx.beans.property.ObjectProperty; import javafx.beans.value.ObservableValue; import javafx.concurrent.Task; import javafx.fxml.FXML; @@ -31,6 +32,7 @@ public class GeneralPreferencesController implements FxController { private final Settings settings; private final boolean trayMenuSupported; private final Optional autoStartStrategy; + private final ObjectProperty selectedTabProperty; private final LicenseHolder licenseHolder; private final ExecutorService executor; public ChoiceBox themeChoiceBox; @@ -42,10 +44,11 @@ public class GeneralPreferencesController implements FxController { public RadioButton nodeOrientationRtl; @Inject - GeneralPreferencesController(Settings settings, @Named("trayMenuSupported") boolean trayMenuSupported, Optional autoStartStrategy, LicenseHolder licenseHolder, ExecutorService executor) { + GeneralPreferencesController(Settings settings, @Named("trayMenuSupported") boolean trayMenuSupported, Optional autoStartStrategy, ObjectProperty selectedTabProperty, LicenseHolder licenseHolder, ExecutorService executor) { this.settings = settings; this.trayMenuSupported = trayMenuSupported; this.autoStartStrategy = autoStartStrategy; + this.selectedTabProperty = selectedTabProperty; this.licenseHolder = licenseHolder; this.executor = executor; } @@ -103,6 +106,12 @@ public class GeneralPreferencesController implements FxController { return licenseHolder; } + + @FXML + public void showDonationTab() { + selectedTabProperty.set(SelectedPreferencesTab.DONATION_KEY); + } + /* Helper classes */ private static class UiThemeConverter extends StringConverter { diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java index 718f9d443..2b3a8d5ea 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java @@ -1,9 +1,7 @@ package org.cryptomator.ui.preferences; -import javafx.beans.Observable; import javafx.beans.binding.BooleanBinding; import javafx.beans.property.ObjectProperty; -import javafx.beans.value.ObservableValue; import javafx.fxml.FXML; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; @@ -11,12 +9,16 @@ import javafx.stage.Stage; import javafx.stage.WindowEvent; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.fxapp.UpdateChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.inject.Inject; @PreferencesScoped public class PreferencesController implements FxController { + private static final Logger LOG = LoggerFactory.getLogger(PreferencesController.class); + private final Stage window; private final ObjectProperty selectedTabProperty; private final BooleanBinding updateAvailable; @@ -37,6 +39,7 @@ public class PreferencesController implements FxController { public void initialize() { window.setOnShowing(this::windowWillAppear); selectedTabProperty.addListener(observable -> this.selectChosenTab()); + tabPane.getSelectionModel().selectedItemProperty().addListener(observable -> this.selectedTabChanged()); } private void selectChosenTab() { @@ -60,6 +63,16 @@ public class PreferencesController implements FxController { } } + private void selectedTabChanged() { + Tab selectedTab = tabPane.getSelectionModel().getSelectedItem(); + try { + SelectedPreferencesTab selectedPreferencesTab = SelectedPreferencesTab.valueOf(selectedTab.getId()); + selectedTabProperty.set(selectedPreferencesTab); + } catch (IllegalArgumentException e) { + LOG.error("Unknown preferences tab id: {}", selectedTab.getId()); + } + } + private void windowWillAppear(@SuppressWarnings("unused") WindowEvent windowEvent) { selectChosenTab(); } diff --git a/main/ui/src/main/resources/css/dark_theme.css b/main/ui/src/main/resources/css/dark_theme.css index 4a31930f8..3c309a9da 100644 --- a/main/ui/src/main/resources/css/dark_theme.css +++ b/main/ui/src/main/resources/css/dark_theme.css @@ -567,6 +567,10 @@ -fx-graphic-text-gap: 6px; } +.hyperlink.hyperlink-underline { + -fx-underline: true; +} + .hyperlink.hyperlink-secondary { -fx-text-fill: TEXT_FILL_MUTED; } diff --git a/main/ui/src/main/resources/css/light_theme.css b/main/ui/src/main/resources/css/light_theme.css index 64e4a527b..3b3594ffd 100644 --- a/main/ui/src/main/resources/css/light_theme.css +++ b/main/ui/src/main/resources/css/light_theme.css @@ -566,6 +566,10 @@ -fx-graphic-text-gap: 6px; } +.hyperlink.hyperlink-underline { + -fx-underline: true; +} + .hyperlink.hyperlink-secondary { -fx-text-fill: TEXT_FILL_MUTED; } diff --git a/main/ui/src/main/resources/fxml/preferences.fxml b/main/ui/src/main/resources/fxml/preferences.fxml index 661ca097f..58faa7179 100644 --- a/main/ui/src/main/resources/fxml/preferences.fxml +++ b/main/ui/src/main/resources/fxml/preferences.fxml @@ -14,7 +14,7 @@ tabClosingPolicy="UNAVAILABLE" tabDragPolicy="FIXED"> - + @@ -22,7 +22,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/main/ui/src/main/resources/fxml/preferences_general.fxml b/main/ui/src/main/resources/fxml/preferences_general.fxml index 97d7e544c..555264bfe 100644 --- a/main/ui/src/main/resources/fxml/preferences_general.fxml +++ b/main/ui/src/main/resources/fxml/preferences_general.fxml @@ -3,11 +3,12 @@ + - - + +