mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
ux: show Unset
menu item only if it is necessary (#690)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
04697093a8
commit
28c93da73b
1 changed files with 35 additions and 38 deletions
|
@ -71,19 +71,25 @@ namespace SourceGit.Views
|
||||||
if (button == null)
|
if (button == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var menu = new ContextMenu();
|
||||||
|
var mode = Models.FilterMode.None;
|
||||||
if (DataContext is Models.Tag tag)
|
if (DataContext is Models.Tag tag)
|
||||||
{
|
{
|
||||||
var mode = tag.FilterMode;
|
mode = tag.FilterMode;
|
||||||
|
|
||||||
var none = new MenuItem();
|
if (mode != Models.FilterMode.None)
|
||||||
none.Icon = App.CreateMenuIcon("Icons.Eye");
|
|
||||||
none.Header = App.Text("Repository.FilterCommits.Default");
|
|
||||||
none.IsEnabled = mode != Models.FilterMode.None;
|
|
||||||
none.Click += (_, ev) =>
|
|
||||||
{
|
{
|
||||||
UpdateTagFilterMode(repo, tag, Models.FilterMode.None);
|
var unset = new MenuItem();
|
||||||
ev.Handled = true;
|
unset.Header = App.Text("Repository.FilterCommits.Default");
|
||||||
};
|
unset.Click += (_, ev) =>
|
||||||
|
{
|
||||||
|
UpdateTagFilterMode(repo, tag, Models.FilterMode.None);
|
||||||
|
ev.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
menu.Items.Add(unset);
|
||||||
|
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||||
|
}
|
||||||
|
|
||||||
var include = new MenuItem();
|
var include = new MenuItem();
|
||||||
include.Icon = App.CreateMenuIcon("Icons.Filter");
|
include.Icon = App.CreateMenuIcon("Icons.Filter");
|
||||||
|
@ -105,32 +111,26 @@ namespace SourceGit.Views
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
|
||||||
menu.Items.Add(none);
|
|
||||||
menu.Items.Add(include);
|
menu.Items.Add(include);
|
||||||
menu.Items.Add(exclude);
|
menu.Items.Add(exclude);
|
||||||
|
|
||||||
if (mode == Models.FilterMode.None)
|
|
||||||
{
|
|
||||||
IsContextMenuOpening = true;
|
|
||||||
menu.Closed += (_, _) => IsContextMenuOpening = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.Open(button);
|
|
||||||
}
|
}
|
||||||
else if (DataContext is ViewModels.BranchTreeNode node)
|
else if (DataContext is ViewModels.BranchTreeNode node)
|
||||||
{
|
{
|
||||||
var mode = node.FilterMode;
|
mode = node.FilterMode;
|
||||||
|
|
||||||
var none = new MenuItem();
|
if (mode != Models.FilterMode.None)
|
||||||
none.Icon = App.CreateMenuIcon("Icons.Eye");
|
|
||||||
none.Header = App.Text("Repository.FilterCommits.Default");
|
|
||||||
none.IsEnabled = mode != Models.FilterMode.None;
|
|
||||||
none.Click += (_, ev) =>
|
|
||||||
{
|
{
|
||||||
UpdateBranchFilterMode(repo, node, Models.FilterMode.None);
|
var unset = new MenuItem();
|
||||||
ev.Handled = true;
|
unset.Header = App.Text("Repository.FilterCommits.Default");
|
||||||
};
|
unset.Click += (_, ev) =>
|
||||||
|
{
|
||||||
|
UpdateBranchFilterMode(repo, node, Models.FilterMode.None);
|
||||||
|
ev.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
menu.Items.Add(unset);
|
||||||
|
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||||
|
}
|
||||||
|
|
||||||
var include = new MenuItem();
|
var include = new MenuItem();
|
||||||
include.Icon = App.CreateMenuIcon("Icons.Filter");
|
include.Icon = App.CreateMenuIcon("Icons.Filter");
|
||||||
|
@ -152,20 +152,17 @@ namespace SourceGit.Views
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
|
||||||
menu.Items.Add(none);
|
|
||||||
menu.Items.Add(include);
|
menu.Items.Add(include);
|
||||||
menu.Items.Add(exclude);
|
menu.Items.Add(exclude);
|
||||||
|
|
||||||
if (mode == Models.FilterMode.None)
|
|
||||||
{
|
|
||||||
IsContextMenuOpening = true;
|
|
||||||
menu.Closed += (_, _) => IsContextMenuOpening = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.Open(button);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode == Models.FilterMode.None)
|
||||||
|
{
|
||||||
|
IsContextMenuOpening = true;
|
||||||
|
menu.Closed += (_, _) => IsContextMenuOpening = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.Open(button);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue