Skip to content

Commit ada767d

Browse files
committed
feature: remember author column width
Signed-off-by: leo <[email protected]>
1 parent d1cc836 commit ada767d

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/App.JsonCodeGen.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,28 @@ public override void Write(Utf8JsonWriter writer, GridLength value, JsonSerializ
3434
}
3535
}
3636

37+
public class DataGridLengthConverter : JsonConverter<DataGridLength>
38+
{
39+
public override DataGridLength Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
40+
{
41+
var size = reader.GetDouble();
42+
return new DataGridLength(size, DataGridLengthUnitType.Pixel, 0, size);
43+
}
44+
45+
public override void Write(Utf8JsonWriter writer, DataGridLength value, JsonSerializerOptions options)
46+
{
47+
writer.WriteNumberValue(value.DisplayValue);
48+
}
49+
}
50+
3751
[JsonSourceGenerationOptions(
3852
WriteIndented = true,
3953
IgnoreReadOnlyFields = true,
4054
IgnoreReadOnlyProperties = true,
4155
Converters = [
4256
typeof(ColorConverter),
4357
typeof(GridLengthConverter),
58+
typeof(DataGridLengthConverter),
4459
]
4560
)]
4661
[JsonSerializable(typeof(Models.ExternalToolPaths))]

src/ViewModels/LayoutInfo.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,17 @@ public GridLength CommitDetailFilesLeftWidth
6565
set => SetProperty(ref _commitDetailFilesLeftWidth, value);
6666
}
6767

68+
public DataGridLength AuthorColumnWidth
69+
{
70+
get => _authorColumnWidth;
71+
set => SetProperty(ref _authorColumnWidth, value);
72+
}
73+
6874
private GridLength _repositorySidebarWidth = new GridLength(250, GridUnitType.Pixel);
6975
private GridLength _workingCopyLeftWidth = new GridLength(300, GridUnitType.Pixel);
7076
private GridLength _stashesLeftWidth = new GridLength(300, GridUnitType.Pixel);
7177
private GridLength _commitDetailChangesLeftWidth = new GridLength(256, GridUnitType.Pixel);
7278
private GridLength _commitDetailFilesLeftWidth = new GridLength(256, GridUnitType.Pixel);
79+
private DataGridLength _authorColumnWidth = new DataGridLength(120, DataGridLengthUnitType.Pixel, 120, 120);
7380
}
7481
}

src/Views/Histories.axaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@
149149
</DataGridTemplateColumn.CellTemplate>
150150
</DataGridTemplateColumn>
151151

152-
<DataGridTemplateColumn MinWidth="80" Width="100" CanUserResize="True" IsReadOnly="True">
152+
<DataGridTemplateColumn MinWidth="80" CanUserResize="True" IsReadOnly="True">
153+
<DataGridTemplateColumn.Width>
154+
<Binding Source="{x:Static vm:Preferences.Instance}"
155+
Path="Layout.AuthorColumnWidth"
156+
Mode="TwoWay"/>
157+
</DataGridTemplateColumn.Width>
153158
<DataGridTemplateColumn.Header>
154159
<TextBlock Classes="table_header" Text="{DynamicResource Text.Histories.Header.Author}" HorizontalAlignment="Center"/>
155160
</DataGridTemplateColumn.Header>

0 commit comments

Comments
 (0)