mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 05:05:00 +00:00
feature<Launcher>: supports restore last opened tabs when startup
This commit is contained in:
parent
2ddc61e162
commit
f6c17e7d34
7 changed files with 90 additions and 20 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
@ -16,6 +17,31 @@ namespace SourceGit.Views {
|
|||
tabs.Add();
|
||||
}
|
||||
|
||||
private void OnClosing(object sender, CancelEventArgs e) {
|
||||
var restore = Models.Preference.Instance.Restore;
|
||||
if (!restore.IsEnabled) return;
|
||||
|
||||
restore.Opened.Clear();
|
||||
|
||||
foreach (var tab in tabs.Tabs) {
|
||||
if (tab.IsWelcomePage) continue;
|
||||
|
||||
// 仅支持恢复加入管理的仓库页,Submodules等未加入管理的不支持
|
||||
var repo = Models.Preference.Instance.FindRepository(tab.Id);
|
||||
if (repo != null) restore.Opened.Add(tab.Id);
|
||||
}
|
||||
|
||||
if (restore.Opened.Count > 0) {
|
||||
if (restore.Opened.IndexOf(tabs.Current) >= 0) {
|
||||
restore.Actived = tabs.Current;
|
||||
} else {
|
||||
restore.Actived = restore.Opened[0];
|
||||
}
|
||||
}
|
||||
|
||||
Models.Preference.Save();
|
||||
}
|
||||
|
||||
#region OPEN_REPO
|
||||
private void OpenRepository(Models.Repository repo) {
|
||||
if (tabs.Goto(repo.Path)) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue