summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-10-24 12:51:18 +0200
committerGitHub <noreply@github.com>2019-10-24 12:51:18 +0200
commit79dae3a87e1c8a66897fc1816059f39c8f25cde4 (patch)
tree9b85b218dcebf09553a554e117adacb4d7aae375 /editor
parent31ca1f5aa1f7985d4d8daec22b44e73eacccc0b3 (diff)
parent2f3db42de874827957846acd247a710d24e8ca45 (diff)
Merge pull request #33028 from bruvzg/mac_dock_proj_list
[macOS ] Project manager dock menu improvements.
Diffstat (limited to 'editor')
-rw-r--r--editor/project_manager.cpp46
1 files changed, 41 insertions, 5 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index d903e153a7..ab62a59be1 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1023,6 +1023,7 @@ public:
ProjectList();
~ProjectList();
+ void update_dock_menu();
void load_projects();
void set_search_term(String p_search_term);
void set_order_option(ProjectListFilter::FilterOption p_option);
@@ -1210,7 +1211,6 @@ void ProjectList::load_projects() {
_projects.clear();
_last_clicked = "";
_selected_project_keys.clear();
- OS::get_singleton()->global_menu_clear("_dock");
// Load data
// TODO Would be nice to change how projects and favourites are stored... it complicates things a bit.
@@ -1248,14 +1248,38 @@ void ProjectList::load_projects() {
create_project_item_control(i);
}
- OS::get_singleton()->global_menu_add_separator("_dock");
- OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
-
sort_projects();
set_v_scroll(0);
update_icons_async();
+
+ update_dock_menu();
+}
+
+void ProjectList::update_dock_menu() {
+ OS::get_singleton()->global_menu_clear("_dock");
+
+ int favs_added = 0;
+ int total_added = 0;
+ for (int i = 0; i < _projects.size(); ++i) {
+ if (!_projects[i].grayed && !_projects[i].missing) {
+ if (_projects[i].favorite) {
+ favs_added++;
+ } else {
+ if (favs_added != 0) {
+ OS::get_singleton()->global_menu_add_separator("_dock");
+ }
+ favs_added = 0;
+ }
+ OS::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", GLOBAL_OPEN_PROJECT, Variant(_projects[i].path.plus_file("project.godot")));
+ total_added++;
+ }
+ }
+ if (total_added != 0) {
+ OS::get_singleton()->global_menu_add_separator("_dock");
+ }
+ OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
}
void ProjectList::create_project_item_control(int p_index) {
@@ -1341,7 +1365,6 @@ void ProjectList::create_project_item_control(int p_index) {
fpath->set_clip_text(true);
_scroll_children->add_child(hb);
- OS::get_singleton()->global_menu_add_item("_dock", item.project_name + " ( " + item.path + " )", GLOBAL_OPEN_PROJECT, Variant(item.path.plus_file("project.godot")));
item.control = hb;
}
@@ -1394,6 +1417,8 @@ void ProjectList::sort_projects() {
// Rewind the coroutine because order of projects changed
update_icons_async();
+
+ update_dock_menu();
}
const Set<String> &ProjectList::get_selected_project_keys() const {
@@ -1470,6 +1495,8 @@ void ProjectList::remove_project(int p_index, bool p_update_settings) {
EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
// Not actually saving the file, in case you are doing more changes to settings
}
+
+ update_dock_menu();
}
bool ProjectList::is_any_project_missing() const {
@@ -1568,6 +1595,7 @@ int ProjectList::refresh_project(const String &dir_path) {
ensure_project_visible(i);
}
load_project_icon(i);
+
index = i;
break;
}
@@ -1642,6 +1670,8 @@ void ProjectList::erase_selected_projects() {
_selected_project_keys.clear();
_last_clicked = "";
+
+ update_dock_menu();
}
// Draws selected project highlight
@@ -1725,6 +1755,8 @@ void ProjectList::_favorite_pressed(Node *p_hb) {
}
}
}
+
+ update_dock_menu();
}
void ProjectList::_show_project(const String &p_path) {
@@ -1929,6 +1961,8 @@ void ProjectManager::_on_projects_updated() {
if (index != -1) {
_project_list->ensure_project_visible(index);
}
+
+ _project_list->update_dock_menu();
}
void ProjectManager::_on_project_created(const String &dir) {
@@ -1937,6 +1971,8 @@ void ProjectManager::_on_project_created(const String &dir) {
_project_list->select_project(i);
_project_list->ensure_project_visible(i);
_open_selected_projects_ask();
+
+ _project_list->update_dock_menu();
}
void ProjectManager::_confirm_update_settings() {