Commit 32396432 authored by Matthieu Gallien's avatar Matthieu Gallien

change the way lyrics and other metadata are shown and improve lyrics

no longer use a ListView but a ColumnLayout inside a Flickable

Use custom appearance for lyrics
parent 951771db
......@@ -361,6 +361,7 @@ if (Qt5Quick_FOUND AND Qt5Widgets_FOUND)
qml/NavigationActionBar.qml
qml/MediaPlayerControl.qml
qml/ContextView.qml
qml/ContextViewLyrics.qml
qml/ContentView.qml
qml/ViewSelector.qml
qml/DataGridView.qml
......
......@@ -33,5 +33,9 @@ void TrackContextMetaDataModel::filterDataFromTrackData()
}
}
void TrackContextMetaDataModel::fillLyricsDataFromTrack()
{
}
#include "moc_trackcontextmetadatamodel.cpp"
......@@ -35,6 +35,8 @@ protected:
void filterDataFromTrackData() override;
void fillLyricsDataFromTrack() override;
};
#endif // TRACKCONTEXTMETADATAMODEL_H
......@@ -255,6 +255,11 @@ MusicListenersManager *TrackMetadataModel::manager() const
return mManager;
}
QString TrackMetadataModel::lyrics() const
{
return mFullData[TrackDataType::key_type::LyricsRole].toString();
}
void TrackMetadataModel::trackData(const TrackMetadataModel::TrackDataType &trackData)
{
if (!mFullData.isEmpty() && trackData.databaseId() != mFullData.databaseId()) {
......@@ -325,14 +330,22 @@ TrackMetadataModel::TrackDataType::mapped_type TrackMetadataModel::dataFromType(
return mFullData[metaData];
}
void TrackMetadataModel::fillLyricsDataFromTrack()
{
beginInsertRows({}, mTrackData.size(), mTrackData.size());
mTrackKeys.push_back(DatabaseInterface::LyricsRole);
mTrackData[DatabaseInterface::LyricsRole] = mLyricsValueWatcher.result();
endInsertRows();
}
void TrackMetadataModel::lyricsValueIsReady()
{
if (!mLyricsValueWatcher.result().isEmpty()) {
beginInsertRows({}, mTrackData.size(), mTrackData.size());
mTrackKeys.push_back(DatabaseInterface::LyricsRole);
mTrackData[DatabaseInterface::LyricsRole] = mLyricsValueWatcher.result();
fillLyricsDataFromTrack();
mFullData[DatabaseInterface::LyricsRole] = mLyricsValueWatcher.result();
endInsertRows();
Q_EMIT lyricsChanged();
}
}
......@@ -381,6 +394,8 @@ void TrackMetadataModel::initializeByTrackId(qulonglong databaseId)
mCoverImage.clear();
mFileUrl.clear();
Q_EMIT lyricsChanged();
Q_EMIT needDataByDatabaseId(ElisaUtils::Track, databaseId);
}
......@@ -391,6 +406,8 @@ void TrackMetadataModel::initializeByTrackFileName(const QUrl &fileName)
mCoverImage.clear();
mFileUrl.clear();
Q_EMIT lyricsChanged();
Q_EMIT needDataByFileName(ElisaUtils::FileName, fileName);
}
......
......@@ -49,6 +49,10 @@ class ELISALIB_EXPORT TrackMetadataModel : public QAbstractListModel
WRITE setManager
NOTIFY managerChanged)
Q_PROPERTY(QString lyrics
READ lyrics
NOTIFY lyricsChanged)
public:
enum ColumnRoles
......@@ -89,6 +93,8 @@ public:
MusicListenersManager* manager() const;
QString lyrics() const;
Q_SIGNALS:
void needDataByDatabaseId(ElisaUtils::PlayListEntryType dataType, qulonglong databaseId);
......@@ -101,6 +107,8 @@ Q_SIGNALS:
void managerChanged();
void lyricsChanged();
public Q_SLOTS:
void trackData(const TrackMetadataModel::TrackDataType &trackData);
......@@ -123,6 +131,8 @@ protected:
TrackDataType::mapped_type dataFromType(TrackDataType::key_type metaData) const;
virtual void fillLyricsDataFromTrack();
private Q_SLOTS:
void lyricsValueIsReady();
......
......@@ -144,24 +144,49 @@ FocusScope {
elide: Text.ElideRight
}
ListView {
id: trackData
Flickable {
id: flickable
clip: true
contentWidth: topItem.width
contentHeight: allMetaData.height
Layout.fillWidth: true
Layout.fillHeight: true
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar {
id: scrollBar
policy: ScrollBar.AlwaysOn
}
boundsBehavior: Flickable.StopAtBounds
clip: true
spacing: 0
ColumnLayout {
id: allMetaData
spacing: 0
width: topItem.width
Repeater {
id: trackData
model: metaDataModel
delegate: MetaDataDelegate {
Layout.fillWidth: true
}
}
ContextViewLyrics {
id: lyricsContextView
Layout.fillWidth: true
model: metaDataModel
visible: metaDataModel.lyrics !== ""
delegate: MetaDataDelegate {
width: scrollBar.visible ? (!LayoutMirroring.enabled ? trackData.width - scrollBar.width : trackData.width) : trackData.width
lyrics: metaDataModel.lyrics
}
}
}
......
/*
* Copyright 2016 Matthieu Gallien <matthieu_gallien@yahoo.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.10
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.2
import org.kde.elisa 1.0
ColumnLayout {
property string lyrics
Label {
id: title
horizontalAlignment: Label.AlignHCenter
text: i18nc("Lyrics label for track metadata view", "Lyrics")
font.weight: Font.Bold
Layout.fillWidth: true
}
Label {
text: lyrics
horizontalAlignment: Text.AlignLeft
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
}
......@@ -43,6 +43,7 @@
<file>qml/PlayListAlbumHeader.qml</file>
<file>qml/BasicPlayListAlbumHeader.qml</file>
<file>qml/MetaDataDelegate.qml</file>
<file>qml/ContextViewLyrics.qml</file>
</qresource>
<qresource prefix="/qml/+windows">
<file alias="Theme.qml">windows/WindowsTheme.qml</file>
......
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