You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-18 14:21:41 +00:00
[macOS] Add methods to modify global and dock menus. Add ability to open multiple editor/project manager instances, recent/favourite project list to project manager dock menu and opened scene list to editor dock menu.
This commit is contained in:
@@ -946,6 +946,11 @@ public:
|
||||
static const char *SIGNAL_SELECTION_CHANGED;
|
||||
static const char *SIGNAL_PROJECT_ASK_OPEN;
|
||||
|
||||
enum MenuOptions {
|
||||
GLOBAL_NEW_WINDOW,
|
||||
GLOBAL_OPEN_PROJECT
|
||||
};
|
||||
|
||||
// Can often be passed by copy
|
||||
struct Item {
|
||||
String project_key;
|
||||
@@ -1181,6 +1186,7 @@ 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.
|
||||
@@ -1218,6 +1224,9 @@ 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);
|
||||
@@ -1305,6 +1314,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -1894,6 +1904,29 @@ void ProjectManager::_confirm_update_settings() {
|
||||
_open_selected_projects();
|
||||
}
|
||||
|
||||
void ProjectManager::_global_menu_action(const Variant &p_id, const Variant &p_meta) {
|
||||
|
||||
int id = (int)p_id;
|
||||
if (id == ProjectList::GLOBAL_NEW_WINDOW) {
|
||||
List<String> args;
|
||||
String exec = OS::get_singleton()->get_executable_path();
|
||||
|
||||
OS::ProcessID pid = 0;
|
||||
OS::get_singleton()->execute(exec, args, false, &pid);
|
||||
} else if (id == ProjectList::GLOBAL_OPEN_PROJECT) {
|
||||
String conf = (String)p_meta;
|
||||
|
||||
if (conf != String()) {
|
||||
List<String> args;
|
||||
args.push_back(conf);
|
||||
String exec = OS::get_singleton()->get_executable_path();
|
||||
|
||||
OS::ProcessID pid = 0;
|
||||
OS::get_singleton()->execute(exec, args, false, &pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectManager::_open_selected_projects() {
|
||||
|
||||
const Set<String> &selected_list = _project_list->get_selected_project_keys();
|
||||
@@ -2236,6 +2269,7 @@ void ProjectManager::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_open_selected_projects_ask", &ProjectManager::_open_selected_projects_ask);
|
||||
ClassDB::bind_method("_open_selected_projects", &ProjectManager::_open_selected_projects);
|
||||
ClassDB::bind_method(D_METHOD("_global_menu_action"), &ProjectManager::_global_menu_action, DEFVAL(Variant()));
|
||||
ClassDB::bind_method("_run_project", &ProjectManager::_run_project);
|
||||
ClassDB::bind_method("_run_project_confirm", &ProjectManager::_run_project_confirm);
|
||||
ClassDB::bind_method("_scan_projects", &ProjectManager::_scan_projects);
|
||||
@@ -2561,6 +2595,7 @@ ProjectManager::ProjectManager() {
|
||||
}
|
||||
|
||||
SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped");
|
||||
SceneTree::get_singleton()->connect("global_menu_action", this, "_global_menu_action");
|
||||
|
||||
run_error_diag = memnew(AcceptDialog);
|
||||
gui_base->add_child(run_error_diag);
|
||||
|
||||
Reference in New Issue
Block a user