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

This commit is contained in:
Tobias Hagemann 2020-08-18 16:08:23 +02:00
parent 841d4eb9c7
commit 710c7d0da7
No known key found for this signature in database
GPG Key ID: 898890C09D3199B3
4 changed files with 30 additions and 1 deletions

View File

@ -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"), //

View File

@ -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();
}
}

View File

@ -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>

View File

@ -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