From 1a71db41d7779b20761371b07e0173abc708eb09 Mon Sep 17 00:00:00 2001 From: Radek Davidek Date: Tue, 20 Jan 2026 18:02:57 +0100 Subject: [PATCH] inline rename with shift f6 --- .../cz/kamma/kfmanager/config/AppConfig.java | 32 +++++++++++++++++++ .../cz/kamma/kfmanager/ui/FileEditor.java | 19 +++++++++-- .../cz/kamma/kfmanager/ui/FilePanelTab.java | 17 ++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/main/java/cz/kamma/kfmanager/config/AppConfig.java b/src/main/java/cz/kamma/kfmanager/config/AppConfig.java index abddda4..596e18d 100644 --- a/src/main/java/cz/kamma/kfmanager/config/AppConfig.java +++ b/src/main/java/cz/kamma/kfmanager/config/AppConfig.java @@ -94,6 +94,38 @@ public class AppConfig { properties.setProperty("window.maximized", String.valueOf(maximized)); } + public int getFileEditorX() { + return Integer.parseInt(properties.getProperty("fileeditor.x", "150")); + } + + public void setFileEditorX(int x) { + properties.setProperty("fileeditor.x", String.valueOf(x)); + } + + public int getFileEditorY() { + return Integer.parseInt(properties.getProperty("fileeditor.y", "150")); + } + + public void setFileEditorY(int y) { + properties.setProperty("fileeditor.y", String.valueOf(y)); + } + + public int getFileEditorWidth() { + return Integer.parseInt(properties.getProperty("fileeditor.width", "800")); + } + + public void setFileEditorWidth(int width) { + properties.setProperty("fileeditor.width", String.valueOf(width)); + } + + public int getFileEditorHeight() { + return Integer.parseInt(properties.getProperty("fileeditor.height", "600")); + } + + public void setFileEditorHeight(int height) { + properties.setProperty("fileeditor.height", String.valueOf(height)); + } + public String getActivePanel() { return properties.getProperty("active.panel", "left"); } diff --git a/src/main/java/cz/kamma/kfmanager/ui/FileEditor.java b/src/main/java/cz/kamma/kfmanager/ui/FileEditor.java index 415b21d..a526ae3 100644 --- a/src/main/java/cz/kamma/kfmanager/ui/FileEditor.java +++ b/src/main/java/cz/kamma/kfmanager/ui/FileEditor.java @@ -65,8 +65,12 @@ public class FileEditor extends JDialog { // Final window positioning and visibility - only set default size if NOT an image if (!isImageFile(file)) { - setSize(800, 600); - setLocationRelativeTo(parent); + setSize(config.getFileEditorWidth(), config.getFileEditorHeight()); + if (config.getFileEditorX() == 150 && config.getFileEditorY() == 150) { + setLocationRelativeTo(parent); + } else { + setLocation(config.getFileEditorX(), config.getFileEditorY()); + } } // Intercept window close (X) so we run the same save-confirm flow as other close actions @@ -1036,7 +1040,18 @@ public class FileEditor extends JDialog { } } + private void saveWindowState() { + if (!isImageFile(file)) { + config.setFileEditorX(this.getX()); + config.setFileEditorY(this.getY()); + config.setFileEditorWidth(this.getWidth()); + config.setFileEditorHeight(this.getHeight()); + config.saveConfig(); + } + } + private void closeEditor() { + saveWindowState(); if (!readOnly && modified) { int result = showSaveConfirmDialog("Soubor byl změněn. Uložit změny?", "Neuložené změny"); diff --git a/src/main/java/cz/kamma/kfmanager/ui/FilePanelTab.java b/src/main/java/cz/kamma/kfmanager/ui/FilePanelTab.java index 1df6fc4..b3af15f 100644 --- a/src/main/java/cz/kamma/kfmanager/ui/FilePanelTab.java +++ b/src/main/java/cz/kamma/kfmanager/ui/FilePanelTab.java @@ -76,6 +76,23 @@ public class FilePanelTab extends JPanel { /** Start inline rename for currently selected item (if single selection). */ public void startInlineRename() { + // If already editing, special logic: select filename without extension + if (fileTable.isEditing()) { + Component ed = fileTable.getEditorComponent(); + if (ed instanceof JTextField) { + JTextField tf = (JTextField) ed; + String text = tf.getText(); + int lastDot = text.lastIndexOf('.'); + if (lastDot > 0) { // Found a dot, and it's not the first character + tf.setSelectionStart(0); + tf.setSelectionEnd(lastDot); + } else { + tf.selectAll(); + } + } + return; + } + // Determine selected row/column according to view mode int selRow = fileTable.getSelectedRow(); if (selRow < 0) return;