Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into dev/aaron-junker/File…
Browse files Browse the repository at this point in the history
…ActionsMenu
  • Loading branch information
Aaron-Junker committed Jan 19, 2025
2 parents 1004526 + ddcad65 commit b73a204
Show file tree
Hide file tree
Showing 50 changed files with 424 additions and 296 deletions.
3 changes: 3 additions & 0 deletions .github/actions/spell-check/allow/code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ howto
onefuzzconfig
oip
onefuzzingestionpreparationtool
OTP
Yubi
Yubico

# KEYS

Expand Down
1 change: 1 addition & 0 deletions .github/actions/spell-check/allow/names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ capturevideosample
cmdow
Controlz
cortana
dlnilsson
fancymouse
firefox
gpt
Expand Down
52 changes: 0 additions & 52 deletions .pipelines/ESRPSigning_abstracted_utils_dll.json

This file was deleted.

97 changes: 0 additions & 97 deletions .pipelines/v2/templates/job-build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,103 +242,6 @@ jobs:
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

- ${{ if eq(parameters.codeSign, true) }}:
- template: steps-esrp-signing.yml
parameters:
displayName: Sign Utilities
signingIdentity: ${{ parameters.signingIdentity }}
inputs:
FolderPath: 'src/modules'
signType: batchSigning
batchSignPolicyFile: '$(build.sourcesdirectory)\.pipelines\ESRPSigning_abstracted_utils_dll.json'
ciPolicyFile: '$(build.sourcesdirectory)\.pipelines\CIPolicy.xml'

- task: VSBuild@1
displayName: Create Hosts File Editor package
inputs:
solution: '**\HostsUILib.csproj'
vsVersion: 17.0
msbuildArgs: >-
/p:CIBuild=true;NoBuild=true -t:pack
/bl:$(LogOutputDirectory)\build-hosts.binlog
/p:NoWarn=NU5104
$(RestoreAdditionalProjectSourcesArg)
configuration: $(BuildConfiguration)
msbuildArchitecture: x64
maximumCpuCount: true
${{ if eq(parameters.enableMsBuildCaching, true) }}:
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

- task: VSBuild@1
displayName: Create Environment Variables Editor package
inputs:
solution: '**\EnvironmentVariablesUILib.csproj'
vsVersion: 17.0
msbuildArgs: >-
/p:CIBuild=true;NoBuild=true -t:pack
/bl:$(LogOutputDirectory)\build-env-var-editor.binlog
/p:NoWarn=NU5104
$(RestoreAdditionalProjectSourcesArg)
configuration: $(BuildConfiguration)
msbuildArchitecture: x64
maximumCpuCount: true
${{ if eq(parameters.enableMsBuildCaching, true) }}:
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

- task: VSBuild@1
displayName: Create Registry Preview package
inputs:
solution: '**\RegistryPreviewUILib.csproj'
vsVersion: 17.0
msbuildArgs: >-
/p:CIBuild=true;NoBuild=true -t:pack
/bl:$(LogOutputDirectory)\build-registry-preview.binlog
/p:NoWarn=NU5104
$(RestoreAdditionalProjectSourcesArg)
configuration: $(BuildConfiguration)
msbuildArchitecture: x64
maximumCpuCount: true
${{ if eq(parameters.enableMsBuildCaching, true) }}:
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

- task: CopyFiles@2
displayName: Stage NuGet packages
inputs:
contents: "**/bin/Release/PowerToys*.nupkg"
flattenFolders: True
targetFolder: $(JobOutputDirectory)/nupkg

- ${{ if eq(parameters.codeSign, true) }}:
- template: steps-esrp-signing.yml
parameters:
displayName: Sign NuGet packages
signingIdentity: ${{ parameters.signingIdentity }}
inputs:
FolderPath: $(JobOutputDirectory)/nupkg
Pattern: '*.nupkg'
UseMinimatch: true
signConfigType: inlineSignParams
inlineOperation: >-
[
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetSign",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
- task: VSBuild@1
displayName: Build BugReportTool
inputs:
Expand Down
1 change: 1 addition & 0 deletions doc/thirdPartyRunPlugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ Below are community created plugins that target a website or software. They are
| [HackMD](https://github.com/8LWXpg/PowerToysRun-HackMD) | [8LWXpg](https://github.com/8LWXpg) | Open HackMD notes |
| [SSH](https://github.com/8LWXpg/PowerToysRun-SSH) | [8LWXpg](https://github.com/8LWXpg) | Connect to ssh clients |
| [Bilibili](https://github.com/Whuihuan/PowerToysRun-Bilibili) | [Whuihuan](https://github.com/Whuihuan) | Use AVID or BVID to parse and jump to Bilibili |
| [YubicoOauthOTP](https://github.com/dlnilsson/Community.PowerToys.Run.Plugin.YubicoOauthOTP) | [dlnilsson](https://github.com/dlnilsson) | Display generated codes from OATH accounts stored on the YubiKey in powerToys Run |
3 changes: 3 additions & 0 deletions src/common/SettingsAPI/FileWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <string>
#include <functional>

#include <wil/resource.h>
#include <wil/filesystem.h>

class FileWatcher
{
std::wstring m_path;
Expand Down
1 change: 0 additions & 1 deletion src/common/SettingsAPI/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
#include <fstream>

#include <common/logger/logger.h>
#include <wil/filesystem.h>
56 changes: 56 additions & 0 deletions src/common/notifications/NotificationUtil.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "pch.h"
#include "NotificationUtil.h"

#include <common/notifications/notifications.h>
#include <common/notifications/dont_show_again.h>
#include <common/utils/resources.h>
#include <common/SettingsAPI/settings_helpers.h>

// Non-Localizable strings
namespace NonLocalizable
{
const wchar_t RunAsAdminInfoPage[] = L"https://aka.ms/powertoysDetectedElevatedHelp";
const wchar_t ToastNotificationButtonUrl[] = L"powertoys://cant_drag_elevated_disable/";
}

namespace notifications
{
NotificationUtil::NotificationUtil()
{
ReadSettings();
auto settingsFileName = PTSettingsHelper::get_powertoys_general_save_file_location();

m_settingsFileWatcher = std::make_unique<FileWatcher>(settingsFileName, [this]() {
ReadSettings();
});
}

NotificationUtil::~NotificationUtil()
{
m_settingsFileWatcher.reset();
}

void NotificationUtil::WarnIfElevationIsRequired(std::wstring title, std::wstring message, std::wstring button1, std::wstring button2)
{
if (m_warningsElevatedApps && !m_warningShown && !is_toast_disabled(ElevatedDontShowAgainRegistryPath, ElevatedDisableIntervalInDays))
{
std::vector<action_t> actions = {
link_button{ button1, NonLocalizable::RunAsAdminInfoPage },
link_button{ button2, NonLocalizable::ToastNotificationButtonUrl }
};

show_toast_with_activations(message,
title,
{},
std::move(actions));

m_warningShown = true;
}
}

void NotificationUtil::ReadSettings()
{
auto settings = PTSettingsHelper::load_general_settings();
m_warningsElevatedApps = settings.GetNamedBoolean(L"enable_warnings_elevated_apps", true);
}
}
44 changes: 13 additions & 31 deletions src/common/notifications/NotificationUtil.h
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
#pragma once

#include <common/notifications/notifications.h>
#include <common/notifications/dont_show_again.h>
#include <common/utils/resources.h>
#include <common/SettingsAPI/settings_helpers.h>

#include "Generated Files/resource.h"
#include <common/SettingsAPI/FileWatcher.h>

namespace notifications
{
// Non-Localizable strings
namespace NonLocalizable
class NotificationUtil
{
const wchar_t RunAsAdminInfoPage[] = L"https://aka.ms/powertoysDetectedElevatedHelp";
const wchar_t ToastNotificationButtonUrl[] = L"powertoys://cant_drag_elevated_disable/";
}
public:
NotificationUtil();
~NotificationUtil();

inline void WarnIfElevationIsRequired(std::wstring title, std::wstring message, std::wstring button1, std::wstring button2)
{
using namespace NonLocalizable;
void WarnIfElevationIsRequired(std::wstring title, std::wstring message, std::wstring button1, std::wstring button2);

auto settings = PTSettingsHelper::load_general_settings();
auto enableWarningsElevatedApps = settings.GetNamedBoolean(L"enable_warnings_elevated_apps", true);
private:
std::unique_ptr<FileWatcher> m_settingsFileWatcher;
bool m_warningsElevatedApps;
bool m_warningShown = false;

static bool warning_shown = false;
if (enableWarningsElevatedApps && !warning_shown && !is_toast_disabled(ElevatedDontShowAgainRegistryPath, ElevatedDisableIntervalInDays))
{
std::vector<action_t> actions = {
link_button{ button1, RunAsAdminInfoPage },
link_button{ button2, ToastNotificationButtonUrl }
};
show_toast_with_activations(message,
title,
{},
std::move(actions));
warning_shown = true;
}
}
}
void ReadSettings();
};
}
3 changes: 2 additions & 1 deletion src/common/notifications/notifications.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="notifications.h" />
<ClInclude Include="NotificationUtil.h" />
<ClInclude Include="dont_show_again.h" />
<ClInclude Include="NotificationUtil.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dont_show_again.cpp" />
<ClCompile Include="notifications.cpp" />
<ClCompile Include="NotificationUtil.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(UsePrecompiledHeaders)' != 'false'">Create</PrecompiledHeader>
</ClCompile>
Expand Down
13 changes: 9 additions & 4 deletions src/modules/Workspaces/WorkspacesSnapshotTool/SnapshotUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <common/utils/elevation.h>
#include <common/utils/process_path.h>
#include <common/utils/resources.h>
#include <common/notifications/NotificationUtil.h>

#include <workspaces-common/WindowEnumerator.h>
Expand All @@ -12,6 +13,8 @@
#include <WorkspacesLib/PwaHelper.h>
#include <WindowProperties/WorkspacesWindowPropertyUtils.h>

#include "Generated Files/resource.h"

#pragma comment(lib, "ntdll.lib")

namespace SnapshotUtils
Expand Down Expand Up @@ -74,10 +77,12 @@ namespace SnapshotUtils
// Notify the user that running as admin is required to process elevated windows.
if (!is_process_elevated() && IsProcessElevated(pid))
{
notifications::WarnIfElevationIsRequired(GET_RESOURCE_STRING(IDS_PROJECTS),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_LEARN_MORE),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_DIALOG_DONT_SHOW_AGAIN));
auto notificationUtil = std::make_unique<notifications::NotificationUtil>();

notificationUtil->WarnIfElevationIsRequired(GET_RESOURCE_STRING(IDS_PROJECTS),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_LEARN_MORE),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_DIALOG_DONT_SHOW_AGAIN));
}

continue;
Expand Down
10 changes: 7 additions & 3 deletions src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <common/utils/process_path.h>

#include <common/utils/elevation.h>
#include <common/notifications/NotificationUtil.h>
#include <Generated Files/resource.h>

#include <interop/shared_constants.h>
Expand All @@ -36,7 +35,8 @@ AlwaysOnTop::AlwaysOnTop(bool useLLKH, DWORD mainThreadId) :
SettingsObserver({SettingId::FrameEnabled, SettingId::Hotkey, SettingId::ExcludeApps}),
m_hinstance(reinterpret_cast<HINSTANCE>(&__ImageBase)),
m_useCentralizedLLKH(useLLKH),
m_mainThreadId(mainThreadId)
m_mainThreadId(mainThreadId),
m_notificationUtil(std::make_unique<notifications::NotificationUtil>())
{
s_instance = this;
DPIAware::EnableDPIAwarenessForThisProcess();
Expand Down Expand Up @@ -64,6 +64,7 @@ AlwaysOnTop::AlwaysOnTop(bool useLLKH, DWORD mainThreadId) :
AlwaysOnTop::~AlwaysOnTop()
{
m_running = false;
m_notificationUtil.reset();

if (m_hPinEvent)
{
Expand Down Expand Up @@ -509,7 +510,10 @@ void AlwaysOnTop::HandleWinHookEvent(WinHookEvent* data) noexcept
{
if (!is_process_elevated() && IsProcessOfWindowElevated(data->hwnd))
{
notifications::WarnIfElevationIsRequired(GET_RESOURCE_STRING(IDS_ALWAYSONTOP), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_LEARN_MORE), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_DIALOG_DONT_SHOW_AGAIN));
m_notificationUtil->WarnIfElevationIsRequired(GET_RESOURCE_STRING(IDS_ALWAYSONTOP),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_LEARN_MORE),
GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_DIALOG_DONT_SHOW_AGAIN));
}
RefreshBorders();
}
Expand Down
Loading

0 comments on commit b73a204

Please sign in to comment.