Add launcher item tooltips
This commit is contained in:
@@ -146,7 +146,8 @@ public partial class LauncherPopup : Window
|
||||
IsExpanded = expandMenusByDefault,
|
||||
Margin = new Thickness(depth * 12, 4, 0, 4),
|
||||
Focusable = true,
|
||||
Tag = item
|
||||
Tag = item,
|
||||
ToolTip = CreateItemToolTip(item)
|
||||
};
|
||||
expander.KeyDown += NavigationControl_KeyDown;
|
||||
expander.Expanded += (_, _) => RebuildNavigationAndReposition();
|
||||
@@ -168,7 +169,8 @@ public partial class LauncherPopup : Window
|
||||
Margin = new Thickness(depth * 12, 2, 0, 2),
|
||||
MinHeight = DisplayModeMetrics.GetRowHeight(GetEffectiveDisplayMode(item)),
|
||||
HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left,
|
||||
Tag = item
|
||||
Tag = item,
|
||||
ToolTip = CreateItemToolTip(item)
|
||||
};
|
||||
|
||||
button.Click += (_, _) => launchItem(item);
|
||||
@@ -204,7 +206,8 @@ public partial class LauncherPopup : Window
|
||||
return new TextBlock
|
||||
{
|
||||
Text = item.Title,
|
||||
ContextMenu = contextMenu
|
||||
ContextMenu = contextMenu,
|
||||
ToolTip = CreateItemToolTip(item)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -354,7 +357,8 @@ public partial class LauncherPopup : Window
|
||||
MinHeight = Math.Max(DisplayModeMetrics.GetRowHeight(GetEffectiveDisplayMode(match.Item)), 48),
|
||||
HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left,
|
||||
Tag = match.Item,
|
||||
ContextMenu = CreateItemContextMenu(match.Item)
|
||||
ContextMenu = CreateItemContextMenu(match.Item),
|
||||
ToolTip = CreateItemToolTip(match.Item, match.ParentPath)
|
||||
};
|
||||
|
||||
button.Click += (_, _) => launchItem(match.Item);
|
||||
@@ -423,6 +427,46 @@ public partial class LauncherPopup : Window
|
||||
return panel;
|
||||
}
|
||||
|
||||
private static System.Windows.Controls.ToolTip CreateItemToolTip(LauncherItem item, string? parentPath = null)
|
||||
{
|
||||
StackPanel panel = new() { MaxWidth = 520 };
|
||||
AddToolTipLine(panel, item.Title, bold: true);
|
||||
AddToolTipLine(panel, $"Type: {item.Type}");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(parentPath))
|
||||
{
|
||||
AddToolTipLine(panel, $"Menu: {parentPath}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(item.Target))
|
||||
{
|
||||
AddToolTipLine(panel, $"Target: {item.Target}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(item.Arguments))
|
||||
{
|
||||
AddToolTipLine(panel, $"Arguments: {item.Arguments}");
|
||||
}
|
||||
|
||||
if (item.IsFavorite)
|
||||
{
|
||||
AddToolTipLine(panel, "Pinned to top");
|
||||
}
|
||||
|
||||
return new System.Windows.Controls.ToolTip { Content = panel };
|
||||
}
|
||||
|
||||
private static void AddToolTipLine(StackPanel panel, string text, bool bold = false)
|
||||
{
|
||||
panel.Children.Add(new TextBlock
|
||||
{
|
||||
Text = text,
|
||||
FontWeight = bold ? FontWeights.SemiBold : FontWeights.Normal,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Margin = panel.Children.Count == 0 ? new Thickness(0) : new Thickness(0, 3, 0, 0)
|
||||
});
|
||||
}
|
||||
|
||||
private static void CollectMatches(IEnumerable<LauncherItem> items, string query, List<string> parentNames, List<SearchMatch> matches)
|
||||
{
|
||||
foreach (LauncherItem item in GetDisplayItems(items))
|
||||
|
||||
Reference in New Issue
Block a user