mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 17:46:52 -04:00
Select updates tab when showing preferences window and an update is available
This commit is contained in:
@@ -1,13 +1,40 @@
|
||||
package org.cryptomator.ui.preferences;
|
||||
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.fxapp.UpdateChecker;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@PreferencesScoped
|
||||
public class PreferencesController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final BooleanBinding updateAvailable;
|
||||
public TabPane tabPane;
|
||||
public Tab generalTab;
|
||||
public Tab updatesTab;
|
||||
|
||||
@Inject
|
||||
public PreferencesController() {}
|
||||
public PreferencesController(@PreferencesWindow Stage window, UpdateChecker updateChecker) {
|
||||
this.window = window;
|
||||
this.updateAvailable = updateChecker.latestVersionProperty().isNotNull();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
window.setOnShowing(this::windowWillAppear);
|
||||
}
|
||||
|
||||
private void windowWillAppear(WindowEvent windowEvent) {
|
||||
if (updateAvailable.get()) {
|
||||
tabPane.getSelectionModel().select(updatesTab);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,17 +4,18 @@
|
||||
<?import javafx.scene.control.TabPane?>
|
||||
<TabPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:id="tabPane"
|
||||
fx:controller="org.cryptomator.ui.preferences.PreferencesController"
|
||||
side="TOP"
|
||||
tabClosingPolicy="UNAVAILABLE"
|
||||
tabDragPolicy="FIXED">
|
||||
<tabs>
|
||||
<Tab text="TODO General">
|
||||
<Tab fx:id="generalTab" text="TODO General">
|
||||
<content>
|
||||
<fx:include source="/fxml/preferences_general.fxml"/>
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab text="TODO Updates">
|
||||
<Tab fx:id="updatesTab" text="TODO Updates">
|
||||
<content>
|
||||
<fx:include source="/fxml/preferences_updates.fxml"/>
|
||||
</content>
|
||||
|
||||
Reference in New Issue
Block a user