mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-09 13:57:05 +01:00
Compare commits
7 Commits
shawn/CLIF
...
leilzh/fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b94bf4fdae | ||
|
|
2d18303f0a | ||
|
|
cdf66a70e9 | ||
|
|
9dcddfd4b8 | ||
|
|
503bcbdf2d | ||
|
|
abf5e5bf8d | ||
|
|
e1e74b8fab |
@@ -16,9 +16,54 @@
|
||||
|
||||
namespace registry
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
struct on_exit
|
||||
{
|
||||
std::function<void()> f;
|
||||
|
||||
on_exit(std::function<void()> f) :
|
||||
f{ std::move(f) } {}
|
||||
~on_exit() { f(); }
|
||||
};
|
||||
|
||||
template<class... Ts>
|
||||
struct overloaded : Ts...
|
||||
{
|
||||
using Ts::operator()...;
|
||||
};
|
||||
|
||||
template<class... Ts>
|
||||
overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
inline const wchar_t* getScopeName(HKEY scope)
|
||||
{
|
||||
if (scope == HKEY_LOCAL_MACHINE)
|
||||
{
|
||||
return L"HKLM";
|
||||
}
|
||||
else if (scope == HKEY_CURRENT_USER)
|
||||
{
|
||||
return L"HKCU";
|
||||
}
|
||||
else if (scope == HKEY_CLASSES_ROOT)
|
||||
{
|
||||
return L"HKCR";
|
||||
}
|
||||
else
|
||||
{
|
||||
return L"HK??";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace install_scope
|
||||
{
|
||||
const wchar_t INSTALL_SCOPE_REG_KEY[] = L"Software\\Classes\\powertoys\\";
|
||||
const wchar_t UNINSTALL_REG_KEY[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
|
||||
|
||||
// Bundle UpgradeCode from PowerToys.wxs (with braces as stored in registry)
|
||||
const wchar_t BUNDLE_UPGRADE_CODE[] = L"{6341382D-C0A9-4238-9188-BE9607E3FAB2}";
|
||||
|
||||
enum class InstallScope
|
||||
{
|
||||
@@ -26,8 +71,67 @@ namespace registry
|
||||
PerUser,
|
||||
};
|
||||
|
||||
// Helper function to find PowerToys bundle in Windows Uninstall registry by BundleUpgradeCode
|
||||
inline bool find_powertoys_bundle_in_uninstall_registry(HKEY rootKey)
|
||||
{
|
||||
HKEY uninstallKey{};
|
||||
if (RegOpenKeyExW(rootKey, UNINSTALL_REG_KEY, 0, KEY_READ, &uninstallKey) != ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
detail::on_exit closeUninstallKey{ [uninstallKey] { RegCloseKey(uninstallKey); } };
|
||||
|
||||
DWORD index = 0;
|
||||
wchar_t subKeyName[256];
|
||||
|
||||
// Enumerate all subkeys under Uninstall
|
||||
while (RegEnumKeyW(uninstallKey, index++, subKeyName, 256) == ERROR_SUCCESS)
|
||||
{
|
||||
HKEY productKey{};
|
||||
if (RegOpenKeyExW(uninstallKey, subKeyName, 0, KEY_READ, &productKey) != ERROR_SUCCESS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
detail::on_exit closeProductKey{ [productKey] { RegCloseKey(productKey); } };
|
||||
|
||||
// Check BundleUpgradeCode value (specific to WiX Bundle installations)
|
||||
wchar_t bundleUpgradeCode[256]{};
|
||||
DWORD bundleUpgradeCodeSize = sizeof(bundleUpgradeCode);
|
||||
|
||||
if (RegQueryValueExW(productKey, L"BundleUpgradeCode", nullptr, nullptr,
|
||||
reinterpret_cast<LPBYTE>(bundleUpgradeCode), &bundleUpgradeCodeSize) == ERROR_SUCCESS)
|
||||
{
|
||||
if (_wcsicmp(bundleUpgradeCode, BUNDLE_UPGRADE_CODE) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline const InstallScope get_current_install_scope()
|
||||
{
|
||||
// 1. Check HKCU Uninstall registry first (user-level bundle)
|
||||
// Note: MSI components are always in HKLM regardless of install scope,
|
||||
// but the Bundle entry will be in HKCU for per-user installations
|
||||
if (find_powertoys_bundle_in_uninstall_registry(HKEY_CURRENT_USER))
|
||||
{
|
||||
Logger::info(L"Found user-level PowerToys bundle via BundleUpgradeCode in HKCU");
|
||||
return InstallScope::PerUser;
|
||||
}
|
||||
|
||||
// 2. Check HKLM Uninstall registry (machine-level bundle)
|
||||
if (find_powertoys_bundle_in_uninstall_registry(HKEY_LOCAL_MACHINE))
|
||||
{
|
||||
Logger::info(L"Found machine-level PowerToys bundle via BundleUpgradeCode in HKLM");
|
||||
return InstallScope::PerMachine;
|
||||
}
|
||||
|
||||
// 3. Fallback to legacy custom registry key detection
|
||||
Logger::info(L"PowerToys bundle not found in Uninstall registry, falling back to legacy detection");
|
||||
|
||||
// Open HKLM key
|
||||
HKEY perMachineKey{};
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
@@ -45,6 +149,7 @@ namespace registry
|
||||
&perUserKey) != ERROR_SUCCESS)
|
||||
{
|
||||
// both keys are missing
|
||||
Logger::warn(L"No PowerToys installation detected, defaulting to PerMachine");
|
||||
return InstallScope::PerMachine;
|
||||
}
|
||||
else
|
||||
@@ -96,47 +201,6 @@ namespace registry
|
||||
template<class>
|
||||
inline constexpr bool always_false_v = false;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
struct on_exit
|
||||
{
|
||||
std::function<void()> f;
|
||||
|
||||
on_exit(std::function<void()> f) :
|
||||
f{ std::move(f) } {}
|
||||
~on_exit() { f(); }
|
||||
};
|
||||
|
||||
template<class... Ts>
|
||||
struct overloaded : Ts...
|
||||
{
|
||||
using Ts::operator()...;
|
||||
};
|
||||
|
||||
template<class... Ts>
|
||||
overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
inline const wchar_t* getScopeName(HKEY scope)
|
||||
{
|
||||
if (scope == HKEY_LOCAL_MACHINE)
|
||||
{
|
||||
return L"HKLM";
|
||||
}
|
||||
else if (scope == HKEY_CURRENT_USER)
|
||||
{
|
||||
return L"HKCU";
|
||||
}
|
||||
else if (scope == HKEY_CLASSES_ROOT)
|
||||
{
|
||||
return L"HKCR";
|
||||
}
|
||||
else
|
||||
{
|
||||
return L"HK??";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ValueChange
|
||||
{
|
||||
using value_t = std::variant<DWORD, std::wstring>;
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_X => new[] { "ẋ", "×" },
|
||||
LetterKey.VK_Y => new[] { "ẏ", "ꝡ" },
|
||||
LetterKey.VK_Z => new[] { "ʒ", "ǯ", "ℤ" },
|
||||
LetterKey.VK_COMMA => new[] { "∙", "₋", "⁻", "–", "√" }, // – is in VK_MINUS for other languages, but not VK_COMMA, so we add it here.
|
||||
LetterKey.VK_COMMA => new[] { "∙", "₋", "⁻", "–", "√", "‟", "《", "》", "‛", "〈", "〉", "″", "‴", "⁗" }, // – is in VK_MINUS for other languages, but not VK_COMMA, so we add it here.
|
||||
LetterKey.VK_PERIOD => new[] { "…", "⁝", "\u0300", "\u0301", "\u0302", "\u0303", "\u0304", "\u0308", "\u030B", "\u030C" },
|
||||
LetterKey.VK_MINUS => new[] { "~", "‐", "‑", "‒", "—", "―", "⁓", "−", "⸺", "⸻", "∓" },
|
||||
LetterKey.VK_SLASH_ => new[] { "÷", "√" },
|
||||
@@ -302,6 +302,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_E => new[] { "€" },
|
||||
LetterKey.VK_S => new[] { "š" },
|
||||
LetterKey.VK_Z => new[] { "ž" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "»", "«" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -317,6 +318,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_U => new[] { "ü" },
|
||||
LetterKey.VK_Z => new[] { "ž" },
|
||||
LetterKey.VK_S => new[] { "š" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "«", "»" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -344,6 +346,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_A => new[] { "ä", "å" },
|
||||
LetterKey.VK_E => new[] { "€" },
|
||||
LetterKey.VK_O => new[] { "ö" },
|
||||
LetterKey.VK_COMMA => new[] { "”", "’", "»" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -360,6 +363,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_O => new[] { "ô", "ö", "ó", "ò", "õ", "œ" },
|
||||
LetterKey.VK_U => new[] { "û", "ù", "ü", "ú" },
|
||||
LetterKey.VK_Y => new[] { "ÿ", "ý" },
|
||||
LetterKey.VK_COMMA => new[] { "«", "»", "‹", "›", "“", "”", "‘", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -376,6 +380,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_U => new[] { "ú" },
|
||||
LetterKey.VK_Y => new[] { "ý" },
|
||||
LetterKey.VK_T => new[] { "þ" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "‚", "‘" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -393,7 +398,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_N => new[] { "ñ" },
|
||||
LetterKey.VK_O => new[] { "ó" },
|
||||
LetterKey.VK_U => new[] { "ú", "ü" },
|
||||
LetterKey.VK_COMMA => new[] { "¿", "?", "¡", "!" },
|
||||
LetterKey.VK_COMMA => new[] { "¿", "?", "¡", "!", "«", "»", "“", "”", "‘", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -411,7 +416,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_O => new[] { "ò", "ó" },
|
||||
LetterKey.VK_U => new[] { "ù", "ú", "ü" },
|
||||
LetterKey.VK_L => new[] { "·" },
|
||||
LetterKey.VK_COMMA => new[] { "¿", "?", "¡", "!" },
|
||||
LetterKey.VK_COMMA => new[] { "¿", "?", "¡", "!", "«", "»", "“", "”", "‘", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -427,6 +432,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_O => new[] { "ō" },
|
||||
LetterKey.VK_S => new[] { "$" },
|
||||
LetterKey.VK_U => new[] { "ū" },
|
||||
LetterKey.VK_COMMA => new[] { "“", "”", "‘", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -443,6 +449,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_N => new[] { "ñ" },
|
||||
LetterKey.VK_O => new[] { "ó", "ö", "ô" },
|
||||
LetterKey.VK_U => new[] { "ú", "ü", "û" },
|
||||
LetterKey.VK_COMMA => new[] { "“", "„", "”", "‘", ",", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -469,6 +476,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_V => new[] { "ü", "ǖ", "ǘ", "ǚ", "ǜ" },
|
||||
LetterKey.VK_Y => new[] { "¥" },
|
||||
LetterKey.VK_Z => new[] { "ẑ" },
|
||||
LetterKey.VK_COMMA => new[] { "“", "”", "‘", "’", "「", "」", "『", "』" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -505,6 +513,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_S => new[] { "ş" },
|
||||
LetterKey.VK_T => new[] { "₺" },
|
||||
LetterKey.VK_U => new[] { "ü", "û" },
|
||||
LetterKey.VK_COMMA => new[] { "“", "”", "‘", "’", "«", "»", "‹", "›" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -522,6 +531,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_O => new[] { "ó" },
|
||||
LetterKey.VK_S => new[] { "ś" },
|
||||
LetterKey.VK_Z => new[] { "ż", "ź" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "”", "‘", "’", "»", "«" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -539,7 +549,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_P => new[] { "π" },
|
||||
LetterKey.VK_S => new[] { "$" },
|
||||
LetterKey.VK_U => new[] { "ú" },
|
||||
LetterKey.VK_COMMA => new[] { "≤", "≥", "≠", "≈", "≙", "±", "₊", "⁺" },
|
||||
LetterKey.VK_COMMA => new[] { "≤", "≥", "≠", "≈", "≙", "±", "₊", "⁺", "“", "”", "‘", "’", "«", "»" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -594,6 +604,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_U => new[] { "ú" },
|
||||
LetterKey.VK_Y => new[] { "ý" },
|
||||
LetterKey.VK_Z => new[] { "ž" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "‚", "‘", "»", "«", "›", "‹" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -608,6 +619,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_I => new[] { "í" },
|
||||
LetterKey.VK_O => new[] { "ó" },
|
||||
LetterKey.VK_U => new[] { "ú" },
|
||||
LetterKey.VK_COMMA => new[] { "“", "”", "‘", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -623,6 +635,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_O => new[] { "ò" },
|
||||
LetterKey.VK_P => new[] { "£" },
|
||||
LetterKey.VK_U => new[] { "ù" },
|
||||
LetterKey.VK_COMMA => new[] { "“", "”", "‘", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -645,6 +658,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_U => new[] { "ů", "ú" },
|
||||
LetterKey.VK_Y => new[] { "ý" },
|
||||
LetterKey.VK_Z => new[] { "ž" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "‚", "‘", "»", "«", "›", "‹" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -659,6 +673,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_O => new[] { "ö" },
|
||||
LetterKey.VK_S => new[] { "ß" },
|
||||
LetterKey.VK_U => new[] { "ü" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "‚", "‘", "»", "«", "›", "‹" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -689,6 +704,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_X => new string[] { "ξ" },
|
||||
LetterKey.VK_Y => new string[] { "υ" },
|
||||
LetterKey.VK_Z => new string[] { "ζ" },
|
||||
LetterKey.VK_COMMA => new[] { "“", "”", "«", "»", },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -710,7 +726,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_U => new[] { "וֹ", "וּ", "װ", "\u05b9" },
|
||||
LetterKey.VK_X => new[] { "\u05b6", "\u05b1" },
|
||||
LetterKey.VK_Y => new[] { "ױ" },
|
||||
LetterKey.VK_COMMA => new[] { "”", "’", "״", "׳" },
|
||||
LetterKey.VK_COMMA => new[] { "”", "’", "'", "״", "׳" },
|
||||
LetterKey.VK_PERIOD => new[] { "\u05ab", "\u05bd", "\u05bf" },
|
||||
LetterKey.VK_MINUS => new[] { "–", "־" },
|
||||
_ => Array.Empty<string>(),
|
||||
@@ -727,6 +743,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_I => new[] { "í" },
|
||||
LetterKey.VK_O => new[] { "ó", "ő", "ö" },
|
||||
LetterKey.VK_U => new[] { "ú", "ű", "ü" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "”", "»", "«" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -740,6 +757,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_I => new[] { "î" },
|
||||
LetterKey.VK_S => new[] { "ș" },
|
||||
LetterKey.VK_T => new[] { "ț" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "”", "«", "»" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -754,6 +772,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_I => new[] { "ì", "í" },
|
||||
LetterKey.VK_O => new[] { "ò", "ó" },
|
||||
LetterKey.VK_U => new[] { "ù", "ú" },
|
||||
LetterKey.VK_COMMA => new[] { "«", "»", "“", "”", "‘", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -772,6 +791,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_R => new[] { "ř" },
|
||||
LetterKey.VK_S => new[] { "ş" },
|
||||
LetterKey.VK_U => new[] { "û", "ü" },
|
||||
LetterKey.VK_COMMA => new[] { "«", "»", "“", "”" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -789,6 +809,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_U => new[] { "û", "ü", "ù", "ú" },
|
||||
LetterKey.VK_Y => new[] { "ŷ", "ÿ", "ỳ", "ý" },
|
||||
LetterKey.VK_W => new[] { "ŵ", "ẅ", "ẁ", "ẃ" },
|
||||
LetterKey.VK_COMMA => new[] { "‘", "’", "“", "“" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -801,6 +822,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_A => new[] { "å", "ä" },
|
||||
LetterKey.VK_E => new[] { "é" },
|
||||
LetterKey.VK_O => new[] { "ö" },
|
||||
LetterKey.VK_COMMA => new[] { "”", "’", "»", "«" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -814,6 +836,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_D => new[] { "đ" },
|
||||
LetterKey.VK_S => new[] { "š" },
|
||||
LetterKey.VK_Z => new[] { "ž" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "‚", "’", "»", "«", "›", "‹" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -838,6 +861,7 @@ namespace PowerAccent.Core
|
||||
{
|
||||
LetterKey.VK_E => new[] { "ѐ" },
|
||||
LetterKey.VK_I => new[] { "ѝ" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "’", "‘" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -869,6 +893,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_E => new[] { "€", "é" },
|
||||
LetterKey.VK_O => new[] { "ø" },
|
||||
LetterKey.VK_S => new[] { "$" },
|
||||
LetterKey.VK_COMMA => new[] { "«", "»", ",", "‘", "’", "„", "“" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -881,6 +906,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_A => new[] { "å", "æ" },
|
||||
LetterKey.VK_E => new[] { "€" },
|
||||
LetterKey.VK_O => new[] { "ø" },
|
||||
LetterKey.VK_COMMA => new[] { "»", "«", "“", "”", "›", "‹", "‘", "’" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -897,6 +923,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_S => new[] { "š" },
|
||||
LetterKey.VK_U => new[] { "ų", "ū" },
|
||||
LetterKey.VK_Z => new[] { "ž" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "‚", "‘" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
@@ -910,6 +937,7 @@ namespace PowerAccent.Core
|
||||
LetterKey.VK_E => new[] { "€" },
|
||||
LetterKey.VK_S => new[] { "š" },
|
||||
LetterKey.VK_Z => new[] { "ž" },
|
||||
LetterKey.VK_COMMA => new[] { "„", "“", "»", "«" },
|
||||
_ => Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public partial class PowerAccent : IDisposable
|
||||
|
||||
// Keys that show a description (like dashes) when ShowCharacterInfoSetting is 1
|
||||
private readonly LetterKey[] _letterKeysShowingDescription = new LetterKey[] { LetterKey.VK_O };
|
||||
private const double ScreenMinPadding = 150;
|
||||
|
||||
private bool _visible;
|
||||
private string[] _characters = Array.Empty<string>();
|
||||
@@ -332,6 +333,11 @@ public partial class PowerAccent : IDisposable
|
||||
return Calculation.GetRawCoordinatesFromPosition(position, screen, window);
|
||||
}
|
||||
|
||||
public double GetDisplayMaxWidth()
|
||||
{
|
||||
return WindowsFunctions.GetActiveDisplay().Size.Width - ScreenMinPadding;
|
||||
}
|
||||
|
||||
public Position GetToolbarPosition()
|
||||
{
|
||||
return _settingService.Position;
|
||||
|
||||
@@ -59,6 +59,7 @@ public partial class Selector : FluentWindow, IDisposable, INotifyPropertyChange
|
||||
_selectedIndex = index;
|
||||
characters.SelectedIndex = _selectedIndex;
|
||||
characterName.Text = _powerAccent.CharacterDescriptions[_selectedIndex];
|
||||
characters.ScrollIntoView(character);
|
||||
}
|
||||
|
||||
private void PowerAccent_OnChangeDisplay(bool isActive, string[] chars)
|
||||
@@ -73,6 +74,7 @@ public partial class Selector : FluentWindow, IDisposable, INotifyPropertyChange
|
||||
characters.ItemsSource = chars;
|
||||
characters.SelectedIndex = _selectedIndex;
|
||||
this.UpdateLayout(); // Required for filling the actual width/height before positioning.
|
||||
SetWindowsSize();
|
||||
SetWindowPosition();
|
||||
Show();
|
||||
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new PowerAccent.Core.Telemetry.PowerAccentShowAccentMenuEvent());
|
||||
@@ -96,6 +98,11 @@ public partial class Selector : FluentWindow, IDisposable, INotifyPropertyChange
|
||||
this.Top = position.Y;
|
||||
}
|
||||
|
||||
private void SetWindowsSize()
|
||||
{
|
||||
this.characters.MaxWidth = _powerAccent.GetDisplayMaxWidth();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
_powerAccent.SaveUsageInfo();
|
||||
|
||||
Binary file not shown.
@@ -638,9 +638,6 @@ Please review the placeholder content that represents the final terms and usage
|
||||
<data name="AdvancedPaste_EnableAIDialogAcceptanceCheckBox.Content" xml:space="preserve">
|
||||
<value>I have read and accept the information above.</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAdvancedAIModerationToggle.Content" xml:space="preserve">
|
||||
<value>Enable OpenAI content moderation</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnablePasteAIModerationToggle.Header" xml:space="preserve">
|
||||
<value>Enable OpenAI content moderation</value>
|
||||
</data>
|
||||
@@ -2092,9 +2089,6 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
|
||||
<data name="TranscodeToMp4.Header" xml:space="preserve">
|
||||
<value>Transcode to .mp4 (H.264/AAC)</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAIDialogOpenAIApiKey.Text" xml:space="preserve">
|
||||
<value>OpenAI API key:</value>
|
||||
</data>
|
||||
<data name="EnableAIDialog_SaveBtnText" xml:space="preserve">
|
||||
<value>Save</value>
|
||||
</data>
|
||||
@@ -4029,7 +4023,7 @@ Activate by holding the key for the character you want to add an accent to, then
|
||||
<comment>Product name: Navigation view item name for Advanced Paste</comment>
|
||||
</data>
|
||||
<data name="AdvancedPaste.ModuleDescription" xml:space="preserve">
|
||||
<value>A tool to quickly format clipboard content into plain text, Markdown, JSON, and more. An AI-powered option requiring an OpenAI API key is available for advanced formatting.</value>
|
||||
<value>Formats clipboard content into plain text, Markdown, JSON, and more. Advanced formatting can use an online or local language model endpoint.</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste.ModuleTitle" xml:space="preserve">
|
||||
<value>Advanced Paste</value>
|
||||
@@ -4559,18 +4553,9 @@ Activate by holding the key for the character you want to add an accent to, then
|
||||
<data name="TermsLink.Text" xml:space="preserve">
|
||||
<value>OpenAI Terms</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAIDialog_Description.Text" xml:space="preserve">
|
||||
<value>Paste with AI allows you to format your clipboard content into any format you need. Learn more about the terms of conditions while using OpenAI and privacy at Microsoft:</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAIDialog_LoginIntoText.Text" xml:space="preserve">
|
||||
<value>• Login into your</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAIDialog_ConfigureOpenAIKey.Text" xml:space="preserve">
|
||||
<value>Configure OpenAI key</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAIDialog_OpenAIApiKeysOverviewText.Text" xml:space="preserve">
|
||||
<value>OpenAI API keys overview</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAIDialog_CreateNewKeyText.Text" xml:space="preserve">
|
||||
<value>• Create a new secret key and paste it in the field below</value>
|
||||
</data>
|
||||
@@ -4588,9 +4573,6 @@ Activate by holding the key for the character you want to add an accent to, then
|
||||
<data name="Peek_SourceCode_FontSize.Header" xml:space="preserve">
|
||||
<value>Font size</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAIDialog_NoteAICreditsText.Text" xml:space="preserve">
|
||||
<value>• NOTE: You need to have available paid credits in your OpenAI account to use this feature. If you do not have credits you will see an 'API key quota exceeded' error</value>
|
||||
</data>
|
||||
<data name="AdvancedPaste_EnableAIDialog_NoteAICreditsErrorText.Text" xml:space="preserve">
|
||||
<value>If you do not have credits you will see an 'API key quota exceeded' error</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user