[TagDialog] Really enable "Open in filemanager" button for local files
ClosedPublic

Authored by wbauer on Sep 18 2019, 8:17 AM.

Details

Summary

QUrl::QUrl() expects a full Url including the scheme (unlike KUrl::KUrl() that supports local paths too).
But for local files, urlString contains the local path without a scheme ("file://").

The problem here is that QUrl cannot detect that the Url is actually pointing to a local file if the scheme is missing (according to the Qt docs, a URL is a local file path if the scheme is "file"), so QUrl::isLocalFile() was always false and the "Open in filemanager" button never got enabled.

So use QUrl::fromUserInput() instead to construct the QUrl, which also supports local paths.

Also, to avoid showing the "file://" scheme in the "Location" text field now, pass QUrl::PreferLocalFile to QUrl::toDisplayString() as suggested in the KUrl::pathOrUrl() docs.

Test Plan

Opened the tag dialog ("Edit track details") for a file in the local collection.
The button is enabled now, clicking it successfully opens the containing folder in dolphin.
The "Location" text field still shows "/path/to/folder/file" (without "file://").

Added a remote podcast to the playlist, and opened the tag dialog.
The button stays disabled, the text field still correctly shows the Url including the scheme ("https://..." in my case).

Diff Detail

Repository
R181 Amarok
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
wbauer created this revision.Sep 18 2019, 8:17 AM
Restricted Application removed a project: Amarok. · View Herald TranscriptSep 18 2019, 8:17 AM
Restricted Application added a subscriber: amarok-devel. · View Herald Transcript
wbauer requested review of this revision.Sep 18 2019, 8:17 AM
wbauer edited the test plan for this revision. (Show Details)Sep 18 2019, 8:22 AM
wbauer added a subscriber: Amarok.Sep 18 2019, 8:54 AM
schweingruber accepted this revision.Sep 19 2019, 7:35 AM
schweingruber added a subscriber: schweingruber.

thanks a bunch, works quite fine for me as well.

This revision is now accepted and ready to land.Sep 19 2019, 7:35 AM
This revision was automatically updated to reflect the committed changes.