mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-19 17:16:53 -04:00
Merge pull request #3194 from AntoineJT/feature/3155-toggle-vault-status-on-double-click
Feature: Double click on a vault in the list to unlock it
This commit is contained in:
@@ -7,6 +7,7 @@ import org.cryptomator.cryptofs.CryptoFileSystemProvider;
|
||||
import org.cryptomator.cryptofs.DirStructure;
|
||||
import org.cryptomator.ui.addvaultwizard.AddVaultWizardComponent;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.fxapp.FxApplicationWindows;
|
||||
import org.cryptomator.ui.removevault.RemoveVaultComponent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -37,6 +38,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -64,6 +66,7 @@ public class VaultListController implements FxController {
|
||||
private final VaultListManager vaultListManager;
|
||||
private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty();
|
||||
private final ResourceBundle resourceBundle;
|
||||
private final FxApplicationWindows appWindows;
|
||||
|
||||
public ListView<Vault> vaultList;
|
||||
public StackPane root;
|
||||
@@ -79,7 +82,8 @@ public class VaultListController implements FxController {
|
||||
AddVaultWizardComponent.Builder addVaultWizard, //
|
||||
RemoveVaultComponent.Builder removeVaultDialogue, //
|
||||
VaultListManager vaultListManager, //
|
||||
ResourceBundle resourceBundle) {
|
||||
ResourceBundle resourceBundle, //
|
||||
FxApplicationWindows appWindows) {
|
||||
this.mainWindow = mainWindow;
|
||||
this.vaults = vaults;
|
||||
this.selectedVault = selectedVault;
|
||||
@@ -88,6 +92,7 @@ public class VaultListController implements FxController {
|
||||
this.removeVaultDialogue = removeVaultDialogue;
|
||||
this.vaultListManager = vaultListManager;
|
||||
this.resourceBundle = resourceBundle;
|
||||
this.appWindows = appWindows;
|
||||
|
||||
this.emptyVaultList = Bindings.isEmpty(vaults);
|
||||
|
||||
@@ -108,6 +113,15 @@ public class VaultListController implements FxController {
|
||||
});
|
||||
vaultList.addEventFilter(MouseEvent.MOUSE_RELEASED, this::deselect);
|
||||
|
||||
//unlock vault on double click
|
||||
vaultList.addEventFilter(MouseEvent.MOUSE_CLICKED, click -> {
|
||||
if (click.getClickCount() >= 2) {
|
||||
Optional.ofNullable(selectedVault.get())
|
||||
.filter(Vault::isLocked)
|
||||
.ifPresent(vault -> appWindows.startUnlockWorkflow(vault, mainWindow));
|
||||
}
|
||||
});
|
||||
|
||||
//don't show context menu when no vault selected
|
||||
vaultList.addEventFilter(ContextMenuEvent.CONTEXT_MENU_REQUESTED, request -> {
|
||||
if (selectedVault.get() == null) {
|
||||
|
||||
Reference in New Issue
Block a user