mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature: remember window size and layout information (#165)
This commit is contained in:
parent
7f2e22def6
commit
f977e76ea7
8 changed files with 94 additions and 5 deletions
80
src/ViewModels/LayoutInfo.cs
Normal file
80
src/ViewModels/LayoutInfo.cs
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
using System;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
|
namespace SourceGit.ViewModels
|
||||||
|
{
|
||||||
|
public class LayoutInfo : ObservableObject
|
||||||
|
{
|
||||||
|
public double LauncherWidth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = 1280;
|
||||||
|
|
||||||
|
public double LauncherHeight
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = 720;
|
||||||
|
|
||||||
|
[JsonConverter(typeof(GridLengthConverter))]
|
||||||
|
public GridLength RepositorySidebarWidth
|
||||||
|
{
|
||||||
|
get => _repositorySidebarWidth;
|
||||||
|
set => SetProperty(ref _repositorySidebarWidth, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonConverter(typeof(GridLengthConverter))]
|
||||||
|
public GridLength WorkingCopyLeftWidth
|
||||||
|
{
|
||||||
|
get => _workingCopyLeftWidth;
|
||||||
|
set => SetProperty(ref _workingCopyLeftWidth, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonConverter(typeof(GridLengthConverter))]
|
||||||
|
public GridLength StashesLeftWidth
|
||||||
|
{
|
||||||
|
get => _stashesLeftWidth;
|
||||||
|
set => SetProperty(ref _stashesLeftWidth, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonConverter(typeof(GridLengthConverter))]
|
||||||
|
public GridLength CommitDetailChangesLeftWidth
|
||||||
|
{
|
||||||
|
get => _commitDetailChangesLeftWidth;
|
||||||
|
set => SetProperty(ref _commitDetailChangesLeftWidth, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonConverter(typeof(GridLengthConverter))]
|
||||||
|
public GridLength CommitDetailFilesLeftWidth
|
||||||
|
{
|
||||||
|
get => _commitDetailFilesLeftWidth;
|
||||||
|
set => SetProperty(ref _commitDetailFilesLeftWidth, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private GridLength _repositorySidebarWidth = new GridLength(250, GridUnitType.Pixel);
|
||||||
|
private GridLength _workingCopyLeftWidth = new GridLength(300, GridUnitType.Pixel);
|
||||||
|
private GridLength _stashesLeftWidth = new GridLength(300, GridUnitType.Pixel);
|
||||||
|
private GridLength _commitDetailChangesLeftWidth = new GridLength(256, GridUnitType.Pixel);
|
||||||
|
private GridLength _commitDetailFilesLeftWidth = new GridLength(256, GridUnitType.Pixel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GridLengthConverter : JsonConverter<GridLength>
|
||||||
|
{
|
||||||
|
public override GridLength Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
var size = reader.GetDouble();
|
||||||
|
return new GridLength(size, GridUnitType.Pixel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, GridLength value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
writer.WriteNumberValue(value.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -109,6 +109,12 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _defaultFontSize, value);
|
set => SetProperty(ref _defaultFontSize, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LayoutInfo Layout
|
||||||
|
{
|
||||||
|
get => _layout;
|
||||||
|
set => SetProperty(ref _layout, value);
|
||||||
|
}
|
||||||
|
|
||||||
public string AvatarServer
|
public string AvatarServer
|
||||||
{
|
{
|
||||||
get => Models.AvatarManager.SelectedServer;
|
get => Models.AvatarManager.SelectedServer;
|
||||||
|
@ -531,6 +537,7 @@ namespace SourceGit.ViewModels
|
||||||
private FontFamily _defaultFont = null;
|
private FontFamily _defaultFont = null;
|
||||||
private FontFamily _monospaceFont = null;
|
private FontFamily _monospaceFont = null;
|
||||||
private double _defaultFontSize = 13;
|
private double _defaultFontSize = 13;
|
||||||
|
private LayoutInfo _layout = new LayoutInfo();
|
||||||
|
|
||||||
private int _maxHistoryCommits = 20000;
|
private int _maxHistoryCommits = 20000;
|
||||||
private bool _restoreTabs = false;
|
private bool _restoreTabs = false;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
x:DataType="vm:CommitDetail">
|
x:DataType="vm:CommitDetail">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="256" MinWidth="200" MaxWidth="480"/>
|
<ColumnDefinition Width="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.CommitDetailChangesLeftWidth, Mode=TwoWay}" MinWidth="200" MaxWidth="480"/>
|
||||||
<ColumnDefinition Width="4"/>
|
<ColumnDefinition Width="4"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
Title="SourceGit"
|
Title="SourceGit"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
MinWidth="1280" MinHeight="720"
|
MinWidth="1280" MinHeight="720"
|
||||||
|
Width="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.LauncherWidth, Mode=TwoWay}"
|
||||||
|
Height="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.LauncherHeight, Mode=TwoWay}"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
ExtendClientAreaToDecorationsHint="True"
|
ExtendClientAreaToDecorationsHint="True"
|
||||||
ExtendClientAreaChromeHints="NoChrome"
|
ExtendClientAreaChromeHints="NoChrome"
|
||||||
|
|
|
@ -103,7 +103,7 @@
|
||||||
<!-- Body -->
|
<!-- Body -->
|
||||||
<Grid Grid.Row="1">
|
<Grid Grid.Row="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="250" MinWidth="200" MaxWidth="400"/>
|
<ColumnDefinition Width="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.RepositorySidebarWidth, Mode=TwoWay}" MinWidth="200" MaxWidth="400"/>
|
||||||
<ColumnDefinition Width="3"/>
|
<ColumnDefinition Width="3"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
x:DataType="vm:CommitDetail">
|
x:DataType="vm:CommitDetail">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="256" MinWidth="200" MaxWidth="480"/>
|
<ColumnDefinition Width="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.CommitDetailFilesLeftWidth, Mode=TwoWay}" MinWidth="200" MaxWidth="480"/>
|
||||||
<ColumnDefinition Width="4"/>
|
<ColumnDefinition Width="4"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
x:DataType="vm:StashesPage">
|
x:DataType="vm:StashesPage">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="300" MinWidth="300"/>
|
<ColumnDefinition Width="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.StashesLeftWidth, Mode=TwoWay}" MinWidth="300"/>
|
||||||
<ColumnDefinition Width="4"/>
|
<ColumnDefinition Width="4"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
x:DataType="vm:WorkingCopy">
|
x:DataType="vm:WorkingCopy">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="300" MinWidth="300"/>
|
<ColumnDefinition Width="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.WorkingCopyLeftWidth, Mode=TwoWay}" MinWidth="300"/>
|
||||||
<ColumnDefinition Width="5"/>
|
<ColumnDefinition Width="5"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
Loading…
Reference in a new issue