mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[PowerRename] upper/lower/titlecase transform feature (#4183)
* Add basic transform functionality * Add basic transform functionality * Change toupper/tolower/isspace to towupper/towlower/towisspace. For loops omitted if possible. * Avoid wcslen() in for statement * Avoid wcslen() in for statement * Add basic transform functionality * Change toupper/tolower/isspace to towupper/towlower/towisspace. For loops omitted if possible. * Avoid wcslen() in for statement * Avoid wcslen() in for statement * Add basic transform functionality * Change toupper/tolower/isspace to towupper/towlower/towisspace. For loops omitted if possible. * Avoid wcslen() in for statement * Adjust Powerrename Interface * Add trimming rename string * Remove leading and trailing spaces from rename string * Add support for transforming only item name or extension. Temporarily remove trimming to refactor. Change CAPITALIZED to TITLECASE * Fix bug when search for area is empty * Add trimming back with refactor(leading spaces, trailing spaces, trailing dots) * Now supports transforming when search area is empty * Add smarter titlecase Transformation breaks when new filename contains an unusable character (\/?:*?"<>|) These characters need to be removed from new name anyway. * minor bugfix * Add unittests, contains failing tests * Remove unnecessary/failing tests * remove generated file * some code formatting and fix memory leak issues * Use proper allocation, change int to size_t * Refactor. Move transforming to Helpers.cpp * Refactor. Move trimming to Helpers.cpp * Change StrDup to SHStrDup. Some refactoring. * Fix memery leak, add proper result controls, use newNameToUse in functon calls becaause it is where the final form of the string is tracked * Change declarations of strings, add proper result controls * Slightly widen the labels to cover the whole text * Add extended characters support * Rename a variable * Correctly identify the last word for titlecase * Add empty line to last line of resource.h
This commit is contained in:
committed by
GitHub
parent
e8685de7f7
commit
30f442d774
@@ -39,7 +39,10 @@ FlagCheckboxMap g_flagCheckboxMap[] = {
|
||||
{ MatchAllOccurences, IDC_CHECK_MATCHALLOCCURENCES },
|
||||
{ ExcludeFolders, IDC_CHECK_EXCLUDEFOLDERS },
|
||||
{ NameOnly, IDC_CHECK_NAMEONLY },
|
||||
{ ExtensionOnly, IDC_CHECK_EXTENSIONONLY }
|
||||
{ ExtensionOnly, IDC_CHECK_EXTENSIONONLY },
|
||||
{ Uppercase, IDC_TRANSFORM_UPPERCASE },
|
||||
{ Lowercase, IDC_TRANSFORM_LOWERCASE },
|
||||
{ Titlecase, IDC_TRANSFORM_TITLECASE }
|
||||
};
|
||||
|
||||
struct RepositionMap
|
||||
@@ -683,6 +686,9 @@ void CPowerRenameUI::_OnCommand(_In_ WPARAM wParam, _In_ LPARAM lParam)
|
||||
case IDC_CHECK_USEREGEX:
|
||||
case IDC_CHECK_EXTENSIONONLY:
|
||||
case IDC_CHECK_NAMEONLY:
|
||||
case IDC_TRANSFORM_UPPERCASE:
|
||||
case IDC_TRANSFORM_LOWERCASE:
|
||||
case IDC_TRANSFORM_TITLECASE:
|
||||
if (BN_CLICKED == HIWORD(wParam))
|
||||
{
|
||||
_ValidateFlagCheckbox(LOWORD(wParam));
|
||||
@@ -891,7 +897,31 @@ void CPowerRenameUI::_SetCheckboxesFromFlags(_In_ DWORD flags)
|
||||
|
||||
void CPowerRenameUI::_ValidateFlagCheckbox(_In_ DWORD checkBoxId)
|
||||
{
|
||||
if (checkBoxId == IDC_CHECK_NAMEONLY)
|
||||
if (checkBoxId == IDC_TRANSFORM_UPPERCASE )
|
||||
{
|
||||
if (Button_GetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_UPPERCASE)) == BST_CHECKED)
|
||||
{
|
||||
Button_SetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_LOWERCASE), FALSE);
|
||||
Button_SetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_TITLECASE), FALSE);
|
||||
}
|
||||
}
|
||||
else if (checkBoxId == IDC_TRANSFORM_LOWERCASE)
|
||||
{
|
||||
if (Button_GetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_LOWERCASE)) == BST_CHECKED)
|
||||
{
|
||||
Button_SetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_UPPERCASE), FALSE);
|
||||
Button_SetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_TITLECASE), FALSE);
|
||||
}
|
||||
}
|
||||
else if (checkBoxId == IDC_TRANSFORM_TITLECASE)
|
||||
{
|
||||
if (Button_GetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_TITLECASE)) == BST_CHECKED)
|
||||
{
|
||||
Button_SetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_UPPERCASE), FALSE);
|
||||
Button_SetCheck(GetDlgItem(m_hwnd, IDC_TRANSFORM_LOWERCASE), FALSE);
|
||||
}
|
||||
}
|
||||
else if (checkBoxId == IDC_CHECK_NAMEONLY)
|
||||
{
|
||||
if (Button_GetCheck(GetDlgItem(m_hwnd, IDC_CHECK_NAMEONLY)) == BST_CHECKED)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user