summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/editor_settings.cpp3
-rw-r--r--editor/project_manager.cpp22
-rw-r--r--editor/project_manager.h1
3 files changed, 20 insertions, 6 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 039ba22a77..fbcab3cbb6 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -581,6 +581,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
/* Extra config */
+ _initial_set("project_manager/sorting_order", 0);
+ hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Last Modified");
+
if (p_extra_config.is_valid()) {
if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 0e2e957333..ac728e8d7c 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1165,10 +1165,12 @@ void ProjectManager::_load_recent_projects() {
bool set_ordered_latest_modification;
ProjectListFilter::FilterOption filter_order_option = project_order_filter->get_filter_option();
- if (filter_order_option == ProjectListFilter::FILTER_NAME)
+ if (filter_order_option == ProjectListFilter::FILTER_NAME) {
set_ordered_latest_modification = false;
- else
+ } else {
set_ordered_latest_modification = true;
+ }
+ EditorSettings::get_singleton()->set("project_manager/sorting_order", (int)filter_order_option);
List<ProjectItem> projects;
List<ProjectItem> favorite_projects;
@@ -1838,16 +1840,19 @@ ProjectManager::ProjectManager() {
Label *sort_label = memnew(Label);
sort_label->set_text(TTR("Sort:"));
sort_filters->add_child(sort_label);
- Vector<String> vec1;
- vec1.push_back("Name");
- vec1.push_back("Last Modified");
+ Vector<String> sort_filter_titles;
+ sort_filter_titles.push_back("Name");
+ sort_filter_titles.push_back("Last Modified");
project_order_filter = memnew(ProjectListFilter);
- project_order_filter->_setup_filters(vec1);
+ project_order_filter->_setup_filters(sort_filter_titles);
project_order_filter->set_filter_size(150);
sort_filters->add_child(project_order_filter);
project_order_filter->connect("filter_changed", this, "_load_recent_projects");
project_order_filter->set_custom_minimum_size(Size2(180, 10) * EDSCALE);
+ int projects_sorting_order = (int)EditorSettings::get_singleton()->get("project_manager/sorting_order");
+ project_order_filter->set_filter_option((ProjectListFilter::FilterOption)projects_sorting_order);
+
sort_filters->add_spacer(true);
Label *search_label = memnew(Label);
search_label->set_text(TTR("Search:"));
@@ -2074,6 +2079,11 @@ ProjectListFilter::FilterOption ProjectListFilter::get_filter_option() {
return _current_filter;
}
+void ProjectListFilter::set_filter_option(FilterOption option) {
+ filter_option->select((int)option);
+ _filter_option_selected(0);
+}
+
void ProjectListFilter::_filter_option_selected(int p_idx) {
FilterOption selected = (FilterOption)(filter_option->get_selected());
if (_current_filter != selected) {
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 88fc081272..e0a0932cf8 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -152,6 +152,7 @@ public:
void set_filter_size(int h_size);
String get_search_term();
FilterOption get_filter_option();
+ void set_filter_option(FilterOption);
ProjectListFilter();
};