Commit df49cb3a authored by Nate Graham's avatar Nate Graham 🔩
Browse files

Port sidebar placeholder message to Kirigami.PlaceholderMessage

Kirigami has a standard component for this that results in a unified
appearance across KDE apps, and using it lets us remove tons of code.
parent 853d55f2
......@@ -22,7 +22,7 @@ find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Network Qml Quick T
find_package(Qt5Core ${REQUIRED_QT_VERSION} CONFIG REQUIRED Private)
set(REQUIRED_KF5_VERSION "5.64.0")
set(REQUIRED_KF5_VERSION "5.70.0")
find_package(ECM ${REQUIRED_KF5_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
......
......@@ -14,7 +14,6 @@ Item {
property string artistIcon: 'image://icon/view-media-artist'
property string albumIcon: 'image://icon/view-media-album-cover'
property string albumCoverIcon: 'image://icon/media-optical-audio'
property string playlistIcon: 'image://icon/view-media-playlist'
property string tracksIcon: 'image://icon/view-media-track'
property string genresIcon: 'image://icon/view-media-genre'
property string clearIcon: 'image://icon/edit-clear'
......
......@@ -10,7 +10,7 @@ import QtQuick.Controls 2.3
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import Qt.labs.platform 1.0 as PlatformDialog
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kirigami 2.12 as Kirigami
import org.kde.elisa 1.0
FocusScope {
......@@ -172,116 +172,65 @@ FocusScope {
]
}
ColumnLayout {
id: emptyPlaylistText
spacing: 0
visible: true
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Layout.fillHeight: true
Layout.fillWidth: true
Item {
id: emptyVisible
visible: elisa.mediaPlayListProxyModel ? elisa.mediaPlayListProxyModel.tracksCount === 0 : true
Layout.fillHeight: true
}
Image {
id: emptyImage
visible: emptyVisible.visible
Layout.alignment: Qt.AlignHCenter
width: elisaTheme.gridDelegateSize
height: elisaTheme.gridDelegateSize
Item {
id: emptyPlaylistMessage
source: elisaTheme.playlistIcon
opacity: 0.25
visible: elisa.mediaPlayListProxyModel ? elisa.mediaPlayListProxyModel.tracksCount === 0 : true
sourceSize {
width: elisaTheme.gridDelegateSize
height: elisaTheme.gridDelegateSize
}
}
LabelWithToolTip {
id: emptyLabel0
visible: emptyVisible.visible
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.fillHeight: true
Layout.fillWidth: true
level: 1
wrapMode: Text.WordWrap
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
horizontalAlignment: Text.AlignHCenter
text: i18nc("Your playlist is empty", "Your playlist is empty")
text: xi18nc("@info", "Your playlist is empty.<nl/><nl/>Add some songs to get started. You can browse your music using the views on the left.")
}
}
Label {
id: emptyLabel1
visible: emptyVisible.visible
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.leftMargin: Kirigami.Units.largeSpacing
PlayListBasicView {
id: playListView
wrapMode: Text.WordWrap
visible: !emptyPlaylistMessage.visible
horizontalAlignment: Text.AlignHCenter
text: i18nc("Text shown when play list is empty", "Add some songs to get started. You can browse your music using the views on the left.")
}
Layout.fillWidth: true
Layout.fillHeight: true
Item {
visible: emptyVisible.visible
Layout.fillHeight: true
}
title: viewTitle.text
playListModel: elisa.mediaPlayListProxyModel
PlayListBasicView {
id: playListView
focus: true
visible: !emptyVisible.visible
onStartPlayback: topItem.startPlayback()
Layout.fillWidth: true
Layout.fillHeight: true
onPausePlayback: topItem.pausePlayback()
title: viewTitle.text
playListModel: elisa.mediaPlayListProxyModel
onDisplayError: showPlayListNotification(errorText, Kirigami.MessageType.Error)
focus: true
}
onStartPlayback: topItem.startPlayback()
Kirigami.InlineMessage {
id: playListNotification
onPausePlayback: topItem.pausePlayback()
Timer {
id: autoHideNotificationTimer
onDisplayError: showPlayListNotification(errorText, Kirigami.MessageType.Error)
interval: 7000
onTriggered: playListNotification.visible = false
}
Kirigami.InlineMessage {
id: playListNotification
Timer {
id: autoHideNotificationTimer
interval: 7000
onTriggered: playListNotification.visible = false
}
type: Kirigami.MessageType.Information
showCloseButton: true
Layout.fillWidth: true
Layout.margins: Kirigami.Units.largeSpacing
onVisibleChanged:
{
if (visible) {
autoHideNotificationTimer.start()
} else {
autoHideNotificationTimer.stop()
}
type: Kirigami.MessageType.Information
showCloseButton: true
Layout.fillWidth: true
Layout.margins: Kirigami.Units.largeSpacing
onVisibleChanged:
{
if (visible) {
autoHideNotificationTimer.start()
} else {
autoHideNotificationTimer.stop()
}
}
}
......
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