mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
Non localized module name (#7170)
* Added get_key to powertoysmodule interface * Replace get_name with get_key * Implement get_key function in modules * Make key global constant in each module * Update settings v1 to use key to load and save files * Fixed fancyzones and preview pane unit tests * Removed setings unit test as the case is not covered anymore * Add constant files for modules and use it to reference module key * Add constant string files to colorpicker, launcher and shortcut guide * correct sunction signature in settings helper * Fix powerpreview merge conflicts * nit fix with include statement location * add check for fields in from_json_string * Updated preview pane tests with correct from_json_string signature * Correct Image resizer naming * Roll back changes for adding check for property and version * Fix image resizer not working
This commit is contained in:
committed by
GitHub
parent
8b759094f7
commit
280d1907d8
@@ -53,11 +53,12 @@ namespace UnitTestsCommonLib
|
|||||||
private:
|
private:
|
||||||
const std::wstring m_json = L"{\"name\":\"Module Name\",\"properties\" : {\"bool_toggle_true\":{\"value\":true},\"bool_toggle_false\":{\"value\":false},\"color_picker\" : {\"value\":\"#ff8d12\"},\"int_spinner\" : {\"value\":10},\"string_text\" : {\"value\":\"a quick fox\"}},\"version\" : \"1.0\" }";
|
const std::wstring m_json = L"{\"name\":\"Module Name\",\"properties\" : {\"bool_toggle_true\":{\"value\":true},\"bool_toggle_false\":{\"value\":false},\"color_picker\" : {\"value\":\"#ff8d12\"},\"int_spinner\" : {\"value\":10},\"string_text\" : {\"value\":\"a quick fox\"}},\"version\" : \"1.0\" }";
|
||||||
const std::wstring m_moduleName = L"Module Name";
|
const std::wstring m_moduleName = L"Module Name";
|
||||||
|
const std::wstring m_moduleKey = L"Module Key";
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TEST_METHOD (LoadFromJsonBoolTrue)
|
TEST_METHOD (LoadFromJsonBoolTrue)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(m_json);
|
PowerToyValues values = PowerToyValues::from_json_string(m_json, m_moduleKey);
|
||||||
auto value = values.get_bool_value(L"bool_toggle_true");
|
auto value = values.get_bool_value(L"bool_toggle_true");
|
||||||
Assert::IsTrue(value.has_value());
|
Assert::IsTrue(value.has_value());
|
||||||
Assert::AreEqual(true, *value);
|
Assert::AreEqual(true, *value);
|
||||||
@@ -65,7 +66,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (LoadFromJsonBoolFalse)
|
TEST_METHOD (LoadFromJsonBoolFalse)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(m_json);
|
PowerToyValues values = PowerToyValues::from_json_string(m_json, m_moduleKey);
|
||||||
auto value = values.get_bool_value(L"bool_toggle_false");
|
auto value = values.get_bool_value(L"bool_toggle_false");
|
||||||
Assert::IsTrue(value.has_value());
|
Assert::IsTrue(value.has_value());
|
||||||
Assert::AreEqual(false, *value);
|
Assert::AreEqual(false, *value);
|
||||||
@@ -73,7 +74,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (LoadFromJsonInt)
|
TEST_METHOD (LoadFromJsonInt)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(m_json);
|
PowerToyValues values = PowerToyValues::from_json_string(m_json, m_moduleKey);
|
||||||
auto value = values.get_int_value(L"int_spinner");
|
auto value = values.get_int_value(L"int_spinner");
|
||||||
Assert::IsTrue(value.has_value());
|
Assert::IsTrue(value.has_value());
|
||||||
Assert::AreEqual(10, *value);
|
Assert::AreEqual(10, *value);
|
||||||
@@ -81,7 +82,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (LoadFromJsonString)
|
TEST_METHOD (LoadFromJsonString)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(m_json);
|
PowerToyValues values = PowerToyValues::from_json_string(m_json, m_moduleKey);
|
||||||
auto value = values.get_string_value(L"string_text");
|
auto value = values.get_string_value(L"string_text");
|
||||||
|
|
||||||
Assert::IsTrue(value.has_value());
|
Assert::IsTrue(value.has_value());
|
||||||
@@ -91,7 +92,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (LoadFromJsonColorPicker)
|
TEST_METHOD (LoadFromJsonColorPicker)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(m_json);
|
PowerToyValues values = PowerToyValues::from_json_string(m_json, m_moduleKey);
|
||||||
auto value = values.get_string_value(L"color_picker");
|
auto value = values.get_string_value(L"color_picker");
|
||||||
|
|
||||||
Assert::IsTrue(value.has_value());
|
Assert::IsTrue(value.has_value());
|
||||||
@@ -101,19 +102,19 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (LoadFromEmptyString)
|
TEST_METHOD (LoadFromEmptyString)
|
||||||
{
|
{
|
||||||
auto func = [] { PowerToyValues values = PowerToyValues::from_json_string(L""); };
|
auto func = [] { PowerToyValues values = PowerToyValues::from_json_string(L"", L"Module Key"); };
|
||||||
Assert::ExpectException<winrt::hresult_error>(func);
|
Assert::ExpectException<winrt::hresult_error>(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD (LoadFromInvalidString_NameMissed)
|
TEST_METHOD (LoadFromInvalidString_NameMissed)
|
||||||
{
|
{
|
||||||
auto func = [] { PowerToyValues values = PowerToyValues::from_json_string(L"{\"properties\" : {\"bool_toggle_true\":{\"value\":true},\"bool_toggle_false\":{\"value\":false},\"color_picker\" : {\"value\":\"#ff8d12\"},\"int_spinner\" : {\"value\":10},\"string_text\" : {\"value\":\"a quick fox\"}},\"version\" : \"1.0\" }"); };
|
auto func = [] { PowerToyValues values = PowerToyValues::from_json_string(L"{\"properties\" : {\"bool_toggle_true\":{\"value\":true},\"bool_toggle_false\":{\"value\":false},\"color_picker\" : {\"value\":\"#ff8d12\"},\"int_spinner\" : {\"value\":10},\"string_text\" : {\"value\":\"a quick fox\"}},\"version\" : \"1.0\" }", L"Module Key"); };
|
||||||
Assert::ExpectException<winrt::hresult_error>(func);
|
Assert::ExpectException<winrt::hresult_error>(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD (LoadFromInvalidString_VersionMissed)
|
TEST_METHOD (LoadFromInvalidString_VersionMissed)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\",\"properties\" : {}}");
|
PowerToyValues values = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\",\"properties\" : {}}", L"Module Key");
|
||||||
const std::wstring expectedStr = L"{\"name\" : \"Module Name\", \"properties\" : {},\"version\" : \"1.0\"}";
|
const std::wstring expectedStr = L"{\"name\" : \"Module Name\", \"properties\" : {},\"version\" : \"1.0\"}";
|
||||||
const auto expected = json::JsonObject::Parse(expectedStr);
|
const auto expected = json::JsonObject::Parse(expectedStr);
|
||||||
const auto actual = json::JsonObject::Parse(values.serialize());
|
const auto actual = json::JsonObject::Parse(values.serialize());
|
||||||
@@ -123,7 +124,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (LoadFromInvalidString_PropertiesMissed)
|
TEST_METHOD (LoadFromInvalidString_PropertiesMissed)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\",\"version\" : \"1.0\" }");
|
PowerToyValues values = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\",\"version\" : \"1.0\" }", L"Module Key");
|
||||||
const std::wstring expectedStr = L"{\"name\":\"Module Name\",\"version\" : \"1.0\" }";
|
const std::wstring expectedStr = L"{\"name\":\"Module Name\",\"version\" : \"1.0\" }";
|
||||||
const auto expected = json::JsonObject::Parse(expectedStr);
|
const auto expected = json::JsonObject::Parse(expectedStr);
|
||||||
const auto actual = json::JsonObject::Parse(values.serialize());
|
const auto actual = json::JsonObject::Parse(values.serialize());
|
||||||
@@ -133,7 +134,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (LoadFromValidString_EmptyProperties)
|
TEST_METHOD (LoadFromValidString_EmptyProperties)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\",\"properties\" : {}, \"version\" : \"1.0\" }");
|
PowerToyValues values = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\",\"properties\" : {}, \"version\" : \"1.0\" }", L"Module Key");
|
||||||
const std::wstring expectedStr = L"{\"name\":\"Module Name\",\"properties\" : {},\"version\" : \"1.0\" }";
|
const std::wstring expectedStr = L"{\"name\":\"Module Name\",\"properties\" : {},\"version\" : \"1.0\" }";
|
||||||
const auto expected = json::JsonObject::Parse(expectedStr);
|
const auto expected = json::JsonObject::Parse(expectedStr);
|
||||||
const auto actual = json::JsonObject::Parse(values.serialize());
|
const auto actual = json::JsonObject::Parse(values.serialize());
|
||||||
@@ -143,7 +144,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (LoadFromValidString_ChangedVersion)
|
TEST_METHOD (LoadFromValidString_ChangedVersion)
|
||||||
{
|
{
|
||||||
PowerToyValues values = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\",\"properties\" : {},\"version\" : \"2.0\"}");
|
PowerToyValues values = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\",\"properties\" : {},\"version\" : \"2.0\"}", L"Module Key");
|
||||||
const std::wstring expectedStr = L"{\"name\" : \"Module Name\", \"properties\" : {},\"version\" : \"1.0\"}"; //version from input json is ignored
|
const std::wstring expectedStr = L"{\"name\" : \"Module Name\", \"properties\" : {},\"version\" : \"1.0\"}"; //version from input json is ignored
|
||||||
|
|
||||||
const auto expected = json::JsonObject::Parse(expectedStr);
|
const auto expected = json::JsonObject::Parse(expectedStr);
|
||||||
@@ -154,7 +155,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (CreateWithName)
|
TEST_METHOD (CreateWithName)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
const std::wstring expectedStr = L"{\"name\":\"Module Name\",\"properties\" : {},\"version\" : \"1.0\" }";
|
const std::wstring expectedStr = L"{\"name\":\"Module Name\",\"properties\" : {},\"version\" : \"1.0\" }";
|
||||||
|
|
||||||
const auto expected = json::JsonObject::Parse(expectedStr);
|
const auto expected = json::JsonObject::Parse(expectedStr);
|
||||||
@@ -165,7 +166,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyBoolPositive)
|
TEST_METHOD (AddPropertyBoolPositive)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property<bool>(L"positive_bool_value", true);
|
values.add_property<bool>(L"positive_bool_value", true);
|
||||||
|
|
||||||
auto value = values.get_bool_value(L"positive_bool_value");
|
auto value = values.get_bool_value(L"positive_bool_value");
|
||||||
@@ -175,7 +176,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyBoolNegative)
|
TEST_METHOD (AddPropertyBoolNegative)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property<bool>(L"negative_bool_value", false);
|
values.add_property<bool>(L"negative_bool_value", false);
|
||||||
|
|
||||||
auto value = values.get_bool_value(L"negative_bool_value");
|
auto value = values.get_bool_value(L"negative_bool_value");
|
||||||
@@ -185,7 +186,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyIntPositive)
|
TEST_METHOD (AddPropertyIntPositive)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
const int intVal = 4392854;
|
const int intVal = 4392854;
|
||||||
values.add_property<int>(L"integer", intVal);
|
values.add_property<int>(L"integer", intVal);
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyIntNegative)
|
TEST_METHOD (AddPropertyIntNegative)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
const int intVal = -4392854;
|
const int intVal = -4392854;
|
||||||
values.add_property<int>(L"integer", intVal);
|
values.add_property<int>(L"integer", intVal);
|
||||||
|
|
||||||
@@ -207,7 +208,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyIntZero)
|
TEST_METHOD (AddPropertyIntZero)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
const int intVal = 0;
|
const int intVal = 0;
|
||||||
values.add_property<int>(L"integer", intVal);
|
values.add_property<int>(L"integer", intVal);
|
||||||
|
|
||||||
@@ -218,7 +219,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyStringEmpty)
|
TEST_METHOD (AddPropertyStringEmpty)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
const std::wstring stringVal = L"";
|
const std::wstring stringVal = L"";
|
||||||
values.add_property<std::wstring>(L"stringval", stringVal);
|
values.add_property<std::wstring>(L"stringval", stringVal);
|
||||||
|
|
||||||
@@ -229,7 +230,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyString)
|
TEST_METHOD (AddPropertyString)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
const std::wstring stringVal = L"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
|
const std::wstring stringVal = L"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
|
||||||
values.add_property<std::wstring>(L"stringval", stringVal);
|
values.add_property<std::wstring>(L"stringval", stringVal);
|
||||||
|
|
||||||
@@ -240,7 +241,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyJsonEmpty)
|
TEST_METHOD (AddPropertyJsonEmpty)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
const auto json = json::JsonObject();
|
const auto json = json::JsonObject();
|
||||||
values.add_property<json::JsonObject>(L"jsonval", json);
|
values.add_property<json::JsonObject>(L"jsonval", json);
|
||||||
|
|
||||||
@@ -251,7 +252,7 @@ namespace UnitTestsCommonLib
|
|||||||
|
|
||||||
TEST_METHOD (AddPropertyJsonObject)
|
TEST_METHOD (AddPropertyJsonObject)
|
||||||
{
|
{
|
||||||
PowerToyValues values(m_moduleName);
|
PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
const auto json = json::JsonObject::Parse(m_json);
|
const auto json = json::JsonObject::Parse(m_json);
|
||||||
values.add_property<json::JsonObject>(L"jsonval", json);
|
values.add_property<json::JsonObject>(L"jsonval", json);
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ namespace PTSettingsHelper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring get_module_save_folder_location(std::wstring_view powertoy_name)
|
std::wstring get_module_save_folder_location(std::wstring_view powertoy_key)
|
||||||
{
|
{
|
||||||
std::wstring result = get_root_save_folder_location();
|
std::wstring result = get_root_save_folder_location();
|
||||||
result += L"\\";
|
result += L"\\";
|
||||||
result += powertoy_name;
|
result += powertoy_key;
|
||||||
std::filesystem::path save_path(result);
|
std::filesystem::path save_path(result);
|
||||||
if (!std::filesystem::exists(save_path))
|
if (!std::filesystem::exists(save_path))
|
||||||
{
|
{
|
||||||
@@ -36,9 +36,9 @@ namespace PTSettingsHelper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring get_module_save_file_location(std::wstring_view powertoy_name)
|
std::wstring get_module_save_file_location(std::wstring_view powertoy_key)
|
||||||
{
|
{
|
||||||
return get_module_save_folder_location(powertoy_name) + settings_filename;
|
return get_module_save_folder_location(powertoy_key) + settings_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring get_powertoys_general_save_file_location()
|
std::wstring get_powertoys_general_save_file_location()
|
||||||
@@ -46,15 +46,15 @@ namespace PTSettingsHelper
|
|||||||
return get_root_save_folder_location() + settings_filename;
|
return get_root_save_folder_location() + settings_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_module_settings(std::wstring_view powertoy_name, json::JsonObject& settings)
|
void save_module_settings(std::wstring_view powertoy_key, json::JsonObject& settings)
|
||||||
{
|
{
|
||||||
const std::wstring save_file_location = get_module_save_file_location(powertoy_name);
|
const std::wstring save_file_location = get_module_save_file_location(powertoy_key);
|
||||||
json::to_file(save_file_location, settings);
|
json::to_file(save_file_location, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
json::JsonObject load_module_settings(std::wstring_view powertoy_name)
|
json::JsonObject load_module_settings(std::wstring_view powertoy_key)
|
||||||
{
|
{
|
||||||
const std::wstring save_file_location = get_module_save_file_location(powertoy_name);
|
const std::wstring save_file_location = get_module_save_file_location(powertoy_key);
|
||||||
auto saved_settings = json::from_file(save_file_location);
|
auto saved_settings = json::from_file(save_file_location);
|
||||||
return saved_settings.has_value() ? std::move(*saved_settings) : json::JsonObject{};
|
return saved_settings.has_value() ? std::move(*saved_settings) : json::JsonObject{};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "settings_objects.h"
|
#include "settings_objects.h"
|
||||||
#include "settings_helpers.h"
|
#include "settings_helpers.h"
|
||||||
|
#include <winrt/base.h>
|
||||||
|
|
||||||
namespace PowerToysSettings
|
namespace PowerToysSettings
|
||||||
{
|
{
|
||||||
@@ -277,27 +278,33 @@ namespace PowerToysSettings
|
|||||||
return L"RESOURCE ID NOT FOUND: " + std::to_wstring(resource_id);
|
return L"RESOURCE ID NOT FOUND: " + std::to_wstring(resource_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerToyValues::PowerToyValues(std::wstring_view powertoy_name)
|
PowerToyValues::PowerToyValues(std::wstring_view powertoy_name, std::wstring_view powertoy_key)
|
||||||
{
|
{
|
||||||
_name = powertoy_name;
|
_key = powertoy_key;
|
||||||
set_version();
|
set_version();
|
||||||
m_json.SetNamedValue(L"name", json::value(powertoy_name));
|
m_json.SetNamedValue(L"name", json::value(powertoy_name));
|
||||||
m_json.SetNamedValue(L"properties", json::JsonObject{});
|
m_json.SetNamedValue(L"properties", json::JsonObject{});
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerToyValues PowerToyValues::from_json_string(std::wstring_view json)
|
PowerToyValues PowerToyValues::from_json_string(std::wstring_view json, std::wstring_view powertoy_key)
|
||||||
{
|
{
|
||||||
PowerToyValues result = PowerToyValues();
|
PowerToyValues result = PowerToyValues();
|
||||||
|
json::JsonObject jsonObject = json::JsonValue::Parse(json).GetObjectW();
|
||||||
|
if (!jsonObject.HasKey(L"name"))
|
||||||
|
{
|
||||||
|
throw winrt::hresult_error(E_NOT_SET, L"name field not set");
|
||||||
|
}
|
||||||
|
|
||||||
result.m_json = json::JsonValue::Parse(json).GetObjectW();
|
result.m_json = json::JsonValue::Parse(json).GetObjectW();
|
||||||
result._name = result.m_json.GetNamedString(L"name");
|
result._key = powertoy_key;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerToyValues PowerToyValues::load_from_settings_file(std::wstring_view powertoy_name)
|
PowerToyValues PowerToyValues::load_from_settings_file(std::wstring_view powertoy_key)
|
||||||
{
|
{
|
||||||
PowerToyValues result = PowerToyValues();
|
PowerToyValues result = PowerToyValues();
|
||||||
result.m_json = PTSettingsHelper::load_module_settings(powertoy_name);
|
result.m_json = PTSettingsHelper::load_module_settings(powertoy_key);
|
||||||
result._name = powertoy_name;
|
result._key = powertoy_key;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +364,7 @@ namespace PowerToysSettings
|
|||||||
void PowerToyValues::save_to_settings_file()
|
void PowerToyValues::save_to_settings_file()
|
||||||
{
|
{
|
||||||
set_version();
|
set_version();
|
||||||
PTSettingsHelper::save_module_settings(_name, m_json);
|
PTSettingsHelper::save_module_settings(_key, m_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerToyValues::set_version()
|
void PowerToyValues::set_version()
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ namespace PowerToysSettings
|
|||||||
class PowerToyValues
|
class PowerToyValues
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PowerToyValues(std::wstring_view powertoy_name);
|
PowerToyValues(std::wstring_view powertoy_name, std::wstring_view powertoy_key);
|
||||||
static PowerToyValues from_json_string(std::wstring_view json);
|
static PowerToyValues from_json_string(std::wstring_view json, std::wstring_view powertoy_key);
|
||||||
static PowerToyValues load_from_settings_file(std::wstring_view powertoy_name);
|
static PowerToyValues load_from_settings_file(std::wstring_view powertoy_key);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void add_property(std::wstring_view name, T value)
|
inline void add_property(std::wstring_view name, T value)
|
||||||
@@ -92,7 +92,7 @@ namespace PowerToysSettings
|
|||||||
const std::wstring m_version = L"1.0";
|
const std::wstring m_version = L"1.0";
|
||||||
void set_version();
|
void set_version();
|
||||||
json::JsonObject m_json;
|
json::JsonObject m_json;
|
||||||
std::wstring _name;
|
std::wstring _key;
|
||||||
PowerToyValues() {}
|
PowerToyValues() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="ColorPickerConstants.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<None Include="resource.base.h" />
|
<None Include="resource.base.h" />
|
||||||
<ClInclude Include="trace.h" />
|
<ClInclude Include="trace.h" />
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace ColorPickerConstants
|
||||||
|
{
|
||||||
|
// Name of the powertoy module.
|
||||||
|
inline const std::wstring ModuleKey = L"ColorPicker";
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "Generated Files/resource.h"
|
#include "Generated Files/resource.h"
|
||||||
#include <common\settings_objects.h>
|
#include <common\settings_objects.h>
|
||||||
#include <common\os-detect.h>
|
#include <common\os-detect.h>
|
||||||
|
#include <colorPicker\ColorPicker\ColorPickerConstants.h>
|
||||||
|
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
|
||||||
@@ -38,6 +39,9 @@ private:
|
|||||||
|
|
||||||
std::wstring app_name;
|
std::wstring app_name;
|
||||||
|
|
||||||
|
//contains the non localized key of the powertoy
|
||||||
|
std::wstring app_key;
|
||||||
|
|
||||||
HANDLE m_hProcess;
|
HANDLE m_hProcess;
|
||||||
|
|
||||||
// Time to wait for process to close after sending WM_CLOSE signal
|
// Time to wait for process to close after sending WM_CLOSE signal
|
||||||
@@ -47,6 +51,7 @@ public:
|
|||||||
ColorPicker()
|
ColorPicker()
|
||||||
{
|
{
|
||||||
app_name = GET_RESOURCE_STRING(IDS_COLORPICKER_NAME);
|
app_name = GET_RESOURCE_STRING(IDS_COLORPICKER_NAME);
|
||||||
|
app_key = ColorPickerConstants::ModuleKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ColorPicker()
|
~ColorPicker()
|
||||||
@@ -63,12 +68,18 @@ public:
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the display name of the powertoy, this will be cached by the runner
|
// Return the localized display name of the powertoy
|
||||||
virtual const wchar_t* get_name() override
|
virtual const wchar_t* get_name() override
|
||||||
{
|
{
|
||||||
return app_name.c_str();
|
return app_name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
virtual const wchar_t* get_key() override
|
||||||
|
{
|
||||||
|
return app_key.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||||
{
|
{
|
||||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||||
@@ -92,7 +103,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse the input JSON string.
|
// Parse the input JSON string.
|
||||||
PowerToysSettings::PowerToyValues values =
|
PowerToysSettings::PowerToyValues values =
|
||||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
|
||||||
|
|
||||||
// If you don't need to do any custom processing of the settings, proceed
|
// If you don't need to do any custom processing of the settings, proceed
|
||||||
// to persists the values calling:
|
// to persists the values calling:
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <lib/FancyZones.h>
|
#include <lib/FancyZones.h>
|
||||||
#include <lib/FancyZonesData.h>
|
#include <lib/FancyZonesData.h>
|
||||||
#include <lib/FancyZonesWinHookEventIDs.h>
|
#include <lib/FancyZonesWinHookEventIDs.h>
|
||||||
|
#include <lib/FancyZonesData.cpp>
|
||||||
|
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
|
||||||
@@ -37,12 +38,18 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
class FancyZonesModule : public PowertoyModuleIface
|
class FancyZonesModule : public PowertoyModuleIface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Return the display name of the powertoy, this will be cached
|
// Return the localized display name of the powertoy
|
||||||
virtual PCWSTR get_name() override
|
virtual PCWSTR get_name() override
|
||||||
{
|
{
|
||||||
return app_name.c_str();
|
return app_name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
virtual const wchar_t* get_key() override
|
||||||
|
{
|
||||||
|
return app_key.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Return JSON with the configuration options.
|
// Return JSON with the configuration options.
|
||||||
// These are the settings shown on the settings page along with their current values.
|
// These are the settings shown on the settings page along with their current values.
|
||||||
virtual bool get_config(_Out_ PWSTR buffer, _Out_ int* buffer_size) override
|
virtual bool get_config(_Out_ PWSTR buffer, _Out_ int* buffer_size) override
|
||||||
@@ -142,7 +149,8 @@ public:
|
|||||||
FancyZonesModule()
|
FancyZonesModule()
|
||||||
{
|
{
|
||||||
app_name = GET_RESOURCE_STRING(IDS_FANCYZONES);
|
app_name = GET_RESOURCE_STRING(IDS_FANCYZONES);
|
||||||
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), FancyZonesModule::get_name());
|
app_key = NonLocalizable::FancyZonesStr;
|
||||||
|
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), FancyZonesModule::get_name(), FancyZonesModule::get_key());
|
||||||
FancyZonesDataInstance().LoadFancyZonesData();
|
FancyZonesDataInstance().LoadFancyZonesData();
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
}
|
}
|
||||||
@@ -190,6 +198,8 @@ private:
|
|||||||
winrt::com_ptr<IFancyZones> m_app;
|
winrt::com_ptr<IFancyZones> m_app;
|
||||||
winrt::com_ptr<IFancyZonesSettings> m_settings;
|
winrt::com_ptr<IFancyZonesSettings> m_settings;
|
||||||
std::wstring app_name;
|
std::wstring app_name;
|
||||||
|
//contains the non localized key of the powertoy
|
||||||
|
std::wstring app_key;
|
||||||
|
|
||||||
static inline FancyZonesModule* s_instance;
|
static inline FancyZonesModule* s_instance;
|
||||||
static inline HHOOK s_llKeyboardHook;
|
static inline HHOOK s_llKeyboardHook;
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ namespace NonLocalizable
|
|||||||
struct FancyZonesSettings : winrt::implements<FancyZonesSettings, IFancyZonesSettings>
|
struct FancyZonesSettings : winrt::implements<FancyZonesSettings, IFancyZonesSettings>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FancyZonesSettings(HINSTANCE hinstance, PCWSTR name)
|
FancyZonesSettings(HINSTANCE hinstance, PCWSTR name, PCWSTR key)
|
||||||
: m_hinstance(hinstance)
|
: m_hinstance(hinstance),
|
||||||
, m_moduleName(name)
|
m_moduleName(name),
|
||||||
|
m_moduleKey(key)
|
||||||
{
|
{
|
||||||
LoadSettings(name, true);
|
LoadSettings(name, true);
|
||||||
}
|
}
|
||||||
@@ -64,6 +65,7 @@ private:
|
|||||||
IFancyZonesCallback* m_callback{};
|
IFancyZonesCallback* m_callback{};
|
||||||
const HINSTANCE m_hinstance;
|
const HINSTANCE m_hinstance;
|
||||||
PCWSTR m_moduleName{};
|
PCWSTR m_moduleName{};
|
||||||
|
PCWSTR m_moduleKey{};
|
||||||
|
|
||||||
Settings m_settings;
|
Settings m_settings;
|
||||||
|
|
||||||
@@ -171,8 +173,8 @@ void FancyZonesSettings::LoadSettings(PCWSTR config, bool fromFile) noexcept
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
PowerToysSettings::PowerToyValues values = fromFile ?
|
PowerToysSettings::PowerToyValues values = fromFile ?
|
||||||
PowerToysSettings::PowerToyValues::load_from_settings_file(m_moduleName) :
|
PowerToysSettings::PowerToyValues::load_from_settings_file(m_moduleKey) :
|
||||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
PowerToysSettings::PowerToyValues::from_json_string(config, m_moduleKey);
|
||||||
|
|
||||||
for (auto const& setting : m_configBools)
|
for (auto const& setting : m_configBools)
|
||||||
{
|
{
|
||||||
@@ -244,7 +246,7 @@ void FancyZonesSettings::SaveSettings() noexcept
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
|
|
||||||
for (auto const& setting : m_configBools)
|
for (auto const& setting : m_configBools)
|
||||||
{
|
{
|
||||||
@@ -271,7 +273,7 @@ void FancyZonesSettings::SaveSettings() noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
winrt::com_ptr<IFancyZonesSettings> MakeFancyZonesSettings(HINSTANCE hinstance, PCWSTR name) noexcept
|
winrt::com_ptr<IFancyZonesSettings> MakeFancyZonesSettings(HINSTANCE hinstance, PCWSTR name, PCWSTR key) noexcept
|
||||||
{
|
{
|
||||||
return winrt::make_self<FancyZonesSettings>(hinstance, name);
|
return winrt::make_self<FancyZonesSettings>(hinstance, name, key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,4 +49,4 @@ interface __declspec(uuid("{BA4E77C4-6F44-4C5D-93D3-CBDE880495C2}")) IFancyZones
|
|||||||
IFACEMETHOD_(const Settings*, GetSettings)() const = 0;
|
IFACEMETHOD_(const Settings*, GetSettings)() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
winrt::com_ptr<IFancyZonesSettings> MakeFancyZonesSettings(HINSTANCE hinstance, PCWSTR config) noexcept;
|
winrt::com_ptr<IFancyZonesSettings> MakeFancyZonesSettings(HINSTANCE hinstance, PCWSTR name, PCWSTR key) noexcept;
|
||||||
@@ -17,11 +17,12 @@ namespace FancyZonesUnitTests
|
|||||||
HINSTANCE m_hInst;
|
HINSTANCE m_hInst;
|
||||||
winrt::com_ptr<IFancyZonesSettings> m_settings;
|
winrt::com_ptr<IFancyZonesSettings> m_settings;
|
||||||
const std::wstring_view m_moduleName = L"FancyZonesUnitTests";
|
const std::wstring_view m_moduleName = L"FancyZonesUnitTests";
|
||||||
|
const std::wstring_view m_modulekey = L"FancyZonesUnitTests";
|
||||||
|
|
||||||
TEST_METHOD_INITIALIZE(Init)
|
TEST_METHOD_INITIALIZE(Init)
|
||||||
{
|
{
|
||||||
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
||||||
m_settings = MakeFancyZonesSettings(m_hInst, m_moduleName.data());
|
m_settings = MakeFancyZonesSettings(m_hInst, m_moduleName.data(), m_modulekey.data());
|
||||||
Assert::IsTrue(m_settings != nullptr);
|
Assert::IsTrue(m_settings != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +58,8 @@ namespace FancyZonesUnitTests
|
|||||||
TEST_CLASS (FancyZonesIZoneWindowHostUnitTests)
|
TEST_CLASS (FancyZonesIZoneWindowHostUnitTests)
|
||||||
{
|
{
|
||||||
HINSTANCE m_hInst{};
|
HINSTANCE m_hInst{};
|
||||||
std::wstring m_settingsLocation = L"FancyZonesUnitTests";
|
std::wstring m_moduleName = L"FancyZonesUnitTests";
|
||||||
|
std::wstring m_moduleKey = L"FancyZonesUnitTests";
|
||||||
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
||||||
winrt::com_ptr<IZoneWindowHost> m_zoneWindowHost = nullptr;
|
winrt::com_ptr<IZoneWindowHost> m_zoneWindowHost = nullptr;
|
||||||
|
|
||||||
@@ -92,7 +94,7 @@ namespace FancyZonesUnitTests
|
|||||||
TEST_METHOD_INITIALIZE(Init)
|
TEST_METHOD_INITIALIZE(Init)
|
||||||
{
|
{
|
||||||
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
||||||
m_settings = MakeFancyZonesSettings(m_hInst, m_settingsLocation.c_str());
|
m_settings = MakeFancyZonesSettings(m_hInst, m_moduleName.c_str(), m_moduleKey.c_str());
|
||||||
Assert::IsTrue(m_settings != nullptr);
|
Assert::IsTrue(m_settings != nullptr);
|
||||||
|
|
||||||
auto fancyZones = MakeFancyZones(m_hInst, m_settings, nullptr);
|
auto fancyZones = MakeFancyZones(m_hInst, m_settings, nullptr);
|
||||||
@@ -104,7 +106,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
TEST_METHOD_CLEANUP(Cleanup)
|
TEST_METHOD_CLEANUP(Cleanup)
|
||||||
{
|
{
|
||||||
auto settingsFolder = PTSettingsHelper::get_module_save_folder_location(m_settingsLocation);
|
auto settingsFolder = PTSettingsHelper::get_module_save_folder_location(m_moduleName);
|
||||||
const auto settingsFile = settingsFolder + L"\\settings.json";
|
const auto settingsFile = settingsFolder + L"\\settings.json";
|
||||||
std::filesystem::remove(settingsFile);
|
std::filesystem::remove(settingsFile);
|
||||||
std::filesystem::remove(settingsFolder);
|
std::filesystem::remove(settingsFolder);
|
||||||
@@ -279,7 +281,8 @@ namespace FancyZonesUnitTests
|
|||||||
TEST_CLASS (FancyZonesIFancyZonesCallbackUnitTests)
|
TEST_CLASS (FancyZonesIFancyZonesCallbackUnitTests)
|
||||||
{
|
{
|
||||||
HINSTANCE m_hInst{};
|
HINSTANCE m_hInst{};
|
||||||
std::wstring m_settingsLocation = L"FancyZonesUnitTests";
|
std::wstring m_moduleName = L"FancyZonesUnitTests";
|
||||||
|
std::wstring m_moduleKey = L"FancyZonesUnitTests";
|
||||||
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
||||||
winrt::com_ptr<IFancyZonesCallback> m_fzCallback = nullptr;
|
winrt::com_ptr<IFancyZonesCallback> m_fzCallback = nullptr;
|
||||||
|
|
||||||
@@ -328,7 +331,7 @@ namespace FancyZonesUnitTests
|
|||||||
TEST_METHOD_INITIALIZE(Init)
|
TEST_METHOD_INITIALIZE(Init)
|
||||||
{
|
{
|
||||||
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
||||||
m_settings = MakeFancyZonesSettings(m_hInst, m_settingsLocation.c_str());
|
m_settings = MakeFancyZonesSettings(m_hInst, m_moduleName.c_str(), m_moduleKey.c_str());
|
||||||
Assert::IsTrue(m_settings != nullptr);
|
Assert::IsTrue(m_settings != nullptr);
|
||||||
|
|
||||||
auto fancyZones = MakeFancyZones(m_hInst, m_settings, nullptr);
|
auto fancyZones = MakeFancyZones(m_hInst, m_settings, nullptr);
|
||||||
@@ -346,7 +349,7 @@ namespace FancyZonesUnitTests
|
|||||||
sendKeyboardInput(VK_LWIN, true);
|
sendKeyboardInput(VK_LWIN, true);
|
||||||
sendKeyboardInput(VK_CONTROL, true);
|
sendKeyboardInput(VK_CONTROL, true);
|
||||||
|
|
||||||
auto settingsFolder = PTSettingsHelper::get_module_save_folder_location(m_settingsLocation);
|
auto settingsFolder = PTSettingsHelper::get_module_save_folder_location(m_moduleName);
|
||||||
const auto settingsFile = settingsFolder + L"\\settings.json";
|
const auto settingsFile = settingsFolder + L"\\settings.json";
|
||||||
std::filesystem::remove(settingsFile);
|
std::filesystem::remove(settingsFile);
|
||||||
std::filesystem::remove(settingsFolder);
|
std::filesystem::remove(settingsFolder);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ namespace FancyZonesUnitTests
|
|||||||
{
|
{
|
||||||
HINSTANCE m_hInst;
|
HINSTANCE m_hInst;
|
||||||
PCWSTR m_moduleName = L"FancyZonesUnitTests";
|
PCWSTR m_moduleName = L"FancyZonesUnitTests";
|
||||||
|
PCWSTR m_moduleKey = L"FancyZonesUnitTests";
|
||||||
std::wstring m_tmpName;
|
std::wstring m_tmpName;
|
||||||
|
|
||||||
const PowerToysSettings::HotkeyObject m_defaultHotkeyObject = PowerToysSettings::HotkeyObject::from_settings(true, false, false, false, VK_OEM_3);
|
const PowerToysSettings::HotkeyObject m_defaultHotkeyObject = PowerToysSettings::HotkeyObject::from_settings(true, false, false, false, VK_OEM_3);
|
||||||
@@ -76,7 +77,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
TEST_METHOD (CreateWithHinstanceDefault)
|
TEST_METHOD (CreateWithHinstanceDefault)
|
||||||
{
|
{
|
||||||
auto actual = MakeFancyZonesSettings({}, m_moduleName);
|
auto actual = MakeFancyZonesSettings({}, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -85,7 +86,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
TEST_METHOD (CreateWithHinstanceNullptr)
|
TEST_METHOD (CreateWithHinstanceNullptr)
|
||||||
{
|
{
|
||||||
auto actual = MakeFancyZonesSettings(nullptr, m_moduleName);
|
auto actual = MakeFancyZonesSettings(nullptr, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -94,7 +95,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
TEST_METHOD (CreateWithNameEmpty)
|
TEST_METHOD (CreateWithNameEmpty)
|
||||||
{
|
{
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, L"");
|
auto actual = MakeFancyZonesSettings(m_hInst, L"", m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -106,7 +107,7 @@ namespace FancyZonesUnitTests
|
|||||||
//prepare data
|
//prepare data
|
||||||
const Settings expected;
|
const Settings expected;
|
||||||
|
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
||||||
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
||||||
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
||||||
@@ -131,7 +132,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
values.save_to_settings_file();
|
values.save_to_settings_file();
|
||||||
|
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -146,7 +147,7 @@ namespace FancyZonesUnitTests
|
|||||||
.excludedAppsArray = { L"APP", L"APP1", L"APP2", L"ANOTHER APP" },
|
.excludedAppsArray = { L"APP", L"APP1", L"APP2", L"ANOTHER APP" },
|
||||||
};
|
};
|
||||||
|
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
||||||
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
||||||
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
||||||
@@ -171,7 +172,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
values.save_to_settings_file();
|
values.save_to_settings_file();
|
||||||
|
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -205,7 +206,7 @@ namespace FancyZonesUnitTests
|
|||||||
.excludedAppsArray = { L"APP" },
|
.excludedAppsArray = { L"APP" },
|
||||||
};
|
};
|
||||||
|
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property(L"fancyzones_zoneColor", expected.zoneColor);
|
values.add_property(L"fancyzones_zoneColor", expected.zoneColor);
|
||||||
values.add_property(L"fancyzones_zoneBorderColor", expected.zoneBorderColor);
|
values.add_property(L"fancyzones_zoneBorderColor", expected.zoneBorderColor);
|
||||||
values.add_property(L"fancyzones_zoneHighlightColor", expected.zoneHighlightColor);
|
values.add_property(L"fancyzones_zoneHighlightColor", expected.zoneHighlightColor);
|
||||||
@@ -215,7 +216,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
values.save_to_settings_file();
|
values.save_to_settings_file();
|
||||||
|
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -227,7 +228,7 @@ namespace FancyZonesUnitTests
|
|||||||
//prepare data
|
//prepare data
|
||||||
const Settings expected;
|
const Settings expected;
|
||||||
|
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
||||||
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
||||||
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
||||||
@@ -249,7 +250,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
values.save_to_settings_file();
|
values.save_to_settings_file();
|
||||||
|
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -261,7 +262,7 @@ namespace FancyZonesUnitTests
|
|||||||
//prepare data
|
//prepare data
|
||||||
const Settings expected;
|
const Settings expected;
|
||||||
|
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
||||||
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
||||||
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
||||||
@@ -284,7 +285,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
values.save_to_settings_file();
|
values.save_to_settings_file();
|
||||||
|
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -296,7 +297,7 @@ namespace FancyZonesUnitTests
|
|||||||
//prepare data
|
//prepare data
|
||||||
const Settings expected;
|
const Settings expected;
|
||||||
|
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
||||||
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
||||||
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
||||||
@@ -320,7 +321,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
values.save_to_settings_file();
|
values.save_to_settings_file();
|
||||||
|
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -332,7 +333,7 @@ namespace FancyZonesUnitTests
|
|||||||
//prepare data
|
//prepare data
|
||||||
const Settings expected;
|
const Settings expected;
|
||||||
|
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
||||||
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
||||||
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
||||||
@@ -356,7 +357,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
values.save_to_settings_file();
|
values.save_to_settings_file();
|
||||||
|
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -366,7 +367,7 @@ namespace FancyZonesUnitTests
|
|||||||
TEST_METHOD (CreateWithEmptyJson)
|
TEST_METHOD (CreateWithEmptyJson)
|
||||||
{
|
{
|
||||||
json::to_file(m_tmpName, json::JsonObject());
|
json::to_file(m_tmpName, json::JsonObject());
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -377,7 +378,7 @@ namespace FancyZonesUnitTests
|
|||||||
{
|
{
|
||||||
std::wofstream{ m_tmpName.data(), std::ios::binary } << L"{ \"version\": \"1.0\", \"name\": \"";
|
std::wofstream{ m_tmpName.data(), std::ios::binary } << L"{ \"version\": \"1.0\", \"name\": \"";
|
||||||
|
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
|
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -387,7 +388,7 @@ namespace FancyZonesUnitTests
|
|||||||
TEST_METHOD (CreateWithCyrillicSymbolsInJson)
|
TEST_METHOD (CreateWithCyrillicSymbolsInJson)
|
||||||
{
|
{
|
||||||
std::wofstream{ m_tmpName.data(), std::ios::binary } << L"{ \"version\": \"1.0\", \"name\": \"ФансиЗонс\"}";
|
std::wofstream{ m_tmpName.data(), std::ios::binary } << L"{ \"version\": \"1.0\", \"name\": \"ФансиЗонс\"}";
|
||||||
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName);
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(actual != nullptr);
|
Assert::IsTrue(actual != nullptr);
|
||||||
|
|
||||||
auto actualSettings = actual->GetSettings();
|
auto actualSettings = actual->GetSettings();
|
||||||
@@ -399,6 +400,7 @@ namespace FancyZonesUnitTests
|
|||||||
{
|
{
|
||||||
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
||||||
PCWSTR m_moduleName = L"FancyZonesUnitTests";
|
PCWSTR m_moduleName = L"FancyZonesUnitTests";
|
||||||
|
PCWSTR m_moduleKey = L"FancyZonesUnitTests";
|
||||||
|
|
||||||
struct FZCallback : public winrt::implements<FZCallback, IFancyZonesCallback>
|
struct FZCallback : public winrt::implements<FZCallback, IFancyZonesCallback>
|
||||||
{
|
{
|
||||||
@@ -474,7 +476,7 @@ namespace FancyZonesUnitTests
|
|||||||
.excludedAppsArray = { L"APP" },
|
.excludedAppsArray = { L"APP" },
|
||||||
};
|
};
|
||||||
|
|
||||||
PowerToysSettings::PowerToyValues values(m_moduleName);
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
||||||
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
||||||
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
||||||
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
||||||
@@ -499,7 +501,7 @@ namespace FancyZonesUnitTests
|
|||||||
|
|
||||||
values.save_to_settings_file();
|
values.save_to_settings_file();
|
||||||
|
|
||||||
m_settings = MakeFancyZonesSettings(hInst, m_moduleName);
|
m_settings = MakeFancyZonesSettings(hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(m_settings != nullptr);
|
Assert::IsTrue(m_settings != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,6 +581,7 @@ namespace FancyZonesUnitTests
|
|||||||
{
|
{
|
||||||
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
||||||
PCWSTR m_moduleName = L"FancyZonesUnitTests";
|
PCWSTR m_moduleName = L"FancyZonesUnitTests";
|
||||||
|
PCWSTR m_moduleKey = L"FancyZonesUnitTests";
|
||||||
|
|
||||||
std::wstring serializedPowerToySettings(const Settings& settings)
|
std::wstring serializedPowerToySettings(const Settings& settings)
|
||||||
{
|
{
|
||||||
@@ -622,7 +625,7 @@ namespace FancyZonesUnitTests
|
|||||||
{
|
{
|
||||||
HINSTANCE hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
HINSTANCE hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
||||||
|
|
||||||
m_settings = MakeFancyZonesSettings(hInst, m_moduleName);
|
m_settings = MakeFancyZonesSettings(hInst, m_moduleName, m_moduleKey);
|
||||||
Assert::IsTrue(m_settings != nullptr);
|
Assert::IsTrue(m_settings != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
src/modules/imageresizer/dll/ImageResizerConstants.h
Normal file
11
src/modules/imageresizer/dll/ImageResizerConstants.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace ImageResizerConstants
|
||||||
|
{
|
||||||
|
// Name of the powertoy module.
|
||||||
|
inline const std::wstring ModuleKey = L"Image Resizer";
|
||||||
|
|
||||||
|
// Name of the ImageResizer save folder.
|
||||||
|
inline const std::wstring ModuleSaveFolderKey = L"ImageResizer";
|
||||||
|
}
|
||||||
@@ -162,6 +162,7 @@
|
|||||||
<ClInclude Include="HDropIterator.h" />
|
<ClInclude Include="HDropIterator.h" />
|
||||||
<ClInclude Include="dllmain.h" />
|
<ClInclude Include="dllmain.h" />
|
||||||
<None Include="resource.base.h" />
|
<None Include="resource.base.h" />
|
||||||
|
<ClInclude Include="ImageResizerConstants.h" />
|
||||||
<ClInclude Include="Settings.h" />
|
<ClInclude Include="Settings.h" />
|
||||||
<ClInclude Include="Generated Files/resource.h" />
|
<ClInclude Include="Generated Files/resource.h" />
|
||||||
<ClInclude Include="ImageResizerExt_i.h" />
|
<ClInclude Include="ImageResizerExt_i.h" />
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <common/settings_helpers.h>
|
#include <common/settings_helpers.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include <imageresizer\dll\ImageResizerConstants.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -44,7 +45,7 @@ namespace
|
|||||||
|
|
||||||
CSettings::CSettings()
|
CSettings::CSettings()
|
||||||
{
|
{
|
||||||
std::wstring result = PTSettingsHelper::get_module_save_folder_location(L"ImageResizer");
|
std::wstring result = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleSaveFolderKey);
|
||||||
jsonFilePath = result + std::wstring(c_imageResizerDataFilePath);
|
jsonFilePath = result + std::wstring(c_imageResizerDataFilePath);
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include <common/common.h>
|
#include <common/common.h>
|
||||||
|
#include <imageresizer\dll\ImageResizerConstants.h>
|
||||||
|
|
||||||
CImageResizerExtModule _AtlModule;
|
CImageResizerExtModule _AtlModule;
|
||||||
HINSTANCE g_hInst_imageResizer = 0;
|
HINSTANCE g_hInst_imageResizer = 0;
|
||||||
@@ -32,6 +33,8 @@ private:
|
|||||||
// Enabled by default
|
// Enabled by default
|
||||||
bool m_enabled = true;
|
bool m_enabled = true;
|
||||||
std::wstring app_name;
|
std::wstring app_name;
|
||||||
|
//contains the non localized key of the powertoy
|
||||||
|
std::wstring app_key;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -39,6 +42,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_enabled = CSettingsInstance().GetEnabled();
|
m_enabled = CSettingsInstance().GetEnabled();
|
||||||
app_name = GET_RESOURCE_STRING(IDS_IMAGERESIZER);
|
app_name = GET_RESOURCE_STRING(IDS_IMAGERESIZER);
|
||||||
|
app_key = ImageResizerConstants::ModuleKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Destroy the powertoy and free memory
|
// Destroy the powertoy and free memory
|
||||||
@@ -47,12 +51,18 @@ public:
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the display name of the powertoy, this will be cached by the runner
|
// Return the localized display name of the powertoy
|
||||||
virtual const wchar_t* get_name() override
|
virtual const wchar_t* get_name() override
|
||||||
{
|
{
|
||||||
return app_name.c_str();
|
return app_name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
virtual const wchar_t* get_key() override
|
||||||
|
{
|
||||||
|
return app_key.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Return JSON with the configuration options.
|
// Return JSON with the configuration options.
|
||||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
- call powertoy_create() to create the PowerToy.
|
- call powertoy_create() to create the PowerToy.
|
||||||
|
|
||||||
On the received object, the runner will call:
|
On the received object, the runner will call:
|
||||||
- get_name() to get the name of the PowerToy,
|
- get_key() to get the non localized ID of the PowerToy,
|
||||||
- enable() to initialize the PowerToy.
|
- enable() to initialize the PowerToy.
|
||||||
- get_hotkeys() to register the hotkeys the PowerToy uses.
|
- get_hotkeys() to register the hotkeys the PowerToy uses.
|
||||||
|
|
||||||
@@ -48,8 +48,10 @@ public:
|
|||||||
std::strong_ordering operator<=>(const Hotkey&) const = default;
|
std::strong_ordering operator<=>(const Hotkey&) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Returns the name of the PowerToy, this will be cached by the runner. */
|
/* Returns the localized name of the PowerToy*/
|
||||||
virtual const wchar_t* get_name() = 0;
|
virtual const wchar_t* get_name() = 0;
|
||||||
|
/* Returns non localized name of the PowerToy, this will be cached by the runner. */
|
||||||
|
virtual const wchar_t* get_key() = 0;
|
||||||
/* Fills a buffer with the available configuration settings.
|
/* Fills a buffer with the available configuration settings.
|
||||||
* If 'buffer' is a null ptr or the buffer size is not large enough
|
* If 'buffer' is a null ptr or the buffer size is not large enough
|
||||||
* sets the required buffer size in 'buffer_size' and return false.
|
* sets the required buffer size in 'buffer_size' and return false.
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ private:
|
|||||||
// The PowerToy name that will be shown in the settings.
|
// The PowerToy name that will be shown in the settings.
|
||||||
const std::wstring app_name = GET_RESOURCE_STRING(IDS_KEYBOARDMANAGER);
|
const std::wstring app_name = GET_RESOURCE_STRING(IDS_KEYBOARDMANAGER);
|
||||||
|
|
||||||
|
//contains the non localized key of the powertoy
|
||||||
|
std::wstring app_key = KeyboardManagerConstants::ModuleName;
|
||||||
|
|
||||||
// Low level hook handles
|
// Low level hook handles
|
||||||
static HHOOK hook_handle;
|
static HHOOK hook_handle;
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ public:
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
PowerToysSettings::PowerToyValues settings =
|
PowerToysSettings::PowerToyValues settings =
|
||||||
PowerToysSettings::PowerToyValues::load_from_settings_file(get_name());
|
PowerToysSettings::PowerToyValues::load_from_settings_file(get_key());
|
||||||
auto current_config = settings.get_string_value(KeyboardManagerConstants::ActiveConfigurationSettingName);
|
auto current_config = settings.get_string_value(KeyboardManagerConstants::ActiveConfigurationSettingName);
|
||||||
|
|
||||||
if (current_config)
|
if (current_config)
|
||||||
@@ -227,12 +230,18 @@ public:
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the display name of the powertoy, this will be cached by the runner
|
// Return the localized display name of the powertoy
|
||||||
virtual const wchar_t* get_name() override
|
virtual const wchar_t* get_name() override
|
||||||
{
|
{
|
||||||
return app_name.c_str();
|
return app_name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
virtual const wchar_t* get_key() override
|
||||||
|
{
|
||||||
|
return app_key.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Return JSON with the configuration options.
|
// Return JSON with the configuration options.
|
||||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||||
{
|
{
|
||||||
@@ -286,7 +295,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse the input JSON string.
|
// Parse the input JSON string.
|
||||||
PowerToysSettings::PowerToyValues values =
|
PowerToysSettings::PowerToyValues values =
|
||||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
|
||||||
|
|
||||||
// If you don't need to do any custom processing of the settings, proceed
|
// If you don't need to do any custom processing of the settings, proceed
|
||||||
// to persists the values calling:
|
// to persists the values calling:
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace LauncherConstants
|
||||||
|
{
|
||||||
|
// Name of the powertoy module.
|
||||||
|
inline const std::wstring ModuleKey = L"PowerToys Run";
|
||||||
|
}
|
||||||
@@ -103,6 +103,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="LauncherConstants.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<ClInclude Include="Generated Files\resource.h" />
|
<ClInclude Include="Generated Files\resource.h" />
|
||||||
<None Include="resource.base.h" />
|
<None Include="resource.base.h" />
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "Generated Files/resource.h"
|
#include "Generated Files/resource.h"
|
||||||
#include <common/os-detect.h>
|
#include <common/os-detect.h>
|
||||||
|
#include <launcher\Microsoft.Launcher\LauncherConstants.h>
|
||||||
|
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
|
||||||
@@ -59,6 +60,9 @@ private:
|
|||||||
//contains the name of the powerToys
|
//contains the name of the powerToys
|
||||||
std::wstring app_name;
|
std::wstring app_name;
|
||||||
|
|
||||||
|
//contains the non localized key of the powertoy
|
||||||
|
std::wstring app_key;
|
||||||
|
|
||||||
// Time to wait for process to close after sending WM_CLOSE signal
|
// Time to wait for process to close after sending WM_CLOSE signal
|
||||||
static const int MAX_WAIT_MILLISEC = 10000;
|
static const int MAX_WAIT_MILLISEC = 10000;
|
||||||
|
|
||||||
@@ -76,6 +80,7 @@ public:
|
|||||||
Microsoft_Launcher()
|
Microsoft_Launcher()
|
||||||
{
|
{
|
||||||
app_name = GET_RESOURCE_STRING(IDS_LAUNCHER_NAME);
|
app_name = GET_RESOURCE_STRING(IDS_LAUNCHER_NAME);
|
||||||
|
app_key = LauncherConstants::ModuleKey;
|
||||||
init_settings();
|
init_settings();
|
||||||
|
|
||||||
SECURITY_ATTRIBUTES sa;
|
SECURITY_ATTRIBUTES sa;
|
||||||
@@ -100,12 +105,18 @@ public:
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the display name of the powertoy, this will be cached by the runner
|
// Return the localized display name of the powertoy
|
||||||
virtual const wchar_t* get_name() override
|
virtual const wchar_t* get_name() override
|
||||||
{
|
{
|
||||||
return app_name.c_str();
|
return app_name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
virtual const wchar_t* get_key() override
|
||||||
|
{
|
||||||
|
return app_key.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Return JSON with the configuration options.
|
// Return JSON with the configuration options.
|
||||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||||
{
|
{
|
||||||
@@ -143,7 +154,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse the input JSON string.
|
// Parse the input JSON string.
|
||||||
PowerToysSettings::PowerToyValues values =
|
PowerToysSettings::PowerToyValues values =
|
||||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
|
||||||
|
|
||||||
parse_hotkey(values);
|
parse_hotkey(values);
|
||||||
// If you don't need to do any custom processing of the settings, proceed
|
// If you don't need to do any custom processing of the settings, proceed
|
||||||
@@ -320,7 +331,7 @@ void Microsoft_Launcher::init_settings()
|
|||||||
{
|
{
|
||||||
// Load and parse the settings file for this PowerToy.
|
// Load and parse the settings file for this PowerToy.
|
||||||
PowerToysSettings::PowerToyValues settings =
|
PowerToysSettings::PowerToyValues settings =
|
||||||
PowerToysSettings::PowerToyValues::load_from_settings_file(get_name());
|
PowerToysSettings::PowerToyValues::load_from_settings_file(get_key());
|
||||||
|
|
||||||
parse_hotkey(settings);
|
parse_hotkey(settings);
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/modules/powerrename/dll/PowerRenameConstants.h
Normal file
8
src/modules/powerrename/dll/PowerRenameConstants.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace PowerRenameConstants
|
||||||
|
{
|
||||||
|
// Name of the powertoy module.
|
||||||
|
inline const std::wstring ModuleKey = L"PowerRename";
|
||||||
|
}
|
||||||
@@ -178,6 +178,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CLSID.h" />
|
<ClInclude Include="CLSID.h" />
|
||||||
<ClInclude Include="Generated Files/resource.h" />
|
<ClInclude Include="Generated Files/resource.h" />
|
||||||
|
<ClInclude Include="PowerRenameConstants.h" />
|
||||||
<ClInclude Include="PowerRenameExt.h" />
|
<ClInclude Include="PowerRenameExt.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<None Include="resource.base.h" />
|
<None Include="resource.base.h" />
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <common/common.h>
|
#include <common/common.h>
|
||||||
#include "Generated Files/resource.h"
|
#include "Generated Files/resource.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <dll/PowerRenameConstants.h>
|
||||||
|
|
||||||
std::atomic<DWORD> g_dwModuleRefCount = 0;
|
std::atomic<DWORD> g_dwModuleRefCount = 0;
|
||||||
HINSTANCE g_hInst = 0;
|
HINSTANCE g_hInst = 0;
|
||||||
@@ -155,14 +156,22 @@ private:
|
|||||||
// Enabled by default
|
// Enabled by default
|
||||||
bool m_enabled = true;
|
bool m_enabled = true;
|
||||||
std::wstring app_name;
|
std::wstring app_name;
|
||||||
|
//contains the non localized key of the powertoy
|
||||||
|
std::wstring app_key;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Return the display name of the powertoy, this will be cached
|
// Return the localized display name of the powertoy
|
||||||
virtual PCWSTR get_name() override
|
virtual PCWSTR get_name() override
|
||||||
{
|
{
|
||||||
return app_name.c_str();
|
return app_name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
virtual const wchar_t* get_key() override
|
||||||
|
{
|
||||||
|
return app_key.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Enable the powertoy
|
// Enable the powertoy
|
||||||
virtual void enable()
|
virtual void enable()
|
||||||
{
|
{
|
||||||
@@ -236,7 +245,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse the input JSON string.
|
// Parse the input JSON string.
|
||||||
PowerToysSettings::PowerToyValues values =
|
PowerToysSettings::PowerToyValues values =
|
||||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
|
||||||
|
|
||||||
CSettingsInstance().SetPersistState(values.get_bool_value(L"bool_persist_input").value());
|
CSettingsInstance().SetPersistState(values.get_bool_value(L"bool_persist_input").value());
|
||||||
CSettingsInstance().SetMRUEnabled(values.get_bool_value(L"bool_mru_enabled").value());
|
CSettingsInstance().SetMRUEnabled(values.get_bool_value(L"bool_mru_enabled").value());
|
||||||
@@ -282,6 +291,7 @@ public:
|
|||||||
{
|
{
|
||||||
init_settings();
|
init_settings();
|
||||||
app_name = GET_RESOURCE_STRING(IDS_POWERRENAME_APP_NAME);
|
app_name = GET_RESOURCE_STRING(IDS_POWERRENAME_APP_NAME);
|
||||||
|
app_key = PowerRenameConstants::ModuleKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
~PowerRenameModule(){};
|
~PowerRenameModule(){};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <dll\PowerRenameConstants.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -92,7 +93,7 @@ public:
|
|||||||
pushIdx(0),
|
pushIdx(0),
|
||||||
nextIdx(1),
|
nextIdx(1),
|
||||||
size(size),
|
size(size),
|
||||||
jsonFilePath(PTSettingsHelper::get_module_save_folder_location(L"PowerRename") + filePath),
|
jsonFilePath(PTSettingsHelper::get_module_save_folder_location(PowerRenameConstants::ModuleKey) + filePath),
|
||||||
registryFilePath(regPath)
|
registryFilePath(regPath)
|
||||||
{
|
{
|
||||||
items.resize(size);
|
items.resize(size);
|
||||||
@@ -395,7 +396,7 @@ IFACEMETHODIMP CRenameMRU::AddMRUString(_In_ PCWSTR entry)
|
|||||||
|
|
||||||
CSettings::CSettings()
|
CSettings::CSettings()
|
||||||
{
|
{
|
||||||
std::wstring result = PTSettingsHelper::get_module_save_folder_location(L"PowerRename");
|
std::wstring result = PTSettingsHelper::get_module_save_folder_location(PowerRenameConstants::ModuleKey);
|
||||||
jsonFilePath = result + std::wstring(c_powerRenameDataFilePath);
|
jsonFilePath = result + std::wstring(c_powerRenameDataFilePath);
|
||||||
UIFlagsFilePath = result + std::wstring(c_powerRenameUIFlagsFilePath);
|
UIFlagsFilePath = result + std::wstring(c_powerRenameUIFlagsFilePath);
|
||||||
Load();
|
Load();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
// Constructor
|
// Constructor
|
||||||
PowerPreviewModule::PowerPreviewModule() :
|
PowerPreviewModule::PowerPreviewModule() :
|
||||||
m_moduleName(GET_RESOURCE_STRING(IDS_MODULE_NAME)),
|
m_moduleName(GET_RESOURCE_STRING(IDS_MODULE_NAME)),
|
||||||
|
app_key(powerpreviewConstants::ModuleKey),
|
||||||
m_fileExplorerModules(
|
m_fileExplorerModules(
|
||||||
{ // SVG Preview Handler settings object.
|
{ // SVG Preview Handler settings object.
|
||||||
new PreviewHandlerSettings(
|
new PreviewHandlerSettings(
|
||||||
@@ -55,12 +56,18 @@ void PowerPreviewModule::destroy()
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the display name of the powertoy, this will be cached.
|
// Return the localized display name of the powertoy
|
||||||
const wchar_t* PowerPreviewModule::get_name()
|
const wchar_t* PowerPreviewModule::get_name()
|
||||||
{
|
{
|
||||||
return m_moduleName.c_str();
|
return m_moduleName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
const wchar_t* PowerPreviewModule::get_key()
|
||||||
|
{
|
||||||
|
return app_key.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Return JSON with the configuration options.
|
// Return JSON with the configuration options.
|
||||||
bool PowerPreviewModule::get_config(_Out_ wchar_t* buffer, _Out_ int* buffer_size)
|
bool PowerPreviewModule::get_config(_Out_ wchar_t* buffer, _Out_ int* buffer_size)
|
||||||
{
|
{
|
||||||
@@ -96,7 +103,7 @@ void PowerPreviewModule::set_config(const wchar_t* config)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PowerToysSettings::PowerToyValues settings = PowerToysSettings::PowerToyValues::from_json_string(config);
|
PowerToysSettings::PowerToyValues settings = PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
|
||||||
|
|
||||||
bool updateSuccess = true;
|
bool updateSuccess = true;
|
||||||
bool isElevated = is_process_elevated(false);
|
bool isElevated = is_process_elevated(false);
|
||||||
@@ -167,7 +174,7 @@ void PowerPreviewModule::init_settings()
|
|||||||
{
|
{
|
||||||
// Load and parse the settings file for this PowerToy.
|
// Load and parse the settings file for this PowerToy.
|
||||||
PowerToysSettings::PowerToyValues settings =
|
PowerToysSettings::PowerToyValues settings =
|
||||||
PowerToysSettings::PowerToyValues::load_from_settings_file(PowerPreviewModule::get_name());
|
PowerToysSettings::PowerToyValues::load_from_settings_file(PowerPreviewModule::get_key());
|
||||||
|
|
||||||
// Load settings states.
|
// Load settings states.
|
||||||
for (auto fileExplorerModule : this->m_fileExplorerModules)
|
for (auto fileExplorerModule : this->m_fileExplorerModules)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "thumbnail_provider.h"
|
#include "thumbnail_provider.h"
|
||||||
#include "preview_handler.h"
|
#include "preview_handler.h"
|
||||||
#include "registry_wrapper.h"
|
#include "registry_wrapper.h"
|
||||||
|
#include <powerpreview\powerpreviewConstants.h>
|
||||||
|
|
||||||
using namespace PowerPreviewSettings;
|
using namespace PowerPreviewSettings;
|
||||||
|
|
||||||
@@ -18,6 +19,8 @@ private:
|
|||||||
// The PowerToy state.
|
// The PowerToy state.
|
||||||
bool m_enabled = false;
|
bool m_enabled = false;
|
||||||
std::wstring m_moduleName;
|
std::wstring m_moduleName;
|
||||||
|
//contains the non localized key of the powertoy
|
||||||
|
std::wstring app_key;
|
||||||
std::vector<FileExplorerPreviewSettings*> m_fileExplorerModules;
|
std::vector<FileExplorerPreviewSettings*> m_fileExplorerModules;
|
||||||
|
|
||||||
// Function to check if the registry states need to be updated
|
// Function to check if the registry states need to be updated
|
||||||
@@ -40,6 +43,7 @@ public:
|
|||||||
|
|
||||||
virtual void destroy();
|
virtual void destroy();
|
||||||
virtual const wchar_t* get_name();
|
virtual const wchar_t* get_name();
|
||||||
|
virtual const wchar_t* get_key();
|
||||||
virtual bool get_config(_Out_ wchar_t* buffer, _Out_ int* buffer_size);
|
virtual bool get_config(_Out_ wchar_t* buffer, _Out_ int* buffer_size);
|
||||||
virtual void set_config(const wchar_t* config);
|
virtual void set_config(const wchar_t* config);
|
||||||
virtual void enable();
|
virtual void enable();
|
||||||
|
|||||||
@@ -109,6 +109,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CLSID.h" />
|
<ClInclude Include="CLSID.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
|
<ClInclude Include="powerpreviewConstants.h" />
|
||||||
<ClInclude Include="preview_handler.h" />
|
<ClInclude Include="preview_handler.h" />
|
||||||
<ClInclude Include="registry_wrapper.h" />
|
<ClInclude Include="registry_wrapper.h" />
|
||||||
<ClInclude Include="registry_wrapper_interface.h" />
|
<ClInclude Include="registry_wrapper_interface.h" />
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace powerpreviewConstants
|
||||||
|
{
|
||||||
|
// Name of the powertoy module.
|
||||||
|
inline const std::wstring ModuleKey = L"File Explorer";
|
||||||
|
}
|
||||||
@@ -82,7 +82,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool defaultState = true;
|
bool defaultState = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(defaultState, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(defaultState, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
previewSettings.LoadState(settings);
|
previewSettings.LoadState(settings);
|
||||||
@@ -97,7 +97,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool defaultState = true;
|
bool defaultState = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(defaultState, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(defaultState, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\"}");
|
auto settings = PowerToyValues::from_json_string(L"{\"name\":\"Module Name\"}", L"FileExplorerPreviewTests");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
previewSettings.LoadState(settings);
|
previewSettings.LoadState(settings);
|
||||||
@@ -113,7 +113,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = true;
|
bool elevated = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
previewSettings.UpdateToggleSettingState(true);
|
previewSettings.UpdateToggleSettingState(true);
|
||||||
// Add expected data in registry
|
// Add expected data in registry
|
||||||
mockRegistryWrapper->SetMockData(previewSettings.GetRegistryValueData());
|
mockRegistryWrapper->SetMockData(previewSettings.GetRegistryValueData());
|
||||||
@@ -134,7 +134,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = true;
|
bool elevated = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
ThumbnailProviderSettings thumbnailSettings = GetThumbnailProviderSettingsObject(true, mockRegistryWrapper);
|
ThumbnailProviderSettings thumbnailSettings = GetThumbnailProviderSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(thumbnailSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(thumbnailSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
thumbnailSettings.UpdateToggleSettingState(true);
|
thumbnailSettings.UpdateToggleSettingState(true);
|
||||||
// Add expected data in registry
|
// Add expected data in registry
|
||||||
mockRegistryWrapper->SetMockData(thumbnailSettings.GetCLSID());
|
mockRegistryWrapper->SetMockData(thumbnailSettings.GetCLSID());
|
||||||
@@ -155,7 +155,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = true;
|
bool elevated = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
previewSettings.UpdateToggleSettingState(true);
|
previewSettings.UpdateToggleSettingState(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -174,7 +174,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = false;
|
bool elevated = false;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
previewSettings.UpdateToggleSettingState(true);
|
previewSettings.UpdateToggleSettingState(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -193,7 +193,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = true;
|
bool elevated = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"true"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"true"), L"FileExplorerPreviewTests");
|
||||||
previewSettings.UpdateToggleSettingState(false);
|
previewSettings.UpdateToggleSettingState(false);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -211,7 +211,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = true;
|
bool elevated = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"true"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"true"), L"FileExplorerPreviewTests");
|
||||||
previewSettings.UpdateToggleSettingState(false);
|
previewSettings.UpdateToggleSettingState(false);
|
||||||
// Add expected data in registry
|
// Add expected data in registry
|
||||||
mockRegistryWrapper->SetMockData(previewSettings.GetRegistryValueData());
|
mockRegistryWrapper->SetMockData(previewSettings.GetRegistryValueData());
|
||||||
@@ -231,7 +231,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = true;
|
bool elevated = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
ThumbnailProviderSettings thumbnailSettings = GetThumbnailProviderSettingsObject(true, mockRegistryWrapper);
|
ThumbnailProviderSettings thumbnailSettings = GetThumbnailProviderSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(thumbnailSettings.GetToggleSettingName(), L"true"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(thumbnailSettings.GetToggleSettingName(), L"true"), L"FileExplorerPreviewTests");
|
||||||
thumbnailSettings.UpdateToggleSettingState(false);
|
thumbnailSettings.UpdateToggleSettingState(false);
|
||||||
// Add expected data in registry
|
// Add expected data in registry
|
||||||
mockRegistryWrapper->SetMockData(thumbnailSettings.GetCLSID());
|
mockRegistryWrapper->SetMockData(thumbnailSettings.GetCLSID());
|
||||||
@@ -251,7 +251,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = false;
|
bool elevated = false;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"true"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"true"), L"FileExplorerPreviewTests");
|
||||||
previewSettings.UpdateToggleSettingState(false);
|
previewSettings.UpdateToggleSettingState(false);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -269,7 +269,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = true;
|
bool elevated = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
previewSettings.UpdateState(settings, enabled, elevated);
|
previewSettings.UpdateState(settings, enabled, elevated);
|
||||||
@@ -285,7 +285,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = false;
|
bool elevated = false;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
previewSettings.UpdateState(settings, enabled, elevated);
|
previewSettings.UpdateState(settings, enabled, elevated);
|
||||||
@@ -301,7 +301,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = true;
|
bool elevated = true;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
previewSettings.UpdateState(settings, enabled, elevated);
|
previewSettings.UpdateState(settings, enabled, elevated);
|
||||||
@@ -319,7 +319,7 @@ namespace FileExplorerPreviewSettingsTest
|
|||||||
bool elevated = false;
|
bool elevated = false;
|
||||||
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
RegistryMock* mockRegistryWrapper = new RegistryMock();
|
||||||
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
PreviewHandlerSettings previewSettings = GetPreviewHandlerSettingsObject(true, mockRegistryWrapper);
|
||||||
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"));
|
auto settings = PowerToyValues::from_json_string(GetJSONSettings(previewSettings.GetToggleSettingName(), L"false"), L"FileExplorerPreviewTests");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
previewSettings.UpdateState(settings, enabled, elevated);
|
previewSettings.UpdateState(settings, enabled, elevated);
|
||||||
|
|||||||
8
src/modules/shortcut_guide/ShortcutGuideConstants.h
Normal file
8
src/modules/shortcut_guide/ShortcutGuideConstants.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace ShortcutGuideConstants
|
||||||
|
{
|
||||||
|
// Name of the powertoy module.
|
||||||
|
inline const std::wstring ModuleKey = L"Shortcut Guide";
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <common/settings_objects.h>
|
#include <common/settings_objects.h>
|
||||||
#include <common/debug_control.h>
|
#include <common/debug_control.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <modules\shortcut_guide\ShortcutGuideConstants.h>
|
||||||
|
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
|
||||||
@@ -94,14 +95,22 @@ namespace
|
|||||||
OverlayWindow::OverlayWindow()
|
OverlayWindow::OverlayWindow()
|
||||||
{
|
{
|
||||||
app_name = GET_RESOURCE_STRING(IDS_SHORTCUT_GUIDE);
|
app_name = GET_RESOURCE_STRING(IDS_SHORTCUT_GUIDE);
|
||||||
|
app_key = ShortcutGuideConstants::ModuleKey;
|
||||||
init_settings();
|
init_settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the localized display name of the powertoy
|
||||||
const wchar_t* OverlayWindow::get_name()
|
const wchar_t* OverlayWindow::get_name()
|
||||||
{
|
{
|
||||||
return app_name.c_str();
|
return app_name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
const wchar_t* OverlayWindow::get_key()
|
||||||
|
{
|
||||||
|
return app_key.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
bool OverlayWindow::get_config(wchar_t* buffer, int* buffer_size)
|
bool OverlayWindow::get_config(wchar_t* buffer, int* buffer_size)
|
||||||
{
|
{
|
||||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||||
@@ -142,7 +151,7 @@ void OverlayWindow::set_config(const wchar_t* config)
|
|||||||
{
|
{
|
||||||
// save configuration
|
// save configuration
|
||||||
PowerToysSettings::PowerToyValues _values =
|
PowerToysSettings::PowerToyValues _values =
|
||||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
|
||||||
_values.save_to_settings_file();
|
_values.save_to_settings_file();
|
||||||
Trace::SettingsChanged(pressTime.value, overlayOpacity.value, theme.value);
|
Trace::SettingsChanged(pressTime.value, overlayOpacity.value, theme.value);
|
||||||
|
|
||||||
@@ -331,7 +340,7 @@ void OverlayWindow::init_settings()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
PowerToysSettings::PowerToyValues settings =
|
PowerToysSettings::PowerToyValues settings =
|
||||||
PowerToysSettings::PowerToyValues::load_from_settings_file(OverlayWindow::get_name());
|
PowerToysSettings::PowerToyValues::load_from_settings_file(OverlayWindow::get_key());
|
||||||
if (const auto val = settings.get_int_value(pressTime.name))
|
if (const auto val = settings.get_int_value(pressTime.name))
|
||||||
{
|
{
|
||||||
pressTime.value = *val;
|
pressTime.value = *val;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
OverlayWindow();
|
OverlayWindow();
|
||||||
|
|
||||||
virtual const wchar_t* get_name() override;
|
virtual const wchar_t* get_name() override;
|
||||||
|
virtual const wchar_t* get_key() override;
|
||||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override;
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override;
|
||||||
|
|
||||||
virtual void set_config(const wchar_t* config) override;
|
virtual void set_config(const wchar_t* config) override;
|
||||||
@@ -37,6 +38,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::wstring app_name;
|
std::wstring app_name;
|
||||||
|
//contains the non localized key of the powertoy
|
||||||
|
std::wstring app_key;
|
||||||
std::unique_ptr<TargetState> target_state;
|
std::unique_ptr<TargetState> target_state;
|
||||||
std::unique_ptr<D2DOverlayWindow> winkey_popup;
|
std::unique_ptr<D2DOverlayWindow> winkey_popup;
|
||||||
bool _enabled = false;
|
bool _enabled = false;
|
||||||
|
|||||||
@@ -109,6 +109,7 @@
|
|||||||
<ClInclude Include="keyboard_state.h" />
|
<ClInclude Include="keyboard_state.h" />
|
||||||
<ClInclude Include="Generated Files/resource.h" />
|
<ClInclude Include="Generated Files/resource.h" />
|
||||||
<None Include="resource.base.h" />
|
<None Include="resource.base.h" />
|
||||||
|
<ClInclude Include="ShortcutGuideConstants.h" />
|
||||||
<ClInclude Include="shortcut_guide.h" />
|
<ClInclude Include="shortcut_guide.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<ClInclude Include="target_state.h" />
|
<ClInclude Include="target_state.h" />
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ int runner(bool isProcessElevated)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto module = load_powertoy(moduleSubdir);
|
auto module = load_powertoy(moduleSubdir);
|
||||||
modules().emplace(module->get_name(), std::move(module));
|
modules().emplace(module->get_key(), std::move(module));
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ PowertoyModule::PowertoyModule(PowertoyModuleIface* module, HMODULE handle) :
|
|||||||
|
|
||||||
void PowertoyModule::update_hotkeys()
|
void PowertoyModule::update_hotkeys()
|
||||||
{
|
{
|
||||||
CentralizedKeyboardHook::ClearModuleHotkeys(module->get_name());
|
CentralizedKeyboardHook::ClearModuleHotkeys(module->get_key());
|
||||||
|
|
||||||
size_t hotkeyCount = module->get_hotkeys(nullptr, 0);
|
size_t hotkeyCount = module->get_hotkeys(nullptr, 0);
|
||||||
std::vector<PowertoyModuleIface::Hotkey> hotkeys(hotkeyCount);
|
std::vector<PowertoyModuleIface::Hotkey> hotkeys(hotkeyCount);
|
||||||
@@ -59,7 +59,7 @@ void PowertoyModule::update_hotkeys()
|
|||||||
|
|
||||||
for (size_t i = 0; i < hotkeyCount; i++)
|
for (size_t i = 0; i < hotkeyCount; i++)
|
||||||
{
|
{
|
||||||
CentralizedKeyboardHook::SetHotkeyAction(module->get_name(), hotkeys[i], [modulePtr, i] {
|
CentralizedKeyboardHook::SetHotkeyAction(module->get_key(), hotkeys[i], [modulePtr, i] {
|
||||||
return modulePtr->on_hotkey(i);
|
return modulePtr->on_hotkey(i);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,12 +66,18 @@ public:
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the display name of the powertoy, this will be cached by the runner
|
// Return the localized display name of the powertoy
|
||||||
virtual const wchar_t* get_name() override
|
virtual const wchar_t* get_name() override
|
||||||
{
|
{
|
||||||
return MODULE_NAME;
|
return MODULE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
||||||
|
virtual const wchar_t* get_key() override
|
||||||
|
{
|
||||||
|
return MODULE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
// Return JSON with the configuration options.
|
// Return JSON with the configuration options.
|
||||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||||
{
|
{
|
||||||
@@ -158,7 +164,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse the input JSON string.
|
// Parse the input JSON string.
|
||||||
PowerToysSettings::PowerToyValues values =
|
PowerToysSettings::PowerToyValues values =
|
||||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
|
||||||
|
|
||||||
// Update a bool property.
|
// Update a bool property.
|
||||||
//if (auto v = values.get_bool_value(L"bool_toggle_1")) {
|
//if (auto v = values.get_bool_value(L"bool_toggle_1")) {
|
||||||
@@ -218,7 +224,7 @@ void $safeprojectname$::init_settings()
|
|||||||
{
|
{
|
||||||
// Load and parse the settings file for this PowerToy.
|
// Load and parse the settings file for this PowerToy.
|
||||||
PowerToysSettings::PowerToyValues settings =
|
PowerToysSettings::PowerToyValues settings =
|
||||||
PowerToysSettings::PowerToyValues::load_from_settings_file($safeprojectname$::get_name());
|
PowerToysSettings::PowerToyValues::load_from_settings_file($safeprojectname$::get_key());
|
||||||
|
|
||||||
// Load a bool property.
|
// Load a bool property.
|
||||||
//if (auto v = settings.get_bool_value(L"bool_toggle_1")) {
|
//if (auto v = settings.get_bool_value(L"bool_toggle_1")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user