format changed files

This commit is contained in:
yuyoyuppe 2019-12-20 16:59:20 +03:00 committed by yuyoyuppe
parent 249addebff
commit 62c65659cc
11 changed files with 101 additions and 105 deletions

View File

@ -16,7 +16,7 @@ void ModuleAddRef()
void ModuleRelease()
{
if(--g_dwModuleRefCount == 0)
if (--g_dwModuleRefCount == 0)
{
PostThreadMessage(main_thread_id, WM_QUIT, 0, 0);
}
@ -81,16 +81,16 @@ public:
{
return S_OK;
}
private:
private:
std::atomic<long> _refCount;
CLSID _clsid;
};
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE ,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
_In_opt_ HINSTANCE,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
main_thread_id = GetCurrentThreadId();
winrt::init_apartment();
@ -101,7 +101,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
{
return 1;
}
// Run msg loop for the local COM server
run_message_loop();

View File

@ -28,11 +28,11 @@ CPowerRenameMenu::~CPowerRenameMenu()
ModuleRelease();
}
HRESULT CPowerRenameMenu::s_CreateInstance(_In_opt_ IUnknown*, _In_ REFIID riid, _Outptr_ void **ppv)
HRESULT CPowerRenameMenu::s_CreateInstance(_In_opt_ IUnknown*, _In_ REFIID riid, _Outptr_ void** ppv)
{
*ppv = nullptr;
HRESULT hr = E_OUTOFMEMORY;
CPowerRenameMenu *pprm = new CPowerRenameMenu();
CPowerRenameMenu* pprm = new CPowerRenameMenu();
if (pprm)
{
hr = pprm->QueryInterface(riid, ppv);
@ -42,7 +42,7 @@ HRESULT CPowerRenameMenu::s_CreateInstance(_In_opt_ IUnknown*, _In_ REFIID riid,
}
// IShellExtInit
HRESULT CPowerRenameMenu::Initialize(_In_opt_ PCIDLIST_ABSOLUTE, _In_ IDataObject *pdtobj, HKEY)
HRESULT CPowerRenameMenu::Initialize(_In_opt_ PCIDLIST_ABSOLUTE, _In_ IDataObject* pdtobj, HKEY)
{
// Check if we have disabled ourselves
if (!CSettings::GetEnabled())
@ -115,7 +115,7 @@ HRESULT CPowerRenameMenu::InvokeCommand(_In_ LPCMINVOKECOMMANDINFO pici)
(LOWORD(pici->lpVerb) == 0))
{
Trace::Invoked();
InvokeStruct* pInvokeData = new(std::nothrow) InvokeStruct;
InvokeStruct* pInvokeData = new (std::nothrow) InvokeStruct;
hr = pInvokeData ? S_OK : E_OUTOFMEMORY;
if (SUCCEEDED(hr))
{
@ -202,8 +202,8 @@ HRESULT __stdcall CPowerRenameMenu::GetIcon(IShellItemArray* /*psiItemArray*/, L
{
if (!CSettings::GetShowIconOnMenu())
{
*ppszIcon = nullptr;
return E_NOTIMPL;
*ppszIcon = nullptr;
return E_NOTIMPL;
}
std::wstring iconResourcePath = get_module_filename();
@ -240,7 +240,7 @@ HRESULT __stdcall CPowerRenameMenu::Invoke(IShellItemArray* psiItemArray, IBindC
MessageBoxW(nullptr, buffer, L"PID", MB_OK);
#endif
Trace::Invoked();
InvokeStruct* pInvokeData = new(std::nothrow) InvokeStruct;
InvokeStruct* pInvokeData = new (std::nothrow) InvokeStruct;
HRESULT hr = pInvokeData ? S_OK : E_OUTOFMEMORY;
if (SUCCEEDED(hr))
{

View File

@ -12,8 +12,7 @@ public:
// IUnknown
IFACEMETHODIMP QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppv)
{
static const QITAB qit[] =
{
static const QITAB qit[] = {
QITABENT(CPowerRenameMenu, IShellExtInit),
QITABENT(CPowerRenameMenu, IContextMenu),
QITABENT(CPowerRenameMenu, IExplorerCommand),
@ -22,12 +21,14 @@ public:
return QISearch(this, qit, riid, ppv);
}
IFACEMETHODIMP_(ULONG) AddRef()
IFACEMETHODIMP_(ULONG)
AddRef()
{
return ++m_refCount;
}
IFACEMETHODIMP_(ULONG) Release()
IFACEMETHODIMP_(ULONG)
Release()
{
LONG refCount = --m_refCount;
if (refCount == 0)
@ -58,7 +59,6 @@ public:
virtual HRESULT __stdcall GetFlags(EXPCMDFLAGS* pFlags) override;
virtual HRESULT __stdcall EnumSubCommands(IEnumExplorerCommand** ppEnum) override;
static HRESULT s_CreateInstance(_In_opt_ IUnknown* punkOuter, _In_ REFIID riid, _Outptr_ void** ppv);
static DWORD WINAPI s_PowerRenameUIThreadProc(_In_ void* pData);
@ -72,4 +72,3 @@ private:
HBITMAP m_hbmpIcon = nullptr;
CComPtr<IDataObject> m_spdo;
};

View File

@ -25,20 +25,21 @@ public:
// IUnknown methods
IFACEMETHODIMP QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppv)
{
static const QITAB qit[] =
{
static const QITAB qit[] = {
QITABENT(CPowerRenameClassFactory, IClassFactory),
{ 0 }
};
return QISearch(this, qit, riid, ppv);
}
IFACEMETHODIMP_(ULONG) AddRef()
IFACEMETHODIMP_(ULONG)
AddRef()
{
return ++m_refCount;
}
IFACEMETHODIMP_(ULONG) Release()
IFACEMETHODIMP_(ULONG)
Release()
{
LONG refCount = --m_refCount;
if (refCount == 0)
@ -121,11 +122,11 @@ STDAPI DllCanUnloadNow(void)
//
// DLL export for creating COM objects
//
STDAPI DllGetClassObject(_In_ REFCLSID clsid, _In_ REFIID riid, _Outptr_ void **ppv)
STDAPI DllGetClassObject(_In_ REFCLSID clsid, _In_ REFIID riid, _Outptr_ void** ppv)
{
*ppv = NULL;
HRESULT hr = E_OUTOFMEMORY;
CPowerRenameClassFactory *pClassFactory = new CPowerRenameClassFactory(clsid);
CPowerRenameClassFactory* pClassFactory = new CPowerRenameClassFactory(clsid);
if (pClassFactory)
{
hr = pClassFactory->QueryInterface(riid, ppv);
@ -154,7 +155,6 @@ void ModuleRelease()
g_dwModuleRefCount--;
}
class PowerRenameModule : public PowertoyModuleIface
{
private:
@ -212,14 +212,12 @@ public:
settings.add_bool_toogle(
L"bool_persist_input",
L"Restore search, replace and flags values on launch from previous run.",
CSettings::GetPersistState()
);
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()
);
CSettings::GetMRUEnabled());
settings.add_int_spinner(
L"int_max_mru_size",
@ -227,20 +225,17 @@ public:
CSettings::GetMaxMRUSize(),
0,
20,
1
);
1);
settings.add_bool_toogle(
L"bool_show_icon_on_menu",
L"Show icon on context menu.",
CSettings::GetShowIconOnMenu()
);
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()
);
CSettings::GetExtendedContextMenuOnly());
return settings.serialize_to_buffer(buffer, buffer_size);
}
@ -249,7 +244,8 @@ public:
// This is called when the user hits Save on the settings page.
virtual void set_config(PCWSTR config) override
{
try {
try
{
// Parse the input JSON string.
PowerToysSettings::PowerToyValues values =
PowerToysSettings::PowerToyValues::from_json_string(config);
@ -260,7 +256,8 @@ public:
CSettings::SetShowIconOnMenu(values.get_bool_value(L"bool_show_icon_on_menu").value());
CSettings::SetExtendedContextMenuOnly(values.get_bool_value(L"bool_show_extended_menu").value());
}
catch (std::exception) {
catch (std::exception)
{
// Improper JSON.
}
}
@ -277,8 +274,8 @@ public:
return 0;
}
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override { }
virtual void signal_system_menu_action(const wchar_t* name) override { }
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override {}
virtual void signal_system_menu_action(const wchar_t* name) override {}
// Destroy the powertoy and free memory
virtual void destroy() override
@ -304,7 +301,6 @@ public:
}
};
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()
{
return new PowerRenameModule();

View File

@ -2,7 +2,7 @@
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <winrt/base.h>
#include <windows.h>

View File

@ -141,7 +141,7 @@ HRESULT _ParseEnumItems(_In_ IEnumShellItems* pesi, _In_ IPowerRenameManager* ps
}
// Iterate through the data source and add paths to the rotation manager
HRESULT EnumerateDataObject(_In_ IUnknown * dataSource, _In_ IPowerRenameManager* psrm)
HRESULT EnumerateDataObject(_In_ IUnknown* dataSource, _In_ IPowerRenameManager* psrm)
{
CComPtr<IShellItemArray> spsia;
IDataObject* dataObj{};
@ -150,7 +150,7 @@ HRESULT EnumerateDataObject(_In_ IUnknown * dataSource, _In_ IPowerRenameManager
{
hr = SHCreateShellItemArrayFromDataObject(dataObj, IID_PPV_ARGS(&spsia));
}
else
else
{
hr = dataSource->QueryInterface(IID_IShellItemArray, reinterpret_cast<void**>(&spsia));
}
@ -181,9 +181,7 @@ HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p
RegisterClass(&wc);
HWND hwnd = CreateWindowEx(
0, wndClassName, nullptr, 0,
0, 0, 0, 0, HWND_MESSAGE,
0, hInst, nullptr);
0, wndClassName, nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInst, nullptr);
if (hwnd)
{
SetWindowLongPtr(hwnd, 0, (LONG_PTR)p);
@ -196,9 +194,7 @@ HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p
return hwnd;
}
BOOL GetEnumeratedFileName(__out_ecount(cchMax) PWSTR pszUniqueName, UINT cchMax,
__in PCWSTR pszTemplate, __in_opt PCWSTR pszDir, unsigned long ulMinLong,
__inout unsigned long* pulNumUsed)
BOOL GetEnumeratedFileName(__out_ecount(cchMax) PWSTR pszUniqueName, UINT cchMax, __in PCWSTR pszTemplate, __in_opt PCWSTR pszDir, unsigned long ulMinLong, __inout unsigned long* pulNumUsed)
{
PWSTR pszName = nullptr;
HRESULT hr = S_OK;

View File

@ -8,6 +8,9 @@ HRESULT GetIconIndexFromPath(_In_ PCWSTR path, _Out_ int* index);
HBITMAP CreateBitmapFromIcon(_In_ HICON hIcon, _In_opt_ UINT width = 0, _In_opt_ UINT height = 0);
HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p);
BOOL GetEnumeratedFileName(
__out_ecount(cchMax) PWSTR pszUniqueName, UINT cchMax,
__in PCWSTR pszTemplate, __in_opt PCWSTR pszDir, unsigned long ulMinLong,
__out_ecount(cchMax) PWSTR pszUniqueName,
UINT cchMax,
__in PCWSTR pszTemplate,
__in_opt PCWSTR pszDir,
unsigned long ulMinLong,
__inout unsigned long* pulNumUsed);

View File

@ -9,7 +9,7 @@
#include <PowerRenameManager.h>
#include <Shobjidl.h>
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
HINSTANCE g_hInst;
void ModuleAddRef() {}

View File

@ -9,9 +9,7 @@
extern HINSTANCE g_hInst;
int g_rgnMatchModeResIDs[] =
{
int g_rgnMatchModeResIDs[] = {
IDS_ENTIREITEMNAME,
IDS_NAMEONLY,
IDS_EXTENSIONONLY
@ -30,17 +28,16 @@ struct FlagCheckboxMap
DWORD id;
};
FlagCheckboxMap g_flagCheckboxMap[] =
{
FlagCheckboxMap g_flagCheckboxMap[] = {
{ UseRegularExpressions, IDC_CHECK_USEREGEX },
{ ExcludeSubfolders, IDC_CHECK_EXCLUDESUBFOLDERS },
{ EnumerateItems, IDC_CHECK_ENUMITEMS },
{ ExcludeFiles, IDC_CHECK_EXCLUDEFILES },
{ CaseSensitive, IDC_CHECK_CASESENSITIVE },
{ MatchAllOccurences, IDC_CHECK_MATCHALLOCCURENCES },
{ ExcludeFolders, IDC_CHECK_EXCLUDEFOLDERS },
{ NameOnly, IDC_CHECK_NAMEONLY },
{ ExtensionOnly, IDC_CHECK_EXTENSIONONLY }
{ ExcludeSubfolders, IDC_CHECK_EXCLUDESUBFOLDERS },
{ EnumerateItems, IDC_CHECK_ENUMITEMS },
{ ExcludeFiles, IDC_CHECK_EXCLUDEFILES },
{ CaseSensitive, IDC_CHECK_CASESENSITIVE },
{ MatchAllOccurences, IDC_CHECK_MATCHALLOCCURENCES },
{ ExcludeFolders, IDC_CHECK_EXCLUDEFOLDERS },
{ NameOnly, IDC_CHECK_NAMEONLY },
{ ExtensionOnly, IDC_CHECK_EXTENSIONONLY }
};
struct RepositionMap
@ -58,30 +55,34 @@ enum
Reposition_Height = 0x8
};
RepositionMap g_repositionMap[] =
{
{ IDC_SEARCHREPLACEGROUP, Reposition_Width },
{ IDC_OPTIONSGROUP, Reposition_Width },
{ IDC_PREVIEWGROUP, Reposition_Width | Reposition_Height },
{ IDC_EDIT_SEARCHFOR, Reposition_Width },
{ IDC_EDIT_REPLACEWITH, Reposition_Width },
{ IDC_LIST_PREVIEW, Reposition_Width | Reposition_Height },
{ IDC_STATUS_MESSAGE, Reposition_Y },
{ ID_RENAME, Reposition_X | Reposition_Y },
{ ID_ABOUT, Reposition_X | Reposition_Y },
{ IDCANCEL, Reposition_X | Reposition_Y }
RepositionMap g_repositionMap[] = {
{ IDC_SEARCHREPLACEGROUP, Reposition_Width },
{ IDC_OPTIONSGROUP, Reposition_Width },
{ IDC_PREVIEWGROUP, Reposition_Width | Reposition_Height },
{ IDC_EDIT_SEARCHFOR, Reposition_Width },
{ IDC_EDIT_REPLACEWITH, Reposition_Width },
{ IDC_LIST_PREVIEW, Reposition_Width | Reposition_Height },
{ IDC_STATUS_MESSAGE, Reposition_Y },
{ ID_RENAME, Reposition_X | Reposition_Y },
{ ID_ABOUT, Reposition_X | Reposition_Y },
{ IDCANCEL, Reposition_X | Reposition_Y }
};
inline int RECT_WIDTH(RECT& r) { return r.right - r.left; }
inline int RECT_HEIGHT(RECT& r) { return r.bottom - r.top; }
inline int RECT_WIDTH(RECT& r)
{
return r.right - r.left;
}
inline int RECT_HEIGHT(RECT& r)
{
return r.bottom - r.top;
}
#define MAX_INPUT_STRING_LEN 1024
// IUnknown
IFACEMETHODIMP CPowerRenameUI::QueryInterface(__in REFIID riid, __deref_out void** ppv)
{
static const QITAB qit[] =
{
static const QITAB qit[] = {
QITABENT(CPowerRenameUI, IPowerRenameUI),
QITABENT(CPowerRenameUI, IPowerRenameManagerEvents),
QITABENT(CPowerRenameUI, IDropTarget),
@ -90,12 +91,14 @@ IFACEMETHODIMP CPowerRenameUI::QueryInterface(__in REFIID riid, __deref_out void
return QISearch(this, qit, riid, ppv);
}
IFACEMETHODIMP_(ULONG) CPowerRenameUI::AddRef()
IFACEMETHODIMP_(ULONG)
CPowerRenameUI::AddRef()
{
return InterlockedIncrement(&m_refCount);
}
IFACEMETHODIMP_(ULONG) CPowerRenameUI::Release()
IFACEMETHODIMP_(ULONG)
CPowerRenameUI::Release()
{
long refCount = InterlockedDecrement(&m_refCount);
if (refCount == 0)
@ -108,7 +111,7 @@ IFACEMETHODIMP_(ULONG) CPowerRenameUI::Release()
HRESULT CPowerRenameUI::s_CreateInstance(_In_ IPowerRenameManager* psrm, _In_opt_ IUnknown* dataSource, _In_ bool enableDragDrop, _Outptr_ IPowerRenameUI** ppsrui)
{
*ppsrui = nullptr;
CPowerRenameUI *prui = new CPowerRenameUI();
CPowerRenameUI* prui = new CPowerRenameUI();
HRESULT hr = prui ? S_OK : E_OUTOFMEMORY;
if (SUCCEEDED(hr))
{
@ -488,7 +491,7 @@ void CPowerRenameUI::_OnRename()
void CPowerRenameUI::_OnAbout()
{
// Launch github page
SHELLEXECUTEINFO info = {0};
SHELLEXECUTEINFO info = { 0 };
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.lpVerb = L"open";
info.lpFile = L"https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename";
@ -538,7 +541,7 @@ HRESULT CPowerRenameUI::_DoModeless(__in_opt HWND hwnd)
INT_PTR CPowerRenameUI::_DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
INT_PTR bRet = TRUE; // default for all handled cases in switch below
INT_PTR bRet = TRUE; // default for all handled cases in switch below
switch (uMsg)
{
@ -699,8 +702,8 @@ void CPowerRenameUI::_OnCommand(_In_ WPARAM wParam, _In_ LPARAM lParam)
BOOL CPowerRenameUI::_OnNotify(_In_ WPARAM wParam, _In_ LPARAM lParam)
{
bool ret = FALSE;
LPNMHDR pnmdr = (LPNMHDR)lParam;
LPNMLISTVIEW pnmlv = (LPNMLISTVIEW)pnmdr;
LPNMHDR pnmdr = (LPNMHDR)lParam;
LPNMLISTVIEW pnmlv = (LPNMLISTVIEW)pnmdr;
NMLVEMPTYMARKUP* pnmMarkup = NULL;
if (pnmdr)
@ -742,15 +745,14 @@ BOOL CPowerRenameUI::_OnNotify(_In_ WPARAM wParam, _In_ LPARAM lParam)
}
break;
case NM_CLICK:
case NM_CLICK: {
if (m_spsrm)
{
if (m_spsrm)
{
m_listview.OnClickList(m_spsrm, (NM_LISTVIEW*)pnmdr);
_UpdateCounts();
}
break;
m_listview.OnClickList(m_spsrm, (NM_LISTVIEW*)pnmdr);
_UpdateCounts();
}
break;
}
}
}
@ -1058,8 +1060,8 @@ void CPowerRenameListView::UpdateItemCheckState(_In_ IPowerRenameManager* psrm,
}
}
#define COL_ORIGINAL_NAME 0
#define COL_NEW_NAME 1
#define COL_ORIGINAL_NAME 0
#define COL_NEW_NAME 1
void CPowerRenameListView::GetDisplayInfo(_In_ IPowerRenameManager* psrm, _Inout_ LV_DISPINFO* plvdi)
{
@ -1234,5 +1236,3 @@ void CPowerRenameListView::_UpdateHeaderCheckState(_In_ bool check)
Header_SetItem(hwndHeader, 0, &hdi);
}
}

View File

@ -46,8 +46,10 @@ public:
// IUnknown
IFACEMETHODIMP QueryInterface(__in REFIID riid, __deref_out void** ppv);
IFACEMETHODIMP_(ULONG) AddRef();
IFACEMETHODIMP_(ULONG) Release();
IFACEMETHODIMP_(ULONG)
AddRef();
IFACEMETHODIMP_(ULONG)
Release();
// IPowerRenameUI
IFACEMETHODIMP Show(_In_opt_ HWND hwndParent);

View File

@ -2,7 +2,7 @@
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>