From f5797a065a5c2c448fd2b1780bd1353d712103c3 Mon Sep 17 00:00:00 2001 From: pekvasnovsky <145220123+pekvasnovsky@users.noreply.github.com> Date: Fri, 15 Mar 2024 23:31:43 +0100 Subject: [PATCH] [Runner]Add 'Quick Access' menu entry to the tray icon (#30087) --- src/runner/Resources.resx | 7 ++++++- src/runner/resource.base.h | 3 ++- src/runner/runner.base.rc | Bin 2968 -> 3146 bytes src/runner/tray_icon.cpp | 16 +++++++++++++++- .../SettingsXAML/Flyout/LaunchPage.xaml | 2 +- .../Settings.UI/Strings/en-us/Resources.resw | 4 ++-- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/runner/Resources.resx b/src/runner/Resources.resx index 92703d2675..902e3a0874 100644 --- a/src/runner/Resources.resx +++ b/src/runner/Resources.resx @@ -106,8 +106,13 @@ PowerToys Update + + Quick access\tLeft-click + Don't localize "\t" as that is what separates the click portion to be right aligned in the menu. + - Settings + Settings\tDouble-click + Don't localize "\t" as that is what separates the click portion to be right aligned in the menu. Documentation diff --git a/src/runner/resource.base.h b/src/runner/resource.base.h index f85cea50f5..22d040cc82 100644 --- a/src/runner/resource.base.h +++ b/src/runner/resource.base.h @@ -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 \ No newline at end of file +#define ID_DOCUMENTATION_MENU_COMMAND 40005 +#define ID_QUICK_ACCESS_MENU_COMMAND 40006 \ No newline at end of file diff --git a/src/runner/runner.base.rc b/src/runner/runner.base.rc index 10a4555db8ec5de58a2a12eb479c9547d7d7c186..5737649c37fdeb87cd10216387ba8ae325ad55ac 100644 GIT binary patch delta 130 zcmbOseoA6P3u9m)Ln%WhLo!1)g91Y$kWOYuWhe&17={uCA0RsoNb3ScbD*k}7<7Ot zJsDgW;u!)NLV+x225%tS5lA~TxH1G!Udw1Wxqwkc8f1bCLq5>_B%tn8WK%XzW@P08 E0OW5PGXMYp delta 16 XcmX>lF++Sq3*%%dCV|avOe|agFrfsG diff --git a/src/runner/tray_icon.cpp b/src/runner/tray_icon.cpp index 6987a6d1cc..015fb158b8 100644 --- a/src/runner/tray_icon.cpp +++ b/src/runner/tray_icon.cpp @@ -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) { diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml index 8bb57e9e9f..0949b813bd 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml @@ -40,7 +40,7 @@