Skip to content

Commit 2856d03

Browse files
authored
Merge pull request #279 from SubtitleEdit/feature/plugin-contract-settings-version-and-video
Mirror SE5 contract: settingsVersion + video duration/resolution
2 parents 3c6d26d + b67b62c commit 2856d03

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

se5/Haxor/PluginContract.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ public sealed class PluginRequest
2424

2525
public string VideoFileName { get; set; } = string.Empty;
2626
public double FrameRate { get; set; }
27+
28+
/// <summary>Total video duration in seconds. Null when no video is loaded or on older SE versions.</summary>
29+
public double? VideoDurationSeconds { get; set; }
30+
31+
/// <summary>Video frame width in pixels. Null when no video is loaded or on older SE versions.</summary>
32+
public int? VideoWidth { get; set; }
33+
34+
/// <summary>Video frame height in pixels. Null when no video is loaded or on older SE versions.</summary>
35+
public int? VideoHeight { get; set; }
36+
2737
public string UiLanguage { get; set; } = string.Empty;
2838
public string Theme { get; set; } = string.Empty;
2939

@@ -34,6 +44,12 @@ public sealed class PluginRequest
3444

3545
/// <summary>This plugin's settings as last persisted by Subtitle Edit (null on first run).</summary>
3646
public JsonElement? Settings { get; set; }
47+
48+
/// <summary>
49+
/// Schema version this plugin attached to <see cref="Settings"/> in its last response.
50+
/// Null on first run, when settings were saved without a version, or on older SE versions.
51+
/// </summary>
52+
public int? SettingsVersion { get; set; }
3753
}
3854

3955
/// <summary>Active theme colors. All values are <c>#AARRGGBB</c> hex strings.</summary>
@@ -78,5 +94,11 @@ public sealed class PluginResponse
7894
/// <summary>Settings to persist; handed back unchanged in the next request.</summary>
7995
public JsonElement? Settings { get; set; }
8096

97+
/// <summary>
98+
/// Schema version for <see cref="Settings"/>. Bump when you change the shape of your
99+
/// settings so you can migrate or reset on the next run. Optional; null = "unversioned".
100+
/// </summary>
101+
public int? SettingsVersion { get; set; }
102+
81103
public string? UndoDescription { get; set; }
82104
}

se5/Plugin-Shared/PluginContract.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ public sealed class PluginRequest
1616
public List<int> SelectedIndices { get; set; } = new();
1717
public string VideoFileName { get; set; } = string.Empty;
1818
public double FrameRate { get; set; }
19+
20+
/// <summary>Total video duration in seconds. Null when no video is loaded or on older SE versions.</summary>
21+
public double? VideoDurationSeconds { get; set; }
22+
23+
/// <summary>Video frame width in pixels. Null when no video is loaded or on older SE versions.</summary>
24+
public int? VideoWidth { get; set; }
25+
26+
/// <summary>Video frame height in pixels. Null when no video is loaded or on older SE versions.</summary>
27+
public int? VideoHeight { get; set; }
28+
1929
public string UiLanguage { get; set; } = string.Empty;
2030
public string Theme { get; set; } = string.Empty;
2131

@@ -24,6 +34,13 @@ public sealed class PluginRequest
2434

2535
public string SeVersion { get; set; } = string.Empty;
2636
public JsonElement? Settings { get; set; }
37+
38+
/// <summary>
39+
/// Schema version this plugin attached to <see cref="Settings"/> in its last response.
40+
/// Null on first run, when settings were saved without a version, or on older SE versions.
41+
/// Use it to migrate or reset settings written by an older build of this plugin.
42+
/// </summary>
43+
public int? SettingsVersion { get; set; }
2744
}
2845

2946
/// <summary>Active theme colors. All values are <c>#AARRGGBB</c> hex strings.</summary>
@@ -53,6 +70,14 @@ public sealed class PluginResponse
5370
public string? Message { get; set; }
5471
public PluginSubtitle? Subtitle { get; set; }
5572
public JsonElement? Settings { get; set; }
73+
74+
/// <summary>
75+
/// Schema version for <see cref="Settings"/>. Bump when you change the shape of your
76+
/// settings so you can detect (and migrate or reset) stale data on the next run via
77+
/// <see cref="PluginRequest.SettingsVersion"/>. Optional; null = "unversioned".
78+
/// </summary>
79+
public int? SettingsVersion { get; set; }
80+
5681
public string? UndoDescription { get; set; }
5782
}
5883

se5/TypewriterEffect/PluginContract.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ public sealed class PluginRequest
1515
public List<int> SelectedIndices { get; set; } = new();
1616
public string VideoFileName { get; set; } = string.Empty;
1717
public double FrameRate { get; set; }
18+
19+
/// <summary>Total video duration in seconds. Null when no video is loaded or on older SE versions.</summary>
20+
public double? VideoDurationSeconds { get; set; }
21+
22+
/// <summary>Video frame width in pixels. Null when no video is loaded or on older SE versions.</summary>
23+
public int? VideoWidth { get; set; }
24+
25+
/// <summary>Video frame height in pixels. Null when no video is loaded or on older SE versions.</summary>
26+
public int? VideoHeight { get; set; }
27+
1828
public string UiLanguage { get; set; } = string.Empty;
1929
public string Theme { get; set; } = string.Empty;
2030

@@ -23,6 +33,12 @@ public sealed class PluginRequest
2333

2434
public string SeVersion { get; set; } = string.Empty;
2535
public JsonElement? Settings { get; set; }
36+
37+
/// <summary>
38+
/// Schema version this plugin attached to <see cref="Settings"/> in its last response.
39+
/// Null on first run, when settings were saved without a version, or on older SE versions.
40+
/// </summary>
41+
public int? SettingsVersion { get; set; }
2642
}
2743

2844
/// <summary>Active theme colors. All values are <c>#AARRGGBB</c> hex strings.</summary>
@@ -52,5 +68,12 @@ public sealed class PluginResponse
5268
public string? Message { get; set; }
5369
public PluginSubtitle? Subtitle { get; set; }
5470
public JsonElement? Settings { get; set; }
71+
72+
/// <summary>
73+
/// Schema version for <see cref="Settings"/>. Bump when you change the shape of your
74+
/// settings so you can migrate or reset on the next run. Optional; null = "unversioned".
75+
/// </summary>
76+
public int? SettingsVersion { get; set; }
77+
5578
public string? UndoDescription { get; set; }
5679
}

0 commit comments

Comments
 (0)