Hide UI preference keys behind adapter

This commit is contained in:
2026-06-12 17:53:57 +02:00
parent 9f1a52401a
commit 058997bd78
6 changed files with 105 additions and 21 deletions

View File

@@ -21,6 +21,38 @@ LegacyStartupPreferenceSnapshot read_legacy_startup_preferences(bool default_vr_
};
}
LegacyCanvasPreferenceSnapshot read_legacy_canvas_preferences()
{
return {
Settings::value_or<Serializer::Float>("vp-scale", 1.0F),
Settings::value_or<Serializer::Integer>("show-cursor", 0),
};
}
LegacyUiPreferenceSnapshot read_legacy_ui_preferences()
{
LegacyUiPreferenceSnapshot snapshot;
snapshot.has_rtl = Settings::has("ui-rtl");
if (snapshot.has_rtl)
snapshot.rtl = Settings::value<Serializer::Integer>("ui-rtl");
if (Settings::has("ui"))
snapshot.state = Settings::get<Serializer::Descriptor>("ui");
return snapshot;
}
LegacyWindowPreferenceSnapshot read_legacy_window_preferences(int default_show_command)
{
LegacyWindowPreferenceSnapshot snapshot;
snapshot.has_ui_scale = Settings::has("ui-scale");
if (snapshot.has_ui_scale)
snapshot.ui_scale = Settings::value<Serializer::Float>("ui-scale");
snapshot.show_command = Settings::value_or<Serializer::Integer>("window-show-cmd", default_show_command);
snapshot.has_window_rect = Settings::has("window-rect");
if (snapshot.has_window_rect)
snapshot.window_rect = Settings::value<Serializer::IVec4>("window-rect");
return snapshot;
}
bool has_legacy_preference(const char* key)
{
return Settings::has(key);
@@ -86,6 +118,24 @@ void unset_legacy_preference(const char* key)
Settings::unset(key);
}
void save_legacy_ui_scale_preference(float scale)
{
Settings::set("ui-scale", Serializer::Float(scale));
Settings::save();
}
void set_legacy_ui_state_preferences(const Serializer::Descriptor& state, bool right_to_left)
{
Settings::set("ui", state);
Settings::set("ui-rtl", Serializer::Boolean(right_to_left));
}
void set_legacy_window_preferences(int show_command, const glm::ivec4& window_rect)
{
Settings::set("window-show-cmd", Serializer::Integer(show_command));
Settings::set("window-rect", Serializer::IVec4(window_rect));
}
void save_legacy_boolean_preference(const char* key, bool value)
{
set_legacy_boolean_preference(key, value);