mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[runner] bug report could be created from tray (#9191)
This commit is contained in:
@@ -161,6 +161,12 @@
|
||||
<value>Exit</value>
|
||||
<comment>Exit as a verb, as in Exit the application</comment>
|
||||
</data>
|
||||
<data name="SUBMIT_BUG_TEXT" xml:space="preserve">
|
||||
<value>Report Bug</value>
|
||||
</data>
|
||||
<data name="BUGREPORT_SUCCESS" xml:space="preserve">
|
||||
<value>Bug report .zip file has been created on your Desktop.</value>
|
||||
</data>
|
||||
<data name="GITHUB_NEW_VERSION_USING_LOCAL_BUILD_ERROR" xml:space="preserve">
|
||||
<value>Updating from a local build is not supported.</value>
|
||||
<comment>User cannot autoupdate from a locally-built PowerToys version</comment>
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
|
||||
#define ID_EXIT_MENU_COMMAND 40001
|
||||
#define ID_SETTINGS_MENU_COMMAND 40002
|
||||
#define ID_ABOUT_MENU_COMMAND 40003
|
||||
#define ID_ABOUT_MENU_COMMAND 40003
|
||||
#define ID_REPORT_BUG_COMMAND 40004
|
||||
Binary file not shown.
@@ -4,6 +4,7 @@
|
||||
#include "tray_icon.h"
|
||||
#include <Windows.h>
|
||||
|
||||
#include <common/utils/process_path.h>
|
||||
#include <common/utils/resources.h>
|
||||
#include <common/version/version.h>
|
||||
|
||||
@@ -57,6 +58,48 @@ void change_menu_item_text(const UINT item_id, wchar_t* new_text)
|
||||
SetMenuItemInfoW(h_menu, item_id, false, &menuitem);
|
||||
}
|
||||
|
||||
void handle_tray_command(HWND window, const WPARAM command_id)
|
||||
{
|
||||
switch (command_id)
|
||||
{
|
||||
case ID_SETTINGS_MENU_COMMAND:
|
||||
open_settings_window();
|
||||
break;
|
||||
case ID_EXIT_MENU_COMMAND:
|
||||
if (h_menu)
|
||||
{
|
||||
DestroyMenu(h_menu);
|
||||
}
|
||||
DestroyWindow(window);
|
||||
break;
|
||||
case ID_ABOUT_MENU_COMMAND:
|
||||
if (!about_box_shown)
|
||||
{
|
||||
about_box_shown = true;
|
||||
std::wstring about_msg = L"PowerToys\nVersion " + get_product_version() + L"\n\xa9 2019 Microsoft Corporation";
|
||||
MessageBoxW(nullptr, about_msg.c_str(), L"About PowerToys", MB_OK);
|
||||
about_box_shown = false;
|
||||
}
|
||||
break;
|
||||
case ID_REPORT_BUG_COMMAND:
|
||||
std::wstring bug_report_path = get_module_folderpath();
|
||||
bug_report_path += L"\\Tools\\BugReportTool.exe";
|
||||
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
||||
sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE };
|
||||
sei.lpFile = bug_report_path.c_str();
|
||||
sei.nShow = SW_HIDE;
|
||||
if (ShellExecuteExW(&sei))
|
||||
{
|
||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||
CloseHandle(sei.hProcess);
|
||||
static const std::wstring bugreport_success = GET_RESOURCE_STRING(IDS_BUGREPORT_SUCCESS);
|
||||
MessageBoxW(nullptr, bugreport_success.c_str(), L"PowerToys", MB_OK);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (message)
|
||||
@@ -82,28 +125,7 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam
|
||||
DestroyWindow(window);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (wparam)
|
||||
{
|
||||
case ID_SETTINGS_MENU_COMMAND:
|
||||
open_settings_window();
|
||||
break;
|
||||
case ID_EXIT_MENU_COMMAND:
|
||||
if (h_menu)
|
||||
{
|
||||
DestroyMenu(h_menu);
|
||||
}
|
||||
DestroyWindow(window);
|
||||
break;
|
||||
case ID_ABOUT_MENU_COMMAND:
|
||||
if (!about_box_shown)
|
||||
{
|
||||
about_box_shown = true;
|
||||
std::wstring about_msg = L"PowerToys\nVersion " + get_product_version() + L"\n\xa9 2019 Microsoft Corporation";
|
||||
MessageBox(nullptr, about_msg.c_str(), L"About PowerToys", MB_OK);
|
||||
about_box_shown = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
handle_tray_command(window, wparam);
|
||||
break;
|
||||
// Shell_NotifyIcon can fail when we invoke it during the time explorer.exe isn't present/ready to handle it.
|
||||
// We'll also never receive wm_taskbar_restart message if the first call to Shell_NotifyIcon failed, so we use
|
||||
@@ -137,8 +159,11 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam
|
||||
{
|
||||
static std::wstring settings_menuitem_label = GET_RESOURCE_STRING(IDS_SETTINGS_MENU_TEXT);
|
||||
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);
|
||||
|
||||
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());
|
||||
}
|
||||
if (!h_sub_menu)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user