MauiKit Image Tools

ImageInfoDialog.qml
1// Copyright 2018-2020 Camilo Higuita <milo.h@aol.com>
2// Copyright 2018-2020 Nitrux Latinoamericana S.C.
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6
7import QtQuick
8
9import QtQuick.Layouts
10import QtQuick.Controls
11
12import QtLocation
13import QtPositioning
14
15import org.mauikit.controls as Maui
16import org.mauikit.filebrowsing as FB
17import org.mauikit.imagetools as IT
18
19/**
20 * @inherit org::mauikit::controls::PopupPage
21 * @brief A popup view presenting with metadata information about a given image file.
22 *
23 * @image html imageinfodialog.png "Image information dialog"
24 *
25 * @code
26 * IT.ImageInfoDialog
27 * {
28 * id: _dialog
29 * url: "file:///home/camiloh/maui-demo-files/Pictures/4416d027-9fa4-4762-8eb6-31de331623a1.jpg"
30 * }
31 * @endcode
32 */
33Maui.PopupPage
34{
35 id: control
36
37 /**
38 * @brief
39 */
40 property alias url : _infoModel.url
41
42 maxHeight: 800
43 maxWidth: 500
44 hint: 1
45
46 title: _infoModel.fileName
47 headBar.visible: true
48 spacing: Maui.Style.space.huge
49
50 signal gpsEdited(var url)
51
52 Rectangle
53 {
54 Layout.fillWidth: true
55 Layout.preferredHeight: 200
56 color: Qt.darker(Maui.Theme.backgroundColor, 1.1)
57
58 Image
59 {
60 id: _img
61 anchors.fill: parent
62 source: control.url
63 fillMode: Image.PreserveAspectCrop
64 sourceSize.width: width
65 sourceSize.height: height
66
67 Rectangle
68 {
69 color: "#333"
70 opacity: 0.5
71 anchors.fill: parent
72 }
73
74 Label
75 {
76 anchors.centerIn: parent
77 text: _infoModel.pixelSize.width + " x " + _infoModel.pixelSize.height
78 color: "white"
79 padding: Maui.Style.defaultPadding
80 background: Rectangle
81 {
82 color: "#333"
83 radius: Maui.Style.radiusV
84 }
85 }
86
87 }
88 }
89
90 FB.TagsBar
91 {
92 Layout.fillWidth: true
93 visible: count > 0
94 allowEditMode: false
95 list.urls: [control.url]
96 list.strict: false
97 }
98
99 Maui.InfoDialog
100 {
101 id: _editTagDialog
102 property alias key : _keyField.text
103 property alias value : _valueField.text
104
105 title: i18n ("Edit")
106 message: i18nd("mauikitimagetools","Editing Exif tag")
107
108 standardButtons: Dialog.Save | Dialog.Cancel
109
111 {
112 id: _keyField
113 Layout.fillWidth: true
114 placeholderText: i18nd("mauikitimagetools","Tag key")
115 }
116
118 {
119 id: _valueField
120 Layout.fillWidth: true
121 placeholderText: i18nd("mauikitimagetools","Tag value")
122 }
123
124 onAccepted:
125 {
126 console.log(_editTagDialog.key, _editTagDialog.value)
127 if(_infoModel.editTag(_editTagDialog.key, _editTagDialog.value))
128 {
129 _editTagDialog.close()
130 }else
131 {
132 _editTagDialog.alert(i18nd("mauikitimagetools","Could not edit the tag"), 2)
133 }
134 }
135
136 onRejected:
137 {
138 _editTagDialog.close()
139 }
140
141 function set(key, value)
142 {
143 _editTagDialog.key = key
144 _editTagDialog.value = value
145 _editTagDialog.open()
146 }
147 }
148
149 Maui.InfoDialog
150 {
151 id: _removeTagDialog
152 property string key
153 property string value
154
155 title: i18n ("Remove")
156 message: i18nd("mauikitimagetools","Are you sure you want to remove the Exif tag %1?", _removeTagDialog.value)
157
158 standardButtons: Dialog.Yes | Dialog.Cancel
159
160 onAccepted:
161 {
162 if(_infoModel.removeTag(_removeTagDialog.key))
163 {
164 _removeTagDialog.close()
165 }else
166 {
167 _removeTagDialog.alert(i18nd("mauikitimagetools","Could not remove the tag"), 2)
168 }
169 }
170
171 onRejected:
172 {
173 _removeTagDialog.close()
174 }
175
176 function set(key, value)
177 {
178 _removeTagDialog.key = key
179 _removeTagDialog.value = value
180 _removeTagDialog.open()
181 }
182 }
183
184 Maui.InfoDialog
185 {
186 id: _commentDialog
187
188 title: i18n ("Comment")
189
190 TextArea
191 {
192 id: _commentArea
193 Layout.fillWidth: true
194 Layout.preferredHeight: 200
195
196 text: _infoModel.exifComment
197 }
198
199 standardButtons: Dialog.Save | Dialog.Cancel
200 onAccepted:
201 {
202 _infoModel.setComment(_commentArea.text)
203 _commentDialog.close()
204 }
205
206 onRejected: _commentDialog.close()
207 }
208
209 Maui.InfoDialog
210 {
211 id: _gpsTagDialog
212
213 title: i18n ("GPS")
214
215 standardButtons: Dialog.Save | Dialog.Cancel
216
218 {
219 id: _lat
220 text: _infoModel.lat
221 Maui.Controls.title: placeholderText
222 placeholderText: i18n("Latitude")
223 validator: DoubleValidator
224 {
225 notation: DoubleValidator.StandardNotation
226 }
227 Layout.fillWidth: true
228 }
229
230 Maui.TextField
231 {
232 id: _lon
233 placeholderText: i18n("Longitude")
234 Maui.Controls.title: placeholderText
235
236 text: _infoModel.lon
237 validator: DoubleValidator
238 {
239 notation: DoubleValidator.StandardNotation
240 }
241 Layout.fillWidth: true
242 }
243
244 // Maui.TextField
245 // {
246 // id: _alt
247 // placeholderText: i18n("Altitude")
248 // Maui.Controls.title: placeholderText
249
250 // text: _infoModel.alt
251 // validator: DoubleValidator
252 // {
253 // notation: DoubleValidator.StandardNotation
254 // }
255
256 // // onAcceptableInputChanged: color = acceptableInput ? "black" : "red";
257
258 // Layout.fillWidth: true
259 // }
260
261 onAccepted:
262 {
263 if(_infoModel.setGpsData(_lat.text, _lon.text))
264 {
265 control.gpsEdited(control.url)
266 _editTagDialog.close()
267 }else
268 {
269 _editTagDialog.alert(i18nd("mauikitimagetools","Could not save the GPS data"), 2)
270 }
271 }
272
273 onRejected:
274 {
275 _gpsTagDialog.close()
276 }
277 }
278
279 Maui.SectionGroup
280 {
281 Layout.fillWidth: true
282
283 title: i18nd("mauikitimagetools","Details")
284 description: i18nd("mauikitimagetools","File information")
285
286 Repeater
287 {
288 model: Maui.BaseModel
289 {
290 list: IT.PicInfoModel
291 {
292 id:_infoModel
293 }
294 }
295
296 delegate: Maui.FlexSectionItem
297 {
298 visible: model.value && String(model.value).length > 0
299 label1.text: model.name
300 label2.text: model.value
301
302 ToolButton
303 {
304 visible: model.key
305 icon.name: "document-edit"
306 onClicked: _editTagDialog.set(model.key, model.value)
307 }
308
309 ToolButton
310 {
311 visible: model.key
312 icon.name: "edit-delete"
313 onClicked: _removeTagDialog.set(model.key, model.value)
314 }
315 }
316 }
317
318 Button
319 {
320 Layout.fillWidth: true
321
322 // icon.name: "list-add"
323 text: "Add Exif tag"
324 onClicked: _editTagDialog.open()
325 }
326 }
327
328 Maui.SectionGroup
329 {
330 Layout.fillWidth: true
331
332 title: i18nd("mauikitimagetools","Comment & Description")
333
334 TextArea
335 {
336 text: _infoModel.exifComment
337 visible: text.length > 0
338 Layout.fillWidth: true
339 Layout.preferredHeight: 100
340 readOnly: true
341 }
342
343 RowLayout
344 {
345 spacing: Maui.Style.defaultSpacing
346 Layout.fillWidth: true
347
348 Button
349 {
350 text: i18n("Add Comment")
351 Layout.fillWidth: true
352 onClicked: _commentDialog.open()
353 }
354
355 Button
356 {
357 text: i18n("Remove Comment")
358 Layout.fillWidth: true
359 visible: _infoModel.exifComment.length>0
360 onClicked: _infoModel.removeComment()
361 Maui.Controls.status: Maui.Controls.Negative
362 }
363 }
364 }
365
367 {
368 Layout.fillWidth: true
369
370 title: i18nd("mauikitimagetools","GPS")
371 description: i18nd("mauikitimagetools","Geolocation tags")
372
374 {
375 visible: _mapLoader.visible
376 label1.text: i18n("City")
377 label2.text: _infoModel.cityName
378 }
379
380 RowLayout
381 {
382 spacing: Maui.Style.defaultSpacing
383 Layout.fillWidth: true
384
385 Button
386 {
387 Layout.fillWidth: true
388 text: i18n("Set GPS info")
389 onClicked: _gpsTagDialog.open()
390 }
391
392 Loader
393 {
394 asynchronous: true
395 active: _mapLoader.active
396 visible: active
397 Layout.fillWidth: true
398
399 sourceComponent: Button
400 {
401 text: i18n("Remove GPS info")
402 Maui.Controls.status: Maui.Controls.Negative
403 onClicked: _infoModel.removeGpsData()
404 }
405 }
406 }
407
408 Loader
409 {
410 id: _mapLoader
411 asynchronous: true
412 active: visible
413 visible: _infoModel.lat !== 0 && _infoModel.lon !== 0
414 Layout.fillWidth: true
415 Layout.preferredHeight: 400
416
417 sourceComponent: Map
418 {
419 id: map
420 color: Maui.Theme.backgroundColor
421
422 // gesture.acceptedGestures: MapGestureArea.NoGesture
423 // gesture.flickDeceleration: 3000
424 // gesture.enabled: true
425
426 plugin: Plugin
427 {
428 id: mapPlugin
429 name: "osm" // "mapboxgl", "esri", ...
430 // specify plugin parameters if necessary
431 // PluginParameter {
432 // name:
433 // value:
434 // }
435 }
436 // center: QtPositioning.coordinate(_infoModel.lat, _infoModel.lon) // Oslo
437 zoomLevel: 16
438 center
439 {
440 latitude: _infoModel.lat
441 longitude:_infoModel.lon
442 }
443
444 MapCircle
445 {
446 center: map.center
447 radius: 50.0
448 color: Maui.Theme.highlightColor
449 }
450
451 Component.onCompleted:
452 {
453 map.addMapItem(map.circle)
454 }
455 }
456 }
457 }
458}
Q_SCRIPTABLE CaptureState status()
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QString name(StandardAction id)
QTextStream & center(QTextStream &stream)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:56:08 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.