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 1.3 as Maui
16import org.mauikit.filebrowsing 1.3 as FB
17import org.mauikit.imagetools 1.3 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 footBar.rightContent: [
51 ToolButton
52 {
53 icon.name: "list-add"
54 text: "Add Exif tag"
55 onClicked: _editTagDialog.open()
56 },
57
58 ToolButton
59 {
60 icon.name: "file-open"
61 text: "Open"
62 }
63 ]
64
65 Rectangle
66 {
67 Layout.fillWidth: true
68 Layout.preferredHeight: 200
69 color: Qt.darker(Maui.Theme.backgroundColor, 1.1)
70
71 Image
72 {
73 id: _img
74 anchors.fill: parent
75 source: control.url
76 fillMode: Image.PreserveAspectCrop
77// sourceSize.width: width
78// sourceSize.height: height
79
80 Rectangle
81 {
82 color: "#333"
83 opacity: 0.5
84 anchors.fill: parent
85 }
86
87 Rectangle
88 {
89 anchors.centerIn: parent
90 color: "#333"
91 radius: Maui.Style.radiusV
92 width: 100
93 height: 32
94 Label
95 {
96 anchors.centerIn: parent
97 text: _img.implicitWidth + " x " + _img.implicitHeight
98 color: "white"
99 }
100 }
101 }
102 }
103
104 FB.TagsBar
105 {
106 Layout.fillWidth: true
107 visible: count > 0
108 allowEditMode: false
109 list.urls: [control.url]
110 list.strict: false
111 }
112
113 Maui.InfoDialog
114 {
115 id: _editTagDialog
116 property alias key : _keyField.text
117 property alias value : _valueField.text
118
119 title: i18n ("Edit")
120 message: i18nd("mauikitimagetools","Editing Exif tag")
121
122 standardButtons: Dialog.Save | Dialog.Cancel
123
124 TextField
125 {
126 id: _keyField
127 Layout.fillWidth: true
128 placeholderText: i18nd("mauikitimagetools","Tag key")
129 }
130
131 TextField
132 {
133 id: _valueField
134 Layout.fillWidth: true
135 placeholderText: i18nd("mauikitimagetools","Tag value")
136 }
137
138 onAccepted:
139 {
140 console.log(_editTagDialog.key, _editTagDialog.value)
141 if(_infoModel.editTag(_editTagDialog.key, _editTagDialog.value))
142 {
143 _editTagDialog.close()
144 }else
145 {
146 _editTagDialog.alert(i18nd("mauikitimagetools","Could not edit the tag"), 2)
147 }
148 }
149
150 onRejected:
151 {
152 _editTagDialog.close()
153 }
154
155 function set(key, value)
156 {
157 _editTagDialog.key = key
158 _editTagDialog.value = value
159 _editTagDialog.open()
160 }
161 }
162
163 Maui.InfoDialog
164 {
165 id: _removeTagDialog
166 property string key
167 property string value
168
169 title: i18n ("Remove")
170 message: i18nd("mauikitimagetools","Are you sure you want to remove the Exif tag %1?", _removeTagDialog.value)
171
172 standardButtons: Dialog.Yes | Dialog.Cancel
173
174 onAccepted:
175 {
176 if(_infoModel.removeTag(_removeTagDialog.key))
177 {
178 _removeTagDialog.close()
179 }else
180 {
181 _removeTagDialog.alert(i18nd("mauikitimagetools","Could not remove the tag"), 2)
182 }
183 }
184
185 onRejected:
186 {
187 _removeTagDialog.close()
188 }
189
190 function set(key, value)
191 {
192 _removeTagDialog.key = key
193 _removeTagDialog.value = value
194 _removeTagDialog.open()
195 }
196 }
197
198 Maui.SectionGroup
199 {
200 Layout.fillWidth: true
201
202 title: i18nd("mauikitimagetools","Details")
203 description: i18nd("mauikitimagetools","File information")
204
205 Repeater
206 {
207 model: Maui.BaseModel
208 {
209 list: IT.PicInfoModel
210 {
211 id:_infoModel
212 }
213 }
214
215 delegate: Maui.FlexSectionItem
216 {
217 visible: model.value && String(model.value).length > 0
218 label1.text: model.name
219 label2.text: model.value
220
221 ToolButton
222 {
223 visible: model.key
224 icon.name: "document-edit"
225 onClicked: _editTagDialog.set(model.key, model.value)
226 }
227
228 ToolButton
229 {
230 visible: model.key
231 icon.name: "edit-delete"
232 onClicked: _removeTagDialog.set(model.key, model.value)
233 }
234 }
235 }
236 }
237
238 Maui.Separator
239 {
240 Layout.fillWidth: true
241 visible: map.visible
242 }
243
244 Map
245 {
246 id: map
247 visible: _infoModel.lat !== 0 && _infoModel.lon !== 0
248 color: Maui.Theme.backgroundColor
249 Layout.fillWidth: true
250 Layout.preferredHeight: 400
251 // gesture.acceptedGestures: MapGestureArea.NoGesture
252 // gesture.flickDeceleration: 3000
253 // gesture.enabled: true
254
255 plugin: Plugin
256 {
257 id: mapPlugin
258 name: "osm" // "mapboxgl", "esri", ...
259 // specify plugin parameters if necessary
260 // PluginParameter {
261 // name:
262 // value:
263 // }
264 }
265// center: QtPositioning.coordinate(_infoModel.lat, _infoModel.lon) // Oslo
266 zoomLevel: 16
267 center
268 {
269 latitude: _infoModel.lat
270 longitude:_infoModel.lon
271 }
272
273 MapCircle
274 {
275 center: map.center
276 radius: 50.0
277 color: Maui.Theme.highlightColor
278 }
279
280 Component.onCompleted:
281 {
282 map.addMapItem(map.circle)
283 }
284 }
285}
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString name(GameStandardAction id)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QTextStream & center(QTextStream &stream)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:32:36 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.