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

ENH: Open Prinables.com Links and Zip Archives #3823

Merged
merged 28 commits into from
May 22, 2024

Conversation

Ocraftyone
Copy link
Contributor

Allows Orca to use the "Open in PrusaSlicer" buttons on Printables.com.

Also implements zip archive support since this is needed to download entire projects from Prinatbles.

@Ocraftyone
Copy link
Contributor Author

Currently this does NOT register with the OS to indicate this ability. It just allows Orca to parse and download when given the same link that would normally be given to PS. Should Orca be registered or should this? I am going back and forth on whether to...

@Eldenroot
Copy link
Contributor

3mf is automatically opened by Bambu lab. Not sure for .zip, it should not be touched.

Also there should be some popup confirmation when you open orca for the first time - do you wanna associate... yes/no

@Ocraftyone
Copy link
Contributor Author

Sorry. I didn't make it clear. I mean for the web links, not zip files

@SoftFever
Copy link
Owner

Currently this does NOT register with the OS to indicate this ability. It just allows Orca to parse and download when given the same link that would normally be given to PS. Should Orca be registered or should this? I am going back and forth on whether to...

You'da man!
I was considering this feature for both Printable and Makerworld recently too.

I thought we have to register Orca to that MIME in the OS, or am I wrong?
Otherwise how does the browser/OS know it need to invoke Orca?

More thoughts regarding the behavior: I'm thinking we should add a menu item so that user can register OrcaSlicer to that MIME type. What do you think?

@Ocraftyone
Copy link
Contributor Author

Yes, to inform the os that orca can open prusaslicer:// links, you have to set it up for each os. I found and implemented it for macOS. I think I found it for linux too. Windows, I am not sure.

@Ocraftyone
Copy link
Contributor Author

At the moment you can also manually specify which app to open a link with, which is how I have been testing it

@Eldenroot
Copy link
Contributor

Windows - yes, but some SW ask you if you wanna use them and associate them with specific extensions... anyway this implementation could be done in future.

@Ocraftyone
Copy link
Contributor Author

I am looking into it. I have the commit that PS implemented the feature on for reference. At the moment, the trouble is that Orca inherits a downloader feature from BBL which is very different from the PS implementation. So I don't know if I should use PS implementation or keep with the BBL implementation and hack together a solution. @SoftFever do you have a preference?

@Eldenroot
Copy link
Contributor

It depends - maybe some hybrid solution to have an easier life when BS will bring new things on their website or new builds will be synced.

I would like to see this in the next nightly ;)

@Ocraftyone
Copy link
Contributor Author

If I went with the PS implementation, I would implement it in a way that it would only effect PS links. The rest would use the existing method.

@SoftFever
Copy link
Owner

If I went with the PS implementation, I would implement it in a way that it would only effect PS links. The rest would use the existing method.

I would opt for this as well.
Would be great to have different functions/classes handle different links.
Which will make future maintenance work easier.

doesn't actually control anything yet
@Eldenroot
Copy link
Contributor

@Ocraftyone any progress with this? To make our life easier .)

@Ocraftyone
Copy link
Contributor Author

Yup. Just took a bit of a break but I am going to implement the rest tonight.

As-is from PS master
@Ocraftyone
Copy link
Contributor Author

Update to those following: I have been working on this in my off time. I have the PS downloader mostly implemented how I like it. I am working on putting the final touches on the new download url notification and the icons associated with it. I believe that the macOS url registration has been set up and I have located the part that controls the Linux desktop integration. All that remains for url registration is to find the code that adds the link registration to the windows registry and implement link registration on Linux and windows. I would also like to implement a setting that deleted downloaded files after being imported.

@Ocraftyone
Copy link
Contributor Author

@Ocraftyone It works on Windows 👍

I'm thinking the registration behavior can be tweaked a bit.
Currently, it automatically registers the current instance on startup. It would be better to ask the user to explicitly register/deregister it (through a menu item).

Yeah. This is PS default behavior and how file types are registered in both. I was wanting to look into using the windows settings to handle file type registration.

@Ocraftyone
Copy link
Contributor Author

@SoftFever
Copy link
Owner

SoftFever commented Apr 7, 2024

It would be better to ask the user to explicitly register/deregister it (through a menu item).

I also think it's a bad practice to register itself as default handler unconditionally without user interaction. Maybe a dedicated checkbox in main settings window will do?

Basically, there should be API like this to make it work.

bool is_set_default();
void set_as_default();
void unset_as_default();

Would be better to register/unregister itself per user request (every time) instead of any kind of implicit register action, not even . Checkbox in main setting is what @Ocraftyone did currently.

There are two issues with such behavior:

  1. The setting file is shared by all Orca instances; whenever the user opens Orca, it reads the setting and registers itself. When we have multiple versions of Orca (stable/beta/dev), this causes a mess.
  2. When a user doesn't want Orca to handle such file type/URL, a setting is not obvious; one will easily forget that, then there are endless fights for the file type handling between Orca and other software. That's kind of rogue behavior that should be avoided.

Hence, we need and should require a very explicit user action to register/unregister the file type.

@Ocraftyone
Copy link
Contributor Author

@SoftFever This is something I need to address in windows too because it has the same unintuitive behavior. I think if the application thinks it should be registered, it should check the registry if it is indeed the registered application (by comparing the registered application path). if it should be registered but is not, then ask the user for intervention. This wouldn't interfere with updates, because the app would still be in the same place, but if the app is a dev version or a portable version, it wont automatically register.

@nevack
Copy link
Contributor

nevack commented Apr 8, 2024

@Ocraftyone I kindly ask you to create some common interface for this functionality, so I can start implementing macOS part independently.

Something like described here #3823 (comment)

It seems like we are blocked here, but I don't clearly see why 😄

@SoftFever
Copy link
Owner

@SoftFever This is something I need to address in windows too because it has the same unintuitive behavior. I think if the application thinks it should be registered, it should check the registry if it is indeed the registered application (by comparing the registered application path). if it should be registered but is not, then ask the user for intervention. This wouldn't interfere with updates, because the app would still be in the same place, but if the app is a dev version or a portable version, it wont automatically register.

Hmm, I still think the right behaviour is
User click the register button -> check the current registration info and popup a warning dialog about overwrite -> register current instance

@Ocraftyone
Copy link
Contributor Author

@SoftFever
My initial plan to fix up how windows registers file/link types was to use Window's settings dialog.

Currently, Orca and PS forcibly set themselves as the handlers for the various file types on Windows. Instead, we can register the application with windows and specify the different file types it can handle. Windows will then show the application in the file associations section of the settings panel. We could then provide a link to the associations page for Orca in preferences. This would leave orca itself out of the registration process, preventing some of the messy issues it currently creates, removes the outdated registration code, and we no longer need to check if we are indeed the default application. All of that is handled by Windows.

There are a few downsides to this idea. 1) Below Windows 10 won't work (but they aren't supported any more by Microsoft) and 2) portable instances of Orca won't be able to be registered (the registry steps would be handled by the CPack installer)

During creating this PR, I had considered making that change a part of it, but I believe it would be a bit out of scope. My suggestion would be to leave the windows portion alone in this PR since it follows the current association standard, then in a later PR, update to a more modern implementation.

Here is the inspiration for the change. Nanazip (a 7zip fork focused on a modern Windows GUI implementation) uses the idea stated above.

image
image

@Ocraftyone
Copy link
Contributor Author

@Ocraftyone I kindly ask you to create some common interface for this functionality, so I can start implementing macOS part independently.

Something like described here #3823 (comment)

It seems like we are blocked here, but I don't clearly see why 😄

I believe the reason we are blocked is because until now only Windows has had dynamic registration functionality. On linux and macos, it was registered at install and not touched again. That, and how windows does its registration is very hacky. It just sets it every time an instance of orca starts. We need to determine if/how we should update windows to match the new macOS functionality. In the mean time, I am happy to point you to where registration is currently done in windows if you want to do a dirty implementation that we can refactor later. GUI_App::open_preferences opens the preferences dialog and then registration is run after it is closed. This block of code is run on init and registers the application if the config says it should be associated.

@SoftFever
Copy link
Owner

I'm fine with focusing only on Windows for this PR. I will create another PR to modify the behavior. It's very important that if we are modifying system settings, especially those of other software types, it must be initiated by the user's explicit and direct action.

@Ocraftyone
Copy link
Contributor Author

Ocraftyone commented Apr 14, 2024

I'm fine with focusing only on Windows for this PR. I will create another PR to modify the behavior.

I don't quite understand this statement. Are you wanting to include the above mentioned changes in this PR or are you wanting to create a different PR that addresses the windows issues and merge that first?

It's very important that if we are modifying system settings, especially those of other software types, it must be initiated by the user's explicit and direct action.

Understood. I definitely think the current behavior is not ideal at all. I am surprised it hasn't been handled by the PS team yet with it being this hacky.

@SoftFever
Copy link
Owner

SoftFever commented Apr 14, 2024

I don't quite understand this statement. Are you wanting to include the above mentioned changes in this PR or are you wanting to create a different PR that addresses the windows issues and merge that first?

Oh, I meant I will create another PR based on your PR. Once that's ready, I will merge your PR first, then that PR.

It's very important that if we are modifying system settings, especially those of other software types, it must be initiated by the user's explicit and direct action.

Understood. I definitely think the current behavior is not ideal at all. I am surprised it hasn't been handled by the PS team yet with it being this hacky.

👍

@Ocraftyone
Copy link
Contributor Author

Oh, I meant I will create another PR based on your PR. Once that's ready, I will merge your PR first, then that PR.

Are you planning on going with a register button or one that goes to windows settings?

@SoftFever
Copy link
Owner

Oh, I meant I will create another PR based on your PR. Once that's ready, I will merge your PR first, then that PR.

Are you planning on going with a register button or one that goes to windows settings?

I'm leaning towards a button

@Ocraftyone
Copy link
Contributor Author

I'm leaning towards a button
I would still suggest updating to the more modern approach that allows for configuration via Windows Settings and maybe adding a register option to the installer

@Ocraftyone
Copy link
Contributor Author

@SoftFever any progress on the other PR?

@SoftFever
Copy link
Owner

@SoftFever any progress on the other PR?

@Ocraftyone do you mind I push changes into this PR directly?
I find the changes are less than I expected.

@Ocraftyone
Copy link
Contributor Author

Go for it!

@SoftFever
Copy link
Owner

Go for it!

Seems I can't push changes into your branches anymore.
So I created a another PR: #5416

@Ocraftyone
Copy link
Contributor Author

Do you want to submit as a PR to my branch and I can merge it?

@SoftFever
Copy link
Owner

Do you want to submit as a PR to my branch and I can merge it?

Thank you!
Since the new PR ha been created already, let's submit it as two PRs.

@SoftFever SoftFever merged commit a764d83 into SoftFever:main May 22, 2024
11 of 12 checks passed
@SoftFever
Copy link
Owner

@Ocraftyone let me know if you find any issue with the changes there

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.

4 participants