diff --git a/src/manageheaderbar.cpp b/src/manageheaderbar.cpp index aacc789f..b04aaf2d 100644 --- a/src/manageheaderbar.cpp +++ b/src/manageheaderbar.cpp @@ -1,369 +1,364 @@ /* * Copyright 2016 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "manageheaderbar.h" #include #include ManageHeaderBar::ManageHeaderBar(QObject *parent) : QObject(parent) { } void ManageHeaderBar::setArtistRole(int value) { mArtistRole = value; Q_EMIT artistRoleChanged(); } int ManageHeaderBar::artistRole() const { return mArtistRole; } void ManageHeaderBar::setTitleRole(int value) { mTitleRole = value; Q_EMIT titleRoleChanged(); } int ManageHeaderBar::titleRole() const { return mTitleRole; } void ManageHeaderBar::setAlbumRole(int value) { mAlbumRole = value; Q_EMIT albumRoleChanged(); } void ManageHeaderBar::setAlbumArtistRole(int value) { mAlbumArtistRole = value; Q_EMIT albumArtistRoleChanged(); } void ManageHeaderBar::setFileNameRole(int value) { mFileNameRole = value; Q_EMIT fileNameRoleChanged(); } int ManageHeaderBar::albumRole() const { return mAlbumRole; } int ManageHeaderBar::albumArtistRole() const { return mAlbumArtistRole; } int ManageHeaderBar::fileNameRole() const { return mFileNameRole; } void ManageHeaderBar::setImageRole(int value) { mImageRole = value; Q_EMIT imageRoleChanged(); } void ManageHeaderBar::setDatabaseIdRole(int databaseIdRole) { mDatabaseIdRole = databaseIdRole; Q_EMIT databaseIdRoleChanged(); } void ManageHeaderBar::setTrackTypeRole(int trackTypeRole) { mTrackTypeIdRole = trackTypeRole; Q_EMIT trackTypeRoleChanged(); } int ManageHeaderBar::imageRole() const { return mImageRole; } int ManageHeaderBar::databaseIdRole() const { return mDatabaseIdRole; } int ManageHeaderBar::trackTypeRole() const { return mTrackTypeIdRole; } void ManageHeaderBar::setAlbumIdRole(int albumIdRole) { mAlbumIdRole = albumIdRole; Q_EMIT albumIdRoleChanged(); } int ManageHeaderBar::albumIdRole() const { return mAlbumIdRole; } QVariant ManageHeaderBar::album() const { if (!mCurrentTrack.isValid()) { return QString(); } return mCurrentTrack.data(mAlbumRole); } QVariant ManageHeaderBar::albumArtist() const { if (!mCurrentTrack.isValid()) { return QString(); } return mCurrentTrack.data(mAlbumArtistRole); } -QString ManageHeaderBar::fileName() const +QUrl ManageHeaderBar::fileUrl() const { - QString result; + QUrl result; if (!mCurrentTrack.isValid()) { return result; } - auto fileNameUrl = mCurrentTrack.data(mFileNameRole).toUrl(); - if (fileNameUrl.isLocalFile()) { - result = fileNameUrl.toLocalFile(); - } else { - result = fileNameUrl.toString(); - } + result = mCurrentTrack.data(mFileNameRole).toUrl(); return result; } QVariant ManageHeaderBar::title() const { if (!mCurrentTrack.isValid()) { return QString(); } return mCurrentTrack.data(mTitleRole); } QVariant ManageHeaderBar::artist() const { if (!mCurrentTrack.isValid()) { return QString(); } return mCurrentTrack.data(mArtistRole); } QUrl ManageHeaderBar::image() const { if (!mCurrentTrack.isValid()) { return {}; } return mCurrentTrack.data(mImageRole).toUrl(); } qulonglong ManageHeaderBar::databaseId() const { if (!mCurrentTrack.isValid()) { return 0; } return mCurrentTrack.data(mDatabaseIdRole).toULongLong(); } ElisaUtils::PlayListEntryType ManageHeaderBar::trackType() const { if (!mCurrentTrack.isValid()) { return ElisaUtils::Unknown; } return mCurrentTrack.data(mTrackTypeIdRole).value(); } qulonglong ManageHeaderBar::albumId() const { if (!mCurrentTrack.isValid()) { return 0; } return mCurrentTrack.data(mAlbumIdRole).toULongLong(); } bool ManageHeaderBar::isValid() const { if (!mCurrentTrack.isValid()) { return false; } return mCurrentTrack.data(mIsValidRole).toBool(); } int ManageHeaderBar::isValidRole() const { return mIsValidRole; } QPersistentModelIndex ManageHeaderBar::currentTrack() const { return mCurrentTrack; } void ManageHeaderBar::notifyArtistProperty() { auto newArtistValue = mCurrentTrack.data(mArtistRole); if (mOldArtist != newArtistValue) { Q_EMIT artistChanged(); mOldArtist = newArtistValue; } } void ManageHeaderBar::notifyTitleProperty() { auto newTitleValue = mCurrentTrack.data(mTitleRole); if (mOldTitle != newTitleValue) { Q_EMIT titleChanged(); mOldTitle = newTitleValue; } } void ManageHeaderBar::notifyAlbumProperty() { auto newAlbumValue = mCurrentTrack.data(mAlbumRole); if (mOldAlbum != newAlbumValue) { Q_EMIT albumChanged(); mOldAlbum = newAlbumValue; } } void ManageHeaderBar::notifyAlbumArtistProperty() { auto newAlbumArtistValue = mCurrentTrack.data(mAlbumArtistRole); if (mOldAlbumArtist != newAlbumArtistValue) { Q_EMIT albumArtistChanged(); mOldAlbumArtist = newAlbumArtistValue; } } void ManageHeaderBar::notifyFileNameProperty() { auto newFileNameValue = mCurrentTrack.data(mFileNameRole); if (mOldFileName != newFileNameValue) { - Q_EMIT fileNameChanged(); + Q_EMIT fileUrlChanged(); mOldFileName = newFileNameValue; } } void ManageHeaderBar::notifyImageProperty() { auto newImageValue = mCurrentTrack.data(mImageRole); if (mOldImage != newImageValue) { Q_EMIT imageChanged(); mOldImage = newImageValue; } } void ManageHeaderBar::notifyDatabaseIdProperty() { bool conversionOk; auto newDatabaseIdValue = mCurrentTrack.data(mDatabaseIdRole).toULongLong(&conversionOk); if (conversionOk && mOldDatabaseId != newDatabaseIdValue) { Q_EMIT databaseIdChanged(); mOldDatabaseId = newDatabaseIdValue; } else if (!conversionOk && mOldDatabaseId != 0) { Q_EMIT databaseIdChanged(); mOldDatabaseId = 0; } } void ManageHeaderBar::notifyTrackTypeProperty() { auto newTrackTypeValue = mCurrentTrack.data(mTrackTypeIdRole).value(); if (mOldTrackType != newTrackTypeValue) { Q_EMIT trackTypeRoleChanged(); mOldTrackType = newTrackTypeValue; } } void ManageHeaderBar::notifyAlbumIdProperty() { bool conversionOk; auto newAlbumIdValue = mCurrentTrack.data(mAlbumIdRole).toULongLong(&conversionOk); if (conversionOk && mOldAlbumId != newAlbumIdValue) { Q_EMIT albumIdChanged(); mOldAlbumId = newAlbumIdValue; } else if (!conversionOk && mOldAlbumId != 0) { Q_EMIT albumIdChanged(); mOldAlbumId = 0; } } void ManageHeaderBar::notifyIsValidProperty() { auto newIsValidValue = mCurrentTrack.data(mIsValidRole).toBool(); if (mOldIsValid != newIsValidValue) { Q_EMIT isValidChanged(); mOldIsValid = newIsValidValue; } } void ManageHeaderBar::setIsValidRole(int isValidRole) { mIsValidRole = isValidRole; emit isValidRoleChanged(); } void ManageHeaderBar::setCurrentTrack(const QPersistentModelIndex ¤tTrack) { mCurrentTrack = currentTrack; Q_EMIT currentTrackChanged(); notifyArtistProperty(); notifyTitleProperty(); notifyAlbumProperty(); notifyAlbumArtistProperty(); notifyFileNameProperty(); notifyImageProperty(); notifyDatabaseIdProperty(); notifyTrackTypeProperty(); notifyAlbumIdProperty(); notifyIsValidProperty(); } #include "moc_manageheaderbar.cpp" diff --git a/src/manageheaderbar.h b/src/manageheaderbar.h index d5852f11..952e9a39 100644 --- a/src/manageheaderbar.h +++ b/src/manageheaderbar.h @@ -1,313 +1,313 @@ /* * Copyright 2016 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef MANAGEHEADERBAR_H #define MANAGEHEADERBAR_H #include "elisaLib_export.h" #include "elisautils.h" #include #include #include #include #include #include class ELISALIB_EXPORT ManageHeaderBar : public QObject { Q_OBJECT Q_PROPERTY(QPersistentModelIndex currentTrack READ currentTrack WRITE setCurrentTrack NOTIFY currentTrackChanged) Q_PROPERTY(int artistRole READ artistRole WRITE setArtistRole NOTIFY artistRoleChanged) Q_PROPERTY(int titleRole READ titleRole WRITE setTitleRole NOTIFY titleRoleChanged) Q_PROPERTY(int albumRole READ albumRole WRITE setAlbumRole NOTIFY albumRoleChanged) Q_PROPERTY(int albumArtistRole READ albumArtistRole WRITE setAlbumArtistRole NOTIFY albumArtistRoleChanged) Q_PROPERTY(int fileNameRole READ fileNameRole WRITE setFileNameRole NOTIFY fileNameRoleChanged) Q_PROPERTY(int imageRole READ imageRole WRITE setImageRole NOTIFY imageRoleChanged) Q_PROPERTY(int databaseIdRole READ databaseIdRole WRITE setDatabaseIdRole NOTIFY databaseIdRoleChanged) Q_PROPERTY(int trackTypeRole READ trackTypeRole WRITE setTrackTypeRole NOTIFY trackTypeRoleChanged) Q_PROPERTY(int albumIdRole READ albumIdRole WRITE setAlbumIdRole NOTIFY albumIdRoleChanged) Q_PROPERTY(int isValidRole READ isValidRole WRITE setIsValidRole NOTIFY isValidRoleChanged) Q_PROPERTY(QVariant artist READ artist NOTIFY artistChanged) Q_PROPERTY(QVariant title READ title NOTIFY titleChanged) Q_PROPERTY(QVariant album READ album NOTIFY albumChanged) Q_PROPERTY(QVariant albumArtist READ albumArtist NOTIFY albumArtistChanged) - Q_PROPERTY(QString fileName - READ fileName - NOTIFY fileNameChanged) + Q_PROPERTY(QUrl fileUrl + READ fileUrl + NOTIFY fileUrlChanged) Q_PROPERTY(QUrl image READ image NOTIFY imageChanged) Q_PROPERTY(qulonglong databaseId READ databaseId NOTIFY databaseIdChanged) Q_PROPERTY(ElisaUtils::PlayListEntryType trackType READ trackType NOTIFY trackTypeChanged) Q_PROPERTY(qulonglong albumId READ albumId NOTIFY albumIdChanged) Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) public: explicit ManageHeaderBar(QObject *parent = nullptr); QPersistentModelIndex currentTrack() const; int artistRole() const; int titleRole() const; int albumRole() const; int albumArtistRole() const; int fileNameRole() const; int imageRole() const; int databaseIdRole() const; int trackTypeRole() const; int albumIdRole() const; int isValidRole() const; QVariant artist() const; QVariant title() const; QVariant album() const; QVariant albumArtist() const; - QString fileName() const; + QUrl fileUrl() const; QUrl image() const; qulonglong databaseId() const; ElisaUtils::PlayListEntryType trackType() const; qulonglong albumId() const; bool isValid() const; Q_SIGNALS: void currentTrackChanged(); void artistRoleChanged(); void titleRoleChanged(); void albumRoleChanged(); void albumArtistRoleChanged(); void fileNameRoleChanged(); void imageRoleChanged(); void databaseIdRoleChanged(); void trackTypeRoleChanged(); void albumIdRoleChanged(); void isValidRoleChanged(); void artistChanged(); void titleChanged(); void albumChanged(); void albumArtistChanged(); - void fileNameChanged(); + void fileUrlChanged(); void imageChanged(); void databaseIdChanged(); void albumIdChanged(); void trackTypeChanged(); void isValidChanged(); public Q_SLOTS: void setCurrentTrack(const QPersistentModelIndex ¤tTrack); void setArtistRole(int value); void setTitleRole(int value); void setAlbumRole(int value); void setAlbumArtistRole(int value); void setFileNameRole(int value); void setImageRole(int value); void setDatabaseIdRole(int databaseIdRole); void setTrackTypeRole(int trackTypeRole); void setAlbumIdRole(int albumIdRole); void setIsValidRole(int isValidRole); private: void notifyArtistProperty(); void notifyTitleProperty(); void notifyAlbumProperty(); void notifyAlbumArtistProperty(); void notifyFileNameProperty(); void notifyImageProperty(); void notifyDatabaseIdProperty(); void notifyTrackTypeProperty(); void notifyAlbumIdProperty(); void notifyIsValidProperty(); QPersistentModelIndex mCurrentTrack; int mArtistRole = Qt::DisplayRole; int mTitleRole = Qt::DisplayRole; int mAlbumRole = Qt::DisplayRole; int mAlbumArtistRole = Qt::DisplayRole; int mFileNameRole = Qt::DisplayRole; int mImageRole = Qt::DisplayRole; int mDatabaseIdRole = Qt::DisplayRole; int mTrackTypeIdRole = Qt::DisplayRole; int mAlbumIdRole = Qt::DisplayRole; int mIsValidRole = Qt::DisplayRole; QVariant mOldArtist; QVariant mOldTitle; QVariant mOldAlbum; QVariant mOldAlbumArtist; QVariant mOldFileName; QVariant mOldImage; qulonglong mOldDatabaseId = 0; ElisaUtils::PlayListEntryType mOldTrackType = ElisaUtils::Unknown; qulonglong mOldAlbumId = 0; bool mOldIsValid = false; }; #endif // MANAGEHEADERBAR_H diff --git a/src/qml/ContentView.qml b/src/qml/ContentView.qml index ac8efae7..9c14bd61 100644 --- a/src/qml/ContentView.qml +++ b/src/qml/ContentView.qml @@ -1,350 +1,350 @@ /* * Copyright 2016-2018 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 import org.kde.elisa 1.0 import org.kde.kirigami 2.8 as Kirigami RowLayout { id: contentViewContainer spacing: 0 property bool showPlaylist property bool showExpandedFilterView property alias currentViewIndex: listViews.currentIndex function goBack() { viewManager.goBack() } function openArtist(name) { viewManager.openChildView(name, '', elisaTheme.artistIcon, 0, ElisaUtils.Artist, ViewManager.NoDiscHeaders) } function openAlbum(album, artist, image, albumID, showDiscHeader) { image = !image ? elisaTheme.defaultAlbumImage : image; viewManager.openChildView(album, artist, image, albumID, ElisaUtils.Album, showDiscHeader); } function openNowPlaying() { viewManager.closeAllViews(); } ViewManager { id: viewManager onSwitchOffAllViews: { listViews.setCurrentIndex(pageModel.indexFromViewType(viewType)) while(browseStackView.depth > 1) { browseStackView.pop() } } onOpenGridView: { if (expectedDepth === 1) { listViews.setCurrentIndex(pageModel.indexFromViewType(viewType)) } while(browseStackView.depth > expectedDepth) { browseStackView.pop() } browseStackView.push(dataGridView, { viewType: viewType, filterType: filterType, mainTitle: pageModel.viewMainTitle(viewType, mainTitle), secondaryTitle: secondaryTitle, image: pageModel.viewImageUrl(viewType, imageUrl), modelType: dataType, defaultIcon: viewDefaultIcon, showRating: viewShowRating, delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText, genreFilterText: genreNameFilter, artistFilter: artistNameFilter, isSubPage: (browseStackView.depth >= 2), stackView: browseStackView, opacity: 0, }) } onOpenListView: { listViews.setCurrentIndex(pageModel.indexFromViewType(viewType)) while(browseStackView.depth > expectedDepth) { browseStackView.pop() } browseStackView.push(dataListView, { viewType: viewType, filterType: filterType, isSubPage: expectedDepth > 1, mainTitle: mainTitle, secondaryTitle: secondaryTitle, databaseId: databaseId, image: imageUrl, modelType: dataType, sortRole: sortRole, sortAscending: sortOrder, stackView: browseStackView, displaySingleAlbum: displaySingleAlbum, showSection: showDiscHeaders, opacity: 0, radioCase: radioCase }) } onSwitchFilesBrowserView: { listViews.setCurrentIndex(pageModel.indexFromViewType(viewType)) while(browseStackView.depth > expectedDepth) { browseStackView.pop() } browseStackView.push(filesBrowserView, { viewType: viewType, mainTitle: mainTitle, image: imageUrl, opacity: 0, }) } onSwitchContextView: { listViews.setCurrentIndex(pageModel.indexFromViewType(viewType)) while(browseStackView.depth > expectedDepth) { browseStackView.pop() } browseStackView.push(albumContext, { viewType: viewType, mainTitle: mainTitle, image: imageUrl, opacity: 0, }) } onPopOneView: { if (browseStackView.depth > 2) { browseStackView.pop() } } } ViewsModel { id: pageModel } ViewSelector { id: listViews model: pageModel Layout.fillHeight: true Behavior on Layout.maximumWidth { NumberAnimation { duration: 150 } } onSwitchView: viewManager.openParentView(viewType, pageModel.viewMainTitle(viewType, ""), pageModel.viewImageUrl(viewType, "")) } Kirigami.Separator { id: viewSelectorSeparatorItem Layout.fillHeight: true } FocusScope { id: mainContentView focus: true Layout.fillHeight: true Layout.fillWidth: true MouseArea { anchors.fill: parent acceptedButtons: Qt.BackButton onClicked: goBack() } Rectangle { radius: 3 color: myPalette.base anchors.fill: parent StackView { id: browseStackView anchors.fill: parent clip: true initialItem: Item { } popEnter: Transition { OpacityAnimator { from: 0.0 to: 1.0 duration: 300 } } popExit: Transition { OpacityAnimator { from: 1.0 to: 0.0 duration: 300 } } pushEnter: Transition { OpacityAnimator { from: 0.0 to: 1.0 duration: 300 } } pushExit: Transition { OpacityAnimator { from: 1.0 to: 0.0 duration: 300 } } replaceEnter: Transition { OpacityAnimator { from: 0.0 to: 1.0 duration: 300 } } replaceExit: Transition { OpacityAnimator { from: 1.0 to: 0.0 duration: 300 } } } } } Kirigami.Separator { id: playListSeparatorItem Layout.fillHeight: true } MediaPlayListView { id: playList Layout.fillHeight: true onStartPlayback: elisa.audioControl.ensurePlay() onPausePlayback: elisa.audioControl.playPause() } states: [ State { name: "browsingViewsNoPlaylist" when: contentViewContainer.showPlaylist === false PropertyChanges { target: playList Layout.minimumWidth: 0 Layout.maximumWidth: 0 Layout.preferredWidth: 0 } PropertyChanges { target: playListSeparatorItem visible: false } }, State { name: 'browsingViews' when: contentViewContainer.showPlaylist === true PropertyChanges { target: playList Layout.minimumWidth: contentViewContainer.width * 0.28 Layout.maximumWidth: contentViewContainer.width * 0.28 Layout.preferredWidth: contentViewContainer.width * 0.28 } PropertyChanges { target: playListSeparatorItem visible: true } } ] transitions: Transition { NumberAnimation { properties: "Layout.minimumWidth, Layout.maximumWidth, Layout.preferredWidth, opacity" easing.type: Easing.InOutQuad duration: 300 } } Component { id: dataGridView DataGridView { StackView.onActivated: viewManager.viewIsLoaded(viewType) expandedFilterView: showExpandedFilterView } } Component { id: dataListView DataListView { StackView.onActivated: viewManager.viewIsLoaded(viewType) expandedFilterView: showExpandedFilterView } } Component { id: filesBrowserView FileBrowserView { StackView.onActivated: viewManager.viewIsLoaded(viewType) expandedFilterView: showExpandedFilterView } } Component { id: albumContext ContextView { StackView.onActivated: viewManager.viewIsLoaded(viewType) databaseId: elisa.manageHeaderBar.databaseId trackType: elisa.manageHeaderBar.trackType title: elisa.manageHeaderBar.title artistName: elisa.manageHeaderBar.artist albumName: elisa.manageHeaderBar.album albumArtUrl: elisa.manageHeaderBar.image - fileUrl: elisa.manageHeaderBar.fileName + fileUrl: elisa.manageHeaderBar.fileUrl } } } diff --git a/src/qml/ContextView.qml b/src/qml/ContextView.qml index c7ecd4c2..22f0402f 100644 --- a/src/qml/ContextView.qml +++ b/src/qml/ContextView.qml @@ -1,278 +1,278 @@ /* * Copyright 2016 Matthieu Gallien * Copyright 2019 Nate Graham * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import QtQuick 2.10 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 import QtQml.Models 2.2 import QtQuick.Layouts 1.2 import org.kde.elisa 1.0 FocusScope { id: topItem property var viewType property int databaseId: 0 property var trackType property alias title: titleLabel.text property string albumName: '' property string artistName: '' property url albumArtUrl: '' - property string fileUrl: '' + property url fileUrl: '' TrackContextMetaDataModel { id: metaDataModel manager: elisa.musicManager } ColumnLayout { anchors.fill: parent spacing: 0 TextMetrics { id: titleHeight text: viewTitle.text font: viewTitle.font } // Header with title HeaderFooterToolbar { type: "header" contentItems: [ Image { id: mainIcon source: elisaTheme.nowPlayingIcon height: viewTitle.height width: height sourceSize.height: height sourceSize.width: width fillMode: Image.PreserveAspectFit asynchronous: true Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft }, Item { id: spacer width: elisaTheme.layoutHorizontalMargin }, LabelWithToolTip { id: viewTitle Layout.fillWidth: true Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter text: i18nc("Title of the context view related to the currently playing track", "Now Playing") font.pointSize: elisaTheme.headerTitleFontSize } ] } // Scrollview to hold all the content Flickable { id: flickable clip: true contentWidth: content.width contentHeight: content.height Layout.fillWidth: true Layout.fillHeight: true boundsBehavior: Flickable.StopAtBounds ScrollBar.vertical: ScrollBar { id: scrollBar policy: ScrollBar.AlwaysOn } // Album Art + title + metadata + lyrics ColumnLayout { id: content width: topItem.width anchors.leftMargin: elisaTheme.layoutHorizontalMargin anchors.rightMargin: elisaTheme.layoutHorizontalMargin // Album art slice Image { id: albumIcon source: albumArtUrl.toString() === '' ? Qt.resolvedUrl(elisaTheme.defaultAlbumImage) : albumArtUrl Layout.maximumHeight: elisaTheme.contextCoverImageSize Layout.preferredHeight: elisaTheme.contextCoverImageSize Layout.fillWidth: true Layout.bottomMargin: elisaTheme.layoutVerticalMargin // Touch the sides of the scrollview Layout.leftMargin: -elisaTheme.layoutHorizontalMargin Layout.rightMargin: -elisaTheme.layoutHorizontalMargin sourceSize.width: topItem.width sourceSize.height: topItem.width asynchronous: true fillMode: Image.PreserveAspectCrop } // Song title LabelWithToolTip { id: titleLabel font.pointSize: elisaTheme.headerTitleFontSize font.weight: Font.Bold horizontalAlignment: Label.AlignHCenter Layout.fillWidth: true Layout.alignment: Qt.AlignTop Layout.topMargin: elisaTheme.layoutVerticalMargin } LabelWithToolTip { id: subtitleLabel text: { if (artistName !== '' && albumName !== '') { return i18nc("display of artist and album in context view", "by %1 from %2", artistName, albumName) } else if (artistName === '' && albumName !== '') { return i18nc("display of album in context view", "from %1", albumName) } else if (artistName !== '' && albumName === '') { i18nc("display of artist in context view", "by %1", artistName) } } font.pointSize: Math.round(elisaTheme.defaultFontPointSize * 1.4) horizontalAlignment: Label.AlignHCenter visible: artistName !== '' && albumName !== '' Layout.fillWidth: true Layout.alignment: Qt.AlignTop } // Horizontal line separating title and subtitle from metadata Rectangle { Layout.fillWidth: true Layout.leftMargin: elisaTheme.layoutHorizontalMargin * 5 Layout.rightMargin: elisaTheme.layoutHorizontalMargin * 5 Layout.topMargin: elisaTheme.layoutVerticalMargin * 2 Layout.bottomMargin: elisaTheme.layoutVerticalMargin * 2 height: 1 color: myPalette.mid } // Metadata ColumnLayout { id: allMetaData spacing: 0 Layout.fillWidth: true Repeater { id: trackData model: metaDataModel delegate: MetaDataDelegate { Layout.fillWidth: true } } } // Horizontal line separating metadata from lyrics Rectangle { Layout.fillWidth: true Layout.leftMargin: elisaTheme.layoutHorizontalMargin * 5 Layout.rightMargin: elisaTheme.layoutHorizontalMargin * 5 Layout.topMargin: elisaTheme.layoutVerticalMargin * 2 Layout.bottomMargin: elisaTheme.layoutVerticalMargin * 2 height: 1 color: myPalette.mid visible: metaDataModel.lyrics !== "" } // Lyrics Label { text: metaDataModel.lyrics wrapMode: Text.WordWrap horizontalAlignment: Label.AlignHCenter Layout.fillWidth: true Layout.bottomMargin: elisaTheme.layoutVerticalMargin visible: metaDataModel.lyrics !== "" } } } // Footer with file path label HeaderFooterToolbar { type: "footer" contentLayoutSpacing: elisaTheme.layoutHorizontalMargin contentItems: [ Image { sourceSize.width: fileNameLabel.height sourceSize.height: fileNameLabel.height source: elisaTheme.folderIcon }, LabelWithToolTip { id: fileNameLabel Layout.fillWidth: true - text: fileUrl + text: metaDataModel.fileUrl elide: Text.ElideLeft } ] } } onDatabaseIdChanged: { - metaDataModel.initializeById(trackType, databaseId) + metaDataModel.initializeByIdAndUrl(trackType, databaseId, fileUrl) } Connections { target: elisa onMusicManagerChanged: { - metaDataModel.initializeById(trackType, databaseId) + metaDataModel.initializeByIdAndUrl(trackType, databaseId, fileUrl) } } Component.onCompleted: { if (elisa.musicManager) { - metaDataModel.initializeById(trackType, databaseId) + metaDataModel.initializeByIdAndUrl(trackType, databaseId, fileUrl) } } }