mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08: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
|
@ -85,6 +85,18 @@ namespace SourceGit {
|
|||
}
|
||||
|
||||
if (repo != null) Models.Watcher.Open(repo);
|
||||
} else {
|
||||
var restore = Models.Preference.Instance.Restore;
|
||||
var actived = null as Models.Repository;
|
||||
if (restore.IsEnabled && restore.Opened.Count > 0) {
|
||||
foreach (var path in restore.Opened) {
|
||||
var repo = Models.Preference.Instance.FindRepository(path);
|
||||
if (repo != null) Models.Watcher.Open(repo);
|
||||
if (path == restore.Actived) actived = repo;
|
||||
}
|
||||
|
||||
if (actived != null) Models.Watcher.Open(actived);
|
||||
}
|
||||
}
|
||||
|
||||
// 检测更新
|
||||
|
|
|
@ -135,6 +135,27 @@ namespace SourceGit.Models {
|
|||
public Change.DisplayMode ChangeInCommitInfo { get; set; } = Change.DisplayMode.Tree;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复上次打开的窗口
|
||||
/// </summary>
|
||||
public class RestoreTabs {
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启该功能
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 上次打开的仓库
|
||||
/// </summary>
|
||||
public List<string> Opened { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 最后浏览的仓库
|
||||
/// </summary>
|
||||
public string Actived { get; set; } = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全局配置
|
||||
/// </summary>
|
||||
|
@ -163,6 +184,7 @@ namespace SourceGit.Models {
|
|||
public WindowInfo Window { get; set; } = new WindowInfo();
|
||||
public List<Group> Groups { get; set; } = new List<Group>();
|
||||
public List<Repository> Repositories { get; set; } = new List<Repository>();
|
||||
public RestoreTabs Restore { get; set; } = new RestoreTabs();
|
||||
#endregion
|
||||
|
||||
#region LOAD_SAVE
|
||||
|
|
|
@ -364,6 +364,7 @@
|
|||
<sys:String x:Key="Text.Preference.UseDark">Use dark theme</sys:String>
|
||||
<sys:String x:Key="Text.Preference.CheckUpdate">Check for update</sys:String>
|
||||
<sys:String x:Key="Text.Preference.AutoFetch">Fetch remotes automatically</sys:String>
|
||||
<sys:String x:Key="Text.Preference.RestoreTabs">Restore windows</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git">GIT SETTING</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path">Install Path :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path.Placeholder">Input path for git.exe</sys:String>
|
||||
|
|
|
@ -363,6 +363,7 @@
|
|||
<sys:String x:Key="Text.Preference.UseDark">启用暗色主题</sys:String>
|
||||
<sys:String x:Key="Text.Preference.CheckUpdate">启用检测更新</sys:String>
|
||||
<sys:String x:Key="Text.Preference.AutoFetch">启用定时自动拉取远程更新</sys:String>
|
||||
<sys:String x:Key="Text.Preference.RestoreTabs">启动时恢复上次打开的仓库</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git">GIT配置</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path">安装路径 :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path.Placeholder">填写git.exe所在位置</sys:String>
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
MinWidth="1280" MinHeight="720"
|
||||
Title="{StaticResource Text.About.Title}"
|
||||
Width="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Width, Mode=TwoWay}"
|
||||
Height="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Height, Mode=TwoWay}">
|
||||
Height="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Height, Mode=TwoWay}"
|
||||
Closing="OnClosing">
|
||||
<controls:DragDropAdornerLayer>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="8"/>
|
||||
<RowDefinition Height="36"/>
|
||||
<RowDefinition Height="28"/>
|
||||
|
@ -135,21 +136,27 @@
|
|||
Grid.Row="5" Grid.Column="1"
|
||||
Content="{StaticResource Text.Preference.AutoFetch}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.AutoFetchRemotes, Mode=TwoWay}"/>
|
||||
|
||||
|
||||
<!-- Restore Windows -->
|
||||
<CheckBox
|
||||
Grid.Row="6" Grid.Column="1"
|
||||
Content="{StaticResource Text.Preference.RestoreTabs}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Restore.IsEnabled, Mode=TwoWay}"/>
|
||||
|
||||
<!-- Git Group -->
|
||||
<TextBlock
|
||||
Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Text="{StaticResource Text.Preference.Git}"
|
||||
FontSize="16" FontWeight="DemiBold"
|
||||
Foreground="{StaticResource Brush.FG2}"/>
|
||||
|
||||
<!-- Git Executable Path -->
|
||||
<TextBlock
|
||||
Grid.Row="8" Grid.Column="0"
|
||||
Grid.Row="9" Grid.Column="0"
|
||||
Text="{StaticResource Text.Preference.Git.Path}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,6,0"/>
|
||||
<Grid Grid.Row="8" Grid.Column="1">
|
||||
<Grid Grid.Row="9" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
|
@ -172,11 +179,11 @@
|
|||
|
||||
<!-- Default Clone Dir -->
|
||||
<TextBlock
|
||||
Grid.Row="9" Grid.Column="0"
|
||||
Grid.Row="10" Grid.Column="0"
|
||||
Text="{StaticResource Text.Preference.Git.Dir}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,6,0"/>
|
||||
<Grid Grid.Row="9" Grid.Column="1">
|
||||
<Grid Grid.Row="10" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
|
@ -199,36 +206,36 @@
|
|||
|
||||
<!-- User -->
|
||||
<TextBlock
|
||||
Grid.Row="10" Grid.Column="0"
|
||||
Grid.Row="11" Grid.Column="0"
|
||||
Text="{StaticResource Text.Preference.Git.User}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,6,0"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="10" Grid.Column="1"
|
||||
Grid.Row="11" Grid.Column="1"
|
||||
Height="24"
|
||||
Text="{Binding ElementName=me, Path=User, Mode=TwoWay}"
|
||||
Placeholder="{StaticResource Text.Preference.Git.User.Placeholder}"/>
|
||||
|
||||
<!-- Email -->
|
||||
<TextBlock
|
||||
Grid.Row="11" Grid.Column="0"
|
||||
Grid.Row="12" Grid.Column="0"
|
||||
Text="{StaticResource Text.Preference.Git.Email}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,6,0"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="11" Grid.Column="1"
|
||||
Grid.Row="12" Grid.Column="1"
|
||||
Height="24"
|
||||
Text="{Binding ElementName=me, Path=Email, Mode=TwoWay}"
|
||||
Placeholder="{StaticResource Text.Preference.Git.Email.Placeholder}"/>
|
||||
|
||||
<!-- CRLF -->
|
||||
<TextBlock
|
||||
Grid.Row="12" Grid.Column="0"
|
||||
Grid.Row="13" Grid.Column="0"
|
||||
Text="{StaticResource Text.Preference.Git.CRLF}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,6,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="12" Grid.Column="1"
|
||||
Grid.Row="13" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:CRLFOption.Supported}}"
|
||||
SelectedValuePath="Value"
|
||||
|
@ -245,19 +252,19 @@
|
|||
|
||||
<!-- Merge Tool Group -->
|
||||
<TextBlock
|
||||
Grid.Row="14" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Grid.Row="15" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Text="{StaticResource Text.Preference.Merger}"
|
||||
FontSize="16" FontWeight="DemiBold"
|
||||
Foreground="{StaticResource Brush.FG2}"/>
|
||||
|
||||
<!-- Merge Tool Type -->
|
||||
<TextBlock
|
||||
Grid.Row="15" Grid.Column="0"
|
||||
Grid.Row="16" Grid.Column="0"
|
||||
Text="{StaticResource Text.Preference.Merger.Type}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,6,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="15" Grid.Column="1"
|
||||
Grid.Row="16" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:MergeTool.Supported}}"
|
||||
DisplayMemberPath="Name"
|
||||
|
@ -267,11 +274,11 @@
|
|||
|
||||
<!-- Merge Tool Executable Path -->
|
||||
<TextBlock
|
||||
Grid.Row="16" Grid.Column="0"
|
||||
Grid.Row="17" Grid.Column="0"
|
||||
Text="{StaticResource Text.Preference.Merger.Path}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,6,0"/>
|
||||
<Grid Grid.Row="16" Grid.Column="1">
|
||||
<Grid Grid.Row="17" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
|
@ -294,12 +301,12 @@
|
|||
|
||||
<!-- Merge Tool Command -->
|
||||
<TextBlock
|
||||
Grid.Row="17" Grid.Column="0"
|
||||
Grid.Row="18" Grid.Column="0"
|
||||
Text="{StaticResource Text.Preference.Merger.Cmd}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,6,0"/>
|
||||
<TextBlock
|
||||
Grid.Row="17" Grid.Column="1"
|
||||
Grid.Row="18" Grid.Column="1"
|
||||
x:Name="txtMergeCmd"
|
||||
Text="{Binding ElementName=me, Path=MergeCmd}"
|
||||
Foreground="{StaticResource Brush.FG2}"/>
|
||||
|
|
Loading…
Reference in a new issue