refactor: show child-window and modal dialog

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2025-07-04 14:49:04 +08:00
parent 4bfcfb8b24
commit a6ebc1502c
29 changed files with 131 additions and 121 deletions

View File

@@ -259,7 +259,7 @@ namespace SourceGit.ViewModels
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) =>
{
App.ShowWindow(new DirHistories(_repo, node.FullPath, _commit.SHA), false);
App.ShowWindow(new DirHistories(_repo, node.FullPath, _commit.SHA));
ev.Handled = true;
};
@@ -351,7 +351,7 @@ namespace SourceGit.ViewModels
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) =>
{
App.ShowWindow(new FileHistories(_repo, change.Path, _commit.SHA), false);
App.ShowWindow(new FileHistories(_repo, change.Path, _commit.SHA));
ev.Handled = true;
};
@@ -361,7 +361,7 @@ namespace SourceGit.ViewModels
blame.IsEnabled = change.Index != Models.ChangeState.Deleted;
blame.Click += (_, ev) =>
{
App.ShowWindow(new Blame(_repo.FullPath, change.Path, _commit), false);
App.ShowWindow(new Blame(_repo.FullPath, change.Path, _commit));
ev.Handled = true;
};
@@ -470,7 +470,7 @@ namespace SourceGit.ViewModels
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) =>
{
App.ShowWindow(new DirHistories(_repo, path, _commit.SHA), false);
App.ShowWindow(new DirHistories(_repo, path, _commit.SHA));
ev.Handled = true;
};
@@ -572,7 +572,7 @@ namespace SourceGit.ViewModels
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) =>
{
App.ShowWindow(new FileHistories(_repo, file.Path, _commit.SHA), false);
App.ShowWindow(new FileHistories(_repo, file.Path, _commit.SHA));
ev.Handled = true;
};
@@ -582,7 +582,7 @@ namespace SourceGit.ViewModels
blame.IsEnabled = file.Type == Models.ObjectType.Blob;
blame.Click += (_, ev) =>
{
App.ShowWindow(new Blame(_repo.FullPath, file.Path, _commit), false);
App.ShowWindow(new Blame(_repo.FullPath, file.Path, _commit));
ev.Handled = true;
};

View File

@@ -645,7 +645,7 @@ namespace SourceGit.ViewModels
var interactiveRebase = new MenuItem();
interactiveRebase.Header = App.Text("CommitCM.InteractiveRebase", current.Name);
interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.Click += (_, e) =>
interactiveRebase.Click += async (_, e) =>
{
if (_repo.LocalChangesCount > 0)
{
@@ -653,7 +653,7 @@ namespace SourceGit.ViewModels
return;
}
App.ShowWindow(new InteractiveRebase(_repo, current, commit), true);
await App.ShowDailog(new InteractiveRebase(_repo, current, commit));
e.Handled = true;
};

View File

@@ -450,9 +450,9 @@ namespace SourceGit.ViewModels
var configure = new MenuItem();
configure.Header = App.Text("Workspace.Configure");
configure.Click += (_, e) =>
configure.Click += async (_, e) =>
{
App.ShowWindow(new ConfigureWorkspace(), true);
await App.ShowDailog(new ConfigureWorkspace());
e.Handled = true;
};
menu.Items.Add(configure);

View File

@@ -1666,9 +1666,9 @@ namespace SourceGit.ViewModels
locks.IsEnabled = _remotes.Count > 0;
if (_remotes.Count == 1)
{
locks.Click += (_, e) =>
locks.Click += async (_, e) =>
{
App.ShowWindow(new LFSLocks(this, _remotes[0].Name), true);
await App.ShowDailog(new LFSLocks(this, _remotes[0].Name));
e.Handled = true;
};
}
@@ -1679,9 +1679,9 @@ namespace SourceGit.ViewModels
var remoteName = remote.Name;
var lockRemote = new MenuItem();
lockRemote.Header = remoteName;
lockRemote.Click += (_, e) =>
lockRemote.Click += async (_, e) =>
{
App.ShowWindow(new LFSLocks(this, remoteName), true);
await App.ShowDailog(new LFSLocks(this, remoteName));
e.Handled = true;
};
locks.Items.Add(lockRemote);
@@ -1984,7 +1984,7 @@ namespace SourceGit.ViewModels
compareWithCurrent.Icon = App.CreateMenuIcon("Icons.Compare");
compareWithCurrent.Click += (_, _) =>
{
App.ShowWindow(new BranchCompare(_fullpath, branch, _currentBranch), false);
App.ShowWindow(new BranchCompare(_fullpath, branch, _currentBranch));
};
menu.Items.Add(new MenuItem() { Header = "-" });
menu.Items.Add(compareWithCurrent);
@@ -2264,7 +2264,7 @@ namespace SourceGit.ViewModels
compareWithHead.Icon = App.CreateMenuIcon("Icons.Compare");
compareWithHead.Click += (_, _) =>
{
App.ShowWindow(new BranchCompare(_fullpath, branch, _currentBranch), false);
App.ShowWindow(new BranchCompare(_fullpath, branch, _currentBranch));
};
menu.Items.Add(compareWithHead);

View File

@@ -334,11 +334,6 @@ namespace SourceGit.ViewModels
UseExternalMergeTool(null);
}
public void OpenAssumeUnchanged()
{
App.ShowWindow(new AssumeUnchangedManager(_repo), true);
}
public void StashAll(bool autoStart)
{
if (!_repo.CanCreatePopup())
@@ -973,9 +968,9 @@ namespace SourceGit.ViewModels
history.Click += (_, e) =>
{
if (hasSelectedFolder)
App.ShowWindow(new DirHistories(_repo, selectedSingleFolder), false);
App.ShowWindow(new DirHistories(_repo, selectedSingleFolder));
else
App.ShowWindow(new FileHistories(_repo, change.Path), false);
App.ShowWindow(new FileHistories(_repo, change.Path));
e.Handled = true;
};
@@ -1166,7 +1161,7 @@ namespace SourceGit.ViewModels
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Click += (_, e) =>
{
App.ShowWindow(new DirHistories(_repo, selectedSingleFolder), false);
App.ShowWindow(new DirHistories(_repo, selectedSingleFolder));
e.Handled = true;
};
menu.Items.Add(new MenuItem() { Header = "-" });
@@ -1215,9 +1210,9 @@ namespace SourceGit.ViewModels
if (services.Count == 1)
{
ai.Click += (_, e) =>
ai.Click += async (_, e) =>
{
App.ShowWindow(new AIAssistant(_repo, services[0], _selectedStaged, t => CommitMessage = t), true);
await App.ShowDailog(new AIAssistant(_repo, services[0], _selectedStaged, t => CommitMessage = t));
e.Handled = true;
};
}
@@ -1229,9 +1224,9 @@ namespace SourceGit.ViewModels
var item = new MenuItem();
item.Header = service.Name;
item.Click += (_, e) =>
item.Click += async (_, e) =>
{
App.ShowWindow(new AIAssistant(_repo, dup, _selectedStaged, t => CommitMessage = t), true);
await App.ShowDailog(new AIAssistant(_repo, dup, _selectedStaged, t => CommitMessage = t));
e.Handled = true;
};
@@ -1421,9 +1416,9 @@ namespace SourceGit.ViewModels
history.Click += (_, e) =>
{
if (hasSelectedFolder)
App.ShowWindow(new DirHistories(_repo, selectedSingleFolder), false);
App.ShowWindow(new DirHistories(_repo, selectedSingleFolder));
else
App.ShowWindow(new FileHistories(_repo, change.Path), false);
App.ShowWindow(new FileHistories(_repo, change.Path));
e.Handled = true;
};
@@ -1532,7 +1527,7 @@ namespace SourceGit.ViewModels
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Click += (_, e) =>
{
App.ShowWindow(new DirHistories(_repo, selectedSingleFolder), false);
App.ShowWindow(new DirHistories(_repo, selectedSingleFolder));
e.Handled = true;
};
@@ -1672,7 +1667,7 @@ namespace SourceGit.ViewModels
if (services.Count == 1)
{
App.ShowWindow(new AIAssistant(_repo, services[0], _staged, t => CommitMessage = t), true);
_ = App.ShowDailog(new AIAssistant(_repo, services[0], _staged, t => CommitMessage = t));
return null;
}
@@ -1682,9 +1677,9 @@ namespace SourceGit.ViewModels
var dup = service;
var item = new MenuItem();
item.Header = service.Name;
item.Click += (_, e) =>
item.Click += async (_, e) =>
{
App.ShowWindow(new AIAssistant(_repo, dup, _staged, t => CommitMessage = t), true);
await App.ShowDailog(new AIAssistant(_repo, dup, _staged, t => CommitMessage = t));
e.Handled = true;
};
@@ -1902,7 +1897,7 @@ namespace SourceGit.ViewModels
{
if ((!autoStage && _staged.Count == 0) || (autoStage && _cached.Count == 0))
{
App.ShowWindow(new ConfirmEmptyCommit(_cached.Count > 0, stageAll => DoCommit(stageAll, autoPush, CommitCheckPassed.FileCount)), true);
_ = App.ShowDailog(new ConfirmEmptyCommit(_cached.Count > 0, stageAll => DoCommit(stageAll, autoPush, CommitCheckPassed.FileCount)));
return;
}
}