mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[FancyZones] Split and reorganize FancyZonesData and JSON Helpers (#5028)
* Rename JsonHelpers to FancyZonesData Add new JsonHelpers.[h|cpp] files * Introduce FancyZonesDataTypes * Move first part of JSON related stuff to JsonHelpers files * Small refactor * Move all json related stuff to JsonHelpers * Minor refactoring * Fix formating * Remove GetPersistFancyZonesJSONPath() and GetPersistAppZoneHistoryFilePath() Remove GetActiveZoneSetTmpPath(), GetDeletedCustomZoneSetsTmpPath and GetAppliedZoneSetTmpPath() Simplify tests * Address PR comment - Rename FancyZonesDataNS to FancyZonesData * Address PR comment - Rename local var * Delete obsolete stuff * Remove double and uneeded includes Introduce const non-localizable string variables Address all othe PR comments * Add comments to explain hardcoded values * Remove FancyZonesData namespace * Introduce const non-localizable string variables in FancyZonesDataTypes * Add comments to explain FancyZonesData maps Co-authored-by: Clint Rutkas <clint@rutkas.com>
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
#include "trace.h"
|
||||
#include "lib/ZoneSet.h"
|
||||
#include "lib/Settings.h"
|
||||
#include "lib/JsonHelpers.h"
|
||||
#include "lib/FancyZonesData.h"
|
||||
#include "lib/FancyZonesDataTypes.h"
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
@@ -71,7 +72,7 @@ void Trace::FancyZones::OnKeyDown(DWORD vkCode, bool win, bool control, bool inM
|
||||
|
||||
void Trace::FancyZones::DataChanged() noexcept
|
||||
{
|
||||
const JSONHelpers::FancyZonesData& data = JSONHelpers::FancyZonesDataInstance();
|
||||
const FancyZonesData& data = FancyZonesDataInstance();
|
||||
int appsHistorySize = static_cast<int>(data.GetAppZoneHistoryMap().size());
|
||||
const auto& customZones = data.GetCustomZoneSetsMap();
|
||||
const auto& devices = data.GetDeviceInfoMap();
|
||||
@@ -82,15 +83,15 @@ void Trace::FancyZones::DataChanged() noexcept
|
||||
return;
|
||||
}
|
||||
|
||||
auto getCustomZoneCount = [&data](const std::variant<JSONHelpers::CanvasLayoutInfo, JSONHelpers::GridLayoutInfo>& layoutInfo) -> int {
|
||||
if (std::holds_alternative<JSONHelpers::GridLayoutInfo>(layoutInfo))
|
||||
auto getCustomZoneCount = [&data](const std::variant<FancyZonesDataTypes::CanvasLayoutInfo, FancyZonesDataTypes::GridLayoutInfo>& layoutInfo) -> int {
|
||||
if (std::holds_alternative<FancyZonesDataTypes::GridLayoutInfo>(layoutInfo))
|
||||
{
|
||||
const auto& info = std::get<JSONHelpers::GridLayoutInfo>(layoutInfo);
|
||||
const auto& info = std::get<FancyZonesDataTypes::GridLayoutInfo>(layoutInfo);
|
||||
return (info.rows() * info.columns());
|
||||
}
|
||||
else if (std::holds_alternative<JSONHelpers::CanvasLayoutInfo>(layoutInfo))
|
||||
else if (std::holds_alternative<FancyZonesDataTypes::CanvasLayoutInfo>(layoutInfo))
|
||||
{
|
||||
const auto& info = std::get<JSONHelpers::CanvasLayoutInfo>(layoutInfo);
|
||||
const auto& info = std::get<FancyZonesDataTypes::CanvasLayoutInfo>(layoutInfo);
|
||||
return static_cast<int>(info.zones.size());
|
||||
}
|
||||
return 0;
|
||||
@@ -108,15 +109,15 @@ void Trace::FancyZones::DataChanged() noexcept
|
||||
std::wstring activeZoneSetInfo;
|
||||
for (const auto& [id, device] : devices)
|
||||
{
|
||||
const JSONHelpers::ZoneSetLayoutType type = device.activeZoneSet.type;
|
||||
const FancyZonesDataTypes::ZoneSetLayoutType type = device.activeZoneSet.type;
|
||||
if (!activeZoneSetInfo.empty())
|
||||
{
|
||||
activeZoneSetInfo += L"; ";
|
||||
}
|
||||
activeZoneSetInfo += L"type: " + JSONHelpers::TypeToString(type);
|
||||
activeZoneSetInfo += L"type: " + FancyZonesDataTypes::TypeToString(type);
|
||||
|
||||
int zoneCount = -1;
|
||||
if (type == JSONHelpers::ZoneSetLayoutType::Custom)
|
||||
if (type == FancyZonesDataTypes::ZoneSetLayoutType::Custom)
|
||||
{
|
||||
const auto& activeCustomZone = customZones.find(device.activeZoneSet.uuid);
|
||||
if (activeCustomZone != customZones.end())
|
||||
|
||||
Reference in New Issue
Block a user