mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 03:18:37 +08:00
24303: remember sorting order in the project manager
This commit is contained in:
parent
01fa0673a4
commit
b675a3f745
@ -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")) {
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user