Changeset View
Changeset View
Standalone View
Standalone View
src/qml/MediaRadioMetadataView.qml
- This file was copied from src/qml/MediaTrackMetadataView.qml.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2017 Alexander Stippich <a.stippich@gmx.net> | 2 | * Copyright 2017 Alexander Stippich <a.stippich@gmx.net> | ||
3 | * Copyright 2018 Matthieu Gallien <matthieu_gallien@yahoo.fr> | 3 | * Copyright 2018 Matthieu Gallien <matthieu_gallien@yahoo.fr> | ||
4 | * Copyright 2019 Jérôme Guidon <guidon@live.fr> | ||||
4 | * | 5 | * | ||
5 | * This program is free software: you can redistribute it and/or | 6 | * This program is free software: you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU Lesser General Public | 7 | * modify it under the terms of the GNU Lesser General Public | ||
7 | * License as published by the Free Software Foundation; either | 8 | * License as published by the Free Software Foundation; either | ||
8 | * version 3 of the License, or (at your option) any later version. | 9 | * version 3 of the License, or (at your option) any later version. | ||
9 | * | 10 | * | ||
10 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 11 Lines | |||||
23 | import QtQuick.Layouts 1.2 | 24 | import QtQuick.Layouts 1.2 | ||
24 | import QtGraphicalEffects 1.0 | 25 | import QtGraphicalEffects 1.0 | ||
25 | import org.kde.elisa 1.0 | 26 | import org.kde.elisa 1.0 | ||
26 | 27 | | |||
27 | Window { | 28 | Window { | ||
28 | id: trackMetadata | 29 | id: trackMetadata | ||
29 | 30 | | |||
30 | property int databaseId: 0 | 31 | property int databaseId: 0 | ||
31 | property string fileName | 32 | property url fileName | ||
32 | 33 | | |||
33 | signal rejected() | 34 | signal rejected() | ||
34 | 35 | | |||
35 | LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft | 36 | LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft | ||
36 | LayoutMirroring.childrenInherit: true | 37 | LayoutMirroring.childrenInherit: true | ||
37 | 38 | | |||
38 | title: i18nc("Window title for track metadata", "View Details") | 39 | title: i18nc("Window title for track metadata", "View Details") | ||
39 | 40 | | |||
40 | TrackMetadataModel { | 41 | TrackMetadataModel { | ||
41 | id: realModel | 42 | id: realModel | ||
42 | 43 | | |||
43 | manager: elisa.musicManager | 44 | manager: elisa.musicManager | ||
45 | isRadio: true | ||||
44 | } | 46 | } | ||
45 | 47 | | |||
46 | modality: Qt.NonModal | 48 | modality: Qt.NonModal | ||
47 | flags: Qt.Dialog | Qt.WindowCloseButtonHint | 49 | flags: Qt.Dialog | Qt.WindowCloseButtonHint | ||
48 | 50 | | |||
49 | color: myPalette.window | 51 | color: myPalette.window | ||
50 | 52 | | |||
51 | minimumHeight: elisaTheme.coverImageSize * 1.8 | 53 | minimumHeight: elisaTheme.coverImageSize * 1.8 | ||
52 | minimumWidth: elisaTheme.coverImageSize * 2.8 | 54 | minimumWidth: elisaTheme.coverImageSize * 5 | ||
53 | 55 | | |||
54 | ColumnLayout { | 56 | ColumnLayout { | ||
55 | anchors.fill: parent | 57 | anchors.fill: parent | ||
56 | anchors.margins: elisaTheme.layoutVerticalMargin | 58 | anchors.margins: elisaTheme.layoutVerticalMargin | ||
57 | 59 | | |||
58 | spacing: elisaTheme.layoutVerticalMargin | 60 | spacing: elisaTheme.layoutVerticalMargin | ||
59 | 61 | | |||
60 | RowLayout { | 62 | RowLayout { | ||
61 | id: metadataView | 63 | id: metadataView | ||
62 | 64 | | |||
63 | Layout.fillHeight: true | 65 | Layout.fillHeight: true | ||
64 | Layout.fillWidth: true | 66 | Layout.fillWidth: true | ||
65 | 67 | | |||
66 | spacing: 0 | 68 | spacing: 0 | ||
67 | 69 | | |||
68 | Image { | | |||
69 | source: realModel.coverUrl | | |||
70 | | ||||
71 | sourceSize.width: elisaTheme.coverImageSize | | |||
72 | sourceSize.height: elisaTheme.coverImageSize | | |||
73 | | ||||
74 | fillMode: Image.PreserveAspectFit | | |||
75 | | ||||
76 | Layout.alignment: Qt.AlignTop | Qt.AlignHCenter | | |||
77 | Layout.preferredHeight: elisaTheme.coverImageSize | | |||
78 | Layout.preferredWidth: elisaTheme.coverImageSize | | |||
79 | Layout.minimumHeight: elisaTheme.coverImageSize | | |||
80 | Layout.minimumWidth: elisaTheme.coverImageSize | | |||
81 | Layout.maximumHeight: elisaTheme.coverImageSize | | |||
82 | Layout.maximumWidth: elisaTheme.coverImageSize | | |||
83 | } | | |||
84 | | ||||
85 | ListView { | 70 | ListView { | ||
86 | id: trackData | 71 | id: trackData | ||
87 | 72 | | |||
88 | Layout.fillWidth: true | 73 | Layout.fillWidth: true | ||
89 | Layout.fillHeight: true | 74 | Layout.fillHeight: true | ||
90 | Layout.leftMargin: 2 * elisaTheme.layoutHorizontalMargin | 75 | Layout.leftMargin: 2 * elisaTheme.layoutHorizontalMargin | ||
91 | 76 | | |||
92 | focus: true | 77 | focus: true | ||
93 | 78 | | |||
94 | ScrollBar.vertical: ScrollBar { | 79 | ScrollBar.vertical: ScrollBar { | ||
95 | id: scrollBar | 80 | id: scrollBar | ||
96 | } | 81 | } | ||
97 | boundsBehavior: Flickable.StopAtBounds | 82 | boundsBehavior: Flickable.StopAtBounds | ||
98 | clip: true | 83 | clip: true | ||
99 | 84 | | |||
100 | ScrollHelper { | 85 | ScrollHelper { | ||
101 | id: scrollHelper | 86 | id: scrollHelper | ||
102 | flickable: trackData | 87 | flickable: trackData | ||
103 | anchors.fill: trackData | 88 | anchors.fill: trackData | ||
104 | } | 89 | } | ||
105 | model: realModel | 90 | model: realModel | ||
106 | 91 | | |||
107 | delegate: MetaDataDelegate { | 92 | delegate: MetaDataDelegate { | ||
93 | radio: true | ||||
108 | width: scrollBar.visible ? (!LayoutMirroring.enabled ? trackData.width - scrollBar.width : trackData.width) : trackData.width | 94 | width: scrollBar.visible ? (!LayoutMirroring.enabled ? trackData.width - scrollBar.width : trackData.width) : trackData.width | ||
95 | onRadioEdited: applyButton.enabled = true | ||||
109 | } | 96 | } | ||
110 | } | 97 | } | ||
111 | } | 98 | } | ||
112 | 99 | | |||
113 | RowLayout { | 100 | RowLayout{ | ||
114 | Layout.alignment: Qt.AlignLeft | Qt.AlignBottom | 101 | spacing: elisaTheme.layoutVerticalMargin | ||
115 | Layout.topMargin: elisaTheme.layoutVerticalMargin | | |||
116 | Layout.bottomMargin: elisaTheme.layoutVerticalMargin | | |||
117 | | ||||
118 | spacing: elisaTheme.layoutHorizontalMargin | | |||
119 | | ||||
120 | Image { | | |||
121 | Layout.preferredWidth: fileNameLabel.height | | |||
122 | Layout.preferredHeight: fileNameLabel.height | | |||
123 | | ||||
124 | sourceSize.width: fileNameLabel.height | | |||
125 | sourceSize.height: fileNameLabel.height | | |||
126 | | ||||
127 | source: elisaTheme.folderIcon | | |||
128 | } | | |||
129 | | ||||
130 | LabelWithToolTip { | | |||
131 | id: fileNameLabel | | |||
132 | | ||||
133 | Layout.fillWidth: true | | |||
134 | 102 | | |||
135 | text: realModel.fileUrl | 103 | DialogButtonBox { | ||
104 | Layout.minimumHeight: implicitHeight | ||||
105 | alignment: Qt.AlignLeft | ||||
136 | 106 | | |||
137 | elide: Text.ElideRight | 107 | Button { | ||
108 | id: deleteButton | ||||
109 | text: qsTr("Delete") | ||||
110 | DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole | ||||
111 | onClicked: realModel.deleteRadio() | ||||
138 | } | 112 | } | ||
139 | } | 113 | } | ||
140 | 114 | | |||
141 | DialogButtonBox { | 115 | DialogButtonBox { | ||
142 | id: buttons | 116 | id: buttons | ||
143 | 117 | | |||
144 | Layout.fillWidth: true | 118 | Layout.fillWidth: true | ||
145 | Layout.minimumHeight: implicitHeight | 119 | Layout.minimumHeight: implicitHeight | ||
146 | | ||||
147 | standardButtons: DialogButtonBox.Close | | |||
148 | alignment: Qt.AlignRight | 120 | alignment: Qt.AlignRight | ||
149 | onRejected: trackMetadata.rejected() | 121 | | ||
122 | Button { | ||||
123 | id: applyButton | ||||
124 | | ||||
125 | text: qsTr("Apply") | ||||
126 | DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole | ||||
127 | onClicked: realModel.saveData() | ||||
128 | enabled: false | ||||
129 | } | ||||
130 | Button { | ||||
131 | text: qsTr("Close") | ||||
132 | DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole | ||||
133 | onClicked: trackMetadata.close() | ||||
134 | } | ||||
135 | } | ||||
150 | } | 136 | } | ||
151 | } | 137 | } | ||
152 | 138 | | |||
153 | Connections { | 139 | Connections { | ||
154 | target: elisa | 140 | target: elisa | ||
155 | 141 | | |||
156 | onMusicManagerChanged: { | 142 | onMusicManagerChanged: { | ||
157 | if (databaseId !== 0) { | 143 | if (databaseId == -1) { | ||
144 | realModel.initializeForNewRadio() | ||||
145 | } else if (databaseId !== 0) { | ||||
158 | realModel.initializeByTrackId(databaseId) | 146 | realModel.initializeByTrackId(databaseId) | ||
159 | } else { | 147 | } | ||
148 | else { | ||||
160 | realModel.initializeByTrackFileName(fileName) | 149 | realModel.initializeByTrackFileName(fileName) | ||
161 | } | 150 | } | ||
162 | } | 151 | } | ||
163 | } | 152 | } | ||
164 | 153 | | |||
154 | Connections{ | ||||
155 | target: realModel | ||||
156 | | ||||
157 | onDisableApplyButton: applyButton.enabled = false | ||||
158 | onShowDeleteButton: deleteButton.visible = true | ||||
159 | onHideDeleteButton: deleteButton.visible = false | ||||
160 | onCloseWindow: trackMetadata.rejected() | ||||
161 | } | ||||
162 | | ||||
165 | Component.onCompleted: { | 163 | Component.onCompleted: { | ||
166 | if (elisa.musicManager) { | 164 | if (elisa.musicManager) { | ||
167 | if (databaseId !== 0) { | 165 | if (databaseId == -1) { | ||
166 | realModel.initializeForNewRadio() | ||||
167 | } else if (databaseId !== 0) { | ||||
168 | realModel.initializeByTrackId(databaseId) | 168 | realModel.initializeByTrackId(databaseId) | ||
169 | } else { | 169 | } else { | ||
170 | realModel.initializeByTrackFileName(fileName) | 170 | realModel.initializeByTrackFileName(fileName) | ||
171 | } | 171 | } | ||
172 | } | 172 | } | ||
173 | } | 173 | } | ||
174 | } | 174 | } |