Sort palette commands by last use
This commit is contained in:
parent
bcd73fc00a
commit
baf2f374f4
4 changed files with 38 additions and 2 deletions
|
|
@ -47,13 +47,15 @@ class EditorCommandPalette : public ConfirmationDialog {
|
|||
Callable callable;
|
||||
String name;
|
||||
String shortcut;
|
||||
int last_used = 0; // Store time as int, because doubles have problems with text serialization.
|
||||
};
|
||||
|
||||
struct CommandEntry {
|
||||
String key_name;
|
||||
String display_name;
|
||||
String shortcut_text;
|
||||
float score;
|
||||
int last_used = 0;
|
||||
float score = 0;
|
||||
};
|
||||
|
||||
struct CommandEntryComparator {
|
||||
|
|
@ -62,6 +64,12 @@ class EditorCommandPalette : public ConfirmationDialog {
|
|||
}
|
||||
};
|
||||
|
||||
struct CommandHistoryComparator {
|
||||
_FORCE_INLINE_ bool operator()(const CommandEntry &A, const CommandEntry &B) const {
|
||||
return A.last_used > B.last_used;
|
||||
}
|
||||
};
|
||||
|
||||
HashMap<String, Command> commands;
|
||||
HashMap<String, Pair<String, Ref<Shortcut>>> unregistered_shortcuts;
|
||||
|
||||
|
|
@ -74,6 +82,7 @@ class EditorCommandPalette : public ConfirmationDialog {
|
|||
void _update_command_keys();
|
||||
void _add_command(String p_command_name, String p_key_name, Callable p_binded_action, String p_shortcut_text = "None");
|
||||
void _theme_changed();
|
||||
void _save_history() const;
|
||||
EditorCommandPalette();
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue