mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
optimize<PageTabBar>: do NOT restore tabs when app exited via closing the last tab
This commit is contained in:
parent
3f2948dd06
commit
21df028601
2 changed files with 14 additions and 13 deletions
|
@ -22,6 +22,7 @@ namespace SourceGit.Views {
|
||||||
if (!restore.IsEnabled) return;
|
if (!restore.IsEnabled) return;
|
||||||
|
|
||||||
restore.Opened.Clear();
|
restore.Opened.Clear();
|
||||||
|
restore.Actived = null;
|
||||||
|
|
||||||
foreach (var tab in tabs.Tabs) {
|
foreach (var tab in tabs.Tabs) {
|
||||||
if (tab.IsWelcomePage) continue;
|
if (tab.IsWelcomePage) continue;
|
||||||
|
|
|
@ -140,16 +140,15 @@ namespace SourceGit.Views.Widgets {
|
||||||
|
|
||||||
public void CloseCurrent() {
|
public void CloseCurrent() {
|
||||||
var curTab = container.SelectedItem as Tab;
|
var curTab = container.SelectedItem as Tab;
|
||||||
if (Tabs.Count == 1) {
|
var idx = container.SelectedIndex;
|
||||||
|
Tabs.Remove(curTab);
|
||||||
|
if (Tabs.Count == 0) {
|
||||||
Application.Current.Shutdown();
|
Application.Current.Shutdown();
|
||||||
} else {
|
} else {
|
||||||
var idx = container.SelectedIndex;
|
|
||||||
Tabs.Remove(curTab);
|
|
||||||
RaiseEvent(new TabEventArgs(TabClosedEvent, this, curTab.Id));
|
|
||||||
|
|
||||||
var last = Tabs.Count - 1;
|
var last = Tabs.Count - 1;
|
||||||
var next = idx > last ? Tabs[last] : Tabs[idx];
|
var next = idx > last ? Tabs[last] : Tabs[idx];
|
||||||
container.SelectedItem = next;
|
container.SelectedItem = next;
|
||||||
|
RaiseEvent(new TabEventArgs(TabClosedEvent, this, curTab.Id));
|
||||||
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
|
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,17 +198,18 @@ namespace SourceGit.Views.Widgets {
|
||||||
|
|
||||||
var curTab = container.SelectedItem as Tab;
|
var curTab = container.SelectedItem as Tab;
|
||||||
if (curTab != null && tab.Id == curTab.Id) {
|
if (curTab != null && tab.Id == curTab.Id) {
|
||||||
if (Tabs.Count > 1) {
|
var idx = Tabs.IndexOf(tab);
|
||||||
var idx = Tabs.IndexOf(tab);
|
Tabs.Remove(tab);
|
||||||
Tabs.Remove(tab);
|
|
||||||
|
|
||||||
var last = Tabs.Count - 1;
|
if (Tabs.Count == 0) {
|
||||||
var next = idx > last ? Tabs[last] : Tabs[idx];
|
|
||||||
container.SelectedItem = next;
|
|
||||||
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
|
|
||||||
} else {
|
|
||||||
Application.Current.Shutdown();
|
Application.Current.Shutdown();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var last = Tabs.Count - 1;
|
||||||
|
var next = idx > last ? Tabs[last] : Tabs[idx];
|
||||||
|
container.SelectedItem = next;
|
||||||
|
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
|
||||||
} else {
|
} else {
|
||||||
Tabs.Remove(tab);
|
Tabs.Remove(tab);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue