feature: workspace support (#445)

This commit is contained in:
leo 2024-09-09 18:26:43 +08:00
parent acd6171350
commit ebc112a627
No known key found for this signature in database
27 changed files with 473 additions and 109 deletions

View file

@ -39,6 +39,9 @@ namespace SourceGit.ViewModels
if (!_instance.IsGitConfigured())
_instance.GitInstallPath = Native.OS.FindGitExecutable();
if (_instance.Workspaces.Count == 0)
_instance.Workspaces.Add(new Workspace() { Name = "Default", Color = 4278221015 });
return _instance;
}
}
@ -133,12 +136,6 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _subjectGuideLength, value);
}
public bool RestoreTabs
{
get => _restoreTabs;
set => SetProperty(ref _restoreTabs, value);
}
public bool UseFixedTabWidth
{
get => _useFixedTabWidth;
@ -304,18 +301,12 @@ namespace SourceGit.ViewModels
set;
} = [];
public List<string> OpenedTabs
public List<Workspace> Workspaces
{
get;
set;
} = [];
public int LastActiveTabIdx
{
get;
set;
} = 0;
public double LastCheckUpdateTime
{
get => _lastCheckUpdateTime;
@ -343,6 +334,19 @@ namespace SourceGit.ViewModels
return true;
}
public Workspace GetActiveWorkspace()
{
foreach (var w in Workspaces)
{
if (w.IsActive)
return w;
}
var first = Workspaces[0];
first.IsActive = true;
return first;
}
public void AddNode(RepositoryNode node, RepositoryNode to, bool save)
{
var collection = to == null ? RepositoryNodes : to.SubNodes;
@ -492,7 +496,6 @@ namespace SourceGit.ViewModels
private int _maxHistoryCommits = 20000;
private int _subjectGuideLength = 50;
private bool _restoreTabs = false;
private bool _useFixedTabWidth = true;
private bool _check4UpdatesOnStartup = true;