mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[PowerRename][ImageResizer]Fallback for tier 1 menus (#19195)
* [PowerRename][ImageResizer]fallback for tier 1 menus * Simplify logic
This commit is contained in:
@@ -5,4 +5,5 @@ namespace PowerRenameConstants
|
||||
{
|
||||
// Name of the powertoy module.
|
||||
inline const std::wstring ModuleKey = L"PowerRename";
|
||||
inline const std::wstring ModulePackageDisplayName = L"PowerRenameContextMenu";
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "PowerRenameExt.h"
|
||||
#include "PowerRenameConstants.h"
|
||||
#include <trace.h>
|
||||
#include <Helpers.h>
|
||||
#include <common/themes/icon_helpers.h>
|
||||
@@ -64,29 +65,17 @@ HRESULT CPowerRenameMenu::QueryContextMenu(HMENU hMenu, UINT index, UINT uIDFirs
|
||||
if (!CSettingsInstance().GetEnabled())
|
||||
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))
|
||||
return E_FAIL;
|
||||
|
||||
if (package::IsWin11OrGreater() && package::IsPackageRegistered(PowerRenameConstants::ModulePackageDisplayName))
|
||||
return E_FAIL;
|
||||
|
||||
// Check if we should only be on the extended context menu
|
||||
if (CSettingsInstance().GetExtendedContextMenuOnly() && (!(uFlags & CMF_EXTENDEDVERBS)))
|
||||
return E_FAIL;
|
||||
|
||||
HRESULT hr = E_UNEXPECTED;
|
||||
if (m_spdo && !(uFlags & (CMF_DEFAULTONLY | CMF_VERBSONLY | CMF_OPTIMIZEFORINVOKE)))
|
||||
{
|
||||
|
||||
@@ -193,8 +193,7 @@ public:
|
||||
std::wstring path = get_module_folderpath(g_hInst);
|
||||
std::wstring packageUri = path + L"\\PowerRenameContextMenuPackage.msix";
|
||||
|
||||
std::wstring packageDisplayName{ L"PowerRenameContextMenu" };
|
||||
if (!package::IsPackageRegistered(packageDisplayName))
|
||||
if (!package::IsPackageRegistered(PowerRenameConstants::ModulePackageDisplayName))
|
||||
{
|
||||
package::RegisterSparsePackage(path, packageUri);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user