Update dock menu on project list changes, add favourites separator.
This commit is contained in:
parent
35944aebde
commit
2f3db42de8
1 changed files with 41 additions and 5 deletions
|
@ -1023,6 +1023,7 @@ public:
|
||||||
ProjectList();
|
ProjectList();
|
||||||
~ProjectList();
|
~ProjectList();
|
||||||
|
|
||||||
|
void update_dock_menu();
|
||||||
void load_projects();
|
void load_projects();
|
||||||
void set_search_term(String p_search_term);
|
void set_search_term(String p_search_term);
|
||||||
void set_order_option(ProjectListFilter::FilterOption p_option);
|
void set_order_option(ProjectListFilter::FilterOption p_option);
|
||||||
|
@ -1210,7 +1211,6 @@ void ProjectList::load_projects() {
|
||||||
_projects.clear();
|
_projects.clear();
|
||||||
_last_clicked = "";
|
_last_clicked = "";
|
||||||
_selected_project_keys.clear();
|
_selected_project_keys.clear();
|
||||||
OS::get_singleton()->global_menu_clear("_dock");
|
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
// TODO Would be nice to change how projects and favourites are stored... it complicates things a bit.
|
// 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);
|
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();
|
sort_projects();
|
||||||
|
|
||||||
set_v_scroll(0);
|
set_v_scroll(0);
|
||||||
|
|
||||||
update_icons_async();
|
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) {
|
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);
|
fpath->set_clip_text(true);
|
||||||
|
|
||||||
_scroll_children->add_child(hb);
|
_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;
|
item.control = hb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1394,6 +1417,8 @@ void ProjectList::sort_projects() {
|
||||||
|
|
||||||
// Rewind the coroutine because order of projects changed
|
// Rewind the coroutine because order of projects changed
|
||||||
update_icons_async();
|
update_icons_async();
|
||||||
|
|
||||||
|
update_dock_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Set<String> &ProjectList::get_selected_project_keys() const {
|
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);
|
EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
|
||||||
// Not actually saving the file, in case you are doing more changes to settings
|
// Not actually saving the file, in case you are doing more changes to settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_dock_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProjectList::is_any_project_missing() const {
|
bool ProjectList::is_any_project_missing() const {
|
||||||
|
@ -1568,6 +1595,7 @@ int ProjectList::refresh_project(const String &dir_path) {
|
||||||
ensure_project_visible(i);
|
ensure_project_visible(i);
|
||||||
}
|
}
|
||||||
load_project_icon(i);
|
load_project_icon(i);
|
||||||
|
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1642,6 +1670,8 @@ void ProjectList::erase_selected_projects() {
|
||||||
|
|
||||||
_selected_project_keys.clear();
|
_selected_project_keys.clear();
|
||||||
_last_clicked = "";
|
_last_clicked = "";
|
||||||
|
|
||||||
|
update_dock_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draws selected project highlight
|
// 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) {
|
void ProjectList::_show_project(const String &p_path) {
|
||||||
|
@ -1929,6 +1961,8 @@ void ProjectManager::_on_projects_updated() {
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
_project_list->ensure_project_visible(index);
|
_project_list->ensure_project_visible(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_project_list->update_dock_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectManager::_on_project_created(const String &dir) {
|
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->select_project(i);
|
||||||
_project_list->ensure_project_visible(i);
|
_project_list->ensure_project_visible(i);
|
||||||
_open_selected_projects_ask();
|
_open_selected_projects_ask();
|
||||||
|
|
||||||
|
_project_list->update_dock_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectManager::_confirm_update_settings() {
|
void ProjectManager::_confirm_update_settings() {
|
||||||
|
|
Loading…
Reference in a new issue