mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[SvgThumbnail]Register as a picture kind (#17080)
This commit is contained in:
@@ -155,7 +155,8 @@ inline registry::ChangeSet getSvgThumbnailHandlerChangeSet(const std::wstring in
|
|||||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||||
L"Microsoft.PowerToys.ThumbnailHandler.Svg.SvgThumbnailProvider",
|
L"Microsoft.PowerToys.ThumbnailHandler.Svg.SvgThumbnailProvider",
|
||||||
L"Svg Thumbnail Provider",
|
L"Svg Thumbnail Provider",
|
||||||
NonLocalizable::ExtSVG);
|
NonLocalizable::ExtSVG,
|
||||||
|
L"Picture");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline registry::ChangeSet getPdfThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
inline registry::ChangeSet getPdfThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
||||||
|
|||||||
@@ -69,9 +69,10 @@ namespace registry
|
|||||||
std::wstring path;
|
std::wstring path;
|
||||||
std::optional<std::wstring> name; // none == default
|
std::optional<std::wstring> name; // none == default
|
||||||
value_t value;
|
value_t value;
|
||||||
|
bool required = true;
|
||||||
|
|
||||||
ValueChange(const HKEY scope, std::wstring path, std::optional<std::wstring> name, value_t value) :
|
ValueChange(const HKEY scope, std::wstring path, std::optional<std::wstring> name, value_t value, bool required = true) :
|
||||||
scope{ scope }, path{ std::move(path) }, name{ std::move(name) }, value{ std::move(value) }
|
scope{ scope }, path{ std::move(path) }, name{ std::move(name) }, value{ std::move(value) }, required{ required }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +269,7 @@ namespace registry
|
|||||||
{
|
{
|
||||||
for (const auto& c : changes)
|
for (const auto& c : changes)
|
||||||
{
|
{
|
||||||
if (!c.isApplied())
|
if (c.required && !c.isApplied())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -281,7 +282,7 @@ namespace registry
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
for (const auto& c : changes)
|
for (const auto& c : changes)
|
||||||
{
|
{
|
||||||
ok = c.apply() && ok;
|
ok = (c.apply()||!c.required) && ok;
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@@ -291,7 +292,7 @@ namespace registry
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
for (const auto& c : changes)
|
for (const auto& c : changes)
|
||||||
{
|
{
|
||||||
ok = c.unApply() && ok;
|
ok = (c.unApply()||!c.required) && ok;
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@@ -317,7 +318,8 @@ namespace registry
|
|||||||
std::wstring handlerCategory,
|
std::wstring handlerCategory,
|
||||||
std::wstring className,
|
std::wstring className,
|
||||||
std::wstring displayName,
|
std::wstring displayName,
|
||||||
std::vector<std::wstring> fileTypes)
|
std::vector<std::wstring> fileTypes,
|
||||||
|
std::wstring fileKindType = L"" )
|
||||||
{
|
{
|
||||||
const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
|
const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
|
||||||
|
|
||||||
@@ -369,6 +371,13 @@ namespace registry
|
|||||||
fileAssociationPath += L"\\shellex\\";
|
fileAssociationPath += L"\\shellex\\";
|
||||||
fileAssociationPath += handlerType == PreviewHandlerType::preview ? IPREVIEW_HANDLER_CLSID : ITHUMBNAIL_PROVIDER_CLSID;
|
fileAssociationPath += handlerType == PreviewHandlerType::preview ? IPREVIEW_HANDLER_CLSID : ITHUMBNAIL_PROVIDER_CLSID;
|
||||||
changes.push_back({ scope, fileAssociationPath, std::nullopt, handlerClsid });
|
changes.push_back({ scope, fileAssociationPath, std::nullopt, handlerClsid });
|
||||||
|
if (!fileKindType.empty())
|
||||||
|
{
|
||||||
|
// Registering a file type as a kind needs to be done at the HKEY_LOCAL_MACHINE level.
|
||||||
|
// Make it optional as well so that we don't fail registering the handler if we can't write to HKEY_LOCAL_MACHINE.
|
||||||
|
std::wstring kindMapPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\KindMap";
|
||||||
|
changes.push_back({ HKEY_LOCAL_MACHINE, kindMapPath, fileType, fileKindType, false});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handlerType == PreviewHandlerType::preview)
|
if (handlerType == PreviewHandlerType::preview)
|
||||||
|
|||||||
Reference in New Issue
Block a user