Warning, /maui/mauikit-imagetools/src/controls.5/ImageInfoDialog.qml is written in an unsupported language. File is not indexed.

0001 // Copyright 2018-2020 Camilo Higuita <milo.h@aol.com>
0002 // Copyright 2018-2020 Nitrux Latinoamericana S.C.
0003 //
0004 // SPDX-License-Identifier: GPL-3.0-or-later
0005 
0006 
0007 import QtQuick 2.13
0008 
0009 import QtQuick.Layouts 1.12
0010 import QtQuick.Controls 2.12
0011 
0012 import QtLocation 5.6
0013 import QtPositioning 5.6
0014 
0015 import org.mauikit.controls 1.3 as Maui
0016 import org.mauikit.filebrowsing 1.3 as FB
0017 import org.mauikit.imagetools 1.3 as IT
0018 
0019 Maui.PopupPage
0020 {
0021     id: control
0022 
0023     property alias url : _infoModel.url
0024 
0025     maxHeight: 800
0026     maxWidth: 500
0027     hint: 1
0028 
0029     title: _infoModel.fileName
0030     headBar.visible: true
0031     spacing: Maui.Style.space.huge
0032     
0033     footBar.rightContent: [
0034         ToolButton
0035         {
0036             icon.name: "list-add"
0037             text: "Add Exif tag"
0038             onClicked: _editTagDialog.open()
0039         },
0040         
0041         ToolButton
0042         {
0043             icon.name: "file-open"
0044             text: "Open"
0045         }        
0046     ]
0047 
0048     Rectangle
0049     {
0050         Layout.fillWidth: true
0051         Layout.preferredHeight: 200
0052         color: Qt.darker(Maui.Theme.backgroundColor, 1.1)
0053 
0054         Image
0055         {
0056             id: _img
0057             anchors.fill: parent
0058             source: control.url
0059             fillMode: Image.PreserveAspectCrop
0060 //            sourceSize.width: width
0061 //            sourceSize.height: height
0062 
0063             Rectangle
0064             {
0065                 color: "#333"
0066                 opacity: 0.5
0067                 anchors.fill: parent
0068             }
0069 
0070             Rectangle
0071             {
0072                 anchors.centerIn: parent
0073                 color: "#333"
0074                 radius: Maui.Style.radiusV
0075                 width: 100
0076                 height: 32
0077                 Label
0078                 {
0079                     anchors.centerIn: parent
0080                     text: _img.implicitWidth + " x " + _img.implicitHeight
0081                     color: "white"
0082                 }
0083             }
0084         }
0085     }
0086 
0087     FB.TagsBar
0088     {
0089         Layout.fillWidth: true
0090         visible: count > 0
0091         allowEditMode: false
0092         list.urls: [control.url]
0093         list.strict: false
0094     }
0095     
0096     Maui.InfoDialog
0097     {
0098         id: _editTagDialog
0099         property alias key : _keyField.text
0100         property alias value : _valueField.text
0101         
0102         title: i18n ("Edit")
0103         message: i18nd("mauikitimagetools","Editing Exif tag")
0104                          standardButtons: Dialog.Save | Dialog.Cancel
0105 
0106         TextField
0107         {
0108             id: _keyField
0109             Layout.fillWidth: true
0110             placeholderText: i18nd("mauikitimagetools","Tag key")
0111         }        
0112         
0113         TextField
0114         {
0115             id: _valueField
0116             Layout.fillWidth: true
0117             placeholderText: i18nd("mauikitimagetools","Tag value")
0118         }
0119         
0120         onAccepted:
0121         {
0122             console.log(_editTagDialog.key, _editTagDialog.value)
0123              if(_infoModel.editTag(_editTagDialog.key, _editTagDialog.value))
0124             {
0125                 _editTagDialog.close()
0126             }else
0127             {
0128                 _editTagDialog.alert(i18nd("mauikitimagetools","Could not edit the tag"), 2)
0129             }
0130         }
0131         
0132         onRejected:
0133         {
0134             _editTagDialog.close()
0135         }
0136         
0137         function set(key, value)
0138         {
0139             _editTagDialog.key = key
0140             _editTagDialog.value = value
0141             _editTagDialog.open()
0142         }
0143     }
0144     
0145      Maui.InfoDialog
0146     {
0147         id: _removeTagDialog
0148         property string key
0149         property string value
0150         
0151         title: i18n ("Remove")
0152         message: i18nd("mauikitimagetools","Are you sure you want to remove the Exif tag %1?", _removeTagDialog.value)
0153                   standardButtons: Dialog.Yes | Dialog.Cancel
0154 
0155         onAccepted:
0156         {
0157             if(_infoModel.removeTag(_removeTagDialog.key))
0158             {
0159                 _removeTagDialog.close()
0160             }else
0161             {
0162                 _removeTagDialog.alert(i18nd("mauikitimagetools","Could not remove the tag"), 2)
0163             }
0164         }
0165         
0166         onRejected:
0167         {
0168             _removeTagDialog.close()
0169         }
0170         
0171         function set(key, value)
0172         {
0173             _removeTagDialog.key = key
0174             _removeTagDialog.value = value
0175             _removeTagDialog.open()
0176         }
0177     }
0178     
0179     Maui.SectionGroup
0180     {
0181         Layout.fillWidth: true
0182 
0183         title: i18nd("mauikitimagetools","Details")
0184         description: i18nd("mauikitimagetools","File information")
0185 
0186         Repeater
0187         {
0188             model: Maui.BaseModel
0189             {
0190                 list: IT.PicInfoModel
0191                 {
0192                     id:_infoModel
0193                 }
0194             }
0195 
0196             delegate: Maui.SectionItem
0197             {
0198                 visible: model.value && String(model.value).length > 0
0199                 Layout.fillWidth: true
0200                 label1.text: model.name
0201                 label2.text: model.value
0202                 columns: 3
0203                 
0204                 ToolButton
0205                 {
0206                     visible: model.key
0207                     icon.name: "document-edit"
0208                     onClicked: _editTagDialog.set(model.key, model.value)
0209                 }
0210                 
0211                   ToolButton
0212                 {
0213                     visible: model.key
0214                     icon.name: "edit-delete"
0215                     onClicked: _removeTagDialog.set(model.key, model.value)
0216                 }
0217             }
0218         }
0219     }
0220 
0221     Maui.Separator
0222     {
0223         Layout.fillWidth: true
0224         visible: map.visible
0225     }
0226 
0227     Map
0228     {
0229         id: map
0230         visible: _infoModel.lat !== 0 &&  _infoModel.lon !== 0
0231         color: Maui.Theme.backgroundColor
0232         Layout.fillWidth: true
0233         Layout.preferredHeight: 400
0234         gesture.acceptedGestures: MapGestureArea.NoGesture
0235         gesture.flickDeceleration: 3000
0236         gesture.enabled: true
0237 
0238         plugin: Plugin
0239         {
0240             id: mapPlugin
0241             name: "osm" // "mapboxgl", "esri", ...
0242             // specify plugin parameters if necessary
0243             // PluginParameter {
0244             //     name:
0245             //     value:
0246             // }
0247         }
0248 //        center: QtPositioning.coordinate(_infoModel.lat, _infoModel.lon) // Oslo
0249         zoomLevel: 16
0250         center
0251         {
0252             latitude: _infoModel.lat
0253             longitude:_infoModel.lon
0254         }
0255         
0256         MapCircle
0257         {
0258             center: map.center
0259             radius: 50.0
0260             color: Maui.Theme.highlightColor
0261         }
0262         
0263         Component.onCompleted: 
0264         {            
0265             map.addMapItem(map.circle)
0266         }
0267     }
0268 }