-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
FileBrowser: "Open containing folder" automatically selects file in the OS's file manager #7700
base: master
Are you sure you want to change the base?
Conversation
Turns out my code was fine, its just that without LV2 support, Works fine with the CI Built binaries. I'll be removing some debug code and opening this PR up for review. |
Sticking to saying "Open containing folder" regardless of OS and opening it using the native file manager (if any) is probably the way to go IMO. It's a lot simpler that way at the cost of little. Also, I'm confused on what this has to do with highlighting files in the Additionally, I think we should be using something like |
Unless you have other concerns, the only downside is maintainability but that should've been fixed in the latest commit.
You're right, this PR is badly titled.
I really do dislike using openUrl. It was really slow for me (like ~5 second wait time) when I was on linux, But almost instant with my PR. |
@sakertooth Many applications have shims that do as the OP is suggesting. I've noticed that this trend has become an unofficial standard over the years for polished software. For example, my IDEs tend to do this same thing and when reading the source code, the techniques are often identical to the OP's. The larger the folder contents, the more useful this feature can become as the file manager will navigate directly to the file that was requested. This is a very well received feature IMO. |
I haven't benchmarked openUrl, but I wholeheartedly agree. A pragmatic solution would leverage the underlying C++ APIs, but Linux lacks a consistently shared framework to leverage something like this and Windows + macOS have the support build into the CLI of their file managers, so this really is the simplest approach for 99% of users. For those 1% of users (e.g. Haiku) we'll need to simply fallback to Qt's inferior handling. |
@sakertooth @AW1534 how much sense would it be to subclass The code also reads more portable anyway since it uses non-LMMS precompiler definitions and focuses on standard ones (e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you have other concerns, the only downside is maintainability but that should've been fixed in the latest commit.
Just took another peek at the code and it's a lot better. In particular, we aren't making so many references to platform-specific applications like Thunar, Nautilus, Dolphin, etc. The use of xdg-mime
and xdg-open
is a nice solution.
Code-wise, I think we can apply some formatting to the new changes, and I think some simplifications can be made. I can help out a bit if you will allow it.
It seems like we merely fallback to using |
This is a great idea which i'm willing to do, but as @sakertooth said, it probably doesnt need to extend from |
Co-authored-by: Tres Finocchiaro <[email protected]>
src/gui/FileBrowser.cpp
Outdated
|
||
#if !defined(_WIN32) && !defined(__APPLE__) | ||
|
||
bool supportsSelectOption(const QString &fileManager) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be refactored to run once on construction only. It should not need to be run each time a file is opened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. I'll do this after i move the code out of the FileBrowser class though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I may have to rethink this logic, since it has a blocking operation in it... I might need some help from @sakertooth on how to refactor this properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this resolved? since it's all cached anyway
absolutely, I'll apply any suggestions you give me |
done |
Co-authored-by: Tres Finocchiaro <[email protected]>
src/gui/FileBrowser.cpp
Outdated
[=, this]{ openContainingFolder(file); } | ||
); | ||
contextMenu.addAction(QIcon(embed::getIconPixmap("folder")), tr("Show in %1").arg(fileManager), | ||
[=, this] { FileRevealer::reveal(fileName); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[=, this] { FileRevealer::reveal(fileName); }); | |
[=] { FileRevealer::reveal(fileName); }); |
src/gui/FileBrowser.cpp
Outdated
case TypeDirectoryItem: { | ||
auto dir = dynamic_cast<Directory*>(item); | ||
QString dirname = dir->fullName(); | ||
contextMenu.addAction(QIcon(embed::getIconPixmap("folder")), tr("Open in %1").arg(fileManager), [=, this] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contextMenu.addAction(QIcon(embed::getIconPixmap("folder")), tr("Open in %1").arg(fileManager), [=, this] { | |
contextMenu.addAction(QIcon(embed::getIconPixmap("folder")), tr("Open in %1").arg(fileManager), [=] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ci will fail. (see my initial commit for example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang (macOS) will error (-Werror
) if they're left for areas that they're unused. The only unused this
that must be removed are the Actions that no longer call a FileBrowser function now, which are the calls to openDir
and reveal
.
If still gcc complains with only the two removals, we can leave it in. Clang is set to not treat warnings as errors in our CI so this is fine.
@regulus79 thanks for the testing! The stock folders are broken because of this:
It's a pretty quick fix. @AW1534 There appears to be an implicit conversion of QString -> QFileInfo for
This is going to be a bit harder to fix. We can suppress all errors with something like https://doc.qt.io/qt-5/qprocess.html#setStandardErrorFile, but this may make it harder for situation like finding the above error. It's sad how noisy Linux GUI apps are.
|
should be good now |
Downloading the MSVC and MinGW builds now! |
Everything works on both MinGW and MSVC Windows builds! 🎉 The right click doesn't work for "--- Factory files ---", as expected, great job. |
Co-authored-by: Tres Finocchiaro <[email protected]>
Co-authored-by: Tres Finocchiaro <[email protected]>
Co-authored-by: Tres Finocchiaro <[email protected]>
Yeah, it seems quite pointless. If we want to indicate which files are factory I think changing the color of factory files is a better option |
It's cool, I keep track of LMMS issues, I'll add this. |
Introduces a new helper class FileManagerServices to manage file selection across different platforms (Windows, macOS, Linux, and other *nix operating systems with
xdg
). Includes methods to open and select files or directories using the default file manager on the respective platform.User-Facing Changes:
Other Changes:
FileManagerServices::canSelect
method to check if file selection is possible.FileManagerServices::select
method to select files or directories using platform-specific commands.