mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
[PowerRename]Save data from the last run outside of the settings file (#28861)
* [PowerRename] Sync settings before saving last window size * address review comments
This commit is contained in:
@@ -6,9 +6,6 @@
|
||||
class CSettings
|
||||
{
|
||||
public:
|
||||
static constexpr inline int DEFAULT_WINDOW_WIDTH = 1400;
|
||||
static constexpr inline int DEFAULT_WINDOW_HEIGHT = 800;
|
||||
|
||||
CSettings();
|
||||
|
||||
inline bool GetEnabled()
|
||||
@@ -28,17 +25,6 @@ public:
|
||||
Save();
|
||||
}
|
||||
|
||||
inline std::tuple<int, int> GetLastWindowSize() const
|
||||
{
|
||||
return std::make_tuple(settings.lastWindowWidth, settings.lastWindowHeight);
|
||||
}
|
||||
|
||||
inline void UpdateLastWindowSize(const int width, const int height)
|
||||
{
|
||||
settings.lastWindowWidth = std::max(width, DEFAULT_WINDOW_WIDTH);
|
||||
settings.lastWindowHeight = std::max(height, DEFAULT_WINDOW_HEIGHT);
|
||||
}
|
||||
|
||||
inline bool GetShowIconOnMenu() const
|
||||
{
|
||||
return settings.showIconOnMenu;
|
||||
@@ -110,28 +96,6 @@ public:
|
||||
WriteFlags();
|
||||
}
|
||||
|
||||
inline const std::wstring& GetSearchText() const
|
||||
{
|
||||
return settings.searchText;
|
||||
}
|
||||
|
||||
inline void SetSearchText(const std::wstring& text)
|
||||
{
|
||||
settings.searchText = text;
|
||||
Save();
|
||||
}
|
||||
|
||||
inline const std::wstring& GetReplaceText() const
|
||||
{
|
||||
return settings.replaceText;
|
||||
}
|
||||
|
||||
inline void SetReplaceText(const std::wstring& text)
|
||||
{
|
||||
settings.replaceText = text;
|
||||
Save();
|
||||
}
|
||||
|
||||
void Save();
|
||||
void Load();
|
||||
|
||||
@@ -146,10 +110,6 @@ private:
|
||||
bool MRUEnabled{ true };
|
||||
unsigned int maxMRUSize{ 10 };
|
||||
unsigned int flags{ 0 };
|
||||
std::wstring searchText{};
|
||||
std::wstring replaceText{};
|
||||
int lastWindowWidth{ DEFAULT_WINDOW_WIDTH };
|
||||
int lastWindowHeight{ DEFAULT_WINDOW_HEIGHT };
|
||||
};
|
||||
|
||||
void Reload();
|
||||
@@ -166,3 +126,60 @@ private:
|
||||
};
|
||||
|
||||
CSettings& CSettingsInstance();
|
||||
|
||||
class LastRunSettings
|
||||
{
|
||||
static constexpr inline int DEFAULT_WINDOW_WIDTH = 1400;
|
||||
static constexpr inline int DEFAULT_WINDOW_HEIGHT = 800;
|
||||
|
||||
int lastWindowWidth{ DEFAULT_WINDOW_WIDTH };
|
||||
int lastWindowHeight{ DEFAULT_WINDOW_HEIGHT };
|
||||
|
||||
std::wstring searchText{};
|
||||
std::wstring replaceText{};
|
||||
|
||||
public:
|
||||
inline LastRunSettings()
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
inline std::tuple<int, int> GetLastWindowSize() const
|
||||
{
|
||||
return std::make_tuple(lastWindowWidth, lastWindowHeight);
|
||||
}
|
||||
|
||||
inline void UpdateLastWindowSize(const int width, const int height)
|
||||
{
|
||||
lastWindowWidth = std::max(width, DEFAULT_WINDOW_WIDTH);
|
||||
lastWindowHeight = std::max(height, DEFAULT_WINDOW_HEIGHT);
|
||||
Save();
|
||||
}
|
||||
|
||||
inline const std::wstring& GetSearchText() const
|
||||
{
|
||||
return searchText;
|
||||
}
|
||||
|
||||
inline void SetSearchText(const std::wstring& text)
|
||||
{
|
||||
searchText = text;
|
||||
Save();
|
||||
}
|
||||
|
||||
inline const std::wstring& GetReplaceText() const
|
||||
{
|
||||
return replaceText;
|
||||
}
|
||||
|
||||
inline void SetReplaceText(const std::wstring& text)
|
||||
{
|
||||
replaceText = text;
|
||||
Save();
|
||||
}
|
||||
|
||||
void Load();
|
||||
void Save();
|
||||
};
|
||||
|
||||
LastRunSettings& LastRunSettingsInstance();
|
||||
|
||||
Reference in New Issue
Block a user