Commit b49c0af4 authored by Nate Graham's avatar Nate Graham 💤
Browse files

Add feature to show files in file manager

Now you can show songs' location on disk using your file manager.

This functionality is implemented as new hover buttons in playlist,
list, and grid browser delegates, and a new always-visible button on the Now
Playing footer toolbar.

The button does not appear on grid delegates for files (e.g. in the
Files view) due to a pre-existing bug also affecting the Details button.
This will have to be fixed separately.

BUG: 406471
FIXED-IN: 20.12
parent 3e052f5a
Pipeline #40589 passed with stage
in 26 seconds
......@@ -35,6 +35,7 @@
#include <KColorSchemeManager>
#include <KCoreAddons/KAboutData>
#include <KIO/OpenFileManagerWindowJob>
#include <QQmlEngine>
#include <QQmlComponent>
......@@ -533,6 +534,11 @@ bool ElisaApplication::eventFilter(QObject *object, QEvent *event)
return false;
}
void ElisaApplication::showInFolder(QUrl filePath)
{
KIO::highlightInFileManager({filePath});
}
const DataTypes::EntryDataList &ElisaApplication::arguments() const
{
return d->mArguments;
......
......@@ -105,6 +105,8 @@ public:
Q_INVOKABLE void installKeyEventFilter(QObject *object);
Q_INVOKABLE void showInFolder(QUrl filePath);
bool eventFilter(QObject *object, QEvent *event) override;
[[nodiscard]] const DataTypes::EntryDataList &arguments() const;
......
......@@ -314,13 +314,6 @@ FocusScope {
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
contentLayoutSpacing: Kirigami.Units.largeSpacing
contentItems: [
Image {
Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium
Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
sourceSize.width: Kirigami.Units.iconSizes.smallMedium
sourceSize.height: Kirigami.Units.iconSizes.smallMedium
source: elisaTheme.folderIcon
},
LabelWithToolTip {
id: fileNameLabel
......@@ -328,6 +321,13 @@ FocusScope {
text: metaDataModel.fileUrl
elide: Text.ElideLeft
},
ToolButton {
icon.name: "document-open-folder"
text: i18n("Show In Folder")
onClicked: {
ElisaApplication.showInFolder(metaDataModel.fileUrl)
}
}
]
}
......
......@@ -11,6 +11,7 @@ import QtQml.Models 2.1
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
import org.kde.kirigami 2.5 as Kirigami
import org.kde.elisa 1.0
FocusScope {
id: gridEntry
......@@ -124,6 +125,30 @@ FocusScope {
sourceComponent: Row {
spacing: 2
Button {
icon.name: 'document-open-folder'
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.delay: 1000
ToolTip.text: i18nc("Show the file for this song in the file manager", "Show in folder")
Accessible.role: Accessible.Button
Accessible.name: ToolTip.text
Accessible.description: ToolTip.text
Accessible.onPressAction: clicked()
onClicked: {
ElisaApplication.showInFolder(gridEntry.fileUrl)
}
Keys.onReturnPressed: clicked()
Keys.onEnterPressed: clicked()
visible: showDetailsButton
width: elisaTheme.delegateToolButtonSize
height: elisaTheme.delegateToolButtonSize
}
Button {
id: detailsButton
objectName: 'detailsButton'
......
......@@ -237,6 +237,17 @@ FocusScope {
sourceComponent: Row {
anchors.centerIn: parent
FlatButtonWithToolTip {
height: singleLineHeight
width: singleLineHeight
text: i18nc("Show the file for this song in the file manager", "Show in folder")
icon.name: "document-open-folder"
onClicked: {
ElisaApplication.showInFolder(mediaTrack.trackUrl)
}
}
FlatButtonWithToolTip {
id: detailsButton
height: singleLineHeight
......
......@@ -225,6 +225,17 @@ FocusScope {
anchors.centerIn: parent
enabled: isValid
FlatButtonWithToolTip {
implicitHeight: playListEntry.height
implicitWidth: playListEntry.height
text: i18nc("Show the file for this song in the file manager", "Show in folder")
icon.name: "document-open-folder"
onClicked: {
ElisaApplication.showInFolder(playListEntry.fileName)
}
}
FlatButtonWithToolTip {
id: infoButton
objectName: 'infoButton'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment