2019-11-12 03:00:42 +08:00
|
|
|
#pragma once
|
|
|
|
|
2020-04-09 01:12:46 +08:00
|
|
|
#include "json.h"
|
|
|
|
|
2019-11-12 03:00:42 +08:00
|
|
|
class CSettings
|
|
|
|
{
|
|
|
|
public:
|
2020-02-13 17:44:03 +08:00
|
|
|
static const int MAX_INPUT_STRING_LEN = 1024;
|
|
|
|
|
2020-04-09 01:12:46 +08:00
|
|
|
CSettings();
|
|
|
|
|
2020-04-16 05:14:17 +08:00
|
|
|
inline bool GetEnabled()
|
|
|
|
{
|
|
|
|
Reload();
|
|
|
|
return settings.enabled;
|
|
|
|
}
|
2020-04-09 01:12:46 +08:00
|
|
|
|
2020-04-16 05:14:17 +08:00
|
|
|
inline void SetEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
settings.enabled = enabled;
|
|
|
|
Save();
|
|
|
|
}
|
2020-04-09 01:12:46 +08:00
|
|
|
|
|
|
|
inline bool GetShowIconOnMenu() const
|
|
|
|
{
|
|
|
|
return settings.showIconOnMenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SetShowIconOnMenu(bool show)
|
|
|
|
{
|
|
|
|
settings.showIconOnMenu = show;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool GetExtendedContextMenuOnly() const
|
|
|
|
{
|
|
|
|
return settings.extendedContextMenuOnly;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SetExtendedContextMenuOnly(bool extendedOnly)
|
|
|
|
{
|
|
|
|
settings.extendedContextMenuOnly = extendedOnly;
|
|
|
|
}
|
2019-11-12 03:00:42 +08:00
|
|
|
|
2020-04-09 01:12:46 +08:00
|
|
|
inline bool GetPersistState() const
|
|
|
|
{
|
|
|
|
return settings.persistState;
|
|
|
|
}
|
2019-11-12 03:00:42 +08:00
|
|
|
|
2020-04-09 01:12:46 +08:00
|
|
|
inline void SetPersistState(bool persistState)
|
|
|
|
{
|
|
|
|
settings.persistState = persistState;
|
|
|
|
}
|
2019-11-12 03:00:42 +08:00
|
|
|
|
2020-04-09 01:12:46 +08:00
|
|
|
inline bool GetMRUEnabled() const
|
|
|
|
{
|
|
|
|
return settings.MRUEnabled;
|
|
|
|
}
|
2019-11-12 03:00:42 +08:00
|
|
|
|
2020-04-09 01:12:46 +08:00
|
|
|
inline void SetMRUEnabled(bool MRUEnabled)
|
|
|
|
{
|
|
|
|
settings.MRUEnabled = MRUEnabled;
|
|
|
|
}
|
2019-11-12 03:00:42 +08:00
|
|
|
|
2020-05-01 19:26:38 +08:00
|
|
|
inline unsigned int GetMaxMRUSize() const
|
2020-04-09 01:12:46 +08:00
|
|
|
{
|
|
|
|
return settings.maxMRUSize;
|
|
|
|
}
|
2019-11-12 03:00:42 +08:00
|
|
|
|
2020-05-01 19:26:38 +08:00
|
|
|
inline void SetMaxMRUSize(unsigned int maxMRUSize)
|
2020-04-09 01:12:46 +08:00
|
|
|
{
|
|
|
|
settings.maxMRUSize = maxMRUSize;
|
|
|
|
}
|
2019-11-12 03:00:42 +08:00
|
|
|
|
2020-05-01 19:26:38 +08:00
|
|
|
inline unsigned int GetFlags() const
|
2020-04-09 01:12:46 +08:00
|
|
|
{
|
|
|
|
return settings.flags;
|
|
|
|
}
|
2019-11-12 03:00:42 +08:00
|
|
|
|
2020-05-01 19:26:38 +08:00
|
|
|
inline void SetFlags(unsigned int flags)
|
2020-04-09 01:12:46 +08:00
|
|
|
{
|
|
|
|
settings.flags = flags;
|
2020-05-05 18:39:15 +08:00
|
|
|
WriteFlags();
|
2020-04-09 01:12:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline const std::wstring& GetSearchText() const
|
|
|
|
{
|
|
|
|
return settings.searchText;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SetSearchText(const std::wstring& text)
|
|
|
|
{
|
|
|
|
settings.searchText = text;
|
2020-04-16 05:14:17 +08:00
|
|
|
Save();
|
2020-04-09 01:12:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline const std::wstring& GetReplaceText() const
|
|
|
|
{
|
|
|
|
return settings.replaceText;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SetReplaceText(const std::wstring& text)
|
|
|
|
{
|
|
|
|
settings.replaceText = text;
|
2020-04-16 05:14:17 +08:00
|
|
|
Save();
|
2020-04-09 01:12:46 +08:00
|
|
|
}
|
|
|
|
|
2020-04-16 05:14:17 +08:00
|
|
|
void Save();
|
|
|
|
void Load();
|
2019-11-12 03:00:42 +08:00
|
|
|
|
|
|
|
private:
|
2020-04-09 01:12:46 +08:00
|
|
|
struct Settings
|
|
|
|
{
|
2020-04-16 05:14:17 +08:00
|
|
|
bool enabled{ true };
|
2020-04-09 01:12:46 +08:00
|
|
|
bool showIconOnMenu{ true };
|
|
|
|
bool extendedContextMenuOnly{ false }; // Disabled by default.
|
|
|
|
bool persistState{ true };
|
|
|
|
bool MRUEnabled{ true };
|
2020-05-01 19:26:38 +08:00
|
|
|
unsigned int maxMRUSize{ 10 };
|
|
|
|
unsigned int flags{ 0 };
|
2020-04-09 01:12:46 +08:00
|
|
|
std::wstring searchText{};
|
|
|
|
std::wstring replaceText{};
|
|
|
|
};
|
|
|
|
|
2020-04-16 05:14:17 +08:00
|
|
|
void Reload();
|
|
|
|
void MigrateFromRegistry();
|
|
|
|
void ParseJson();
|
2020-04-09 01:12:46 +08:00
|
|
|
|
2020-05-05 18:39:15 +08:00
|
|
|
void ReadFlags();
|
|
|
|
void WriteFlags();
|
|
|
|
|
2020-04-09 01:12:46 +08:00
|
|
|
Settings settings;
|
|
|
|
std::wstring jsonFilePath;
|
2020-05-05 18:39:15 +08:00
|
|
|
std::wstring UIFlagsFilePath;
|
2020-04-16 05:14:17 +08:00
|
|
|
FILETIME lastLoadedTime;
|
2019-11-12 03:00:42 +08:00
|
|
|
};
|
|
|
|
|
2020-04-09 01:12:46 +08:00
|
|
|
CSettings& CSettingsInstance();
|
|
|
|
|
2019-11-12 03:00:42 +08:00
|
|
|
HRESULT CRenameMRUSearch_CreateInstance(_Outptr_ IUnknown** ppUnk);
|
|
|
|
HRESULT CRenameMRUReplace_CreateInstance(_Outptr_ IUnknown** ppUnk);
|