|
@@ -1,26 +1,18 @@
|
|
|
package org.cryptomator.ui.mainwindow;
|
|
|
|
|
|
-import javafx.beans.binding.BooleanBinding;
|
|
|
import javafx.beans.property.BooleanProperty;
|
|
|
import javafx.beans.property.SimpleBooleanProperty;
|
|
|
import javafx.fxml.FXML;
|
|
|
import javafx.scene.input.DragEvent;
|
|
|
import javafx.scene.input.TransferMode;
|
|
|
-import javafx.scene.layout.HBox;
|
|
|
import javafx.scene.layout.StackPane;
|
|
|
-import javafx.stage.Stage;
|
|
|
-import org.cryptomator.common.LicenseHolder;
|
|
|
import org.cryptomator.common.vaults.VaultListManager;
|
|
|
import org.cryptomator.ui.common.FxController;
|
|
|
-import org.cryptomator.ui.fxapp.FxApplication;
|
|
|
-import org.cryptomator.ui.fxapp.UpdateChecker;
|
|
|
-import org.cryptomator.ui.preferences.SelectedPreferencesTab;
|
|
|
import org.cryptomator.ui.wrongfilealert.WrongFileAlertComponent;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
-import javax.inject.Named;
|
|
|
import java.io.File;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.NoSuchFileException;
|
|
@@ -34,29 +26,14 @@ public class MainWindowController implements FxController {
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(MainWindowController.class);
|
|
|
private static final String MASTERKEY_FILENAME = "masterkey.cryptomator"; // TODO: deduplicate constant declared in multiple classes
|
|
|
|
|
|
- private final Stage window;
|
|
|
- private final FxApplication application;
|
|
|
- private final boolean minimizeToSysTray;
|
|
|
- private final UpdateChecker updateChecker;
|
|
|
- private final BooleanBinding updateAvailable;
|
|
|
- private final LicenseHolder licenseHolder;
|
|
|
private final VaultListManager vaultListManager;
|
|
|
private final WrongFileAlertComponent.Builder wrongFileAlert;
|
|
|
private final BooleanProperty draggingOver = new SimpleBooleanProperty();
|
|
|
private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty();
|
|
|
- public HBox titleBar;
|
|
|
public StackPane root;
|
|
|
- private double xOffset;
|
|
|
- private double yOffset;
|
|
|
|
|
|
@Inject
|
|
|
- public MainWindowController(@MainWindow Stage window, FxApplication application, @Named("trayMenuSupported") boolean minimizeToSysTray, UpdateChecker updateChecker, LicenseHolder licenseHolder, VaultListManager vaultListManager, WrongFileAlertComponent.Builder wrongFileAlert) {
|
|
|
- this.window = window;
|
|
|
- this.application = application;
|
|
|
- this.minimizeToSysTray = minimizeToSysTray;
|
|
|
- this.updateChecker = updateChecker;
|
|
|
- this.updateAvailable = updateChecker.latestVersionProperty().isNotNull();
|
|
|
- this.licenseHolder = licenseHolder;
|
|
|
+ public MainWindowController(VaultListManager vaultListManager, WrongFileAlertComponent.Builder wrongFileAlert) {
|
|
|
this.vaultListManager = vaultListManager;
|
|
|
this.wrongFileAlert = wrongFileAlert;
|
|
|
}
|
|
@@ -64,15 +41,6 @@ public class MainWindowController implements FxController {
|
|
|
@FXML
|
|
|
public void initialize() {
|
|
|
LOG.debug("init MainWindowController");
|
|
|
- titleBar.setOnMousePressed(event -> {
|
|
|
- xOffset = event.getSceneX();
|
|
|
- yOffset = event.getSceneY();
|
|
|
- });
|
|
|
- titleBar.setOnMouseDragged(event -> {
|
|
|
- window.setX(event.getScreenX() - xOffset);
|
|
|
- window.setY(event.getScreenY() - yOffset);
|
|
|
- });
|
|
|
- updateChecker.automaticallyCheckForUpdatesIfEnabled();
|
|
|
root.setOnDragEntered(this::handleDragEvent);
|
|
|
root.setOnDragOver(this::handleDragEvent);
|
|
|
root.setOnDragDropped(this::handleDragEvent);
|
|
@@ -122,39 +90,8 @@ public class MainWindowController implements FxController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @FXML
|
|
|
- public void close() {
|
|
|
- if (minimizeToSysTray) {
|
|
|
- window.close();
|
|
|
- } else {
|
|
|
- window.setIconified(true);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @FXML
|
|
|
- public void showPreferences() {
|
|
|
- application.showPreferencesWindow(SelectedPreferencesTab.ANY);
|
|
|
- }
|
|
|
-
|
|
|
- @FXML
|
|
|
- public void showDonationKeyPreferences() {
|
|
|
- application.showPreferencesWindow(SelectedPreferencesTab.DONATION_KEY);
|
|
|
- }
|
|
|
-
|
|
|
/* Getter/Setter */
|
|
|
|
|
|
- public LicenseHolder getLicenseHolder() {
|
|
|
- return licenseHolder;
|
|
|
- }
|
|
|
-
|
|
|
- public BooleanBinding updateAvailableProperty() {
|
|
|
- return updateAvailable;
|
|
|
- }
|
|
|
-
|
|
|
- public boolean isUpdateAvailable() {
|
|
|
- return updateAvailable.get();
|
|
|
- }
|
|
|
-
|
|
|
public BooleanProperty draggingOverProperty() {
|
|
|
return draggingOver;
|
|
|
}
|