mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: add property RestoreOnStartup
property to ViewModels.Workspace
(#488)
This commit is contained in:
parent
900ebd8282
commit
84fda6a8db
9 changed files with 59 additions and 25 deletions
|
@ -150,8 +150,9 @@
|
|||
<x:String x:Key="Text.Configure.User" xml:space="preserve">Benutzername</x:String>
|
||||
<x:String x:Key="Text.Configure.User.Placeholder" xml:space="preserve">Benutzername für dieses Repository</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace" xml:space="preserve">Arbeitsplätze</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Name" xml:space="preserve">Name</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Color" xml:space="preserve">Farbe</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Name" xml:space="preserve">Name</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Restore" xml:space="preserve">Zuletzt geöffnete Tabs beim Starten wiederherstellen</x:String>
|
||||
<x:String x:Key="Text.Copy" xml:space="preserve">Kopieren</x:String>
|
||||
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Kopiere gesamten Text</x:String>
|
||||
<x:String x:Key="Text.CopyMessage" xml:space="preserve">COMMIT-NACHRICHT KOPIEREN</x:String>
|
||||
|
|
|
@ -149,8 +149,9 @@
|
|||
<x:String x:Key="Text.Configure.User" xml:space="preserve">User Name</x:String>
|
||||
<x:String x:Key="Text.Configure.User.Placeholder" xml:space="preserve">User name for this repository</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace" xml:space="preserve">Workspaces</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Name" xml:space="preserve">Name</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Color" xml:space="preserve">Color</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Name" xml:space="preserve">Name</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Restore" xml:space="preserve">Restore tabs on startup</x:String>
|
||||
<x:String x:Key="Text.Copy" xml:space="preserve">Copy</x:String>
|
||||
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Copy All Text</x:String>
|
||||
<x:String x:Key="Text.CopyMessage" xml:space="preserve">COPY MESSAGE</x:String>
|
||||
|
|
|
@ -152,8 +152,9 @@
|
|||
<x:String x:Key="Text.Configure.User" xml:space="preserve">用户名</x:String>
|
||||
<x:String x:Key="Text.Configure.User.Placeholder" xml:space="preserve">应用于本仓库的用户名</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace" xml:space="preserve">工作区</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Name" xml:space="preserve">名称</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Color" xml:space="preserve">颜色</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Name" xml:space="preserve">名称</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Restore" xml:space="preserve">启动时恢复打开的仓库</x:String>
|
||||
<x:String x:Key="Text.Copy" xml:space="preserve">复制</x:String>
|
||||
<x:String x:Key="Text.CopyAllText" xml:space="preserve">复制全部文本</x:String>
|
||||
<x:String x:Key="Text.CopyMessage" xml:space="preserve">复制内容</x:String>
|
||||
|
|
|
@ -152,8 +152,9 @@
|
|||
<x:String x:Key="Text.Configure.User" xml:space="preserve">使用者名稱</x:String>
|
||||
<x:String x:Key="Text.Configure.User.Placeholder" xml:space="preserve">用於本存放庫的使用者名稱</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace" xml:space="preserve">工作區</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Name" xml:space="preserve">名稱</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Color" xml:space="preserve">顏色</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Name" xml:space="preserve">名稱</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Restore" xml:space="preserve">啟動時還原上次開啟的存放庫</x:String>
|
||||
<x:String x:Key="Text.Copy" xml:space="preserve">複製</x:String>
|
||||
<x:String x:Key="Text.CopyAllText" xml:space="preserve">複製全部內容</x:String>
|
||||
<x:String x:Key="Text.CopyMessage" xml:space="preserve">複製內容</x:String>
|
||||
|
|
|
@ -36,10 +36,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public void Add()
|
||||
{
|
||||
var workspace = new Workspace();
|
||||
workspace.Name = $"Unnamed {DateTime.Now:yyyy-MM-dd HH:mm:ss}";
|
||||
workspace.Color = 4278221015;
|
||||
|
||||
var workspace = new Workspace() { Name = $"Unnamed {DateTime.Now:yyyy-MM-dd HH:mm:ss}" };
|
||||
Preference.Instance.Workspaces.Add(workspace);
|
||||
Workspaces.Add(workspace);
|
||||
Selected = workspace;
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
ActiveWorkspace = new Workspace() { Name = "Unnamed", Color = 4278221015 };
|
||||
ActiveWorkspace = new Workspace() { Name = "Unnamed" };
|
||||
|
||||
foreach (var w in pref.Workspaces)
|
||||
w.IsActive = false;
|
||||
|
|
|
@ -22,15 +22,9 @@ namespace SourceGit.ViewModels
|
|||
_isLoading = false;
|
||||
}
|
||||
|
||||
if (!_instance.IsGitConfigured())
|
||||
_instance.GitInstallPath = Native.OS.FindGitExecutable();
|
||||
|
||||
if (_instance._shellOrTerminal == -1)
|
||||
_instance.AutoSelectShellOrTerminal();
|
||||
|
||||
if (_instance.Workspaces.Count == 0)
|
||||
_instance.Workspaces.Add(new Workspace() { Name = "Default", Color = 4278221015 });
|
||||
|
||||
_instance.PrepareGit();
|
||||
_instance.PrepareShellOrTerminal();
|
||||
_instance.PrepareWorkspaces();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
@ -501,8 +495,18 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void AutoSelectShellOrTerminal()
|
||||
private void PrepareGit()
|
||||
{
|
||||
var path = Native.OS.GitExecutable;
|
||||
if (string.IsNullOrEmpty(path) || !File.Exists(path))
|
||||
GitInstallPath = Native.OS.FindGitExecutable();
|
||||
}
|
||||
|
||||
private void PrepareShellOrTerminal()
|
||||
{
|
||||
if (_shellOrTerminal >= 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < Models.ShellOrTerminal.Supported.Count; i++)
|
||||
{
|
||||
var shell = Models.ShellOrTerminal.Supported[i];
|
||||
|
@ -514,6 +518,24 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void PrepareWorkspaces()
|
||||
{
|
||||
if (Workspaces.Count == 0)
|
||||
{
|
||||
Workspaces.Add(new Workspace() { Name = "Default" });
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var workspace in Workspaces)
|
||||
{
|
||||
if (!workspace.RestoreOnStartup)
|
||||
{
|
||||
workspace.Repositories.Clear();
|
||||
workspace.ActiveIdx = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RepositoryNode FindNodeRecursive(string id, List<RepositoryNode> collection)
|
||||
{
|
||||
foreach (var node in collection)
|
||||
|
|
|
@ -43,6 +43,12 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _isActive, value);
|
||||
}
|
||||
|
||||
public bool RestoreOnStartup
|
||||
{
|
||||
get => _restoreOnStartup;
|
||||
set => SetProperty(ref _restoreOnStartup, value);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public IBrush Brush
|
||||
{
|
||||
|
@ -57,8 +63,9 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
|
||||
private string _name = string.Empty;
|
||||
private uint _color = 0;
|
||||
private uint _color = 4278221015;
|
||||
private bool _isActive = false;
|
||||
private IBrush _brush = null;
|
||||
private bool _restoreOnStartup = true;
|
||||
private IBrush _brush = new SolidColorBrush(4278221015);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</Grid>
|
||||
|
||||
<!-- BODY -->
|
||||
<Grid Grid.Row="1" ColumnDefinitions="200,16,256" Height="324" Margin="8">
|
||||
<Grid Grid.Row="1" ColumnDefinitions="200,16,256" MinHeight="356" Margin="8">
|
||||
<Border Grid.Column="0"
|
||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
|
||||
Background="{DynamicResource Brush.Contents}">
|
||||
|
@ -107,12 +107,16 @@
|
|||
<ContentControl Grid.Column="2" Content="{Binding Selected}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:Workspace">
|
||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto">
|
||||
<Grid RowDefinitions="Auto,32,32,Auto,256">
|
||||
<TextBlock Grid.Row="0" Text="{DynamicResource Text.ConfigureWorkspace.Name}"/>
|
||||
<TextBox Grid.Row="1" Margin="0,4,0,0" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/>
|
||||
|
||||
<TextBlock Grid.Row="2" Margin="0,12,0,4" Text="{DynamicResource Text.ConfigureWorkspace.Color}"/>
|
||||
<v:ColorPicker Grid.Row="3" HorizontalAlignment="Left" Value="{Binding Color, Mode=TwoWay}"/>
|
||||
<CheckBox Grid.Row="2"
|
||||
Content="{DynamicResource Text.ConfigureWorkspace.Restore}"
|
||||
IsChecked="{Binding RestoreOnStartup, Mode=TwoWay}"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Margin="0,8,0,4" Text="{DynamicResource Text.ConfigureWorkspace.Color}"/>
|
||||
<v:ColorPicker Grid.Row="4" HorizontalAlignment="Left" Value="{Binding Color, Mode=TwoWay}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
|
|
Loading…
Reference in a new issue