mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
* Flatten everything and succeed build * Figure out Settings assets * Remove UseCommonOutputDirectory tag * Proper settings app path * [VCM] Fix assets location * Fix some runtime paths * [RegistryPreview]Use MRTCore specific pri file * [Hosts]Use MRTCore specific pri file * [Settings]Use MRTCore specific pri file * [Peek]Use MRTCore specific pri file * [FileLocksmith]Use MRTCore specific pri file * [ScreenRuler]Use MRTCore specific pri file * [PowerRename]Use MRTCore specific pri file * [Peek]Move assets to own folder * [FileLocksmith] Use own Assets path * [Hosts]Use own assets folder * [PowerRename]Use own assets dir * [MeasureTool] Use its own assets folder * [ImageResizer]Use its own assets path * Fix spellcheck * Fix tab instead of space in project files * Normalize target frameworks and platforms * Remove WINRT_NO_MAKE_DETECTION flag. No longer needed? * Fix AOT and Hosts locations * Fix Dll version differences on dependency * Add Common.UI.csproj as refernce to fix dll versions * Update ControlzEx to normalize dll versions * Update System.Management version to 7.0.2 * Add GPOWrapper to Registry Preview to fix dll versions * [PTRun]Reference Microsoft.Extensions.Hosting to fix dll versions * Fix remaining output paths / dll version conflicts * [KeyboardManager]Executables still on their own directories * Fix Monaco paths * WinAppSDK apps get to play outside again * Enable VCM settings again * Fix KBM Editor path again * [Monaco]Set to own Assets dir * Fix installer preamble; Fix publish. remove unneeded publishes * Remove Hardlink functions * Installer builds again (still needs work to work) * Readd Monaco to spellcheck excludes * Fix spellcheck and call publish.cmd again * [Installer] Remove components that don't need own dirs * [Installer] Refactor Power Launcher * [Installer] Refactor Color Picker * [Installer] Refactor Monaco assets * [Installer]Generate File script no longer needs to remove files * [Installer]Refactor FileLocksmith * [Installer] Refactor Hosts * [Installer]Refactor Image Resizer * [Installer]Refactor MouseUtils * [Installer]Refactor MWB * [Installer]Refactor MeasureTool * [Installer]Refactor Peek * [Installer]Refactor PowerRename and registry fixes * [Installer]Refactor RegistryPreview * [Installer]Refactor ShortcutGuide * [Installer]Refactor Settings * [Installer]Clean up some unused stuff * [Installer]Clean up stuff for user install * [Installer]Fix WinUi3Apps wxs * [Installer]Fix misplaced folders * [Installer]Move x86 VCM dll to right path * Fix monaco language list location * [Installer]Fix VCM directory reference * [CI]Fix signing * [Installer] Fix resources folder for release CI * [ci]Looks like we still ship NLog on PowerToys Run * [Settings]Add dependency to avoid dll collision with Experimentation * [RegistryPreview]Move XAML files to own path * [RegistryPreview]Fix app icon * [Hosts]Move XAML files to their own path * [FileLocksmith]Move XAML files to their own path * [Peek]Move XAML files to own path * [ScreenRuler]Move XAML files to its own path * [Settings]Move XAML to its own path * [ColorPicker]Move Resources to Assets * [ShortcutGuide]Move svgs to own Assets path * [Awake]Move images to assets path * [Runner]Remove debug checks for PowerToys Run assets * [PTRun]Move images to its own assets path * [ImageResizer]Icon for context menu on own assets path * [PowerRename]Move ico to its own path * Remove unneeded intermediary directories * Remove further int dirs * Move tests to its own output path * Fix spellcheck * spellcheck: remove warnings * [CppAnalyzers]Ignore rule in a tool * [CI]Check if all deps.json files reference same versions * fix spellcheck * [ci]Fix task identation * [ci]Add script to guard against asset conflicts * [ci]Add more deps.json audit steps in the release build * Add xbf to spellcheck expects * Fix typo in asset conflict check scripts * Fix some more dependency conflicts * Downgrade CsWinRT to have the same dll version as sdk * [ci]Do a recursive check for every deps.json * Fix spellcheck error inside comment * [ci]Fix asset script error * [ci]Name deps.json verify tasks a bit better * [ci]Improve deps json verify script output * [ci]Update WinRT version to the same running in CI * Also upgrade CsWinRT in NOTICE.MD * [PowerRename]Move XAML files to own path * [Common]Fix Settings executable path * [ci]Verify there's no xbf files in app directories * [installer]Fix firewall path * [Monaco]Move new files to their proper assets path * [Monaco]Fix paths for new files after merge * [Feedback]Removed unneeded build conditions * [Feedback]Clear vcxproj direct reference to frameworks * [Feedback]RunPlugins name to hold PTRun plugins * [Feedback]Remove unneeded foreach * [Feedback]Shortcut Guide svgs with ** in project file * [Feedback]Fix spellcheck
269 lines
13 KiB
C++
269 lines
13 KiB
C++
#pragma once
|
|
|
|
#include "registry.h"
|
|
|
|
#include <common/utils/json.h>
|
|
|
|
#include <filesystem>
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
namespace NonLocalizable
|
|
{
|
|
const static wchar_t* MONACO_LANGUAGES_FILE_NAME = L"Assets\\Monaco\\monaco_languages.json";
|
|
const static wchar_t* ListID = L"list";
|
|
const static wchar_t* ExtensionsID = L"extensions";
|
|
const static std::vector<std::wstring> ExtSVG = { L".svg" };
|
|
const static std::vector<std::wstring> ExtMarkdown = { L".md", L".markdown", L".mdown", L".mkdn", L".mkd", L".mdwn", L".mdtxt", L".mdtext" };
|
|
const static std::vector<std::wstring> ExtPDF = { L".pdf" };
|
|
const static std::vector<std::wstring> ExtGCode = { L".gcode" };
|
|
const static std::vector<std::wstring> ExtSTL = { L".stl" };
|
|
const static std::vector<std::wstring> ExtNoNoNo = {
|
|
L".svgz" //Monaco cannot handle this file type at all; it's a binary file.
|
|
};
|
|
}
|
|
|
|
inline registry::ChangeSet getSvgPreviewHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
return generatePreviewHandler(PreviewHandlerType::preview,
|
|
perUser,
|
|
L"{FCDD4EED-41AA-492F-8A84-31A1546226E0}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } /
|
|
LR"d(PowerToys.SvgPreviewHandlerCpp.dll)d")
|
|
.wstring(),
|
|
L"SvgPreviewHandler",
|
|
L"Svg Preview Handler",
|
|
NonLocalizable::ExtSVG);
|
|
}
|
|
|
|
inline registry::ChangeSet getMdPreviewHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
return generatePreviewHandler(PreviewHandlerType::preview,
|
|
perUser,
|
|
L"{60789D87-9C3C-44AF-B18C-3DE2C2820ED3}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } / LR"d(PowerToys.MarkdownPreviewHandlerCpp.dll)d").wstring(),
|
|
L"MarkdownPreviewHandler",
|
|
L"Markdown Preview Handler",
|
|
NonLocalizable::ExtMarkdown);
|
|
}
|
|
|
|
inline registry::ChangeSet getMonacoPreviewHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
|
|
// Set up a list of extensions for the preview handler to take over
|
|
std::vector<std::wstring> extensions;
|
|
|
|
// Set up a list of extensions that Monaco support but the preview handler shouldn't take over
|
|
std::vector<std::wstring> ExtExclusions;
|
|
ExtExclusions.insert(ExtExclusions.end(), NonLocalizable::ExtMarkdown.begin(), NonLocalizable::ExtMarkdown.end());
|
|
ExtExclusions.insert(ExtExclusions.end(), NonLocalizable::ExtSVG.begin(), NonLocalizable::ExtSVG.end());
|
|
ExtExclusions.insert(ExtExclusions.end(), NonLocalizable::ExtNoNoNo.begin(), NonLocalizable::ExtNoNoNo.end());
|
|
bool IsExcluded = false;
|
|
|
|
std::wstring languagesFilePath = fs::path{ installationDir } / NonLocalizable::MONACO_LANGUAGES_FILE_NAME;
|
|
auto json = json::from_file(languagesFilePath);
|
|
|
|
if (json)
|
|
{
|
|
try
|
|
{
|
|
auto list = json->GetNamedArray(NonLocalizable::ListID);
|
|
for (uint32_t i = 0; i < list.Size(); ++i)
|
|
{
|
|
auto entry = list.GetObjectAt(i);
|
|
if (entry.HasKey(NonLocalizable::ExtensionsID))
|
|
{
|
|
auto extensionsList = entry.GetNamedArray(NonLocalizable::ExtensionsID);
|
|
|
|
for (uint32_t j = 0; j < extensionsList.Size(); ++j)
|
|
{
|
|
auto extension = extensionsList.GetStringAt(j);
|
|
|
|
// Ignore extensions in the exclusion list
|
|
IsExcluded = false;
|
|
|
|
for (std::wstring k : ExtExclusions)
|
|
{
|
|
if (std::wstring{ extension } == k)
|
|
{
|
|
IsExcluded = true;
|
|
break;
|
|
}
|
|
}
|
|
if (IsExcluded)
|
|
{
|
|
continue;
|
|
}
|
|
extensions.push_back(std::wstring{ extension });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (...)
|
|
{
|
|
}
|
|
}
|
|
|
|
return generatePreviewHandler(PreviewHandlerType::preview,
|
|
perUser,
|
|
L"{D8034CFA-F34B-41FE-AD45-62FCBB52A6DA}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } / LR"d(PowerToys.MonacoPreviewHandlerCpp.dll)d").wstring(),
|
|
L"MonacoPreviewHandler",
|
|
L"Monaco Preview Handler",
|
|
extensions);
|
|
}
|
|
|
|
inline registry::ChangeSet getPdfPreviewHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
return generatePreviewHandler(PreviewHandlerType::preview,
|
|
perUser,
|
|
L"{A5A41CC7-02CB-41D4-8C9B-9087040D6098}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } / LR"d(PowerToys.PdfPreviewHandlerCpp.dll)d").wstring(),
|
|
L"PdfPreviewHandler",
|
|
L"Pdf Preview Handler",
|
|
NonLocalizable::ExtPDF);
|
|
}
|
|
|
|
inline registry::ChangeSet getGcodePreviewHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
return generatePreviewHandler(PreviewHandlerType::preview,
|
|
perUser,
|
|
L"{A0257634-8812-4CE8-AF11-FA69ACAEAFAE}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } / LR"d(PowerToys.GcodePreviewHandlerCpp.dll)d").wstring(),
|
|
L"GcodePreviewHandler",
|
|
L"G-code Preview Handler",
|
|
NonLocalizable::ExtGCode);
|
|
}
|
|
|
|
inline registry::ChangeSet getSvgThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
|
perUser,
|
|
L"{10144713-1526-46C9-88DA-1FB52807A9FF}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } / LR"d(PowerToys.SvgThumbnailProviderCpp.dll)d").wstring(),
|
|
L"SvgThumbnailProvider",
|
|
L"Svg Thumbnail Provider",
|
|
NonLocalizable::ExtSVG,
|
|
L"Picture");
|
|
}
|
|
|
|
inline registry::ChangeSet getPdfThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
|
perUser,
|
|
L"{D8BB9942-93BD-412D-87E4-33FAB214DC1A}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } / LR"d(PowerToys.PdfThumbnailProviderCpp.dll)d").wstring(),
|
|
L"PdfThumbnailProvider",
|
|
L"Pdf Thumbnail Provider",
|
|
NonLocalizable::ExtPDF);
|
|
}
|
|
|
|
inline registry::ChangeSet getGcodeThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
|
perUser,
|
|
L"{F2847CBE-CD03-4C83-A359-1A8052C1B9D5}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } / LR"d(PowerToys.GcodeThumbnailProviderCpp.dll)d").wstring(),
|
|
L"GcodeThumbnailProvider",
|
|
L"G-code Thumbnail Provider",
|
|
NonLocalizable::ExtGCode);
|
|
}
|
|
|
|
inline registry::ChangeSet getStlThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
using namespace registry::shellex;
|
|
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
|
perUser,
|
|
L"{77257004-6F25-4521-B602-50ECC6EC62A6}",
|
|
get_std_product_version(),
|
|
(fs::path{ installationDir } / LR"d(PowerToys.StlThumbnailProviderCpp.dll)d").wstring(),
|
|
L"StlThumbnailProvider",
|
|
L"Stl Thumbnail Provider",
|
|
NonLocalizable::ExtSTL);
|
|
}
|
|
|
|
inline registry::ChangeSet getRegistryPreviewSetDefaultAppChangeSet(const std::wstring installationDir, const bool perUser)
|
|
{
|
|
const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
|
|
|
|
using vec_t = std::vector<registry::ValueChange>;
|
|
vec_t changes;
|
|
|
|
std::wstring appName = L"Registry Preview";
|
|
std::wstring fullAppName = L"PowerToys.RegistryPreview";
|
|
std::wstring registryKeyPrefix = L"Software\\Classes\\";
|
|
|
|
std::wstring appPath = installationDir + L"\\WinUI3Apps\\PowerToys.RegistryPreview.exe";
|
|
std::wstring command = appPath + L" \"----ms-protocol:ms-encodedlaunch:App?ContractId=Windows.File&Verb=open&File=%1\"";
|
|
|
|
changes.push_back({ scope, registryKeyPrefix + fullAppName + L"\\" + L"Application", L"ApplicationName", appName });
|
|
changes.push_back({ scope, registryKeyPrefix + fullAppName + L"\\" + L"DefaultIcon", std::nullopt, appPath });
|
|
changes.push_back({ scope, registryKeyPrefix + fullAppName + L"\\" + L"shell\\open\\command", std::nullopt, command });
|
|
changes.push_back({ scope, registryKeyPrefix + L".reg\\OpenWithProgIDs", fullAppName, L"" });
|
|
|
|
return { changes };
|
|
}
|
|
|
|
inline registry::ChangeSet getRegistryPreviewChangeSet(const std::wstring installationDir,const bool perUser)
|
|
{
|
|
const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
|
|
|
|
using vec_t = std::vector<registry::ValueChange>;
|
|
vec_t changes;
|
|
|
|
std::wstring command = installationDir;
|
|
command.append(L"\\WinUI3Apps\\PowerToys.RegistryPreview.exe \"%1\"");
|
|
changes.push_back({ scope, L"Software\\Classes\\regfile\\shell\\preview\\command", std::nullopt, command });
|
|
|
|
std::wstring icon_path = installationDir;
|
|
icon_path.append(L"\\WinUI3Apps\\Assets\\RegistryPreview\\app.ico");
|
|
changes.push_back({ scope, L"Software\\Classes\\regfile\\shell\\preview", L"icon", icon_path });
|
|
|
|
return { changes };
|
|
}
|
|
|
|
inline std::vector<registry::ChangeSet> getAllOnByDefaultModulesChangeSets(const std::wstring installationDir)
|
|
{
|
|
constexpr bool PER_USER = true;
|
|
return { getSvgPreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getMdPreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getMonacoPreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getGcodePreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getSvgThumbnailHandlerChangeSet(installationDir, PER_USER),
|
|
getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
|
|
getStlThumbnailHandlerChangeSet(installationDir, PER_USER),
|
|
getRegistryPreviewChangeSet(installationDir, PER_USER) };
|
|
}
|
|
|
|
inline std::vector<registry::ChangeSet> getAllModulesChangeSets(const std::wstring installationDir)
|
|
{
|
|
constexpr bool PER_USER = true;
|
|
return { getSvgPreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getMdPreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getMonacoPreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getPdfPreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getGcodePreviewHandlerChangeSet(installationDir, PER_USER),
|
|
getSvgThumbnailHandlerChangeSet(installationDir, PER_USER),
|
|
getPdfThumbnailHandlerChangeSet(installationDir, PER_USER),
|
|
getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
|
|
getStlThumbnailHandlerChangeSet(installationDir, PER_USER),
|
|
getRegistryPreviewChangeSet(installationDir, PER_USER),
|
|
getRegistryPreviewSetDefaultAppChangeSet(installationDir, PER_USER) };
|
|
}
|