mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01: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
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "settings_objects.h"
|
||||
#include "settings_helpers.h"
|
||||
#include <winrt/base.h>
|
||||
|
||||
namespace PowerToysSettings
|
||||
{
|
||||
@@ -277,27 +278,33 @@ namespace PowerToysSettings
|
||||
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();
|
||||
m_json.SetNamedValue(L"name", json::value(powertoy_name));
|
||||
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();
|
||||
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._name = result.m_json.GetNamedString(L"name");
|
||||
result._key = powertoy_key;
|
||||
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();
|
||||
result.m_json = PTSettingsHelper::load_module_settings(powertoy_name);
|
||||
result._name = powertoy_name;
|
||||
result.m_json = PTSettingsHelper::load_module_settings(powertoy_key);
|
||||
result._key = powertoy_key;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -357,7 +364,7 @@ namespace PowerToysSettings
|
||||
void PowerToyValues::save_to_settings_file()
|
||||
{
|
||||
set_version();
|
||||
PTSettingsHelper::save_module_settings(_name, m_json);
|
||||
PTSettingsHelper::save_module_settings(_key, m_json);
|
||||
}
|
||||
|
||||
void PowerToyValues::set_version()
|
||||
|
||||
Reference in New Issue
Block a user