mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 21:24:59 +00: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
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue