mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-22 12:41:27 +00:00
fix decrypt file name dialog to reuse one window per vault
This commit is contained in:
@@ -97,8 +97,7 @@ public class DecryptFileNamesViewController implements FxController {
|
||||
});
|
||||
cipherToCleartextTable.setOnDragDropped(event -> {
|
||||
if (event.getGestureSource() == null && event.getDragboard().hasFiles()) {
|
||||
checkAndDecrypt(event.getDragboard().getFiles().stream().map(File::toPath).toList());
|
||||
cipherToCleartextTable.setItems(mapping);
|
||||
decrypt(event.getDragboard().getFiles().stream().map(File::toPath).toList());
|
||||
}
|
||||
});
|
||||
cipherToCleartextTable.setOnDragExited(_ -> cipherToCleartextTable.setItems(mapping));
|
||||
@@ -124,9 +123,7 @@ public class DecryptFileNamesViewController implements FxController {
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!initialList.isEmpty()) {
|
||||
checkAndDecrypt(initialList);
|
||||
}
|
||||
decrypt(initialList);
|
||||
}
|
||||
|
||||
private void copySingleCelltoClipboard() {
|
||||
@@ -149,10 +146,18 @@ public class DecryptFileNamesViewController implements FxController {
|
||||
fileChooser.setInitialDirectory(vault.getPath().toFile());
|
||||
var ciphertextNodes = fileChooser.showOpenMultipleDialog(window);
|
||||
if (ciphertextNodes != null) {
|
||||
checkAndDecrypt(ciphertextNodes.stream().map(File::toPath).toList());
|
||||
decrypt(ciphertextNodes.stream().map(File::toPath).toList());
|
||||
}
|
||||
}
|
||||
|
||||
public void decrypt(List<Path> pathsToDecrypt) {
|
||||
if (pathsToDecrypt.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
checkAndDecrypt(pathsToDecrypt);
|
||||
cipherToCleartextTable.setItems(mapping);
|
||||
}
|
||||
|
||||
private void checkAndDecrypt(List<Path> pathsToDecrypt) {
|
||||
mapping.clear();
|
||||
//Assumption: All files are in the same directory
|
||||
|
||||
@@ -28,15 +28,23 @@ public interface DecryptNameComponent {
|
||||
@FxmlScene(FxmlFile.DECRYPTNAMES)
|
||||
Lazy<Scene> decryptNamesView();
|
||||
|
||||
DecryptFileNamesViewController controller();
|
||||
|
||||
@DecryptNameWindow
|
||||
Vault vault();
|
||||
|
||||
default void showDecryptFileNameWindow() {
|
||||
showDecryptFileNameWindow(List.of());
|
||||
}
|
||||
|
||||
default void showDecryptFileNameWindow(List<Path> pathsToDecrypt) {
|
||||
Stage s = window();
|
||||
s.setScene(decryptNamesView().get());
|
||||
s.sizeToScene();
|
||||
if (vault().isUnlocked()) {
|
||||
controller().decrypt(pathsToDecrypt);
|
||||
s.show();
|
||||
s.requestFocus();
|
||||
} else {
|
||||
LOG.error("Aborted showing DecryptFileName window: vault state is not {}, but {}.", VaultState.Value.UNLOCKED, vault().getState());
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class VaultDetailUnlockedController implements FxController {
|
||||
private final DecryptNameComponent.Factory decryptNameWindowFactory;
|
||||
private final ResourceBundle resourceBundle;
|
||||
private final LoadingCache<Vault, VaultStatisticsComponent> vaultStats;
|
||||
private final LoadingCache<Vault, DecryptNameComponent> decryptNameWindows;
|
||||
private final VaultStatisticsComponent.Builder vaultStatsBuilder;
|
||||
private final ObservableValue<Boolean> accessibleViaPath;
|
||||
private final ObservableValue<Boolean> accessibleViaUri;
|
||||
@@ -96,6 +97,7 @@ public class VaultDetailUnlockedController implements FxController {
|
||||
this.decryptNameWindowFactory = decryptNameWindowFactory;
|
||||
this.resourceBundle = resourceBundle;
|
||||
this.vaultStats = CacheBuilder.newBuilder().weakValues().build(CacheLoader.from(this::buildVaultStats));
|
||||
this.decryptNameWindows = CacheBuilder.newBuilder().weakValues().build(CacheLoader.from(this::buildDecryptNameWindow));
|
||||
this.vaultStatsBuilder = vaultStatsBuilder;
|
||||
var mp = vault.flatMap(Vault::mountPointProperty);
|
||||
this.accessibleViaPath = mp.map(m -> m instanceof Mountpoint.WithPath).orElse(false);
|
||||
@@ -167,7 +169,7 @@ public class VaultDetailUnlockedController implements FxController {
|
||||
}
|
||||
|
||||
private void showDecryptNameWindow(List<Path> pathsToDecrypt) {
|
||||
decryptNameWindowFactory.create(vault.get(), mainWindow, pathsToDecrypt).showDecryptFileNameWindow();
|
||||
decryptNameWindows.getUnchecked(vault.get()).showDecryptFileNameWindow(pathsToDecrypt);
|
||||
}
|
||||
|
||||
private boolean startsWithVaultAccessPoint(Path path) {
|
||||
@@ -220,6 +222,10 @@ public class VaultDetailUnlockedController implements FxController {
|
||||
return vaultStatsBuilder.vault(vault).build();
|
||||
}
|
||||
|
||||
private DecryptNameComponent buildDecryptNameWindow(Vault vault) {
|
||||
return decryptNameWindowFactory.create(vault, mainWindow, List.of());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void revealAccessLocation() {
|
||||
vaultService.reveal(vault.get());
|
||||
|
||||
Reference in New Issue
Block a user