Skip to content

Commit cf9cd01

Browse files
committed
Added tooltip retrived from the shell
1 parent a0fa3a3 commit cf9cd01

File tree

6 files changed

+33
-3
lines changed

6 files changed

+33
-3
lines changed

src/Files.App.CsWin32/ManualGuid.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public static Guid* IID_IStorageProviderStatusUISourceFactory
3838

3939
[GuidRVAGen.Guid("2E941141-7F97-4756-BA1D-9DECDE894A3D")]
4040
public static partial Guid* IID_IApplicationActivationManager { get; }
41+
42+
[GuidRVAGen.Guid("00021500-0000-0000-C000-000000000046")]
43+
public static partial Guid* IID_IQueryInfo { get; }
4144
}
4245

4346
public static unsafe partial class CLSID

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,5 @@ BITMAP
224224
GetObject
225225
_SICHINTF
226226
RoGetAgileReference
227+
IQueryInfo
228+
QITIPF_FLAGS

src/Files.App.Storage/Storables/WindowsStorage/WindowsStorableHelpers.Shell.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,24 @@ public unsafe static HRESULT TryInvokeContextMenuVerbs(this IWindowsStorable sto
124124

125125
return hr;
126126
}
127+
128+
public unsafe static HRESULT TryGetShellTooltip(this IWindowsStorable storable, out string? tooltip)
129+
{
130+
tooltip = null;
131+
132+
using ComPtr<IQueryInfo> pQueryInfo = default;
133+
HRESULT hr = storable.ThisPtr.Get()->BindToHandler(null, BHID.BHID_SFUIObject, IID.IID_IQueryInfo, (void**)pQueryInfo.GetAddressOf());
134+
if (hr.ThrowIfFailedOnDebug().Failed)
135+
return hr;
136+
137+
pQueryInfo.Get()->GetInfoTip((uint)QITIPF_FLAGS.QITIPF_DEFAULT, out var pszTip);
138+
if (hr.ThrowIfFailedOnDebug().Failed)
139+
return hr;
140+
141+
tooltip = pszTip.ToString();
142+
PInvoke.CoTaskMemFree(pszTip);
143+
144+
return HRESULT.S_OK;
145+
}
127146
}
128147
}

src/Files.App/Data/Items/WidgetFolderCardItem.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@ public sealed partial class WidgetFolderCardItem : WidgetCardItem, IWidgetCardIt
1919

2020
public bool IsPinned { get; set; }
2121

22+
public string Tooltip { get; set; }
23+
2224
private BitmapImage? _Thumbnail;
2325
public BitmapImage? Thumbnail { get => _Thumbnail; set => SetProperty(ref _Thumbnail, value); }
2426

2527
// Constructor
2628

27-
public WidgetFolderCardItem(IWindowsStorable item, string text, bool isPinned)
29+
public WidgetFolderCardItem(IWindowsStorable item, string text, bool isPinned, string tooltip)
2830
{
2931
AutomationProperties = text;
3032
Item = item;
3133
Text = text;
3234
IsPinned = isPinned;
3335
Path = item.GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEPARSING);
36+
Tooltip = tooltip;
3437
}
3538

3639
// Methods

src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
DataContext="{x:Bind}"
3838
PointerPressed="Button_PointerPressed"
3939
RightTapped="Button_RightTapped"
40-
Tag="{x:Bind Path}">
40+
Tag="{x:Bind Path}"
41+
ToolTipService.ToolTip="{x:Bind Tooltip}">
4142
<Grid
4243
HorizontalAlignment="Stretch"
4344
VerticalAlignment="Stretch"

src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ public Task RefreshWidgetAsync()
7575
await foreach (IWindowsStorable folder in HomePageContext.HomeFolder.GetQuickAccessFolderAsync(default))
7676
{
7777
folder.GetPropertyValue<bool>("System.Home.IsPinned", out var isPinned);
78+
folder.TryGetShellTooltip(out var tooltip);
7879

7980
Items.Insert(
8081
Items.Count,
8182
new WidgetFolderCardItem(
8283
folder,
8384
folder.GetDisplayName(SIGDN.SIGDN_PARENTRELATIVEFORUI),
84-
isPinned));
85+
isPinned,
86+
tooltip ?? string.Empty));
8587
}
8688
});
8789
}

0 commit comments

Comments
 (0)