Skip to content

Conversation

@michaelgregorius
Copy link
Contributor

Add functionality to open the containing folder of a file that's selected
in LMMS' file browser.

Technical details

Add a new private method openContainingFolder to FileBrowser. Add a new
action to the context menu of a selected file. This action in turn calls
the added method.

The current implementation of openContainingFolder delegates to
QDesktopServices::openUrl with the directory of the selected file. Please
note that this will only open the directory but not select the file as
this is much more complicated due to different implementations that are
needed for the different platforms (Linux/Windows/MacOS).

Using QDesktopServices::openUrl seems to be the most simple cross
platform way which uses functionality that's already available in Qt.

Add functionality to open the containing folder of a file that's selected
in LMMS' file browser.

Technical details
------------------
Add a new private method openContainingFolder to FileBrowser. Add a new
action to the context menu of a selected file. This action in turn calls
the added method.

The current implementation of openContainingFolder delegates to
QDesktopServices::openUrl with the directory of the selected file. Please
note that this will only open the directory but not select the file as
this is much more complicated due to different implementations that are
needed for the different platforms (Linux/Windows/MacOS).

Using QDesktopServices::openUrl seems to be the most simple cross
platform way which uses functionality that's already available in Qt.
@michaelgregorius
Copy link
Contributor Author

Implements #5453.

I propose to merge it like this which for now only opens the directory of the file as this is already an improvement for the end use.

In case someone wants to enhance it by also selecting the file in the opened file browser some hints on how to do this can be found here: https://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt.

@LmmsBot
Copy link

LmmsBot commented Apr 14, 2020

🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩

Linux

Windows

macOS

🤖
{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://5981-15778896-gh.circle-artifacts.com/0/lmms-1.2.1.633-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/5981?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://5979-15778896-gh.circle-artifacts.com/0/lmms-1.2.1.633-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/5979?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://5980-15778896-gh.circle-artifacts.com/0/lmms-1.2.1.633-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/5980?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/2kw303jei5jm5j6y/artifacts/build/lmms-1.2.1-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/32340834"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/mah67i54bk71jnbq/artifacts/build/lmms-1.2.1-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/32340834"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://5983-15778896-gh.circle-artifacts.com/0/lmms-1.2.1.633-mac10.13.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/5983?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "c37fdd005529f1fbc19d974c62d617fe89dfe988"}

Move openContainingFolder to the end of the method block.

Adjust FileBrowserTreeWidget::contextMenuEvent to the coding conventions
and also make the code more readable by splitting up some conditions.

Add comments to clarify as to why the member m_contextMenuItem is set to
nullptr at the end of the execution of contextMenuEvent. Please note
that this implementation is not exception safe and should be changed in
the future, e.g. by passing the FileItem as a parameter of the slot.
@PhysSong
Copy link
Member

Please note that this will only open the directory but not select the file

Could you add a comment to the code itself as well, to make the intention clear?

Add a comment which describes that only the folder is opened without
selecting any file. Also explain why it is only done like this for now.
@michaelgregorius
Copy link
Contributor Author

Please note that this will only open the directory but not select the file

Could you add a comment to the code itself as well, to make the intention clear?

Hi @PhysSong , done with commit c37fdd0.

@michaelgregorius michaelgregorius merged commit 31996fe into LMMS:master Apr 23, 2020
@michaelgregorius michaelgregorius deleted the 5453-OpenContainingFolder branch April 23, 2020 17:48
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
…gFolder

Implements "Open containing folder" (LMMS#5453)
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