mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
[PowerRename] Remember last window size and optimize sorting (#27978)
We don't need to sort deeper layers, because they're being enumerated using explorer API and will appear in order anyway
This commit is contained in:
@@ -102,7 +102,10 @@ HRESULT CPowerRenameEnum::_ParseEnumItems(_In_ IEnumShellItems* pesi, _In_ int d
|
||||
l->Compare(r, SICHINT_DISPLAY, &res);
|
||||
return res < 0;
|
||||
};
|
||||
std::sort(begin(items), end(items), cmpShellItems);
|
||||
|
||||
// We need to sort only the first layer, because later ones are enumerated correctly
|
||||
if (depth == 0)
|
||||
std::sort(begin(items), end(items), cmpShellItems);
|
||||
|
||||
for (const auto& item : items)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace
|
||||
const wchar_t c_replaceText[] = L"ReplaceText";
|
||||
const wchar_t c_mruEnabled[] = L"MRUEnabled";
|
||||
const wchar_t c_useBoostLib[] = L"UseBoostLib";
|
||||
const wchar_t c_lastWindowWidth[] = L"LastWindowWidth";
|
||||
const wchar_t c_lastWindowHeight[] = L"LastWindowHeight";
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +51,8 @@ void CSettings::Save()
|
||||
jsonData.SetNamedValue(c_searchText, json::value(settings.searchText));
|
||||
jsonData.SetNamedValue(c_replaceText, json::value(settings.replaceText));
|
||||
jsonData.SetNamedValue(c_useBoostLib, json::value(settings.useBoostLib));
|
||||
jsonData.SetNamedValue(c_lastWindowWidth, json::value(settings.lastWindowWidth));
|
||||
jsonData.SetNamedValue(c_lastWindowHeight, json::value(settings.lastWindowHeight));
|
||||
|
||||
json::to_file(jsonFilePath, jsonData);
|
||||
GetSystemTimeAsFileTime(&lastLoadedTime);
|
||||
@@ -139,6 +143,9 @@ void CSettings::ParseJson()
|
||||
{
|
||||
settings.useBoostLib = jsonSettings.GetNamedBoolean(c_useBoostLib);
|
||||
}
|
||||
|
||||
settings.lastWindowWidth = static_cast<int>(jsonSettings.GetNamedNumber(c_lastWindowWidth, DEFAULT_WINDOW_WIDTH));
|
||||
settings.lastWindowHeight = static_cast<int>(jsonSettings.GetNamedNumber(c_lastWindowHeight, DEFAULT_WINDOW_HEIGHT));
|
||||
}
|
||||
catch (const winrt::hresult_error&)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
class CSettings
|
||||
{
|
||||
public:
|
||||
static constexpr inline int DEFAULT_WINDOW_WIDTH = 1400;
|
||||
static constexpr inline int DEFAULT_WINDOW_HEIGHT = 800;
|
||||
|
||||
CSettings();
|
||||
|
||||
inline bool GetEnabled()
|
||||
@@ -25,6 +28,17 @@ 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;
|
||||
@@ -134,6 +148,8 @@ private:
|
||||
unsigned int flags{ 0 };
|
||||
std::wstring searchText{};
|
||||
std::wstring replaceText{};
|
||||
int lastWindowWidth{ DEFAULT_WINDOW_WIDTH };
|
||||
int lastWindowHeight{ DEFAULT_WINDOW_HEIGHT };
|
||||
};
|
||||
|
||||
void Reload();
|
||||
|
||||
Reference in New Issue
Block a user