From a7a86059a843b96c71f16bcdcab3197bdb5672f1 Mon Sep 17 00:00:00 2001 From: Radek Davidek Date: Fri, 20 Feb 2026 13:34:25 +0100 Subject: [PATCH] drag and drop fixed --- .../cz/kamma/kfmanager/ui/FilePanelTab.java | 17 +++++++++++++---- .../java/cz/kamma/kfmanager/ui/MainWindow.java | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main/java/cz/kamma/kfmanager/ui/FilePanelTab.java b/src/main/java/cz/kamma/kfmanager/ui/FilePanelTab.java index 2578d31..0c8c669 100644 --- a/src/main/java/cz/kamma/kfmanager/ui/FilePanelTab.java +++ b/src/main/java/cz/kamma/kfmanager/ui/FilePanelTab.java @@ -459,8 +459,9 @@ public class FilePanelTab extends JPanel { } } - // If CTRL is NOT pressed and SHIFT is NOT pressed, unselect all other items before selecting this one - if (!e.isControlDown() && !e.isShiftDown()) { + // If CTRL is NOT pressed and SHIFT is NOT pressed, unselect all other items before selecting this one, + // but only if the clicked item is not already marked (to allow dragging a multiple selection). + if (!e.isControlDown() && !e.isShiftDown() && !item.isMarked()) { unselectAll(); } // Toggle marked state if CTRL is pressed @@ -508,8 +509,9 @@ public class FilePanelTab extends JPanel { } } - // If CTRL is NOT pressed and SHIFT is NOT pressed, unselect all other items before selecting this one - if (!e.isControlDown() && !e.isShiftDown()) { + // If CTRL is NOT pressed and SHIFT is NOT pressed, unselect all other items before selecting this one, + // but only if the clicked item is not already marked (to allow dragging a multiple selection). + if (!e.isControlDown() && !e.isShiftDown() && !item.isMarked()) { unselectAll(); } if (e.isControlDown() && !item.getName().equals("..")) { @@ -607,6 +609,13 @@ public class FilePanelTab extends JPanel { } }; } + + @Override + protected void exportDone(JComponent source, Transferable data, int action) { + if (action == COPY || action == MOVE) { + unselectAll(); + } + } }); fileTable.setFocusTraversalKeysEnabled(false); diff --git a/src/main/java/cz/kamma/kfmanager/ui/MainWindow.java b/src/main/java/cz/kamma/kfmanager/ui/MainWindow.java index 9197582..448b49a 100644 --- a/src/main/java/cz/kamma/kfmanager/ui/MainWindow.java +++ b/src/main/java/cz/kamma/kfmanager/ui/MainWindow.java @@ -458,7 +458,23 @@ public class MainWindow extends JFrame { try { List files = (List) support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor); if (files != null && !files.isEmpty()) { - showAddToolbarShortcutDialog(files.getFirst()); + if (files.size() == 1) { + showAddToolbarShortcutDialog(files.get(0)); + } else { + // Add all as shortcuts with default names/icons + List shortcuts = config.getToolbarShortcuts(); + for (File f : files) { + String label = f.getName(); + String command = f.getAbsolutePath(); + String workDir = f.isDirectory() ? f.getAbsolutePath() : f.getParent(); + shortcuts.add(new AppConfig.ToolbarShortcut(command, label, "", workDir)); + } + config.saveToolbarShortcuts(shortcuts); + createToolBar(); // refresh + JOptionPane.showMessageDialog(MainWindow.this, + files.size() + " shortcuts added to toolbar.", + "Shortcuts Added", JOptionPane.INFORMATION_MESSAGE); + } } return true; } catch (Exception e) {