mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 21:41:51 +02:00
* Fix crashing bug in event vector cleanup
* Fix warnings in settings.cpp * Add settings to ui of powertoys
This commit is contained in:
@@ -160,6 +160,7 @@
|
|||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>$(SolutionDir)$(Platform)\$(Configuration)\PowerRenameLib.lib;$(SolutionDir)$(Platform)\$(Configuration)\PowerRenameUI.lib;Pathcch.lib;comctl32.lib;$(SolutionDir)$(Platform)\$(Configuration)\..\..\src\modules\powerrename\UI\$(Platform)\$(Configuration)\PowerRenameUI.res;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(SolutionDir)$(Platform)\$(Configuration)\PowerRenameLib.lib;$(SolutionDir)$(Platform)\$(Configuration)\PowerRenameUI.lib;Pathcch.lib;comctl32.lib;$(SolutionDir)$(Platform)\$(Configuration)\..\..\src\modules\powerrename\UI\$(Platform)\$(Configuration)\PowerRenameUI.res;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<ModuleDefinitionFile>PowerRenameExt.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>PowerRenameExt.def</ModuleDefinitionFile>
|
||||||
|
<DelayLoadDLLs>gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;shlwapi.dll;oleaut32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -207,6 +207,39 @@ public:
|
|||||||
// Link to the GitHub PowerRename sub-page
|
// Link to the GitHub PowerRename sub-page
|
||||||
settings.set_overview_link(L"https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename");
|
settings.set_overview_link(L"https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename");
|
||||||
|
|
||||||
|
settings.add_bool_toogle(
|
||||||
|
L"bool_persist_input",
|
||||||
|
L"Restore search, replace and flags values on launch from previous run.",
|
||||||
|
CSettings::GetPersistState()
|
||||||
|
);
|
||||||
|
|
||||||
|
settings.add_bool_toogle(
|
||||||
|
L"bool_mru_enabled",
|
||||||
|
L"Enable autocomplete and autosuggest of recently used inputs for search and replace values.",
|
||||||
|
CSettings::GetMRUEnabled()
|
||||||
|
);
|
||||||
|
|
||||||
|
settings.add_int_spinner(
|
||||||
|
L"int_max_mru_size",
|
||||||
|
L"Maximum number of items to show in recently used list for autocomplete dropdown.",
|
||||||
|
CSettings::GetMaxMRUSize(),
|
||||||
|
0,
|
||||||
|
20,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
settings.add_bool_toogle(
|
||||||
|
L"bool_show_icon_on_menu",
|
||||||
|
L"Show icon on context menu.",
|
||||||
|
CSettings::GetShowIconOnMenu()
|
||||||
|
);
|
||||||
|
|
||||||
|
settings.add_bool_toogle(
|
||||||
|
L"bool_show_extended_menu",
|
||||||
|
L"Only show the PowerRename menu item on the extended context menu (SHIFT + Right-click).",
|
||||||
|
CSettings::GetExtendedContextMenuOnly()
|
||||||
|
);
|
||||||
|
|
||||||
return settings.serialize_to_buffer(buffer, buffer_size);
|
return settings.serialize_to_buffer(buffer, buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,6 +247,22 @@ public:
|
|||||||
// This is called when the user hits Save on the settings page.
|
// This is called when the user hits Save on the settings page.
|
||||||
virtual void set_config(PCWSTR config) override
|
virtual void set_config(PCWSTR config) override
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
// Parse the input JSON string.
|
||||||
|
PowerToysSettings::PowerToyValues values =
|
||||||
|
PowerToysSettings::PowerToyValues::from_json_string(config);
|
||||||
|
|
||||||
|
CSettings::SetPersistState(values.get_bool_value(L"bool_persist_input"));
|
||||||
|
CSettings::SetMRUEnabled(values.get_bool_value(L"bool_mru_enabled"));
|
||||||
|
CSettings::SetMaxMRUSize(values.get_int_value(L"int_max_mru_size"));
|
||||||
|
CSettings::SetShowIconOnMenu(values.get_bool_value(L"bool_show_icon_on_menu"));
|
||||||
|
CSettings::SetExtendedContextMenuOnly(values.get_int_value(L"bool_show_extended_menu"));
|
||||||
|
|
||||||
|
values.save_to_settings_file();
|
||||||
|
}
|
||||||
|
catch (std::exception & ex) {
|
||||||
|
// Improper JSON.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signal from the Settings editor to call a custom action.
|
// Signal from the Settings editor to call a custom action.
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ IFACEMETHODIMP CPowerRenameManager::Advise(_In_ IPowerRenameManagerEvents* renam
|
|||||||
srme.cookie = m_cookie;
|
srme.cookie = m_cookie;
|
||||||
srme.pEvents = renameOpEvents;
|
srme.pEvents = renameOpEvents;
|
||||||
renameOpEvents->AddRef();
|
renameOpEvents->AddRef();
|
||||||
m_PowerRenameManagerEvents.push_back(srme);
|
m_powerRenameManagerEvents.push_back(srme);
|
||||||
|
|
||||||
*cookie = m_cookie;
|
*cookie = m_cookie;
|
||||||
|
|
||||||
@@ -60,16 +60,16 @@ IFACEMETHODIMP CPowerRenameManager::UnAdvise(_In_ DWORD cookie)
|
|||||||
HRESULT hr = E_FAIL;
|
HRESULT hr = E_FAIL;
|
||||||
CSRWExclusiveAutoLock lock(&m_lockEvents);
|
CSRWExclusiveAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (std::vector<RENAME_MGR_EVENT>::iterator it = m_powerRenameManagerEvents.begin(); it != m_powerRenameManagerEvents.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it.cookie == cookie)
|
if (it->cookie == cookie)
|
||||||
{
|
{
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
it.cookie = 0;
|
it->cookie = 0;
|
||||||
if (it.pEvents)
|
if (it->pEvents)
|
||||||
{
|
{
|
||||||
it.pEvents->Release();
|
it->pEvents->Release();
|
||||||
it.pEvents = nullptr;
|
it->pEvents = nullptr;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -921,7 +921,7 @@ void CPowerRenameManager::_OnItemAdded(_In_ IPowerRenameItem* renameItem)
|
|||||||
{
|
{
|
||||||
CSRWSharedAutoLock lock(&m_lockEvents);
|
CSRWSharedAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (auto it : m_powerRenameManagerEvents)
|
||||||
{
|
{
|
||||||
if (it.pEvents)
|
if (it.pEvents)
|
||||||
{
|
{
|
||||||
@@ -934,7 +934,7 @@ void CPowerRenameManager::_OnUpdate(_In_ IPowerRenameItem* renameItem)
|
|||||||
{
|
{
|
||||||
CSRWSharedAutoLock lock(&m_lockEvents);
|
CSRWSharedAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (auto it : m_powerRenameManagerEvents)
|
||||||
{
|
{
|
||||||
if (it.pEvents)
|
if (it.pEvents)
|
||||||
{
|
{
|
||||||
@@ -947,7 +947,7 @@ void CPowerRenameManager::_OnError(_In_ IPowerRenameItem* renameItem)
|
|||||||
{
|
{
|
||||||
CSRWSharedAutoLock lock(&m_lockEvents);
|
CSRWSharedAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (auto it : m_powerRenameManagerEvents)
|
||||||
{
|
{
|
||||||
if (it.pEvents)
|
if (it.pEvents)
|
||||||
{
|
{
|
||||||
@@ -960,7 +960,7 @@ void CPowerRenameManager::_OnRegExStarted(_In_ DWORD threadId)
|
|||||||
{
|
{
|
||||||
CSRWSharedAutoLock lock(&m_lockEvents);
|
CSRWSharedAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (auto it : m_powerRenameManagerEvents)
|
||||||
{
|
{
|
||||||
if (it.pEvents)
|
if (it.pEvents)
|
||||||
{
|
{
|
||||||
@@ -973,7 +973,7 @@ void CPowerRenameManager::_OnRegExCanceled(_In_ DWORD threadId)
|
|||||||
{
|
{
|
||||||
CSRWSharedAutoLock lock(&m_lockEvents);
|
CSRWSharedAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (auto it : m_powerRenameManagerEvents)
|
||||||
{
|
{
|
||||||
if (it.pEvents)
|
if (it.pEvents)
|
||||||
{
|
{
|
||||||
@@ -986,7 +986,7 @@ void CPowerRenameManager::_OnRegExCompleted(_In_ DWORD threadId)
|
|||||||
{
|
{
|
||||||
CSRWSharedAutoLock lock(&m_lockEvents);
|
CSRWSharedAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (auto it : m_powerRenameManagerEvents)
|
||||||
{
|
{
|
||||||
if (it.pEvents)
|
if (it.pEvents)
|
||||||
{
|
{
|
||||||
@@ -999,7 +999,7 @@ void CPowerRenameManager::_OnRenameStarted()
|
|||||||
{
|
{
|
||||||
CSRWSharedAutoLock lock(&m_lockEvents);
|
CSRWSharedAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (auto it : m_powerRenameManagerEvents)
|
||||||
{
|
{
|
||||||
if (it.pEvents)
|
if (it.pEvents)
|
||||||
{
|
{
|
||||||
@@ -1012,7 +1012,7 @@ void CPowerRenameManager::_OnRenameCompleted()
|
|||||||
{
|
{
|
||||||
CSRWSharedAutoLock lock(&m_lockEvents);
|
CSRWSharedAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (auto it : m_powerRenameManagerEvents)
|
||||||
{
|
{
|
||||||
if (it.pEvents)
|
if (it.pEvents)
|
||||||
{
|
{
|
||||||
@@ -1026,17 +1026,17 @@ void CPowerRenameManager::_ClearEventHandlers()
|
|||||||
CSRWExclusiveAutoLock lock(&m_lockEvents);
|
CSRWExclusiveAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
// Cleanup event handlers
|
// Cleanup event handlers
|
||||||
for (auto it : m_PowerRenameManagerEvents)
|
for (std::vector<RENAME_MGR_EVENT>::iterator it = m_powerRenameManagerEvents.begin(); it != m_powerRenameManagerEvents.end(); ++it)
|
||||||
{
|
{
|
||||||
it.cookie = 0;
|
it->cookie = 0;
|
||||||
if (it.pEvents)
|
if (it->pEvents)
|
||||||
{
|
{
|
||||||
it.pEvents->Release();
|
it->pEvents->Release();
|
||||||
it.pEvents = nullptr;
|
it->pEvents = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_PowerRenameManagerEvents.clear();
|
m_powerRenameManagerEvents.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPowerRenameManager::_ClearPowerRenameItems()
|
void CPowerRenameManager::_ClearPowerRenameItems()
|
||||||
@@ -1044,10 +1044,14 @@ void CPowerRenameManager::_ClearPowerRenameItems()
|
|||||||
CSRWExclusiveAutoLock lock(&m_lockItems);
|
CSRWExclusiveAutoLock lock(&m_lockItems);
|
||||||
|
|
||||||
// Cleanup rename items
|
// Cleanup rename items
|
||||||
for (auto it : m_renameItems)
|
for (std::map<int, IPowerRenameItem*>::iterator it = m_renameItems.begin(); it != m_renameItems.end(); ++it)
|
||||||
|
{
|
||||||
|
IPowerRenameItem* pItem = it->second;
|
||||||
|
if (pItem)
|
||||||
{
|
{
|
||||||
IPowerRenameItem* pItem = it.second;
|
|
||||||
pItem->Release();
|
pItem->Release();
|
||||||
|
it->second = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_renameItems.clear();
|
m_renameItems.clear();
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ protected:
|
|||||||
CComPtr<IPowerRenameItemFactory> m_spItemFactory;
|
CComPtr<IPowerRenameItemFactory> m_spItemFactory;
|
||||||
CComPtr<IPowerRenameRegEx> m_spRegEx;
|
CComPtr<IPowerRenameRegEx> m_spRegEx;
|
||||||
|
|
||||||
_Guarded_by_(m_lockEvents) std::vector<RENAME_MGR_EVENT> m_PowerRenameManagerEvents;
|
_Guarded_by_(m_lockEvents) std::vector<RENAME_MGR_EVENT> m_powerRenameManagerEvents;
|
||||||
_Guarded_by_(m_lockItems) std::map<int, IPowerRenameItem*> m_renameItems;
|
_Guarded_by_(m_lockItems) std::map<int, IPowerRenameItem*> m_renameItems;
|
||||||
|
|
||||||
// Parent HWND used by IFileOperation
|
// Parent HWND used by IFileOperation
|
||||||
|
|||||||
@@ -53,16 +53,16 @@ IFACEMETHODIMP CPowerRenameRegEx::UnAdvise(_In_ DWORD cookie)
|
|||||||
HRESULT hr = E_FAIL;
|
HRESULT hr = E_FAIL;
|
||||||
CSRWExclusiveAutoLock lock(&m_lockEvents);
|
CSRWExclusiveAutoLock lock(&m_lockEvents);
|
||||||
|
|
||||||
for (auto it : m_renameRegExEvents)
|
for (std::vector<RENAME_REGEX_EVENT>::iterator it = m_renameRegExEvents.begin(); it != m_renameRegExEvents.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it.cookie == cookie)
|
if (it->cookie == cookie)
|
||||||
{
|
{
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
it.cookie = 0;
|
it->cookie = 0;
|
||||||
if (it.pEvents)
|
if (it->pEvents)
|
||||||
{
|
{
|
||||||
it.pEvents->Release();
|
it->pEvents->Release();
|
||||||
it.pEvents = nullptr;
|
it->pEvents = nullptr;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public:
|
|||||||
|
|
||||||
// IEnumString
|
// IEnumString
|
||||||
IFACEMETHODIMP Next(__in ULONG celt, __out_ecount_part(celt, *pceltFetched) LPOLESTR* rgelt, __out_opt ULONG* pceltFetched);
|
IFACEMETHODIMP Next(__in ULONG celt, __out_ecount_part(celt, *pceltFetched) LPOLESTR* rgelt, __out_opt ULONG* pceltFetched);
|
||||||
IFACEMETHODIMP Skip(__in ULONG celt) { return E_NOTIMPL; }
|
IFACEMETHODIMP Skip(__in ULONG) { return E_NOTIMPL; }
|
||||||
IFACEMETHODIMP Reset();
|
IFACEMETHODIMP Reset();
|
||||||
IFACEMETHODIMP Clone(__deref_out IEnumString** ppenum) { *ppenum = nullptr; return E_NOTIMPL; }
|
IFACEMETHODIMP Clone(__deref_out IEnumString** ppenum) { *ppenum = nullptr; return E_NOTIMPL; }
|
||||||
|
|
||||||
@@ -380,8 +380,6 @@ IFACEMETHODIMP CRenameMRU::AddMRUString(_In_ PCWSTR entry)
|
|||||||
|
|
||||||
HRESULT CRenameMRU::_CreateMRUList(_In_ MRUINFO* pmi)
|
HRESULT CRenameMRU::_CreateMRUList(_In_ MRUINFO* pmi)
|
||||||
{
|
{
|
||||||
HRESULT hr = E_FAIL;
|
|
||||||
|
|
||||||
if (m_mruHandle != NULL)
|
if (m_mruHandle != NULL)
|
||||||
{
|
{
|
||||||
_FreeMRUList();
|
_FreeMRUList();
|
||||||
|
|||||||
@@ -164,6 +164,7 @@
|
|||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>$(OutDir)PowerRenameLib.lib;$(OutDir)PowerRenameUI.lib;Pathcch.lib;comctl32.lib;$(OutDir)..\..\src\modules\powerrename\UI\$(Platform)\$(Configuration)\PowerRenameUI.res;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(OutDir)PowerRenameLib.lib;$(OutDir)PowerRenameUI.lib;Pathcch.lib;comctl32.lib;$(OutDir)..\..\src\modules\powerrename\UI\$(Platform)\$(Configuration)\PowerRenameUI.res;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<DelayLoadDLLs>gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;shlwapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -357,6 +357,8 @@ void CPowerRenameUI::_Cleanup()
|
|||||||
{
|
{
|
||||||
RevokeDragDrop(m_hwnd);
|
RevokeDragDrop(m_hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_hwnd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPowerRenameUI::_EnumerateItems(_In_ IDataObject* pdtobj)
|
void CPowerRenameUI::_EnumerateItems(_In_ IDataObject* pdtobj)
|
||||||
@@ -446,6 +448,8 @@ HRESULT CPowerRenameUI::_WriteSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CPowerRenameUI::_OnCloseDlg()
|
void CPowerRenameUI::_OnCloseDlg()
|
||||||
|
{
|
||||||
|
if (m_hwnd != NULL)
|
||||||
{
|
{
|
||||||
if (m_modeless)
|
if (m_modeless)
|
||||||
{
|
{
|
||||||
@@ -456,6 +460,7 @@ void CPowerRenameUI::_OnCloseDlg()
|
|||||||
EndDialog(m_hwnd, 1);
|
EndDialog(m_hwnd, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CPowerRenameUI::_OnDestroyDlg()
|
void CPowerRenameUI::_OnDestroyDlg()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user