Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/runner/runner.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,28 @@
<ItemGroup>
<EmbeddedResource Include="Resources.resx" />
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="svgs\PowerToysDark.ico">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(OutDir)\svgs</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(OutDir)\svgs</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\svgs</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\svgs</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include="svgs\PowerToysWhite.ico">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(OutDir)\svgs</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(OutDir)\svgs</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\svgs</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\svgs</DestinationFolders>
</CopyFileToFolders>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\..\deps\spdlog.props" />
<ImportGroup Label="ExtensionTargets">
Expand Down
2 changes: 2 additions & 0 deletions src/runner/runner.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="svgs\icon.ico" />
<CopyFileToFolders Include="svgs\PowerToysDark.ico" />
<CopyFileToFolders Include="svgs\PowerToysWhite.ico" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
Binary file added src/runner/svgs/PowerToysDark.ico
Binary file not shown.
Binary file added src/runner/svgs/PowerToysWhite.ico
Binary file not shown.
24 changes: 23 additions & 1 deletion src/runner/tray_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <common/version/version.h>
#include <common/logger/logger.h>
#include <common/utils/elevation.h>
#include <common/Themes/theme_listener.h>
#include "bug_report.h"

namespace
Expand All @@ -37,6 +38,7 @@
bool double_clicked = false;
POINT tray_icon_click_point;

static ThemeListener theme_listener;
}

// Struct to fill with callback and the data. The window_proc is responsible for cleaning it.
Expand Down Expand Up @@ -262,6 +264,25 @@
return DefWindowProc(window, message, wparam, lparam);
}

static HICON get_icon(AppTheme theme)
{
return static_cast<HICON>(LoadImage(NULL,
theme == AppTheme::Dark ?
L"svgs/PowerToysWhite.ico" :
L"svgs/PowerToysDark.ico",
IMAGE_ICON,
0,
0,
LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED));
}


static void handle_theme_change()
{
tray_icon_data.hIcon = get_icon(theme_listener.AppTheme);
Shell_NotifyIcon(NIM_MODIFY, &tray_icon_data);
}

void update_bug_report_menu_status(bool isRunning)
{
if (h_sub_menu != nullptr)
Expand All @@ -273,7 +294,7 @@
void start_tray_icon(bool isProcessElevated)
{
auto h_instance = reinterpret_cast<HINSTANCE>(&__ImageBase);
auto icon = LoadIcon(h_instance, MAKEINTRESOURCE(APPICON));
HICON const icon = get_icon(theme_listener.AppTheme);
if (icon)
{
UINT id_tray_icon = 1;
Expand Down Expand Up @@ -320,6 +341,7 @@
ChangeWindowMessageFilterEx(hwnd, WM_COMMAND, MSGFLT_ALLOW, nullptr);

tray_icon_created = Shell_NotifyIcon(NIM_ADD, &tray_icon_data) == TRUE;
theme_listener.AddChangedHandler(&handle_theme_change);

// Register callback to update bug report menu item status
BugReportManager::instance().register_callback([](bool isRunning) {
Expand Down
Loading