some improvements and fixes

This commit is contained in:
Radek Davidek 2026-02-09 13:28:39 +01:00
parent bf1ec599ee
commit 392e70ba01

View File

@ -146,6 +146,9 @@ public class KeepassApp extends JFrame {
initMenuBar();
initComponents();
// Try to load last opened database
loadLastDatabase();
// Small delay to let OS/Window Manager settle before checking tray
Timer trayTimer = new Timer(1000, e -> initSystemTray());
trayTimer.setRepeats(false);
@ -441,29 +444,16 @@ public class KeepassApp extends JFrame {
int row = entryTable.rowAtPoint(e.getPoint());
int col = entryTable.columnAtPoint(e.getPoint());
if (row >= 0 && col >= 0) {
// Double click on username (col 1) or password (col 2) copies to clipboard
if (col == 1 || col == 2) {
int modelRow = entryTable.convertRowIndexToModel(row);
Entry entry = currentEntries.get(modelRow);
String content;
switch (col) {
case 0:
content = entry.getTitle();
break;
case 1:
content = entry.getUsername();
break;
case 2:
content = entry.getPassword();
break;
case 3:
content = entry.getUrl();
break;
case 4:
content = entry.getNotes();
break;
default:
content = "";
}
String content = (col == 1) ? entry.getUsername() : entry.getPassword();
copyTextToClipboard(content, entryTable.getColumnName(col));
} else {
// Double click on other columns opens edit dialog
editEntry();
}
}
}
}
@ -701,6 +691,25 @@ public class KeepassApp extends JFrame {
}
}
private void loadLastDatabase() {
String recentFiles = prefs.get(PREF_RECENT_LIST, "");
if (recentFiles.isEmpty()) {
return;
}
String[] paths = recentFiles.split(";");
if (paths.length == 0 || paths[0].isEmpty()) {
return;
}
String lastFilePath = paths[0];
File lastFile = new File(lastFilePath);
if (lastFile.exists()) {
openDatabase(lastFile);
}
}
private void saveDatabase() {
if (database == null || currentFile == null || currentPassword == null) {
JOptionPane.showMessageDialog(this, "No database open to save.", "Warning", JOptionPane.WARNING_MESSAGE);