mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-06-30 23:49:42 +02:00
Compare commits
5 Commits
copilot/fi
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ac509ab2b | ||
|
|
e8afe02adf | ||
|
|
8da754c1b6 | ||
|
|
92fe5b531e | ||
|
|
71d55ac50f |
1
_codeql_detected_source_root
Symbolic link
1
_codeql_detected_source_root
Symbolic link
@@ -0,0 +1 @@
|
||||
.
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <common/utils/resources.h>
|
||||
#include <Settings.h>
|
||||
#include <trace.h>
|
||||
#include <ImageResizerConstants.h>
|
||||
|
||||
#include <wil/win32_helpers.h>
|
||||
#include <wrl/module.h>
|
||||
@@ -120,6 +121,16 @@ public:
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Check if the extension is actually supported by Image Resizer
|
||||
// This prevents showing the menu for file types like .psd that Windows
|
||||
// perceives as images but Image Resizer cannot process
|
||||
if (!ImageResizerConstants::IsSupportedImageExtension(pszExt))
|
||||
{
|
||||
CoTaskMemFree(pszPath);
|
||||
*cmdState = ECS_HIDDEN;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// TODO: Instead, detect whether there's a WIC codec installed that can handle this file
|
||||
AssocGetPerceivedType(pszExt, &type, &flag, NULL);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ImageResizerConstants
|
||||
{
|
||||
@@ -10,4 +12,27 @@ namespace ImageResizerConstants
|
||||
inline const std::wstring ModuleOldSaveFolderKey = L"ImageResizer";
|
||||
inline const std::wstring ModuleSaveFolderKey = L"Image Resizer";
|
||||
inline const std::wstring ModulePackageDisplayName = L"ImageResizerContextMenu";
|
||||
|
||||
// List of supported image extensions that Image Resizer can process
|
||||
// This must match the list in RuntimeRegistration.h
|
||||
// Note: All extensions must be in lowercase for case-insensitive comparison
|
||||
inline const std::vector<std::wstring> SupportedImageExtensions = {
|
||||
L".bmp", L".dib", L".gif", L".jfif", L".jpe", L".jpeg", L".jpg",
|
||||
L".jxr", L".png", L".rle", L".tif", L".tiff", L".wdp"
|
||||
};
|
||||
|
||||
// Helper function to check if a file extension is supported by Image Resizer
|
||||
inline bool IsSupportedImageExtension(LPCWSTR extension)
|
||||
{
|
||||
if (extension == nullptr || wcslen(extension) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert to lowercase for case-insensitive comparison
|
||||
std::wstring ext(extension);
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), ::towlower);
|
||||
|
||||
return std::find(SupportedImageExtensions.begin(), SupportedImageExtensions.end(), ext) != SupportedImageExtensions.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <Settings.h>
|
||||
#include <trace.h>
|
||||
#include <ImageResizerConstants.h>
|
||||
|
||||
#include <common/themes/icon_helpers.h>
|
||||
#include <common/utils/process_path.h>
|
||||
@@ -97,6 +98,15 @@ HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu,
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Check if the extension is actually supported by Image Resizer
|
||||
// This prevents showing the menu for file types like .psd that Windows
|
||||
// perceives as images but Image Resizer cannot process
|
||||
if (!ImageResizerConstants::IsSupportedImageExtension(pszExt))
|
||||
{
|
||||
free(pszPath);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// TODO: Instead, detect whether there's a WIC codec installed that can handle this file
|
||||
AssocGetPerceivedType(pszExt, &type, &flag, NULL);
|
||||
|
||||
@@ -417,6 +427,16 @@ HRESULT __stdcall CContextMenuHandler::GetState(IShellItemArray* psiItemArray, B
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Check if the extension is actually supported by Image Resizer
|
||||
// This prevents showing the menu for file types like .psd that Windows
|
||||
// perceives as images but Image Resizer cannot process
|
||||
if (!ImageResizerConstants::IsSupportedImageExtension(pszExt))
|
||||
{
|
||||
CoTaskMemFree(pszPath);
|
||||
*pCmdState = ECS_HIDDEN;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// TODO: Instead, detect whether there's a WIC codec installed that can handle this file
|
||||
AssocGetPerceivedType(pszExt, &type, &flag, NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user