Changeset View
Changeset View
Standalone View
Standalone View
src/qml/MediaPlayListView.qml
Show All 25 Lines | |||||
26 | 26 | | |||
27 | FocusScope { | 27 | FocusScope { | ||
28 | property StackView parentStackView | 28 | property StackView parentStackView | ||
29 | 29 | | |||
30 | property int placeholderHeight: elisaTheme.dragDropPlaceholderHeight | 30 | property int placeholderHeight: elisaTheme.dragDropPlaceholderHeight | ||
31 | 31 | | |||
32 | signal startPlayback() | 32 | signal startPlayback() | ||
33 | signal pausePlayback() | 33 | signal pausePlayback() | ||
34 | signal displayError(var errorText) | 34 | | ||
35 | function showPlayListNotification(message, type, action) { | ||||
36 | if (!message) { | ||||
37 | return; | ||||
38 | } | ||||
39 | | ||||
40 | if (type) { | ||||
41 | playListNotification.type = type; | ||||
42 | } else { | ||||
43 | playListNotification.type = Kirigami.MessageType.Information; | ||||
44 | } | ||||
45 | | ||||
46 | if (action) { | ||||
47 | playListNotification.actions = action; | ||||
48 | } else { | ||||
49 | playListNotification.actions = []; | ||||
50 | } | ||||
51 | | ||||
52 | playListNotification.text = message ? message : ""; | ||||
53 | playListNotification.visible = true; | ||||
54 | } | ||||
55 | | ||||
56 | function hideNotification() { | ||||
57 | playListNotification.visible = false; | ||||
58 | } | ||||
59 | | ||||
60 | Kirigami.Action { | ||||
61 | id: undoAction | ||||
62 | text: i18nc("Undo", "Undo") | ||||
63 | icon.name: "dialog-cancel" | ||||
64 | onTriggered: elisa.mediaPlayList.undoClearPlayList() | ||||
ngraham: This should be colored as a warning or error. | |||||
65 | } | ||||
66 | | ||||
67 | Kirigami.Action { | ||||
68 | id: retryLoadAction | ||||
69 | text: i18nc("Retry", "Retry") | ||||
70 | icon.name: "edit-redo" | ||||
71 | onTriggered: loadPlaylist.trigger() | ||||
72 | } | ||||
73 | | ||||
74 | Kirigami.Action { | ||||
75 | id: retrySaveAction | ||||
76 | text: i18nc("Retry", "Retry") | ||||
77 | icon.name: "edit-redo" | ||||
78 | onTriggered: savePlaylist.trigger() | ||||
79 | } | ||||
80 | | ||||
81 | Connections { | ||||
82 | target: elisa.mediaPlayList | ||||
83 | onPlayListLoadFailed: { | ||||
84 | showPlayListNotification(i18nc("Message when playlist load failed", "Loading failed"), Kirigami.MessageType.Error, retryLoadAction) | ||||
85 | } | ||||
86 | } | ||||
87 | | ||||
88 | Connections { | ||||
89 | target: elisa.mediaPlayList | ||||
90 | onDisplayUndoInline: { | ||||
91 | showPlayListNotification(i18nc("Playlist cleared", "Playlist cleared"), Kirigami.MessageType.Information, undoAction) | ||||
92 | } | ||||
93 | } | ||||
94 | | ||||
95 | Connections { | ||||
96 | target: elisa.mediaPlayList | ||||
97 | onHideUndoInline: hideNotification() | ||||
98 | } | ||||
35 | 99 | | |||
36 | id: topItem | 100 | id: topItem | ||
37 | 101 | | |||
38 | Accessible.role: Accessible.Pane | 102 | Accessible.role: Accessible.Pane | ||
39 | Accessible.name: viewTitle.text | 103 | Accessible.name: viewTitle.text | ||
40 | 104 | | |||
41 | Action { | 105 | Action { | ||
42 | id: clearPlayList | 106 | id: clearPlayList | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 150 | PlatformDialog.FileDialog { | |||
89 | defaultSuffix: 'm3u' | 153 | defaultSuffix: 'm3u' | ||
90 | folder: PlatformDialog.StandardPaths.writableLocation(PlatformDialog.StandardPaths.MusicLocation) | 154 | folder: PlatformDialog.StandardPaths.writableLocation(PlatformDialog.StandardPaths.MusicLocation) | ||
91 | nameFilters: [i18nc("file type (mime type) for m3u playlist", "Playlist (*.m3u)")] | 155 | nameFilters: [i18nc("file type (mime type) for m3u playlist", "Playlist (*.m3u)")] | ||
92 | 156 | | |||
93 | onAccepted: | 157 | onAccepted: | ||
94 | { | 158 | { | ||
95 | if (fileMode === PlatformDialog.FileDialog.SaveFile) { | 159 | if (fileMode === PlatformDialog.FileDialog.SaveFile) { | ||
96 | if (!elisa.mediaPlayList.savePlaylist(fileDialog.file)) { | 160 | if (!elisa.mediaPlayList.savePlaylist(fileDialog.file)) { | ||
97 | displayError(i18nc("message of passive notification when playlist load failed", "Save of playlist failed")) | 161 | showPlayListNotification(i18nc("Message when saving a playlist failed", "Saving failed"), Kirigami.MessageType.Error, retrySaveAction) | ||
In the message and in the comment you are once talking about save and once about load. mgallien: In the message and in the comment you are once talking about save and once about load. | |||||
98 | } | 162 | } | ||
99 | } else { | 163 | } else { | ||
100 | elisa.mediaPlayList.loadPlaylist(fileDialog.file) | 164 | elisa.mediaPlayList.loadPlaylist(fileDialog.file) | ||
101 | } | 165 | } | ||
102 | } | 166 | } | ||
103 | } | 167 | } | ||
104 | 168 | | |||
105 | ColumnLayout { | 169 | ColumnLayout { | ||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | 284 | PlayListBasicView { | |||
229 | playListModel: elisa.mediaPlayList | 293 | playListModel: elisa.mediaPlayList | ||
230 | 294 | | |||
231 | focus: true | 295 | focus: true | ||
232 | 296 | | |||
233 | onStartPlayback: topItem.startPlayback() | 297 | onStartPlayback: topItem.startPlayback() | ||
234 | 298 | | |||
235 | onPausePlayback: topItem.pausePlayback() | 299 | onPausePlayback: topItem.pausePlayback() | ||
236 | 300 | | |||
237 | onDisplayError: topItem.displayError(errorText) | 301 | onDisplayError: showPlayListNotification(errorText, Kirigami.MessageType.Error) | ||
238 | 302 | | |||
239 | } | 303 | } | ||
240 | 304 | | |||
241 | Kirigami.InlineMessage { | 305 | Kirigami.InlineMessage { | ||
242 | 306 | id: playListNotification | |||
243 | Connections { | | |||
244 | target: elisa.mediaPlayList | | |||
245 | onDisplayUndoInline: undoClear.visible = true | | |||
246 | } | | |||
247 | | ||||
248 | Connections { | | |||
249 | target: elisa.mediaPlayList | | |||
250 | onHideUndoInline: undoClear.visible = false | | |||
251 | } | | |||
252 | 307 | | |||
253 | Timer { | 308 | Timer { | ||
254 | id: autoHideUndoTimer | 309 | id: autoHideNotificationTimer | ||
255 | 310 | | |||
256 | interval: 7000 | 311 | interval: 7000 | ||
257 | 312 | | |||
258 | onTriggered: undoClear.visible = false | 313 | onTriggered: playListNotification.visible = false | ||
259 | } | 314 | } | ||
260 | 315 | | |||
261 | id: undoClear | | |||
262 | | ||||
263 | text: i18nc("Playlist cleared", "Playlist cleared") | | |||
264 | type: Kirigami.MessageType.Information | 316 | type: Kirigami.MessageType.Information | ||
265 | showCloseButton: true | 317 | showCloseButton: true | ||
266 | Layout.topMargin: 5 | 318 | Layout.topMargin: 5 | ||
267 | Layout.fillWidth: true | 319 | Layout.fillWidth: true | ||
268 | Layout.rightMargin: elisaTheme.layoutHorizontalMargin | 320 | Layout.rightMargin: elisaTheme.layoutHorizontalMargin | ||
269 | Layout.leftMargin: elisaTheme.layoutHorizontalMargin | 321 | Layout.leftMargin: elisaTheme.layoutHorizontalMargin | ||
270 | 322 | | |||
271 | onVisibleChanged: | 323 | onVisibleChanged: | ||
272 | { | 324 | { | ||
273 | if (visible) { | 325 | if (visible) { | ||
274 | autoHideUndoTimer.start() | 326 | autoHideNotificationTimer.start() | ||
275 | } else { | 327 | } else { | ||
276 | autoHideUndoTimer.stop() | 328 | autoHideNotificationTimer.stop() | ||
277 | } | 329 | } | ||
278 | } | 330 | } | ||
279 | | ||||
280 | actions: [ | | |||
281 | Kirigami.Action { | | |||
282 | text: i18nc("Undo", "Undo") | | |||
283 | icon.name: "dialog-cancel" | | |||
284 | onTriggered: elisa.mediaPlayList.undoClearPlayList() | | |||
285 | } | | |||
286 | ] | | |||
287 | } | 331 | } | ||
288 | } | 332 | } | ||
289 | 333 | | |||
290 | // Footer with number of tracks label | 334 | // Footer with number of tracks label | ||
291 | HeaderFooterToolbar { | 335 | HeaderFooterToolbar { | ||
292 | type: "footer" | 336 | type: "footer" | ||
293 | contentItems: [ | 337 | contentItems: [ | ||
294 | LabelWithToolTip { | 338 | LabelWithToolTip { | ||
Show All 13 Lines |
This should be colored as a warning or error.