[AdvancedPaste]Additional actions - Image to text, Paste as file (txt, png, html) (#35167)

* [AdvancedPaste] Additional actions, including Image to text

* Spellcheck issue

* [AdvancedPaste] Paste as file and many other improvements

* Fixed typo

* Fixed typo

* [AdvancedPaste] Improved paste window menu layout

* [AdvancedPaste] Improved settings window layout

* [AdvancedPaste] Removed AudioToText for the moment

* Code cleanup

* Minor fixes

* Changed log-line with potentially sensitive info

* Extra telemetry for AdvancedPaste

* Added 'Hotkey' suffix to AdvancedPaste_Settings telemetry event
This commit is contained in:
Ani
2024-10-18 15:34:09 +02:00
committed by GitHub
parent 14139affc5
commit dd5cd2a570
41 changed files with 1435 additions and 624 deletions

View File

@@ -58,45 +58,44 @@ void Trace::AdvancedPaste_SettingsTelemetry(const PowertoyModuleIface::Hotkey& p
const PowertoyModuleIface::Hotkey& advancedPasteUIHotkey,
const PowertoyModuleIface::Hotkey& pasteMarkdownHotkey,
const PowertoyModuleIface::Hotkey& pasteJsonHotkey,
const bool preview_custom_format_output) noexcept
const bool preview_custom_format_output,
const std::unordered_map<std::wstring, PowertoyModuleIface::Hotkey>& additionalActionsHotkeys) noexcept
{
std::wstring pastePlainHotkeyStr =
std::wstring(pastePlainHotkey.win ? L"Win + " : L"") +
std::wstring(pastePlainHotkey.ctrl ? L"Ctrl + " : L"") +
std::wstring(pastePlainHotkey.shift ? L"Shift + " : L"") +
std::wstring(pastePlainHotkey.alt ? L"Alt + " : L"") +
std::wstring(L"VK ") + std::to_wstring(pastePlainHotkey.key);
const auto getHotKeyStr = [](const PowertoyModuleIface::Hotkey& hotKey)
{
return std::wstring(hotKey.win ? L"Win + " : L"") +
std::wstring(hotKey.ctrl ? L"Ctrl + " : L"") +
std::wstring(hotKey.shift ? L"Shift + " : L"") +
std::wstring(hotKey.alt ? L"Alt + " : L"") +
std::wstring(L"VK ") + std::to_wstring(hotKey.key);
};
std::wstring advancedPasteUIHotkeyStr =
std::wstring(advancedPasteUIHotkey.win ? L"Win + " : L"") +
std::wstring(advancedPasteUIHotkey.ctrl ? L"Ctrl + " : L"") +
std::wstring(advancedPasteUIHotkey.shift ? L"Shift + " : L"") +
std::wstring(advancedPasteUIHotkey.alt ? L"Alt + " : L"") +
std::wstring(L"VK ") + std::to_wstring(advancedPasteUIHotkey.key);
std::vector<std::wstring> hotkeyStrs;
const auto getHotkeyCStr = [&](const PowertoyModuleIface::Hotkey& hotkey)
{
hotkeyStrs.push_back(getHotKeyStr(hotkey)); // Probably unnecessary, but offers protection against the macro TraceLoggingWideString expanding to something that would invalidate the pointer
return hotkeyStrs.back().c_str();
};
std::wstring pasteMarkdownHotkeyStr =
std::wstring(pasteMarkdownHotkey.win ? L"Win + " : L"") +
std::wstring(pasteMarkdownHotkey.ctrl ? L"Ctrl + " : L"") +
std::wstring(pasteMarkdownHotkey.shift ? L"Shift + " : L"") +
std::wstring(pasteMarkdownHotkey.alt ? L"Alt + " : L"") +
std::wstring(L"VK ") + std::to_wstring(pasteMarkdownHotkey.key);
std::wstring pasteJsonHotkeyStr =
std::wstring(pasteJsonHotkey.win ? L"Win + " : L"") +
std::wstring(pasteJsonHotkey.ctrl ? L"Ctrl + " : L"") +
std::wstring(pasteJsonHotkey.shift ? L"Shift + " : L"") +
std::wstring(pasteJsonHotkey.alt ? L"Alt + " : L"") +
std::wstring(L"VK ") + std::to_wstring(pasteJsonHotkey.key);
const auto getAdditionalActionHotkeyCStr = [&](const std::wstring& name)
{
const auto it = additionalActionsHotkeys.find(name);
return it != additionalActionsHotkeys.end() ? getHotkeyCStr(it->second) : L"";
};
TraceLoggingWrite(
g_hProvider,
"AdvancedPaste_Settings",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
TraceLoggingWideString(pastePlainHotkeyStr.c_str(), "PastePlainHotkey"),
TraceLoggingWideString(advancedPasteUIHotkeyStr.c_str(), "AdvancedPasteUIHotkey"),
TraceLoggingWideString(pasteMarkdownHotkeyStr.c_str(), "PasteMarkdownHotkey"),
TraceLoggingWideString(pasteJsonHotkeyStr.c_str(), "PasteJsonHotkey"),
TraceLoggingBoolean(preview_custom_format_output, "ShowCustomPreview")
TraceLoggingWideString(getHotkeyCStr(pastePlainHotkey), "PastePlainHotkey"),
TraceLoggingWideString(getHotkeyCStr(advancedPasteUIHotkey), "AdvancedPasteUIHotkey"),
TraceLoggingWideString(getHotkeyCStr(pasteMarkdownHotkey), "PasteMarkdownHotkey"),
TraceLoggingWideString(getHotkeyCStr(pasteJsonHotkey), "PasteJsonHotkey"),
TraceLoggingBoolean(preview_custom_format_output, "ShowCustomPreview"),
TraceLoggingWideString(getAdditionalActionHotkeyCStr(L"ImageToText"), "ImageToTextHotkey"),
TraceLoggingWideString(getAdditionalActionHotkeyCStr(L"PasteAsTxtFile"), "PasteAsTxtFileHotkey"),
TraceLoggingWideString(getAdditionalActionHotkeyCStr(L"PasteAsPngFile"), "PasteAsPngFileHotkey"),
TraceLoggingWideString(getAdditionalActionHotkeyCStr(L"PasteAsHtmlFile"), "PasteAsHtmlFileHotkey")
);
}