PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Adds BgcodeThumbnailProvider and BgcodePreviewHandler

Open pedrolamas opened this issue 8 months ago • 6 comments

Summary of the Pull Request

PR Checklist

  • [X] Closes: #30352
  • [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
  • [X] New binaries: Added on the required places
  • [ ] Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

image

image

Validation Steps Performed

  • Close PowerToys if installed in your machine
  • Full build the solution: PowerToys.sln
  • Start PowerToys from PowerToys\x64\Debug\PowerToys.exe or PowerToys\x64\Release\PowerToys.exe
  • Toggle the "Binary G-code thumbnail previewer" setting to enable
  • Open HelperFiles folder on the tests and check if the icon changes to an image
  • Check explorer preview to see if image is also shown there

pedrolamas avatar Apr 08 '25 15:04 pedrolamas

So, first things first: the Binary G-code format was created by Prusa and made open-source under AGPL-3.0 license.

I have taken their specifications document and ported only what was required to read and decode the thumbnails inside the binary g-code data.

I did discuss with @crutkas to merge this inside the g-code providers, however in the end I decided to make it a new provider as the format is not "yet" a defacto standard (like standard g-code format is), plus the g-code thumbnail provider only gets a stream so I would need to identify the type from the data instead of just using the filename (as that is not available without refactoring the provider)

pedrolamas avatar Apr 08 '25 15:04 pedrolamas

shifting to draft so it doesn't accidently get merged

crutkas avatar Apr 08 '25 16:04 crutkas

@pedrolamas synced with our team here. We can proceed but would be amazing if we could get Prusa to give the thumbs up here just so we can have a true end to end approval with them.

crutkas avatar May 05 '25 16:05 crutkas

Hi @josefprusa, sorry to rehash this but can I get you to ok this directly here so it gets on the record with Microsoft? Thanks! 🙂

... (ask) Prusa if they are ok from a licensing perspective with you using the spec to write a code contribution to PowerToys, an MIT licensed project? This would be allowing them then to make the call and it then also wouldn't be a surprise to them.

Same thing as we discussed on DMs, I partially ported part of the bgcode definition to C# so we can read the thumbnail data from the files and show them in Windows File Explorer, all we need is your confirmation here on the PR that you are ok with this.

pedrolamas avatar May 06 '25 16:05 pedrolamas

@pedrolamas possible to resolve the conflicts so we can get this in?

crutkas avatar Jun 07 '25 03:06 crutkas

@crutkas all conflicts resolved!

pedrolamas avatar Jun 07 '25 14:06 pedrolamas

@crutkas I've fixed all conflicts and made some changes as recommended by copilot, so I think it should be all good to go!

pedrolamas avatar Jun 21 '25 13:06 pedrolamas

/azp run

lei9444 avatar Jun 23 '25 12:06 lei9444

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jun 23 '25 12:06 azure-pipelines[bot]

/azp run

pedrolamas avatar Jun 23 '25 20:06 pedrolamas

Commenter does not have sufficient privileges for PR 38667 in repo microsoft/PowerToys

azure-pipelines[bot] avatar Jun 23 '25 20:06 azure-pipelines[bot]

/azp run

lei9444 avatar Jun 24 '25 01:06 lei9444

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jun 24 '25 01:06 azure-pipelines[bot]

/azp run

lei9444 avatar Jul 10 '25 02:07 lei9444

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jul 10 '25 02:07 azure-pipelines[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

:x: Errors and Warnings Count
:warning: binary-file 3
:x: forbidden-pattern 1

See :x: Event descriptions for more information.

These words are not needed and should be removed fff

Some files were automatically ignored :see_no_evil:

These sample patterns would exclude them:

^src/modules/powerrename/PowerRenameUITest/testItems/

You should consider adding them to:

.github/actions/spell-check/excludes.txt

File matching is via Perl regular expressions.

To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.

To update file exclusions and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:pedrolamas/PowerToys.git repository on the pedrolamas/bgcode-thumbnail-provider branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/c635c2f3f714eec2fcf27b643a1919b9a811ef2e/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/16184745002/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Forbidden patterns :no_good: (1)

In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.

These forbidden patterns matched content:

Should be a

\san (?=(?:[b-df-gj-npqtv-xz]|h(?!our|tml|ttp)|r(?!c\b)|s(?!sh|vg))[a-z])
If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Jul 10 '25 02:07 github-actions[bot]

/azp run

lei9444 avatar Jul 10 '25 02:07 lei9444

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jul 10 '25 02:07 azure-pipelines[bot]

/azp run

lei9444 avatar Jul 10 '25 06:07 lei9444

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jul 10 '25 06:07 azure-pipelines[bot]

/azp run

lei9444 avatar Jul 10 '25 08:07 lei9444

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jul 10 '25 08:07 azure-pipelines[bot]