mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
[PowerRename][ImageResizer] Tier1 Win11 Context menu (#19000)
* Test win11 tier1 context menu
* Try to test signing
* Cleanup
* Cleanup project file
* Sign dll
Add PowerToys preffix
Add assets to installer
* expect.txt
* Switch to named pipes
Unregister package on uninstall
Remove unneeded files
Cleanup
* Bring back check if package registered but use per-user method
* Fix win11 check
* expect.txt
* Check if package already registered
* Revert "Check if package already registered"
FindPackages() method needs admin privileges.
This reverts commit 5af584fed4.
* Fix PowerRename args checking
* Cleanup assets
* Tier1 context menu ImageResizer
Minor cleanups
Move logic to package.h
* [WIP] Signing and installer
Expect.txt
* Localized context menu title
* Retarget everything 10.0.18362.0 -> 10.0.19041.0
* Address PR comments
- check if selection renamable
- minor cleanup
- struct initialization
* Fix ImageResizerLib project configuration
* More Windows version updates
* Remove unneeded file & try fix resource build error
* Add Microsoft.PowerToys prefix to packages
* Test
* Fix convert-resx-to-rc.ps1 script issue causing resource files compile error
Don't generate empty STRINGTABLE for resx files without data
* Avoid duplicate context menu items
* [BugReportTool] Report installed context menu packages
This commit is contained in:
@@ -6,9 +6,10 @@
|
||||
#include <Settings.h>
|
||||
#include "Generated Files/resource.h"
|
||||
|
||||
#include <common/utils/resources.h>
|
||||
#include <common/utils/process_path.h>
|
||||
#include <common/utils/HDropIterator.h>
|
||||
#include <common/utils/resources.h>
|
||||
#include <common/utils/package.h>
|
||||
#include <common/utils/process_path.h>
|
||||
|
||||
extern HINSTANCE g_hInst;
|
||||
|
||||
@@ -63,9 +64,24 @@ HRESULT CPowerRenameMenu::QueryContextMenu(HMENU hMenu, UINT index, UINT uIDFirs
|
||||
if (!CSettingsInstance().GetEnabled())
|
||||
return E_FAIL;
|
||||
|
||||
// Check if we should only be on the extended context menu
|
||||
if (CSettingsInstance().GetExtendedContextMenuOnly() && (!(uFlags & CMF_EXTENDEDVERBS)))
|
||||
return E_FAIL;
|
||||
// Win11 context menu can't distinguish between extended and default menu, so use this one
|
||||
if (package::IsWin11OrGreater())
|
||||
{
|
||||
if (CSettingsInstance().GetExtendedContextMenuOnly() && (uFlags & CMF_EXTENDEDVERBS))
|
||||
{
|
||||
// continue
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if we should only be on the extended context menu
|
||||
if (CSettingsInstance().GetExtendedContextMenuOnly() && (!(uFlags & CMF_EXTENDEDVERBS)))
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Check if at least one of the selected items is actually renamable.
|
||||
if (!DataObjectContainsRenamableItem(m_spdo))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{B25AC7A5-FB9F-4789-B392-D5C85E948670}</ProjectGuid>
|
||||
<RootNamespace>PowerRenameExt</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Configuration">
|
||||
@@ -64,6 +64,9 @@
|
||||
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
|
||||
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\version\version.vcxproj">
|
||||
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\PowerRenameLib.vcxproj">
|
||||
<Project>{51920f1f-c28c-4adf-8660-4238766796c2}</Project>
|
||||
</ProjectReference>
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "Generated Files/resource.h"
|
||||
#include "PowerRenameConstants.h"
|
||||
#include "PowerRenameExt.h"
|
||||
|
||||
#include <interface/powertoy_module_interface.h>
|
||||
#include <settings.h>
|
||||
#include <trace.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
#include <common/SettingsAPI/settings_objects.h>
|
||||
#include <common/logger/logger.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/package.h>
|
||||
#include <common/utils/process_path.h>
|
||||
#include <common/utils/resources.h>
|
||||
#include "Generated Files/resource.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <dll/PowerRenameConstants.h>
|
||||
|
||||
std::atomic<DWORD> g_dwModuleRefCount = 0;
|
||||
HINSTANCE g_hInst = 0;
|
||||
@@ -161,6 +168,8 @@ private:
|
||||
std::wstring app_key;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// Return the localized display name of the powertoy
|
||||
virtual PCWSTR get_name() override
|
||||
{
|
||||
@@ -178,6 +187,19 @@ public:
|
||||
{
|
||||
Logger::info(L"PowerRename enabled");
|
||||
m_enabled = true;
|
||||
|
||||
if (package::IsWin11OrGreater())
|
||||
{
|
||||
std::wstring path = get_module_folderpath(g_hInst);
|
||||
std::wstring packageUri = path + L"\\PowerRenameContextMenuPackage.msix";
|
||||
|
||||
std::wstring packageDisplayName{ L"PowerRenameContextMenu" };
|
||||
if (!package::IsPackageRegistered(packageDisplayName))
|
||||
{
|
||||
package::RegisterSparsePackage(path, packageUri);
|
||||
}
|
||||
}
|
||||
|
||||
save_settings();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user