[Runner]Add 'Quick Access' menu entry to the tray icon (#30087)

This commit is contained in:
pekvasnovsky 2024-03-15 23:31:43 +01:00 committed by GitHub
parent efe88a2f41
commit f5797a065a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 28 additions and 7 deletions

View File

@ -106,8 +106,13 @@
<data name="TOAST_TITLE" xml:space="preserve">
<value>PowerToys Update</value>
</data>
<data name="QUICK_ACCESS_MENU_TEXT" xml:space="preserve">
<value>Quick access\tLeft-click</value>
<comment>Don't localize "\t" as that is what separates the click portion to be right aligned in the menu.</comment>
</data>
<data name="SETTINGS_MENU_TEXT" xml:space="preserve">
<value>Settings</value>
<value>Settings\tDouble-click</value>
<comment>Don't localize "\t" as that is what separates the click portion to be right aligned in the menu.</comment>
</data>
<data name="DOCUMENTATION_MENU_TEXT" xml:space="preserve">
<value>Documentation</value>

View File

@ -19,4 +19,5 @@
#define ID_SETTINGS_MENU_COMMAND 40002
#define ID_ABOUT_MENU_COMMAND 40003
#define ID_REPORT_BUG_COMMAND 40004
#define ID_DOCUMENTATION_MENU_COMMAND 40005
#define ID_DOCUMENTATION_MENU_COMMAND 40005
#define ID_QUICK_ACCESS_MENU_COMMAND 40006

View File

@ -8,7 +8,8 @@
BEGIN
POPUP "POPUP"
BEGIN
MENUITEM "Settings", ID_SETTINGS_MENU_COMMAND
MENUITEM "Quick access\tLeft-click", ID_QUICK_ACCESS_MENU_COMMAND
MENUITEM "Settings\tDouble-click", ID_SETTINGS_MENU_COMMAND
//MENUITEM "About", ID_ABOUT_MENU_COMMAND
MENUITEM SEPARATOR
MENUITEM "Documentation" ID_DOCUMENTATION_MENU_COMMAND

View File

@ -68,6 +68,11 @@ void change_menu_item_text(const UINT item_id, wchar_t* new_text)
SetMenuItemInfoW(h_menu, item_id, false, &menuitem);
}
void open_quick_access_flyout_window(const POINT flyout_position)
{
open_settings_window(std::nullopt, true, flyout_position);
}
void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
{
switch (command_id)
@ -105,6 +110,13 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
RunNonElevatedEx(L"https://aka.ms/PowerToysOverview", L"", L"");
break;
}
case ID_QUICK_ACCESS_MENU_COMMAND:
{
POINT mouse_pointer;
GetCursorPos(&mouse_pointer);
open_quick_access_flyout_window(mouse_pointer);
break;
}
}
}
@ -113,7 +125,7 @@ void click_timer_elapsed()
double_click_timer_running = false;
if (!double_clicked)
{
open_settings_window(std::nullopt, true, tray_icon_click_point);
open_quick_access_flyout_window(tray_icon_click_point);
}
}
@ -181,10 +193,12 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam
static std::wstring exit_menuitem_label = GET_RESOURCE_STRING(IDS_EXIT_MENU_TEXT);
static std::wstring submit_bug_menuitem_label = GET_RESOURCE_STRING(IDS_SUBMIT_BUG_TEXT);
static std::wstring documentation_menuitem_label = GET_RESOURCE_STRING(IDS_DOCUMENTATION_MENU_TEXT);
static std::wstring quick_access_menuitem_label = GET_RESOURCE_STRING(IDS_QUICK_ACCESS_MENU_TEXT);
change_menu_item_text(ID_SETTINGS_MENU_COMMAND, settings_menuitem_label.data());
change_menu_item_text(ID_EXIT_MENU_COMMAND, exit_menuitem_label.data());
change_menu_item_text(ID_REPORT_BUG_COMMAND, submit_bug_menuitem_label.data());
change_menu_item_text(ID_DOCUMENTATION_MENU_COMMAND, documentation_menuitem_label.data());
change_menu_item_text(ID_QUICK_ACCESS_MENU_COMMAND, quick_access_menuitem_label.data());
}
if (!h_sub_menu)
{

View File

@ -40,7 +40,7 @@
<Grid Padding="36,32,36,0">
<TextBlock
x:Uid="ShortcutsTxt"
x:Uid="QuickAccessTxt"
VerticalAlignment="Center"
Style="{StaticResource BodyStrongTextBlockStyle}" />
<Button

View File

@ -3804,8 +3804,8 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="SettingsTooltip.Text" xml:space="preserve">
<value>Settings</value>
</data>
<data name="ShortcutsTxt.Text" xml:space="preserve">
<value>Shortcuts</value>
<data name="QuickAccessTxt.Text" xml:space="preserve">
<value>Quick access</value>
</data>
<data name="UpdateAvailable.Title" xml:space="preserve">
<value>Update available</value>