Skip to content

Commit

Permalink
Add Ctrl + A and Ctrl + Shift + A to (de)select all projects in proje…
Browse files Browse the repository at this point in the history
…ct manager

These keyboard shortcuts are commonly used in applications to (de)select
all entries in a list.
  • Loading branch information
Calinou committed Oct 17, 2024
1 parent 04692d8 commit b0df62b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,16 @@ void ProjectManager::shortcut_input(const Ref<InputEvent> &p_ev) {
keycode_handled = false;
}
} break;
case Key::A: {
if (k->is_command_or_control_pressed()) {

Check failure on line 1022 in editor/project_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor w/ Mono (target=editor)

this statement may fall through [-Werror=implicit-fallthrough=]

Check failure on line 1022 in editor/project_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, scu_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=gold)

this statement may fall through [-Werror=implicit-fallthrough=]
if (k->is_shift_pressed()) {
project_list->deselect_all_visible_projects();
} else {
project_list->select_all_visible_projects();
}
_update_project_buttons();
}
}
default: {

Check failure on line 1031 in editor/project_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

Check failure on line 1031 in editor/project_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
keycode_handled = false;
} break;
Expand Down
16 changes: 16 additions & 0 deletions editor/project_manager/project_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,22 @@ void ProjectList::select_first_visible_project() {
}
}

void ProjectList::deselect_all_visible_projects() {
for (int i = 0; i < _projects.size(); i++) {
if (_projects[i].control->is_visible()) {
_deselect_project_nocheck(i);
}
}
}

void ProjectList::select_all_visible_projects() {
for (int i = 0; i < _projects.size(); i++) {
if (_projects[i].control->is_visible()) {
_select_project_nocheck(i);
}
}
}

Vector<ProjectList::Item> ProjectList::get_selected_projects() const {
Vector<Item> items;
if (_selected_project_paths.size() == 0) {
Expand Down
2 changes: 2 additions & 0 deletions editor/project_manager/project_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ class ProjectList : public ScrollContainer {

void select_project(int p_index);
void select_first_visible_project();
void select_all_visible_projects();
void deselect_all_visible_projects();
Vector<Item> get_selected_projects() const;
const HashSet<String> &get_selected_project_keys() const;
int get_single_selected_index() const;
Expand Down

0 comments on commit b0df62b

Please sign in to comment.