Changeset View
Changeset View
Standalone View
Standalone View
src/qml/MediaTrackMetadataView.qml
Show All 21 Lines | |||||
22 | import QtQml.Models 2.2 | 22 | import QtQml.Models 2.2 | ||
23 | import QtQuick.Layouts 1.2 | 23 | import QtQuick.Layouts 1.2 | ||
24 | import QtGraphicalEffects 1.0 | 24 | import QtGraphicalEffects 1.0 | ||
25 | import org.kde.elisa 1.0 | 25 | import org.kde.elisa 1.0 | ||
26 | 26 | | |||
27 | Window { | 27 | Window { | ||
28 | id: trackMetadata | 28 | id: trackMetadata | ||
29 | 29 | | |||
30 | property int databaseId: 0 | 30 | property int initialDatabaseId: 0 | ||
31 | property var modelType | ||||
31 | property string fileName | 32 | property string fileName | ||
32 | property alias isRadio: realModel.isRadio | 33 | property bool editableMetadata | ||
34 | property alias showImage: metadataImage.visible | ||||
35 | property alias showTrackFileName: fileNameRow.visible | ||||
36 | property alias showDeleteButton: deleteButtonBox.visible | ||||
37 | property alias showApplyButton: applyButton.visible | ||||
jguidon: Is this variable used ? | |||||
33 | 38 | | |||
34 | signal rejected() | 39 | signal rejected() | ||
35 | 40 | | |||
36 | LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft | 41 | LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft | ||
37 | LayoutMirroring.childrenInherit: true | 42 | LayoutMirroring.childrenInherit: true | ||
38 | 43 | | |||
39 | title: { | 44 | title: (initialDatabaseId === -1) ? i18nc("Window title for track metadata", "Create a Radio") : i18nc("Window title for track metadata", "View Details") | ||
40 | if (trackMetadata.isRadio && databaseId === -1) { | | |||
41 | return i18nc("Window title for track metadata", "Create a Radio") | | |||
42 | } | | |||
43 | | ||||
44 | return i18nc("Window title for track metadata", "View Details") | | |||
45 | } | | |||
46 | 45 | | |||
47 | TrackMetadataModel { | 46 | TrackMetadataModel { | ||
48 | id: realModel | 47 | id: realModel | ||
49 | 48 | | |||
50 | manager: elisa.musicManager | 49 | manager: elisa.musicManager | ||
51 | } | 50 | } | ||
52 | 51 | | |||
53 | modality: Qt.NonModal | 52 | modality: Qt.NonModal | ||
Show All 14 Lines | 66 | RowLayout { | |||
68 | id: metadataView | 67 | id: metadataView | ||
69 | 68 | | |||
70 | Layout.fillHeight: true | 69 | Layout.fillHeight: true | ||
71 | Layout.fillWidth: true | 70 | Layout.fillWidth: true | ||
72 | 71 | | |||
73 | spacing: 0 | 72 | spacing: 0 | ||
74 | 73 | | |||
75 | Image { | 74 | Image { | ||
75 | id: metadataImage | ||||
76 | | ||||
76 | source: realModel.coverUrl | 77 | source: realModel.coverUrl | ||
77 | 78 | | |||
78 | sourceSize.width: elisaTheme.coverImageSize | 79 | sourceSize.width: elisaTheme.coverImageSize | ||
79 | sourceSize.height: elisaTheme.coverImageSize | 80 | sourceSize.height: elisaTheme.coverImageSize | ||
80 | 81 | | |||
81 | fillMode: Image.PreserveAspectFit | 82 | fillMode: Image.PreserveAspectFit | ||
82 | 83 | | |||
83 | Layout.alignment: Qt.AlignTop | Qt.AlignHCenter | 84 | Layout.alignment: Qt.AlignTop | Qt.AlignHCenter | ||
84 | Layout.preferredHeight: elisaTheme.coverImageSize | 85 | Layout.preferredHeight: elisaTheme.coverImageSize | ||
85 | Layout.preferredWidth: elisaTheme.coverImageSize | 86 | Layout.preferredWidth: elisaTheme.coverImageSize | ||
86 | Layout.minimumHeight: elisaTheme.coverImageSize | 87 | Layout.minimumHeight: elisaTheme.coverImageSize | ||
87 | Layout.minimumWidth: elisaTheme.coverImageSize | 88 | Layout.minimumWidth: elisaTheme.coverImageSize | ||
88 | Layout.maximumHeight: elisaTheme.coverImageSize | 89 | Layout.maximumHeight: elisaTheme.coverImageSize | ||
89 | Layout.maximumWidth: elisaTheme.coverImageSize | 90 | Layout.maximumWidth: elisaTheme.coverImageSize | ||
90 | | ||||
91 | visible: !trackMetadata.isRadio | | |||
92 | } | 91 | } | ||
93 | 92 | | |||
94 | ListView { | 93 | ListView { | ||
95 | id: trackData | 94 | id: trackData | ||
96 | 95 | | |||
97 | Layout.fillWidth: true | 96 | Layout.fillWidth: true | ||
98 | Layout.fillHeight: true | 97 | Layout.fillHeight: true | ||
99 | Layout.leftMargin: 2 * elisaTheme.layoutHorizontalMargin | 98 | Layout.leftMargin: 2 * elisaTheme.layoutHorizontalMargin | ||
Show All 25 Lines | 123 | Component { | |||
125 | id: editableMetaDataDelegate | 124 | id: editableMetaDataDelegate | ||
126 | 125 | | |||
127 | EditableMetaDataDelegate { | 126 | EditableMetaDataDelegate { | ||
128 | width: scrollBar.visible ? (!LayoutMirroring.enabled ? trackData.width - scrollBar.width : trackData.width) : trackData.width | 127 | width: scrollBar.visible ? (!LayoutMirroring.enabled ? trackData.width - scrollBar.width : trackData.width) : trackData.width | ||
129 | onRadioEdited: applyButton.enabled = true | 128 | onRadioEdited: applyButton.enabled = true | ||
130 | } | 129 | } | ||
131 | } | 130 | } | ||
132 | 131 | | |||
133 | delegate: trackMetadata.isRadio ? editableMetaDataDelegate: metaDataDelegate | 132 | delegate: editableMetadata ? editableMetaDataDelegate: metaDataDelegate | ||
134 | } | 133 | } | ||
135 | } | 134 | } | ||
136 | 135 | | |||
137 | RowLayout { | 136 | RowLayout { | ||
137 | id: fileNameRow | ||||
138 | | ||||
138 | Layout.alignment: Qt.AlignLeft | Qt.AlignBottom | 139 | Layout.alignment: Qt.AlignLeft | Qt.AlignBottom | ||
139 | Layout.topMargin: elisaTheme.layoutVerticalMargin | 140 | Layout.topMargin: elisaTheme.layoutVerticalMargin | ||
140 | Layout.bottomMargin: elisaTheme.layoutVerticalMargin | 141 | Layout.bottomMargin: elisaTheme.layoutVerticalMargin | ||
141 | 142 | | |||
142 | spacing: elisaTheme.layoutHorizontalMargin | 143 | spacing: elisaTheme.layoutHorizontalMargin | ||
143 | 144 | | |||
144 | Image { | 145 | Image { | ||
145 | Layout.preferredWidth: fileNameLabel.height | 146 | Layout.preferredWidth: fileNameLabel.height | ||
Show All 9 Lines | 155 | LabelWithToolTip { | |||
155 | id: fileNameLabel | 156 | id: fileNameLabel | ||
156 | 157 | | |||
157 | Layout.fillWidth: true | 158 | Layout.fillWidth: true | ||
158 | 159 | | |||
159 | text: realModel.fileUrl | 160 | text: realModel.fileUrl | ||
160 | 161 | | |||
161 | elide: Text.ElideRight | 162 | elide: Text.ElideRight | ||
162 | } | 163 | } | ||
163 | | ||||
164 | visible: !trackMetadata.isRadio | | |||
165 | } | 164 | } | ||
166 | 165 | | |||
167 | RowLayout{ | 166 | RowLayout { | ||
168 | spacing: elisaTheme.layoutVerticalMargin | 167 | spacing: elisaTheme.layoutVerticalMargin | ||
169 | 168 | | |||
170 | DialogButtonBox { | 169 | DialogButtonBox { | ||
170 | id: deleteButtonBox | ||||
171 | | ||||
171 | Layout.minimumHeight: implicitHeight | 172 | Layout.minimumHeight: implicitHeight | ||
172 | alignment: Qt.AlignLeft | 173 | alignment: Qt.AlignLeft | ||
173 | 174 | | |||
174 | Button { | 175 | Button { | ||
175 | id: deleteButton | 176 | id: deleteButton | ||
176 | text: qsTr("Delete") | 177 | text: qsTr("Delete") | ||
177 | DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole | 178 | DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole | ||
178 | onClicked: realModel.deleteRadio() | 179 | onClicked: | ||
180 | { | ||||
181 | elisa.musicManager.deleteElementById(modelType, realModel.databaseId) | ||||
182 | trackMetadata.close() | ||||
183 | } | ||||
179 | } | 184 | } | ||
180 | } | 185 | } | ||
181 | 186 | | |||
182 | DialogButtonBox { | 187 | DialogButtonBox { | ||
183 | id: buttons | 188 | id: buttons | ||
184 | 189 | | |||
185 | Layout.fillWidth: true | 190 | Layout.fillWidth: true | ||
186 | Layout.minimumHeight: implicitHeight | 191 | Layout.minimumHeight: implicitHeight | ||
187 | alignment: Qt.AlignRight | 192 | alignment: Qt.AlignRight | ||
188 | 193 | | |||
189 | Button { | 194 | Button { | ||
190 | id: applyButton | 195 | id: applyButton | ||
191 | 196 | | |||
192 | text: qsTr("Apply") | 197 | text: qsTr("Apply") | ||
193 | DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole | 198 | DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole | ||
194 | onClicked: realModel.saveData() | 199 | onClicked: | ||
200 | { | ||||
201 | realModel.saveData() | ||||
202 | enabled = false | ||||
I guess we do not care if the data has been successfully saved in the database ? (maybe I think too much like a web application :) ) jguidon: I guess we do not care if the data has been successfully saved in the database ? (maybe I think… | |||||
I do not think that update of a radio can reasonably fail no matter which data is set. One nice addition could be a check for field length if it makes sense. At least for me, this is a subject for a latter patch. mgallien: I do not think that update of a radio can reasonably fail no matter which data is set.
One… | |||||
203 | if (!deleteButtonBox.visible && editableMetadata) { | ||||
204 | deleteButtonBox.visible = true | ||||
205 | } | ||||
206 | } | ||||
195 | enabled: false | 207 | enabled: false | ||
196 | } | 208 | } | ||
197 | Button { | 209 | Button { | ||
198 | text: qsTr("Close") | 210 | text: qsTr("Close") | ||
199 | DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole | 211 | DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole | ||
200 | onClicked: trackMetadata.close() | 212 | onClicked: trackMetadata.close() | ||
201 | } | 213 | } | ||
202 | } | 214 | } | ||
203 | | ||||
204 | visible: trackMetadata.isRadio | | |||
205 | } | | |||
206 | | ||||
207 | DialogButtonBox { | | |||
208 | id: buttonsTrack | | |||
209 | | ||||
210 | Layout.fillWidth: true | | |||
211 | Layout.minimumHeight: implicitHeight | | |||
212 | | ||||
213 | standardButtons: DialogButtonBox.Close | | |||
214 | alignment: Qt.AlignRight | | |||
215 | onRejected: trackMetadata.close() | | |||
216 | | ||||
217 | visible: !trackMetadata.isRadio | | |||
218 | } | 215 | } | ||
219 | } | 216 | } | ||
220 | 217 | | |||
221 | Connections { | 218 | Connections { | ||
222 | target: elisa | 219 | target: elisa | ||
223 | 220 | | |||
224 | onMusicManagerChanged: { | 221 | onMusicManagerChanged: { | ||
225 | if (databaseId === -1) { | 222 | if (initialDatabaseId === -1) { | ||
226 | realModel.initializeForNewRadio() | 223 | realModel.initializeForNewRadio() | ||
227 | } else if (databaseId !== 0) { | 224 | } else if (initialDatabaseId !== 0) { | ||
228 | realModel.initializeByTrackId(databaseId) | 225 | realModel.initializeById(modelType, initialDatabaseId) | ||
229 | } else { | 226 | } else { | ||
230 | realModel.initializeByTrackFileName(fileName) | 227 | realModel.initializeByTrackFileName(fileName) | ||
231 | } | 228 | } | ||
232 | } | 229 | } | ||
233 | } | 230 | } | ||
234 | 231 | | |||
235 | Connections{ | | |||
236 | target: realModel | | |||
237 | | ||||
238 | onDisableApplyButton: applyButton.enabled = false | | |||
239 | onShowDeleteButton: deleteButton.visible = true | | |||
240 | onHideDeleteButton: deleteButton.visible = false | | |||
241 | onCloseWindow: trackMetadata.close() | | |||
242 | } | | |||
243 | | ||||
244 | Component.onCompleted: { | 232 | Component.onCompleted: { | ||
245 | if (elisa.musicManager) { | 233 | if (elisa.musicManager) { | ||
246 | if (databaseId === -1) { | 234 | if (initialDatabaseId === -1) { | ||
247 | realModel.initializeForNewRadio() | 235 | realModel.initializeForNewRadio() | ||
248 | } else if (databaseId !== 0) { | 236 | } else if (initialDatabaseId !== 0) { | ||
249 | realModel.initializeByTrackId(databaseId) | 237 | realModel.initializeById(modelType, initialDatabaseId) | ||
250 | } else { | 238 | } else { | ||
251 | realModel.initializeByTrackFileName(fileName) | 239 | realModel.initializeByTrackFileName(fileName) | ||
252 | } | 240 | } | ||
253 | } | 241 | } | ||
254 | } | 242 | } | ||
255 | } | 243 | } |
Is this variable used ?