Commit 68d40f2d authored by Nate Graham's avatar Nate Graham
Browse files

Port Playlist inlinemessages to PassiveNotification

We were basically replicating the functionality; might as well just use
the real thing. Then we can benefit from future improvements and have
less custom code.

The connections to the model's signal are moved into ElisaMainWindow so
that they are made only once, not once per instantiation of
MediaPlayListView. That caused logic to be executed twice.

BUG: 447607
FIXED-IN: 22.04
parent f7850cfe
Pipeline #129596 passed with stage
in 7 minutes and 2 seconds
......@@ -497,9 +497,7 @@ void MediaPlayListProxyModel::enqueue(const DataTypes::EntryDataList &newEntries
d->mTriggerPlay = triggerPlay;
if (enqueueMode == ElisaUtils::ReplacePlayList) {
if (rowCount() == 0) {
Q_EMIT hideUndoNotification();
} else {
if (rowCount() != 0) {
clearPlayList();
}
}
......@@ -685,7 +683,6 @@ void MediaPlayListProxyModel::undoClearPlayList()
d->mPlayListModel->clearPlayList();
setPersistentState(d->mPersistentSettingsForUndo);
Q_EMIT hideUndoNotification();
Q_EMIT undoClearPlayListPlayer();
}
......@@ -816,9 +813,7 @@ void MediaPlayListProxyModel::enqueueDirectory(const QUrl &fileName, ElisaUtils:
if (!fileName.isLocalFile()) return;
// clear playlist if required
if (enqueueMode == ElisaUtils::ReplacePlayList) {
if (rowCount() == 0) {
Q_EMIT hideUndoNotification();
} else {
if (rowCount() != 0) {
clearPlayList();
}
}
......
......@@ -20,6 +20,17 @@ Kirigami.ApplicationWindow {
visible: true
Connections {
target: ElisaApplication.mediaPlayListProxyModel
function onPlayListLoadFailed() {
showPassiveNotification(i18n("Loading failed"), 7000, i18n("Retry"), function() { loadPlaylistButton.clicked(); })
}
function onDisplayUndoNotification() {
showPassiveNotification(i18n("Playlist cleared"), 7000, i18n("Undo"), function() { ElisaApplication.mediaPlayListProxyModel.undoClearPlayList(); })
}
}
contextDrawer: Kirigami.ContextDrawer {
id: playlistDrawer
handleClosedIcon.source: "view-media-playlist"
......
......@@ -28,32 +28,6 @@ Kirigami.Page {
property var playListNotification
property var playListView
function hideNotification() {
playListNotification.visible = false;
}
function showPlayListNotification(message, type, action) {
if (!message) {
return;
}
if (type) {
playListNotification.type = type;
} else {
playListNotification.type = Kirigami.MessageType.Information;
}
if (action) {
playListNotification.actions = action;
} else {
playListNotification.actions = [];
}
playListNotification.text = message ? message : "";
playListNotification.visible = true;
}
title: i18nc("@info Title of the view of the playlist; keep this string as short as possible because horizontal space is quite scarce", "Playlist")
padding: 0
......@@ -64,60 +38,6 @@ Kirigami.Page {
Accessible.role: Accessible.Pane
Accessible.name: topItem.title
Timer {
id: mobileClearedMessageTimer
interval: 3000
onTriggered: mobileClearedMessage.visible = false
}
Kirigami.Action {
id: undoAction
text: i18nc("Undo", "Undo")
icon.name: "edit-undo"
onTriggered: ElisaApplication.mediaPlayListProxyModel.undoClearPlayList()
}
Kirigami.Action {
id: retryLoadAction
text: i18nc("Retry", "Retry")
icon.name: "edit-redo"
onTriggered: loadPlaylistButton.clicked()
}
Kirigami.Action {
id: retrySaveAction
text: i18nc("Retry", "Retry")
icon.name: "edit-redo"
onTriggered: savePlaylistButton.clicked()
}
Connections {
target: ElisaApplication.mediaPlayListProxyModel
function onPlayListLoadFailed() {
showPlayListNotification(i18nc("Message when playlist load failed", "Loading failed"), Kirigami.MessageType.Error, retryLoadAction)
}
}
Connections {
target: ElisaApplication.mediaPlayListProxyModel
function onDisplayUndoNotification() {
if (Kirigami.Settings.isMobile) {
// cleared playlist message
mobileClearedMessage.visible = true;
mobileClearedMessageTimer.restart();
} else {
showPlayListNotification(i18nc("Playlist cleared", "Playlist cleared"), Kirigami.MessageType.Information, undoAction);
}
}
}
Connections {
target: ElisaApplication.mediaPlayListProxyModel
function onHideUndoNotification() {
hideNotification()
}
}
// TODO: Once we depend on Frameworks 5.80, change this to
// "Kirigami.ApplicationHeaderStyle.None" and remove the custom header
globalToolBarStyle: Kirigami.ApplicationHeaderStyle.None
......@@ -320,35 +240,6 @@ Kirigami.Page {
explanation: i18n("Add some songs to get started. You can browse your music using the views on the left.")
visible: playListView.count === 0
}
Kirigami.InlineMessage {
id: playListNotification
Component.onCompleted: topItem.playListNotification = playListNotification
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
margins: Kirigami.Units.largeSpacing
}
type: Kirigami.MessageType.Information
showCloseButton: true
onVisibleChanged: {
if (visible) {
autoHideNotificationTimer.start()
} else {
autoHideNotificationTimer.stop()
}
}
Timer {
id: autoHideNotificationTimer
interval: 7000
onTriggered: playListNotification.visible = false
}
}
}
}
}
......@@ -549,7 +440,7 @@ Kirigami.Page {
{
if (fileMode === PlatformDialog.FileDialog.SaveFile) {
if (!ElisaApplication.mediaPlayListProxyModel.savePlayList(fileDialog.file)) {
showPlayListNotification(i18nc("Message when saving a playlist failed", "Saving failed"), Kirigami.MessageType.Error, retrySaveAction)
showPassiveNotification(i18n("Saving failed"), 7000, i18n("Retry"), function() { savePlaylistButton.clicked(); })
}
} else {
ElisaApplication.mediaPlayListProxyModel.loadPlayList(fileDialog.file)
......
Supports Markdown
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