Skip to content

Commit 409a644

Browse files
committed
Add a style option button to quick setttings
1 parent 0fdbf05 commit 409a644

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

editor/project_manager/quick_settings_dialog.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void QuickSettingsDialog::_fetch_setting_values() {
4444
#ifndef ANDROID_ENABLED
4545
editor_languages.clear();
4646
#endif
47+
editor_styles.clear();
4748
editor_themes.clear();
4849
editor_scales.clear();
4950
editor_network_modes.clear();
@@ -59,6 +60,8 @@ void QuickSettingsDialog::_fetch_setting_values() {
5960
#ifndef ANDROID_ENABLED
6061
editor_languages = pi.hint_string.split(";", false);
6162
#endif
63+
} else if (pi.name == "interface/theme/style") {
64+
editor_styles = pi.hint_string.split(",");
6265
} else if (pi.name == "interface/theme/color_preset") {
6366
editor_themes = pi.hint_string.split(",");
6467
} else if (pi.name == "interface/editor/display_scale") {
@@ -90,6 +93,19 @@ void QuickSettingsDialog::_update_current_values() {
9093
}
9194
}
9295
#endif
96+
// Style options.
97+
{
98+
const String current_style = EDITOR_GET("interface/theme/style");
99+
100+
for (int i = 0; i < editor_styles.size(); i++) {
101+
const String &style_value = editor_styles[i];
102+
if (current_style == style_value) {
103+
style_option_button->set_text(current_style);
104+
style_option_button->select(i);
105+
style_option_button->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
106+
}
107+
}
108+
}
93109

94110
// Theme options.
95111
{
@@ -183,6 +199,11 @@ void QuickSettingsDialog::_language_selected(int p_id) {
183199
}
184200
#endif
185201

202+
void QuickSettingsDialog::_style_selected(int p_id) {
203+
const String selected_style = style_option_button->get_item_text(p_id);
204+
_set_setting_value("interface/theme/style", selected_style);
205+
}
206+
186207
void QuickSettingsDialog::_theme_selected(int p_id) {
187208
const String selected_theme = theme_option_button->get_item_text(p_id);
188209
_set_setting_value("interface/theme/color_preset", selected_theme);
@@ -295,6 +316,19 @@ QuickSettingsDialog::QuickSettingsDialog() {
295316
_add_setting_control(TTRC("Language"), language_option_button);
296317
}
297318
#endif
319+
// Style options.
320+
{
321+
style_option_button = memnew(OptionButton);
322+
style_option_button->set_fit_to_longest_item(false);
323+
style_option_button->connect(SceneStringName(item_selected), callable_mp(this, &QuickSettingsDialog::_style_selected));
324+
325+
for (int i = 0; i < editor_styles.size(); i++) {
326+
const String &style_value = editor_styles[i];
327+
style_option_button->add_item(style_value, i);
328+
}
329+
330+
_add_setting_control(TTRC("Style"), style_option_button);
331+
}
298332

299333
// Theme options.
300334
{

editor/project_manager/quick_settings_dialog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class QuickSettingsDialog : public AcceptDialog {
4545
#ifndef ANDROID_ENABLED
4646
Vector<String> editor_languages;
4747
#endif
48+
Vector<String> editor_styles;
4849
Vector<String> editor_themes;
4950
Vector<String> editor_scales;
5051
Vector<String> editor_network_modes;
@@ -64,6 +65,7 @@ class QuickSettingsDialog : public AcceptDialog {
6465
// Also, the dropdown it spawns is very tall and can't be scrolled without a hardware mouse.
6566
OptionButton *language_option_button = nullptr;
6667
#endif
68+
OptionButton *style_option_button = nullptr;
6769
OptionButton *theme_option_button = nullptr;
6870
OptionButton *scale_option_button = nullptr;
6971
OptionButton *network_mode_option_button = nullptr;
@@ -75,6 +77,7 @@ class QuickSettingsDialog : public AcceptDialog {
7577
#ifndef ANDROID_ENABLED
7678
void _language_selected(int p_id);
7779
#endif
80+
void _style_selected(int p_id);
7881
void _theme_selected(int p_id);
7982
void _scale_selected(int p_id);
8083
void _network_mode_selected(int p_id);

0 commit comments

Comments
 (0)