Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Actions menu #31220

Open
wants to merge 115 commits into
base: main
Choose a base branch
from
Open

File Actions menu #31220

wants to merge 115 commits into from

Conversation

Aaron-Junker
Copy link
Collaborator

@Aaron-Junker Aaron-Junker commented Feb 1, 2024

Summary of the Pull Request

Adding a new menu invokable by selecting files in explorer and pressing a shortcut set in the settings.

Screenshots

image
image
image
image
image
image
image

PR Checklist

Detailed Description of the Pull Request / Additional comments

Things left to do:

  • Add installer
  • Add icon
  • DPI Awareness

Validation Steps Performed

</ui:MenuItem.Icon>
</ui:MenuItem>
<Separator/>
<ui:MenuItem Header="Copy path of files sperated by">

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[sperated](#security-tab) is not a recognized word. \(unrecognized-spelling\)
@Aaron-Junker
Copy link
Collaborator Author

@niels9001 Do you have an idea why the contextmenu doesn't take the WPFUI style?

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-spelling found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@Aaron-Junker
Copy link
Collaborator Author

Aaron-Junker commented Jul 21, 2024

@jaimecbernardo I fixed all your found issues except for the first one (which is dependend on microsoft/microsoft-ui-xaml#3627). So this is ready for round two.

This comment has been minimized.

Copy link
Collaborator

@stefansjfw stefansjfw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did partial review of the code (around 50%). I do another round of review tomorrow. Here are some comments/questions:

  • I'd prefer not to have dependencies between modules. E.g. FileActionsMenu depending on Peek.Helpers. If possible move Peek.Helpers to Common
  • "New folder with selection" option creates folder named "New folder with selection" :) If not possible to get to renaming state right away, some other name might be better. maybe just "New Folder ()" as explorer does by default
  • I don't get Uninstall option for several different apps I tried with. Can you give me an example where it appears so I can give it a try?
  • Can we move launching PowerToys (ImageResizer, Powerrename, FileLocsmith) out of UI thread so there is no UI freeze until the process is launched)?
  • Menu is too big on different scaling/rersolution. Can we make it dpi aware? e.g. it appears too big on 100% scaling - 2560x1440
  • Is CopyImageToClipboard option really needed? That's what OS does by default if I'm not wrong? Is there a scenario where this is additionally useful?

And last but not least, great work Aaron! Great set of tools! Some polishing is needed, but overall, already in a very solid state!

@@ -34,7 +34,9 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
<PackageVersion Include="Microsoft.Security.Extensions" Version="1.3.0" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? FileActionsMenu.Ui builds fine without it

<PackageVersion Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" />
<PackageVersion Include="Microsoft.UI.Xaml" Version="2.8.6" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used anywhere?

@@ -88,7 +91,8 @@
<PackageVersion Include="UTF.Unknown" Version="2.5.1" />
<PackageVersion Include="Vanara.PInvoke.User32" Version="3.4.11" />
<PackageVersion Include="Vanara.PInvoke.Shell32" Version="3.4.11" />
<PackageVersion Include="WinUIEx" Version="2.2.0" />
<PackageVersion Include="WinUIEx" Version="2.3.4" />
<PackageVersion Include="WindowsAPICodePack" Version="7.0.4" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure it;s safe to use this one?

</None>
<None Update="Assets\Monaco\monacoSpecialLanguages.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Assets\Monaco\customTokenColors.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason this stayed "Always"? Or what's the reason for these changes in this file? These files are small, so performance hit between Always and PreserveNewest is not big

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes these files are small, but all together they still took some extra seconds everytime I built the project.

return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredFileActionsMenuEnabledValue();
}

public static GpoRuleConfigured GetConfiguredPowerRenameEnabledValue()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:O nice catch!

/// <exception cref="ArgumentNullException">When <paramref name="value"/> is null.</exception>
public static T GetOrArgumentNullException<T>(this T? value)
{
return value ?? throw new ArgumentNullException(nameof(value));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. Is this exception handled anywhere?


public IAction[]? SubMenuItems => null;

public int Category => 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have more descriptive Category values?


public IconElement? Icon => new FontIcon { Glyph = "\ue74d" };

public bool IsVisible => SelectedItems.Length == 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get uninstall action for several different executables. Can you give me an example where it appears?


public string[] SelectedItems { get => _selectedItems.GetOrArgumentNullException(); set => _selectedItems = value; }

public string Title => "As for XML encoded string";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localize


public IconElement? Icon => new FontIcon { Glyph = "\ue785" };

public bool IsVisible => SelectedItems.Any(file => File.Exists(file + ":Zone.Identifier"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is Zone.Identifier only related to unblock files? i.e. is it safe to delete every Zone.Identifier file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zone.Identifier is an alternative file stream (that's why there's a colon). It is only documented to be used for this feature and doesn't hold any other data.

@stefansjfw
Copy link
Collaborator

stefansjfw commented Aug 6, 2024

One more comment, we need to align new csproj files here with fd706de and 12098cb

@Aaron-Junker
Copy link
Collaborator Author

Thank you for the first review. Your suggestions shouldn't be too hard to implement.

  • I don't get Uninstall option for several different apps I tried with. Can you give me an example where it appears so I can give it a try?

I know it works for PowerToys and I think for 7-Zip. But I will have to try it again this weekend.

  • Menu is too big on different scaling/rersolution. Can we make it dpi aware? e.g. it appears too big on 100% scaling - 2560x1440

I thought it is DPI-aware. Can you share a screenshot how big it appears.

Btw it should be in compact mode. When debugging with VS, it sometimes appears bigger as it should be🤷

  • Is CopyImageToClipboard option really needed? That's what OS does by default if I'm not wrong? Is there a scenario where this is additionally useful?

No, normal behaviour is copying the file object of the image to the clipboard, not the bitmap data. (#5256)

@stefansjfw
Copy link
Collaborator

stefansjfw commented Aug 6, 2024

image

This is when running via installer on mentioned resolution

EDIT:

HEre's better screenshot - compared to regular context menu, you see how bigger the items are

image

@stefansjfw
Copy link
Collaborator

Thank you for the first review. Your suggestions shouldn't be too hard to implement.

  • I don't get Uninstall option for several different apps I tried with. Can you give me an example where it appears so I can give it a try?

I know it works for PowerToys and I think for 7-Zip. But I will have to try it again this weekend.

Running installed PT - Crashes when I try to run the menu for 7zip 🤔

  • Menu is too big on different scaling/rersolution. Can we make it dpi aware? e.g. it appears too big on 100% scaling - 2560x1440

I thought it is DPI-aware. Can you share a screenshot how big it appears.

Btw it should be in compact mode. When debugging with VS, it sometimes appears bigger as it should be🤷

See screenshots in previous comment

  • Is CopyImageToClipboard option really needed? That's what OS does by default if I'm not wrong? Is there a scenario where this is additionally useful?

No, normal behaviour is copying the file object of the image to the clipboard, not the bitmap data. (#5256)

ok. I saw image on clipboard and though that's it. Thanks

@stefansjfw
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Collaborator

@stefansjfw stefansjfw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did second half of the code review. Comments are mostly minor.

I'd extract what's needed from Peek.Helpers to some Common.Helpers to break dependency between modules. Other than that looks ok.

Once you address current comments I'll do another review. Thank you!


if (dialog.ShowDialog() == DialogResult.OK)
{
FileActionProgressHelper fileActionProgressHelper = new("Saving file", 1, () => { });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localize

{
_fileActionsMenuShortcut = value ?? Settings.Properties.DefaultFileActionsMenuShortcut;
Settings.Properties.FileActionsMenuShortcut = value;
OnPropertyChanged(nameof(FileActionsMenuShortcut));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to call OnPropertyChanged. it is called in RaisePropertyChanged

src/modules/FileActionsMenu/FileActionsMenu/Resource.resx Outdated Show resolved Hide resolved
@stefansjfw
Copy link
Collaborator

stefansjfw commented Aug 7, 2024

in addition to .csproj needed alignments, there'll be a need for telemetry alignment once #34078 is in

@htcfreek
Copy link
Collaborator

What is required to get this in? Waiting for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants