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

Add "Create desktop shortcut" feature. #1516

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

xslendix
Copy link
Contributor

@xslendix xslendix commented Nov 25, 2022

This PR adds a way of adding a shortcut to directly start an instance as
requested by issues #1088 and #541.

It is important to note, however, that this feature has not been implemented
for Mac.

Right now, I need someone that is able to test whether they can get this to
build and run under Windows.

@samiscool51
Copy link

samiscool51 commented Nov 26, 2022

managed to get it to build and run but unfortunately the option to create a shortcut doesn't appear in the instance toolbar:
image
i built it for QT5 on windows 10 LTSC 1809, i'll give QT6 a go to see if it appears there.

@samiscool51
Copy link

update: QT6 version also doesn't have the option sadly.

@glowiak
Copy link
Contributor

glowiak commented Nov 26, 2022

Great. For *UNIX you just need to write a .desktop file and place it in ~/.local/share/applications so this would be much easier

@xslendix
Copy link
Contributor Author

managed to get it to build and run but unfortunately the option to create a shortcut doesn't appear in the instance toolbar: image i built it for QT5 on windows 10 LTSC 1809, i'll give QT6 a go to see if it appears there.

This is incredibly weird behaviour, as the option should appear only if not compiled for Macs. Are you sure you compiled correctly? Maybe you forgot to switch branch?

@xslendix
Copy link
Contributor Author

I have built it on Windows, the option appears but it seems to not do anything.

@xslendix
Copy link
Contributor Author

I have fixed the issues with the feature on Windows.

@xslendix xslendix force-pushed the shortcut branch 2 times, most recently from 5c00c96 to 1f07497 Compare November 26, 2022 13:40
@samiscool51
Copy link

samiscool51 commented Nov 26, 2022

Maybe you forgot to switch branch?

my bad, i forgor to switch branches. tested it again with the correct branch and it launches and works properly.

@binex-dsk
Copy link
Collaborator

I'm not big into the idea of including direct windows API calls in MainWindow.cpp, but this looks pretty cool

@xslendix
Copy link
Contributor Author

I'm not big into the idea of including direct windows API calls in MainWindow.cpp, but this looks pretty cool

Me neither, but I don't think anyone wants to spend time re-implementing
system libraries.

@binex-dsk
Copy link
Collaborator

binex-dsk commented Nov 27, 2022

I'm not big into the idea of including direct windows API calls in MainWindow.cpp, but this looks pretty cool

Me neither, but I don't think anyone wants to spend time re-implementing
system libraries.

I think the rest of the codebase has some weird sys_{windows,Unix,etc}.cpp thing that implements platform-specific functions like getting CPU/RAM information. I'd recommend looking into that; you can define a universal createInstanceShortcut function in sys.h or whatever it is and then implement it for each OS in the sys files.

edit: Actually that's part of the systeminfo library so it won't work. I would still prefer having one universal function and individually implementing it for each OS though, in a separate file perhaps.

@xslendix
Copy link
Contributor Author

Personally, I would leave it there. If somehow there is a need more system
libraries, then yes, those functions deserve their own special file. I don't
really see the point in making both a C++ source file and header just for one
function.

@binex-dsk
Copy link
Collaborator

Personally, I would leave it there. If somehow there is a need more system
libraries, then yes, those functions deserve their own special file. I don't
really see the point in making both a C++ source file and header just for one
function.

The point I see is for future potential implementations that need system specific libraries.

However you could be a gigachad and force whoever needs that to do it themselves

launcher/ui/MainWindow.cpp Outdated Show resolved Hide resolved
@binex-dsk
Copy link
Collaborator

I'd leave this as a draft until it gets implemented and tested on MacOS

@xslendix
Copy link
Contributor Author

I'd leave this as a draft until it gets implemented and tested on MacOS

I will not be implementing this for Mac, as I have zero familiarity with it's internals. If someone wants to add support for it, a new PR can always be made.

@binex-dsk
Copy link
Collaborator

I'd leave this as a draft until it gets implemented and tested on MacOS

I will not be implementing this for Mac, as I have zero familiarity with it's internals. If someone wants to add support for it, a new PR can always be made.

zased?

@LennyMcLennington
Copy link
Member

LennyMcLennington commented Jan 4, 2023

Does it want Qt::endl? instead of just endl? Builds failing on qt6.

@xslendix xslendix force-pushed the shortcut branch 2 times, most recently from 1aaa878 to 4eb48cf Compare February 9, 2023 23:24
@LennyMcLennington LennyMcLennington added this to the 6.0 milestone Feb 14, 2023
@LennyMcLennington
Copy link
Member

LennyMcLennington commented Jun 2, 2023

Does this work with flatpak and appimage? I don't really see how it could work with flatpak, and if it won't work with them then it should at least be disabled in the UI.

Also, when you add the option to the instance toolbar, you're not checking whether the target is MacOS so the action will still be added, and when the MacOS user clicks it, it will create a .desktop file since in the actual function you only check for windows and then just #else and make a .desktop file

This patch adds a way of adding a shortcut to directly start an
instance. How this works is it uses the already existing "-l" command
line option. This, however, has not been implemented for Mac, which is
something that can definetly be improved in the future if anyone wants
to work on it :^)

Signed-off-by: xSlendiX <slendi@socopon.com>
This patch adds the ability to make working shortcuts on flatpak.
However, this requires permissions to write files to the /home/Desktop
directory. This means the flathub/org.polymc.PolyMC repository needs to
be updated.

Signed-off-by: xSlendiX <slendi@socopon.com>
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.

None yet

5 participants