mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 13:35:31 +02:00
[PowerRename] Add ModificationTime and AccessTime support when renaming with $YY-$MM-$DD patterns (#39653)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request 1. Add new configuration to control this behaviour. By default, set to creation time to align with previous version 2. Add UI in PowerRename's MainWindow 3. Implement the logic  Original discussion here: https://github.com/microsoft/PowerToys/pull/38186 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] **Closes:** #36040 - [x] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected - [x] **Tests:** Added/updated and all pass - [x] **Localization:** All end user facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed --------- Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com> Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
This commit is contained in:
@@ -184,6 +184,7 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="48" />
|
||||
<RowDefinition Height="48" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel
|
||||
@@ -558,6 +559,33 @@
|
||||
Content=""
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
x:Name="FileTimeLabel"
|
||||
x:Uid="TextBlock_FileTime"
|
||||
Margin="0,16,0,8"
|
||||
FontSize="12"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
Spacing="4">
|
||||
<ComboBox
|
||||
x:Name="comboBox_fileTimeParts"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Width="200"
|
||||
HorizontalAlignment="Stretch"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=FileDateLabel}"
|
||||
SelectedIndex="0">
|
||||
<ComboBoxItem x:Uid="FileTimeParts_CreationTime" />
|
||||
<ComboBoxItem x:Uid="FileTimeParts_ModificationTime" />
|
||||
<ComboBoxItem x:Uid="FileTimeParts_AccessTime" />
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<Rectangle
|
||||
|
||||
@@ -792,6 +792,32 @@ namespace winrt::PowerRenameUI::implementation
|
||||
button_settings().Click([&](auto const&, auto const&) {
|
||||
OpenSettingsApp();
|
||||
});
|
||||
|
||||
// ComboBox RenameParts
|
||||
comboBox_fileTimeParts().SelectionChanged([&](auto const&, auto const&) {
|
||||
int selectedIndex = comboBox_fileTimeParts().SelectedIndex();
|
||||
if (selectedIndex == 0)
|
||||
{
|
||||
// default behaviour. Date Created
|
||||
UpdateFlag(CreationTime, UpdateFlagCommand::Set);
|
||||
UpdateFlag(ModificationTime, UpdateFlagCommand::Reset);
|
||||
UpdateFlag(AccessTime, UpdateFlagCommand::Reset);
|
||||
}
|
||||
else if (selectedIndex == 1)
|
||||
{
|
||||
// Date Modified
|
||||
UpdateFlag(ModificationTime, UpdateFlagCommand::Set);
|
||||
UpdateFlag(CreationTime, UpdateFlagCommand::Reset);
|
||||
UpdateFlag(AccessTime, UpdateFlagCommand::Reset);
|
||||
}
|
||||
else if (selectedIndex == 2)
|
||||
{
|
||||
// Accessed
|
||||
UpdateFlag(AccessTime, UpdateFlagCommand::Set);
|
||||
UpdateFlag(CreationTime, UpdateFlagCommand::Reset);
|
||||
UpdateFlag(ModificationTime, UpdateFlagCommand::Reset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::ToggleItem(int32_t id, bool checked)
|
||||
|
||||
@@ -411,4 +411,16 @@
|
||||
<data name="ToggleButton_RandItems.[using:Microsoft.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Random string features</value>
|
||||
</data>
|
||||
<data name="TextBlock_FileTime.Text" xml:space="preserve">
|
||||
<value>Time used for replacement</value>
|
||||
</data>
|
||||
<data name="FileTimeParts_CreationTime.Content" xml:space="preserve">
|
||||
<value>Creation Time</value>
|
||||
</data>
|
||||
<data name="FileTimeParts_ModificationTime.Content" xml:space="preserve">
|
||||
<value>Modification Time</value>
|
||||
</data>
|
||||
<data name="FileTimeParts_AccessTime.Content" xml:space="preserve">
|
||||
<value>Access Time</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user