Procházet zdrojové kódy

added button to main window title if debug mode is enabled, fixes #1065

Tobias Hagemann před 4 roky
rodič
revize
710c7d0da7

+ 1 - 0
main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java

@@ -6,6 +6,7 @@ package org.cryptomator.ui.controls;
 public enum FontAwesome5Icon {
 	ANCHOR("\uF13D"), //
 	ARROW_UP("\uF062"), //
+	BUG("\uF188"), //
 	CHECK("\uF00C"), //
 	COG("\uF013"), //
 	COGS("\uF085"), //

+ 20 - 1
main/ui/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java

@@ -1,10 +1,12 @@
 package org.cryptomator.ui.mainwindow;
 
+import javafx.beans.binding.Bindings;
 import javafx.beans.binding.BooleanBinding;
 import javafx.fxml.FXML;
 import javafx.scene.layout.HBox;
 import javafx.stage.Stage;
 import org.cryptomator.common.LicenseHolder;
+import org.cryptomator.common.settings.Settings;
 import org.cryptomator.ui.common.FxController;
 import org.cryptomator.ui.fxapp.FxApplication;
 import org.cryptomator.ui.fxapp.UpdateChecker;
@@ -30,12 +32,14 @@ public class MainWindowTitleController implements FxController {
 	private final UpdateChecker updateChecker;
 	private final BooleanBinding updateAvailable;
 	private final LicenseHolder licenseHolder;
+	private final Settings settings;
+	private final BooleanBinding debugModeEnabled;
 
 	private double xOffset;
 	private double yOffset;
 
 	@Inject
-	MainWindowTitleController(AppLifecycleListener appLifecycle, @MainWindow Stage window, FxApplication application, @Named("trayMenuSupported") boolean minimizeToSysTray, UpdateChecker updateChecker, LicenseHolder licenseHolder) {
+	MainWindowTitleController(AppLifecycleListener appLifecycle, @MainWindow Stage window, FxApplication application, @Named("trayMenuSupported") boolean minimizeToSysTray, UpdateChecker updateChecker, LicenseHolder licenseHolder, Settings settings) {
 		this.appLifecycle = appLifecycle;
 		this.window = window;
 		this.application = application;
@@ -43,6 +47,8 @@ public class MainWindowTitleController implements FxController {
 		this.updateChecker = updateChecker;
 		this.updateAvailable = updateChecker.latestVersionProperty().isNotNull();
 		this.licenseHolder = licenseHolder;
+		this.settings = settings;
+		this.debugModeEnabled = Bindings.createBooleanBinding(this::isDebugModeEnabled, settings.debugMode());
 	}
 
 	@FXML
@@ -82,6 +88,11 @@ public class MainWindowTitleController implements FxController {
 		application.showPreferencesWindow(SelectedPreferencesTab.ANY);
 	}
 
+	@FXML
+	public void showGeneralPreferences() {
+		application.showPreferencesWindow(SelectedPreferencesTab.GENERAL);
+	}
+
 	@FXML
 	public void showDonationKeyPreferences() {
 		application.showPreferencesWindow(SelectedPreferencesTab.DONATION_KEY);
@@ -104,4 +115,12 @@ public class MainWindowTitleController implements FxController {
 	public boolean isMinimizeToSysTray() {
 		return minimizeToSysTray;
 	}
+
+	public BooleanBinding debugModeEnabledProperty() {
+		return debugModeEnabled;
+	}
+
+	public boolean isDebugModeEnabled() {
+		return settings.debugMode().get();
+	}
 }

+ 8 - 0
main/ui/src/main/resources/fxml/main_window_title.fxml

@@ -32,6 +32,14 @@
 				<Tooltip text="%main.donationKeyMissing.tooltip"/>
 			</tooltip>
 		</Button>
+		<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#showGeneralPreferences" focusTraversable="false" visible="${controller.debugModeEnabled}">
+			<graphic>
+				<FontAwesome5IconView glyph="BUG" glyphSize="16"/>
+			</graphic>
+			<tooltip>
+				<Tooltip text="%main.debugModeEnabled.tooltip"/>
+			</tooltip>
+		</Button>
 		<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#showPreferences" focusTraversable="false">
 			<graphic>
 				<StackPane>

+ 1 - 0
main/ui/src/main/resources/i18n/strings.properties

@@ -165,6 +165,7 @@ preferences.about=About
 main.closeBtn.tooltip=Close
 main.minimizeBtn.tooltip=Minimize
 main.preferencesBtn.tooltip=Preferences
+main.debugModeEnabled.tooltip=Debug mode is enabled
 main.donationKeyMissing.tooltip=Please consider donating
 ## Drag 'n' Drop
 main.dropZone.dropVault=Add this vault