浏览代码

enable themes for donators

Sebastian Stenzel 5 年之前
父节点
当前提交
85e773abef

+ 6 - 2
main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java

@@ -9,6 +9,7 @@ import javafx.beans.value.ObservableValue;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableSet;
 import javafx.stage.Stage;
+import org.cryptomator.common.LicenseHolder;
 import org.cryptomator.common.settings.Settings;
 import org.cryptomator.common.settings.UiTheme;
 import org.cryptomator.common.vaults.Vault;
@@ -41,11 +42,12 @@ public class FxApplication extends Application {
 	private final QuitComponent.Builder quitWindowBuilder;
 	private final Optional<MacFunctions> macFunctions;
 	private final VaultService vaultService;
+	private final LicenseHolder licenseHolder;
 	private final ObservableSet<Stage> visibleStages = FXCollections.observableSet();
 	private final BooleanBinding hasVisibleStages = Bindings.isNotEmpty(visibleStages);
 
 	@Inject
-	FxApplication(Settings settings, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, UnlockComponent.Builder unlockWindowBuilder, QuitComponent.Builder quitWindowBuilder, Optional<MacFunctions> macFunctions, VaultService vaultService) {
+	FxApplication(Settings settings, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, UnlockComponent.Builder unlockWindowBuilder, QuitComponent.Builder quitWindowBuilder, Optional<MacFunctions> macFunctions, VaultService vaultService, LicenseHolder licenseHolder) {
 		this.settings = settings;
 		this.mainWindow = mainWindow;
 		this.preferencesWindow = preferencesWindow;
@@ -53,6 +55,7 @@ public class FxApplication extends Application {
 		this.quitWindowBuilder = quitWindowBuilder;
 		this.macFunctions = macFunctions;
 		this.vaultService = vaultService;
+		this.licenseHolder = licenseHolder;
 	}
 
 	public void start() {
@@ -123,7 +126,8 @@ public class FxApplication extends Application {
 		loadSelectedStyleSheet(newValue);
 	}
 
-	private void loadSelectedStyleSheet(UiTheme theme) {
+	private void loadSelectedStyleSheet(UiTheme desiredTheme) {
+		UiTheme theme = licenseHolder.isValidLicense() ? desiredTheme : UiTheme.LIGHT;
 		switch (theme) {
 //			case CUSTOM:
 //				// TODO

+ 8 - 1
main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java

@@ -11,6 +11,7 @@ import javafx.scene.control.RadioButton;
 import javafx.scene.control.Toggle;
 import javafx.scene.control.ToggleGroup;
 import javafx.util.StringConverter;
+import org.cryptomator.common.LicenseHolder;
 import org.cryptomator.common.settings.Settings;
 import org.cryptomator.common.settings.UiTheme;
 import org.cryptomator.ui.common.FxController;
@@ -30,6 +31,7 @@ public class GeneralPreferencesController implements FxController {
 	private final Settings settings;
 	private final boolean trayMenuSupported;
 	private final Optional<AutoStartStrategy> autoStartStrategy;
+	private final LicenseHolder licenseHolder;
 	private final ExecutorService executor;
 	public ChoiceBox<UiTheme> themeChoiceBox;
 	public CheckBox startHiddenCheckbox;
@@ -40,10 +42,11 @@ public class GeneralPreferencesController implements FxController {
 	public RadioButton nodeOrientationRtl;
 
 	@Inject
-	GeneralPreferencesController(Settings settings, @Named("trayMenuSupported") boolean trayMenuSupported, Optional<AutoStartStrategy> autoStartStrategy, ExecutorService executor) {
+	GeneralPreferencesController(Settings settings, @Named("trayMenuSupported") boolean trayMenuSupported, Optional<AutoStartStrategy> autoStartStrategy, LicenseHolder licenseHolder, ExecutorService executor) {
 		this.settings = settings;
 		this.trayMenuSupported = trayMenuSupported;
 		this.autoStartStrategy = autoStartStrategy;
+		this.licenseHolder = licenseHolder;
 		this.executor = executor;
 	}
 
@@ -96,6 +99,10 @@ public class GeneralPreferencesController implements FxController {
 		});
 	}
 
+	public LicenseHolder getLicenseHolder() {
+		return licenseHolder;
+	}
+
 	/* Helper classes */
 
 	private static class UiThemeConverter extends StringConverter<UiTheme> {

+ 1 - 1
main/ui/src/main/resources/fxml/preferences_general.fxml

@@ -21,7 +21,7 @@
 	<children>
 		<HBox spacing="6" alignment="CENTER_LEFT">
 			<Label text="%preferences.general.theme"/>
-			<ChoiceBox fx:id="themeChoiceBox"/>
+			<ChoiceBox fx:id="themeChoiceBox" disable="${!controller.licenseHolder.validLicense}"/>
 		</HBox>
 		
 		<HBox spacing="6" alignment="CENTER_LEFT">