2
* \file FrameEditDialog.qml
3
* Dialog to edit frames.
9
* Copyright (C) 2015 Urs Fleisch
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation; version 3.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Lesser General Public License for more details.
20
* You should have received a copy of the GNU Lesser General Public License
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
import "../componentsqtquick" //@!Ubuntu
26
//import Ubuntu.Components 1.1 //@Ubuntu
27
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
28
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
34
property QtObject frameObject
35
signal frameEdited(variant frame)
37
function open(frame) {
38
page.title = frame.internalName
39
fieldList.model = frame.fields
42
if (frame.type === Frame.FT_Picture) {
43
app.setCoverArtImageData(frame.getBinaryData())
50
text: _modelData.value
54
onActiveFocusChanged: {
56
_modelData.value = text
65
text: _modelData.value
66
onActiveFocusChanged: {
68
_modelData.value = text
79
model: if (_modelData.id === Frame.ID_TextEnc)
80
script.getTextEncodingNames()
81
else if (_modelData.id === Frame.ID_PictureType)
82
script.getPictureTypeNames()
83
else if (_modelData.id === Frame.ID_TimestampFormat)
84
script.getTimestampFormatNames()
85
else if (_modelData.id === Frame.ID_ContentType)
86
script.getContentTypeNames()
87
currentIndex: _modelData.value
88
onCurrentIndexChanged: _modelData.value = currentIndex
93
id: exportFileSelectDialog
95
property variant field
100
script.writeFile(path, field.value)
107
id: importFileSelectDialog
109
property variant field
111
title: qsTr("Import")
114
field.value = script.readFile(path)
125
spacing: constants.spacing
132
constants.openPopup(importFileSelectDialog, importButton,
133
{"filePath": app.dirName + "/" +
134
configs.fileConfig().defaultCoverFileName,
135
"field": _modelData})
145
constants.openPopup(exportFileSelectDialog, exportButton,
146
{"filePath": app.dirName + "/" +
147
configs.fileConfig().defaultCoverFileName,
148
"field": _modelData})
158
fillMode: Image.PreserveAspectFit
159
source: app.coverArtImageId
168
height: constants.gu(30)
172
spacing: constants.spacing
180
property QtObject _modelData: modelData
182
if (typeof modelData.value === "number")
183
if (modelData.id === Frame.ID_TextEnc ||
184
modelData.id === Frame.ID_PictureType ||
185
modelData.id === Frame.ID_TimestampFormat ||
186
modelData.id === Frame.ID_ContentType)
190
else if (typeof modelData.value === "string")
191
if (modelData.id === Frame.ID_Text)
195
else if (typeof modelData.value === "object")
196
if (modelData.id === Frame.ID_Data &&
197
modelData.type === Frame.FT_Picture)
201
visible: index != fieldList.count - 1
207
spacing: constants.spacing
209
width: (parent.width - parent.spacing) / 2
213
page.frameEdited(null)
218
width: (parent.width - parent.spacing) / 2
221
fieldList.focus = false // to force editingFinished on delegate
223
page.frameEdited(frameObject)