mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-19 16:45:28 +00:00
#3321: settings saved before turn Cache Frames When Idle on once (settings version 6)
This commit is contained in:
1 parent
d9a11b6917
commit
717b32fd10
4 files changed
+25
-6
No files matched your search
@@ -39,7 +39,7 @@ pub use sections::{
|
||||
use sections::{Extra, default_labels, lenient_comp_presets};
|
||||
|
||||
/// Current settings layout version.
|
||||
pub const PREFS_VERSION: u32 = 5;
|
||||
pub const PREFS_VERSION: u32 = 6;
|
||||
/// Settings file name in the config store.
|
||||
pub const PREFS_FILE: &str = "prefs.json";
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ use super::{Appearance, General, Map, PREFS_VERSION, Prefs, Startup, Value, json
|
||||
/// - version 4 and earlier had the Layer Cache, Footage Frame Cache and Preview (RAM) Cache
|
||||
/// budgets (`memory.layerCacheMb` / `mediaCacheMb` / `previewCacheMb`); they are dropped: the
|
||||
/// caches share one budget (#3298).
|
||||
/// - version 5 and earlier saved Cache Frames When Idle off, the default then (every save kept
|
||||
/// it); it becomes the new default, on, once (#3321). Off saved later is the user's choice.
|
||||
/// (Released builds wrote version 4; version 5 came only from pre-release builds of #3301,
|
||||
/// nearly all of them with the default still off. A file without a version predates both.)
|
||||
pub fn migrate(mut v: Value) -> Value {
|
||||
let Some(obj) = v.as_object_mut() else { return json!({}) };
|
||||
let version = obj.get("version").and_then(Value::as_u64).unwrap_or(0);
|
||||
@@ -61,6 +65,12 @@ pub fn migrate(mut v: Value) -> Value {
|
||||
m.remove(key);
|
||||
}
|
||||
}
|
||||
if version < 6
|
||||
&& let Some(p) = obj.get_mut("previews").and_then(Value::as_object_mut)
|
||||
&& p.get("cacheFramesWhenIdle") == Some(&json!(false))
|
||||
{
|
||||
p.insert("cacheFramesWhenIdle".into(), json!(true));
|
||||
}
|
||||
// Settings saved before appearance modes had one theme: keep showing it, as a fixed Dark or
|
||||
// Light mode, instead of switching established users to Auto.
|
||||
if let Some(a) = obj.get_mut("appearance").and_then(Value::as_object_mut)
|
||||
|
||||
@@ -263,15 +263,23 @@ fn a_low_memory_episode_toasts_once_and_reapplies_the_budget() {
|
||||
assert_eq!(toasts(&mut s), 1);
|
||||
}
|
||||
|
||||
/// #3321: Cache Frames When Idle is on by default; a saved "off" stays off.
|
||||
/// #3321: Cache Frames When Idle is on by default. Settings saved before held the old default
|
||||
/// (off) and turn it on once; off saved after that is the user's choice and stays.
|
||||
#[test]
|
||||
fn cache_frames_when_idle_is_on_by_default() {
|
||||
use crate::prefs::Prefs;
|
||||
assert!(Prefs::default().previews.cache_frames_when_idle);
|
||||
assert!(Prefs::from_json(r#"{"version": 5, "previews": {"fastPreviews": true}}"#).previews.cache_frames_when_idle, "not saved: on");
|
||||
let off = Prefs::from_json(r#"{"version": 5, "previews": {"cacheFramesWhenIdle": false}}"#);
|
||||
assert!(Prefs::from_json(r#"{"version": 6, "previews": {"fastPreviews": true}}"#).previews.cache_frames_when_idle, "not saved: on");
|
||||
// An old file with the old default: on, once.
|
||||
let old = Prefs::from_json(r#"{"version": 5, "previews": {"cacheFramesWhenIdle": false}}"#);
|
||||
assert!(old.previews.cache_frames_when_idle, "the old default becomes the new one");
|
||||
assert!(Prefs::from_json(r#"{"version": 4, "previews": {"cacheFramesWhenIdle": true}}"#).previews.cache_frames_when_idle, "on stays on");
|
||||
// Turned off after the migration: stays off, also after the next save.
|
||||
let off = Prefs::from_json(r#"{"version": 6, "previews": {"cacheFramesWhenIdle": false}}"#);
|
||||
assert!(!off.previews.cache_frames_when_idle, "saved off: off");
|
||||
assert!(!Prefs::from_json(&off.to_json()).previews.cache_frames_when_idle, "and after the next save");
|
||||
let mut p = old;
|
||||
p.previews.cache_frames_when_idle = false;
|
||||
assert!(!Prefs::from_json(&p.to_json()).previews.cache_frames_when_idle, "and after the next save");
|
||||
}
|
||||
|
||||
/// #3298: settings saved with the three cache budgets (version 4, or a later file that still
|
||||
|
||||
+2
-1
@@ -57,7 +57,8 @@ Commands (CLI, MCP, control channel):
|
||||
after a second without input or edits, the viewer renders the work area into the RAM preview
|
||||
in the background, from the current time on, until it is cached or the budget is full. Any
|
||||
input, edit, playback or a frame the viewer waits for stops it at once (it starts again after
|
||||
the next quiet second). A saved setting of off stays off
|
||||
the next quiet second). Settings saved by an older version hold the old default (off) and are
|
||||
switched on once when read; off saved after that stays off
|
||||
- `previews.fastPreviews`: Fast Previews (Draft 3D, Faster Effects)
|
||||
- `appearance.appearanceMode`: Appearance Mode (`auto` / `dark` / `light`). `auto` (Sync with System) follows the operating system's light or dark appearance while the app runs: on Linux the desktop app reads the XDG desktop portal (`org.freedesktop.appearance` `color-scheme`) once and then listens for its `SettingChanged` signal on a worker thread, repainting only when the value changes (nothing polls); `gsettings` runs at most once at start-up, by absolute path, when the portal gives no answer. Elsewhere it uses what the window system reports. With no answer it shows the dark theme. New installs stay `dark`; Sync with System is opt-in. The Tools bar's appearance button (a monitor, sun or moon) cycles Sync with System, Light and Dark (`view.theme.toggle`, Next Appearance Mode).
|
||||
- `appearance.darkTheme`: Dark Theme (`dark` / `darker`), shown in dark appearance
|
||||
|
||||
Reference in new issue
Block a user