Commit a5f6f0b6 authored by Firlaev-Hans Fiete's avatar Firlaev-Hans Fiete Committed by Nate Graham
Browse files

Fix Open and Save Playlist global menu entries

Before, the two entries "Open Playlist…" and "Save Playlist…" in the "File" menu
were bound to the same action as "Refresh Music Collection" which is obviously
not wanted.
parent 4ff13b19
Pipeline #168703 passed with stage
in 6 minutes and 48 seconds
......@@ -87,6 +87,7 @@ Kirigami.ApplicationWindow {
property var togglePartyModeAction: ElisaApplication.action("togglePartyMode")
property var mediaPlayerControl: Kirigami.Settings.isMobile ? mobileFooterBarLoader.item : headerBarLoader.item
property var fileDialog: fileDialog
Action {
shortcut: ElisaApplication.actionShortcut(goBackAction)
......@@ -137,6 +138,36 @@ Kirigami.ApplicationWindow {
id: elisaTheme
}
FileDialog {
id: fileDialog
function savePlaylist() {
fileDialog.fileMode = FileDialog.SaveFile
fileDialog.file = ''
fileDialog.open()
}
function loadPlaylist() {
fileDialog.fileMode = FileDialog.OpenFile
fileDialog.file = ''
fileDialog.open()
}
defaultSuffix: 'm3u8'
folder: StandardPaths.writableLocation(StandardPaths.MusicLocation)
nameFilters: [i18nc("file type (mime type) for m3u and m3u8 playlist file formats", "Playlist (*.m3u*)")]
onAccepted:
{
if (fileMode === FileDialog.SaveFile) {
if (!ElisaApplication.mediaPlayListProxyModel.savePlayList(fileDialog.file)) {
showPassiveNotification(i18n("Saving failed"), 7000, i18n("Retry"), function() { savePlaylistButton.clicked(); })
}
} else {
ElisaApplication.mediaPlayListProxyModel.loadPlayList(fileDialog.file)
}
}
}
Settings {
id: persistentSettings
......
......@@ -10,7 +10,6 @@ import QtQuick.Controls 2.3
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import QtQml.Models 2.1
import Qt.labs.platform 1.0 as PlatformDialog
import org.kde.kirigami 2.15 as Kirigami
import org.kde.elisa 1.0
......@@ -65,9 +64,7 @@ Kirigami.Page {
displayHint: Kirigami.DisplayHint.KeepVisible
enabled: ElisaApplication.mediaPlayListProxyModel ? ElisaApplication.mediaPlayListProxyModel.tracksCount > 0 : false
onTriggered: {
fileDialog.fileMode = PlatformDialog.FileDialog.SaveFile
fileDialog.file = ''
fileDialog.open()
mainWindow.fileDialog.savePlaylist()
}
},
Kirigami.Action {
......@@ -76,9 +73,7 @@ Kirigami.Page {
icon.name: 'document-open'
displayHint: Kirigami.DisplayHint.KeepVisible
onTriggered: {
fileDialog.fileMode = PlatformDialog.FileDialog.OpenFile
fileDialog.file = ''
fileDialog.open()
mainWindow.fileDialog.loadPlaylist()
}
}
]
......@@ -373,24 +368,5 @@ Kirigami.Page {
}
}
}
PlatformDialog.FileDialog {
id: fileDialog
defaultSuffix: 'm3u8'
folder: PlatformDialog.StandardPaths.writableLocation(PlatformDialog.StandardPaths.MusicLocation)
nameFilters: [i18nc("file type (mime type) for m3u and m3u8 playlist file formats", "Playlist (*.m3u*)")]
onAccepted:
{
if (fileMode === PlatformDialog.FileDialog.SaveFile) {
if (!ElisaApplication.mediaPlayListProxyModel.savePlayList(fileDialog.file)) {
showPassiveNotification(i18n("Saving failed"), 7000, i18n("Retry"), function() { savePlaylistButton.clicked(); })
}
} else {
ElisaApplication.mediaPlayListProxyModel.loadPlayList(fileDialog.file)
}
}
}
}
......@@ -16,13 +16,17 @@ MenuBar {
MenuItem {
text: i18nc("menu entry", "Save Playlist…")
iconName: "document-save"
onTriggered: ElisaApplication.musicManager.resetMusicData()
onTriggered: {
mainWindow.fileDialog.savePlaylist()
}
}
MenuItem {
text: i18nc("menu entry", "Open Playlist…")
iconName: "document-open"
onTriggered: ElisaApplication.musicManager.resetMusicData()
onTriggered: {
mainWindow.fileDialog.loadPlaylist()
}
}
MenuItem {
......
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