Added search to shortcut config
This commit is contained in:
parent
1726bacf78
commit
bb2a456456
2 changed files with 56 additions and 14 deletions
|
@ -97,11 +97,24 @@ void EditorSettingsDialog::_clear_search_box() {
|
||||||
property_editor->get_property_editor()->update_tree();
|
property_editor->get_property_editor()->update_tree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorSettingsDialog::_clear_shortcut_search_box() {
|
||||||
|
if (shortcut_search_box->get_text()=="")
|
||||||
|
return;
|
||||||
|
|
||||||
|
shortcut_search_box->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorSettingsDialog::_filter_shortcuts(const String& p_filter) {
|
||||||
|
shortcut_filter = p_filter;
|
||||||
|
_update_shortcuts();
|
||||||
|
}
|
||||||
|
|
||||||
void EditorSettingsDialog::_notification(int p_what) {
|
void EditorSettingsDialog::_notification(int p_what) {
|
||||||
|
|
||||||
if (p_what==NOTIFICATION_ENTER_TREE) {
|
if (p_what==NOTIFICATION_ENTER_TREE) {
|
||||||
|
|
||||||
clear_button->set_icon(get_icon("Close","EditorIcons"));
|
clear_button->set_icon(get_icon("Close","EditorIcons"));
|
||||||
|
shortcut_clear_button->set_icon(get_icon("Close","EditorIcons"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,12 +150,11 @@ void EditorSettingsDialog::_update_shortcuts() {
|
||||||
sections[section_name]=section;
|
sections[section_name]=section;
|
||||||
section->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
|
section->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
|
||||||
section->set_custom_bg_color(1,get_color("prop_subsection","Editor"));
|
section->set_custom_bg_color(1,get_color("prop_subsection","Editor"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shortcut_filter.is_subsequence_ofi(sc->get_name())) {
|
||||||
TreeItem *item = shortcuts->create_item(section);
|
TreeItem *item = shortcuts->create_item(section);
|
||||||
|
|
||||||
|
|
||||||
item->set_text(0,sc->get_name());
|
item->set_text(0,sc->get_name());
|
||||||
item->set_text(1,sc->get_as_text());
|
item->set_text(1,sc->get_as_text());
|
||||||
if (!sc->is_shortcut(original) && !(sc->get_shortcut().type==InputEvent::NONE && original.type==InputEvent::NONE)) {
|
if (!sc->is_shortcut(original) && !(sc->get_shortcut().type==InputEvent::NONE && original.type==InputEvent::NONE)) {
|
||||||
|
@ -153,10 +165,15 @@ void EditorSettingsDialog::_update_shortcuts() {
|
||||||
item->set_tooltip(0,E->get());
|
item->set_tooltip(0,E->get());
|
||||||
item->set_metadata(0,E->get());
|
item->set_metadata(0,E->get());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove sections with no shortcuts
|
||||||
|
for(Map<String,TreeItem*>::Element *E=sections.front();E;E=E->next()) {
|
||||||
|
TreeItem *section = E->get();
|
||||||
|
if (section->get_children() == NULL) {
|
||||||
|
root->remove_child(section);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorSettingsDialog::_shortcut_button_pressed(Object* p_item,int p_column,int p_idx) {
|
void EditorSettingsDialog::_shortcut_button_pressed(Object* p_item,int p_column,int p_idx) {
|
||||||
|
@ -265,7 +282,9 @@ void EditorSettingsDialog::_bind_methods() {
|
||||||
ObjectTypeDB::bind_method(_MD("_settings_save"),&EditorSettingsDialog::_settings_save);
|
ObjectTypeDB::bind_method(_MD("_settings_save"),&EditorSettingsDialog::_settings_save);
|
||||||
ObjectTypeDB::bind_method(_MD("_settings_changed"),&EditorSettingsDialog::_settings_changed);
|
ObjectTypeDB::bind_method(_MD("_settings_changed"),&EditorSettingsDialog::_settings_changed);
|
||||||
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
|
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
|
||||||
|
ObjectTypeDB::bind_method(_MD("_clear_shortcut_search_box"),&EditorSettingsDialog::_clear_shortcut_search_box);
|
||||||
ObjectTypeDB::bind_method(_MD("_shortcut_button_pressed"),&EditorSettingsDialog::_shortcut_button_pressed);
|
ObjectTypeDB::bind_method(_MD("_shortcut_button_pressed"),&EditorSettingsDialog::_shortcut_button_pressed);
|
||||||
|
ObjectTypeDB::bind_method(_MD("_filter_shortcuts"),&EditorSettingsDialog::_filter_shortcuts);
|
||||||
ObjectTypeDB::bind_method(_MD("_update_shortcuts"),&EditorSettingsDialog::_update_shortcuts);
|
ObjectTypeDB::bind_method(_MD("_update_shortcuts"),&EditorSettingsDialog::_update_shortcuts);
|
||||||
ObjectTypeDB::bind_method(_MD("_press_a_key_confirm"),&EditorSettingsDialog::_press_a_key_confirm);
|
ObjectTypeDB::bind_method(_MD("_press_a_key_confirm"),&EditorSettingsDialog::_press_a_key_confirm);
|
||||||
ObjectTypeDB::bind_method(_MD("_wait_for_key"),&EditorSettingsDialog::_wait_for_key);
|
ObjectTypeDB::bind_method(_MD("_wait_for_key"),&EditorSettingsDialog::_wait_for_key);
|
||||||
|
@ -311,6 +330,23 @@ EditorSettingsDialog::EditorSettingsDialog() {
|
||||||
tabs->add_child(vbc);
|
tabs->add_child(vbc);
|
||||||
vbc->set_name(TTR("Shortcuts"));
|
vbc->set_name(TTR("Shortcuts"));
|
||||||
|
|
||||||
|
hbc = memnew( HBoxContainer );
|
||||||
|
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
|
vbc->add_child(hbc);
|
||||||
|
|
||||||
|
l = memnew( Label );
|
||||||
|
l->set_text(TTR("Search:")+" ");
|
||||||
|
hbc->add_child(l);
|
||||||
|
|
||||||
|
shortcut_search_box = memnew( LineEdit );
|
||||||
|
shortcut_search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
|
hbc->add_child(shortcut_search_box);
|
||||||
|
shortcut_search_box->connect("text_changed", this, "_filter_shortcuts");
|
||||||
|
|
||||||
|
shortcut_clear_button = memnew( ToolButton );
|
||||||
|
hbc->add_child(shortcut_clear_button);
|
||||||
|
shortcut_clear_button->connect("pressed",this,"_clear_shortcut_search_box");
|
||||||
|
|
||||||
shortcuts = memnew( Tree );
|
shortcuts = memnew( Tree );
|
||||||
vbc->add_margin_child("Shortcut List:",shortcuts,true);
|
vbc->add_margin_child("Shortcut List:",shortcuts,true);
|
||||||
shortcuts->set_columns(2);
|
shortcuts->set_columns(2);
|
||||||
|
|
|
@ -45,7 +45,9 @@ class EditorSettingsDialog : public AcceptDialog {
|
||||||
TabContainer *tabs;
|
TabContainer *tabs;
|
||||||
|
|
||||||
LineEdit *search_box;
|
LineEdit *search_box;
|
||||||
|
LineEdit *shortcut_search_box;
|
||||||
ToolButton *clear_button;
|
ToolButton *clear_button;
|
||||||
|
ToolButton *shortcut_clear_button;
|
||||||
SectionedPropertyEditor *property_editor;
|
SectionedPropertyEditor *property_editor;
|
||||||
|
|
||||||
Timer *timer;
|
Timer *timer;
|
||||||
|
@ -56,6 +58,7 @@ class EditorSettingsDialog : public AcceptDialog {
|
||||||
Label *press_a_key_label;
|
Label *press_a_key_label;
|
||||||
InputEvent last_wait_for_key;
|
InputEvent last_wait_for_key;
|
||||||
String shortcut_configured;
|
String shortcut_configured;
|
||||||
|
String shortcut_filter;
|
||||||
|
|
||||||
virtual void cancel_pressed();
|
virtual void cancel_pressed();
|
||||||
virtual void ok_pressed();
|
virtual void ok_pressed();
|
||||||
|
@ -69,8 +72,11 @@ class EditorSettingsDialog : public AcceptDialog {
|
||||||
void _press_a_key_confirm();
|
void _press_a_key_confirm();
|
||||||
void _wait_for_key(const InputEvent& p_event);
|
void _wait_for_key(const InputEvent& p_event);
|
||||||
|
|
||||||
|
void _clear_shortcut_search_box();
|
||||||
void _clear_search_box();
|
void _clear_search_box();
|
||||||
|
|
||||||
|
void _filter_shortcuts(const String& p_filter);
|
||||||
|
|
||||||
void _update_shortcuts();
|
void _update_shortcuts();
|
||||||
void _shortcut_button_pressed(Object* p_item,int p_column,int p_idx);
|
void _shortcut_button_pressed(Object* p_item,int p_column,int p_idx);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue