diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -360,7 +360,6 @@ qml/RatingStar.qml qml/DraggableItem.qml - qml/PassiveNotification.qml qml/TopNotification.qml qml/TopNotificationItem.qml qml/TrackImportNotification.qml diff --git a/src/qml/ContentView.qml b/src/qml/ContentView.qml --- a/src/qml/ContentView.qml +++ b/src/qml/ContentView.qml @@ -304,8 +304,6 @@ onStartPlayback: elisa.audioControl.ensurePlay() onPausePlayback: elisa.audioControl.playPause() - - onDisplayError: messageNotification.showNotification(errorText) } } } diff --git a/src/qml/ElisaMainWindow.qml b/src/qml/ElisaMainWindow.qml --- a/src/qml/ElisaMainWindow.qml +++ b/src/qml/ElisaMainWindow.qml @@ -156,18 +156,6 @@ onMutedChanged: headerBar.playerControl.muted = elisa.audioPlayer.muted } - Connections { - target: elisa.mediaPlayList - - onPlayListLoadFailed: { - messageNotification.showNotification(i18nc("message of passive notification when playlist load failed", "Load of playlist failed"), 3000) - } - } - - PassiveNotification { - id: messageNotification - } - Rectangle { color: myPalette.base anchors.fill: parent diff --git a/src/qml/MediaPlayListView.qml b/src/qml/MediaPlayListView.qml --- a/src/qml/MediaPlayListView.qml +++ b/src/qml/MediaPlayListView.qml @@ -31,7 +31,71 @@ signal startPlayback() signal pausePlayback() - signal displayError(var errorText) + + 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; + } + + function hideNotification() { + playListNotification.visible = false; + } + + Kirigami.Action { + id: undoAction + text: i18nc("Undo", "Undo") + icon.name: "dialog-cancel" + onTriggered: elisa.mediaPlayList.undoClearPlayList() + } + + Kirigami.Action { + id: retryLoadAction + text: i18nc("Retry", "Retry") + icon.name: "edit-redo" + onTriggered: loadPlaylist.trigger() + } + + Kirigami.Action { + id: retrySaveAction + text: i18nc("Retry", "Retry") + icon.name: "edit-redo" + onTriggered: savePlaylist.trigger() + } + + Connections { + target: elisa.mediaPlayList + onPlayListLoadFailed: { + showPlayListNotification(i18nc("Message when playlist load failed", "Loading failed"), Kirigami.MessageType.Error, retryLoadAction) + } + } + + Connections { + target: elisa.mediaPlayList + onDisplayUndoInline: { + showPlayListNotification(i18nc("Playlist cleared", "Playlist cleared"), Kirigami.MessageType.Information, undoAction) + } + } + + Connections { + target: elisa.mediaPlayList + onHideUndoInline: hideNotification() + } id: topItem @@ -94,7 +158,7 @@ { if (fileMode === PlatformDialog.FileDialog.SaveFile) { if (!elisa.mediaPlayList.savePlaylist(fileDialog.file)) { - displayError(i18nc("message of passive notification when playlist load failed", "Save of playlist failed")) + showPlayListNotification(i18nc("Message when saving a playlist failed", "Saving failed"), Kirigami.MessageType.Error, retrySaveAction) } } else { elisa.mediaPlayList.loadPlaylist(fileDialog.file) @@ -234,33 +298,21 @@ onPausePlayback: topItem.pausePlayback() - onDisplayError: topItem.displayError(errorText) + onDisplayError: showPlayListNotification(errorText, Kirigami.MessageType.Error) } Kirigami.InlineMessage { - - Connections { - target: elisa.mediaPlayList - onDisplayUndoInline: undoClear.visible = true - } - - Connections { - target: elisa.mediaPlayList - onHideUndoInline: undoClear.visible = false - } + id: playListNotification Timer { - id: autoHideUndoTimer + id: autoHideNotificationTimer interval: 7000 - onTriggered: undoClear.visible = false + onTriggered: playListNotification.visible = false } - id: undoClear - - text: i18nc("Playlist cleared", "Playlist cleared") type: Kirigami.MessageType.Information showCloseButton: true Layout.topMargin: 5 @@ -271,19 +323,11 @@ onVisibleChanged: { if (visible) { - autoHideUndoTimer.start() + autoHideNotificationTimer.start() } else { - autoHideUndoTimer.stop() + autoHideNotificationTimer.stop() } } - - actions: [ - Kirigami.Action { - text: i18nc("Undo", "Undo") - icon.name: "dialog-cancel" - onTriggered: elisa.mediaPlayList.undoClearPlayList() - } - ] } } diff --git a/src/qml/PassiveNotification.qml b/src/qml/PassiveNotification.qml deleted file mode 100644 --- a/src/qml/PassiveNotification.qml +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2015 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.5 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.2 -import QtGraphicalEffects 1.0 - -MouseArea { - id: root - z: 9999999 - width: background.width - height: background.height - opacity: 0 - enabled: appearAnimation.appear - - anchors { - horizontalCenter: parent.horizontalCenter - bottom: parent.bottom - bottomMargin: 3 * 4 - } - function showNotification(message, timeout, actionText, callBack) { - if (!message) { - return; - } - appearAnimation.running = false; - appearAnimation.appear = true; - appearAnimation.running = true; - if (timeout === "short") { - timer.interval = 1000; - } else if (timeout === "long") { - timer.interval = 4500; - } else if (timeout > 0) { - timer.interval = timeout; - } else { - timer.interval = 4500; - } - messageLabel.text = message ? message : ""; - actionButton.text = actionText ? actionText : ""; - actionButton.callBack = callBack ? callBack : ""; - - timer.restart(); - } - - function hideNotification() { - appearAnimation.running = false; - appearAnimation.appear = false; - appearAnimation.running = true; - } - - - onClicked: { - appearAnimation.appear = false; - appearAnimation.running = true; - } - - transform: Translate { - id: transform - y: root.height - } - - Timer { - id: timer - interval: 4000 - onTriggered: { - appearAnimation.appear = false; - appearAnimation.running = true; - } - } - ParallelAnimation { - id: appearAnimation - property bool appear: true - NumberAnimation { - target: root - properties: "opacity" - to: appearAnimation.appear ? 1 : 0 - duration: 1000 - easing.type: Easing.InOutQuad - } - NumberAnimation { - target: transform - properties: "y" - to: appearAnimation.appear ? 0 : background.height - duration: 1000 - easing.type: appearAnimation.appear ? Easing.OutQuad : Easing.InQuad - } - } - - Item { - id: background - width: backgroundRect.width + 3 - height: backgroundRect.height + 3 - Rectangle { - id: backgroundRect - anchors.centerIn: parent - radius: 5 - color: myPalette.button - opacity: 0.6 - width: mainLayout.width + Math.round((height - mainLayout.height)) - height: Math.max(mainLayout.height + 5*2, 3*2) - } - RowLayout { - id: mainLayout - anchors.centerIn: parent - Label { - id: messageLabel - Layout.maximumWidth: Math.min(root.parent.width - 20*2, implicitWidth) - elide: Text.ElideRight - wrapMode: Text.WordWrap - maximumLineCount: 4 - color: myPalette.buttonText - } - Button { - id: actionButton - property var callBack - visible: text != "" - onClicked: { - appearAnimation.appear = false; - appearAnimation.running = true; - if (callBack) { - callBack(); - } - } - Accessible.onPressAction: onClicked - } - } - layer.enabled: true - layer.effect: DropShadow { - horizontalOffset: 0 - verticalOffset: 0 - radius: 3 - samples: 32 - color: Qt.rgba(0, 0, 0, 0.5) - } - } -} - diff --git a/src/resources.qrc b/src/resources.qrc --- a/src/resources.qrc +++ b/src/resources.qrc @@ -9,7 +9,6 @@ qml/ContextView.qml qml/ContentView.qml qml/DraggableItem.qml - qml/PassiveNotification.qml qml/NavigationActionBar.qml qml/PlayListEntry.qml qml/Theme.qml