[FancyZones] Split zones-settings: app zone history (#15690)

This commit is contained in:
Seraphima Zykova
2022-01-24 14:54:17 +03:00
committed by GitHub
parent 7833ace553
commit 453bb613af
15 changed files with 582 additions and 525 deletions

View File

@@ -0,0 +1,49 @@
#pragma once
#include <FancyZonesLib/FancyZonesDataTypes.h>
#include <FancyZonesLib/ModuleConstants.h>
#include <common/SettingsAPI/settings_helpers.h>
class AppZoneHistory
{
public:
using TAppZoneHistoryMap = std::unordered_map<std::wstring, std::vector<FancyZonesDataTypes::AppZoneHistoryData>>;
static AppZoneHistory& instance();
inline static std::wstring AppZoneHistoryFileName()
{
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
#if defined(UNIT_TESTS)
return saveFolderPath + L"\\test-app-zone-history.json";
#endif
return saveFolderPath + L"\\app-zone-history.json";
}
void SetVirtualDesktopCheckCallback(std::function<bool(GUID)> callback);
void LoadData();
void SaveData();
bool SetAppLastZones(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId, const std::wstring& zoneSetId, const ZoneIndexSet& zoneIndexSet);
bool RemoveAppLastZone(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId, const std::wstring_view& zoneSetId);
void RemoveApp(const std::wstring& appPath);
const TAppZoneHistoryMap& GetFullAppZoneHistory() const noexcept;
std::optional<FancyZonesDataTypes::AppZoneHistoryData> GetZoneHistory(const std::wstring& appPath, const FancyZonesDataTypes::DeviceIdData& deviceId) const noexcept;
bool IsAnotherWindowOfApplicationInstanceZoned(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId) const noexcept;
void UpdateProcessIdToHandleMap(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId);
ZoneIndexSet GetAppLastZoneIndexSet(HWND window, const FancyZonesDataTypes::DeviceIdData& deviceId, const std::wstring_view& zoneSetId) const;
void RemoveDesktopAppZoneHistory(GUID desktopId);
private:
AppZoneHistory();
~AppZoneHistory() = default;
TAppZoneHistoryMap m_history;
std::function<bool(GUID)> m_virtualDesktopCheckCallback;
};