added global keyboard shortcut (Ctrl+S) to save database if there are unsaved changes
This commit is contained in:
parent
2e4e0d3f77
commit
de90564c5b
@ -14,6 +14,7 @@ import java.awt.Toolkit;
|
|||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.event.ComponentAdapter;
|
import java.awt.event.ComponentAdapter;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
@ -24,7 +25,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JRootPane;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JCheckBoxMenuItem;
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
@ -45,6 +48,7 @@ import javax.swing.JTable;
|
|||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@ -422,6 +426,18 @@ public class KeepassApp extends JFrame {
|
|||||||
add(statusBar, BorderLayout.PAGE_END);
|
add(statusBar, BorderLayout.PAGE_END);
|
||||||
|
|
||||||
statusLabel.setText(" Ready");
|
statusLabel.setText(" Ready");
|
||||||
|
|
||||||
|
// Ctrl+S global keyboard shortcut to save vault if there are changes
|
||||||
|
getRootPane().getInputMap(JRootPane.WHEN_IN_FOCUSED_WINDOW).put(
|
||||||
|
KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK), "saveDatabase");
|
||||||
|
getRootPane().getActionMap().put("saveDatabase", new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||||
|
if (hasUnsavedChanges) {
|
||||||
|
saveDatabase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user