Warning, /maui/booth/src/main.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 import QtQml 2.14
0007 import QtQuick 2.14
0008 import QtQuick.Controls 2.14
0009 import QtQuick.Layouts 1.3
0010 import QtMultimedia 5.14
0011 import Qt.labs.settings 1.0
0012 
0013 import org.mauikit.controls 1.3 as Maui
0014 
0015 import "widgets"
0016 import "views"
0017 
0018 Maui.ApplicationWindow
0019 {
0020     id: root
0021 
0022     Maui.Style.styleType: Maui.Handy.isAndroid ? Maui.Style.Dark  : undefined
0023     Maui.Style.accentColor: "#ffaa00"
0024 
0025     property alias appSettings : settings
0026 
0027     Settings
0028     {
0029         id: settings
0030         category: "Browser"
0031 
0032         property bool darkMode: true
0033         property bool readQR: true
0034     }
0035 
0036     Maui.Page
0037     {
0038         anchors.fill: parent
0039 
0040         floatingHeader: true
0041         autoHideHeader: true
0042 
0043         showCSDControls: true
0044 
0045         footBar.rightContent: Maui.ToolButtonMenu
0046         {
0047             icon.name: "view-refresh"
0048 
0049             Repeater
0050             {
0051                 model: QtMultimedia.availableCameras
0052                 delegate: MenuItem
0053                 {
0054                     autoExclusive: true
0055                     checked: modelData.deviceId === _cameraPage.camera.deviceId
0056                     action: Action
0057                     {
0058                         checkable: true
0059                         text: modelData.displayName
0060                     }
0061 
0062                     onTriggered:
0063                     {
0064                         _cameraPage.camera.deviceId = modelData.deviceId
0065                     }
0066                 }
0067             }
0068         }
0069 
0070         headBar.background: Rectangle
0071         {
0072             color: Maui.Theme.backgroundColor
0073             opacity: 0.5
0074         }
0075 
0076         headBar.rightContent: [
0077 
0078             ToolButton
0079             {
0080                 icon.name: "love" //flash
0081             },
0082 
0083             Maui.ToolButtonMenu
0084             {
0085                 icon.name: "adjustlevels" //focus
0086 
0087                 Menu
0088                 {
0089                     title: i18n("Mode")
0090 
0091                     Repeater
0092                     {
0093                         model:_cameraPage.camera.focus.supportedFocusModes
0094                         delegate: MenuItem
0095                         {
0096                             checkable: true
0097                             autoExclusive: true
0098                             checked: modelData === _cameraPage.camera.focus.focusMode
0099 
0100                             text: switch(modelData)
0101                             {
0102                                 case Camera.FocusManual: return i18n("Manual")
0103                                 case Camera.FocusHyperfocal: return i18n("Hyperfocal")
0104                                 case Camera.FocusInfinity: return i18n("Infinity")
0105                                 case Camera.FocusAuto: return i18n("Auto")
0106                                 case Camera.FocusContinuous: return i18n("Continuous")
0107                                 case Camera.FocusMacro: return i18n("Macro")
0108                             }
0109 
0110                             onTriggered:
0111                             {
0112                                 _cameraPage.camera.focus.focusMode = modelData
0113                                 _cameraPage.camera.searchAndLock()
0114                             }
0115                         }
0116                     }
0117                 }
0118 
0119                 Menu
0120                 {
0121                     title: i18n("Point")
0122 
0123                     Repeater
0124                     {
0125                         model:_cameraPage.camera.focus.supportedFocusPointModes
0126                         delegate: MenuItem
0127                         {
0128                             checkable: true
0129                             autoExclusive: true
0130                             checked: modelData === _cameraPage.camera.focus.focusPointMode
0131                             text: switch(modelData)
0132                             {
0133                                 case Camera.FocusPointAuto: return i18n("Auto")
0134                                 case Camera.FocusPointCenter: return i18n("Center")
0135                                 case Camera.FocusPointFaceDetection: return i18n("Face Detection")
0136                                 case Camera.FocusPointCustom: return i18n("Custom")
0137                             }
0138 
0139                             onTriggered:
0140                             {
0141 
0142                                 _cameraPage.camera.focus.focusPointMode = modelData
0143                                 _cameraPage.camera.searchAndLock()
0144 
0145                             }
0146                         }
0147                     }
0148                 }
0149             },
0150 
0151             ToolButton
0152             {
0153                 id: _timer
0154                 property int secs : 0
0155                 checked: secs > 0
0156                 display: secs === 0 ? ToolButton.IconOnly : ToolButton.TextBesideIcon
0157                 text: secs + "s"
0158                 icon.name: "timer"
0159                 onClicked:
0160                 {
0161                     switch(secs)
0162                     {
0163                     case 0: secs = 5; break;
0164                     case 5: secs = 10; break;
0165                     case 10: secs = 15; break;
0166                     case 15: secs = 0; break;
0167                     }
0168 
0169                 }
0170             },
0171 
0172             Maui.ToolButtonMenu
0173             {
0174                 icon.name: "overflow-menu"
0175 
0176                 MenuItem
0177                 {
0178                     text: i18n("Read QR")
0179                     icon.name: "view-barcode"
0180                     checkable: true
0181                     checked: settings.readQR
0182                     onToggled: settings.readQR = checked
0183                 }
0184 
0185                 Menu
0186                 {
0187                     title: i18n("Resolutions")
0188 
0189                     Repeater
0190                     {
0191                         model: _cameraPage.camera.imageCapture.supportedResolutions
0192                         delegate: MenuItem
0193                         {
0194                             autoExclusive: true
0195                             checkable: true
0196                             checked: modelData === _cameraPage.camera.imageCapture.resolution
0197                             text: modelData.width + "x" + modelData.height
0198                             onTriggered: _cameraPage.camera.imageCapture.resolution = modelData
0199                         }
0200                     }
0201                 }
0202             }
0203         ]
0204 
0205         footBar.leftContent: Maui.ToolButtonMenu
0206         {
0207             icon.name: "camera-photo"
0208             MenuItem
0209             {
0210                 checked: _cameraPage.state === "PhotoCapture"
0211                 autoExclusive: true
0212                 checkable: true
0213 
0214                 text: i18n ("Photo")
0215                 onTriggered: _cameraPage.state = "PhotoCapture"
0216             }
0217 
0218             MenuItem
0219             {
0220                 checked: _cameraPage.state === "VideoCapture"
0221                 checkable: true
0222                 autoExclusive: true
0223                 onTriggered: _cameraPage.state = "VideoCapture"
0224 
0225                 text: i18n ("Video")
0226             }
0227 
0228             MenuItem
0229             {
0230                 checked: _cameraPage.state === "PhotoCapture" && _cameraPage.manualMode
0231                 autoExclusive: true
0232                 checkable: true
0233 
0234                 text: i18n ("Manual")
0235                 onTriggered:
0236                 {
0237                     _cameraPage.state = "PhotoCapture"
0238                     _cameraPage.manualMode = true
0239                 }
0240 
0241             }
0242         }
0243 
0244 
0245         //                Maui.ToolActions
0246         //                {
0247         //                    expanded : isWide
0248         //                    autoExclusive: true
0249         //                    currentIndex: 0
0250         //                    display: ToolButton.TextBesideIcon
0251         //                    cyclic: true
0252 
0253         //                    Action
0254         //                    {
0255         //                        icon.name: "camera-photo"
0256         //                        text: i18n("Photo")
0257         //                        checked: cameraPage.state === "PhotoCapture"
0258         //                        onTriggered: cameraPage.state = "PhotoCapture"
0259         //                    }
0260 
0261         //                    Action
0262         //                    {
0263         //                        icon.name: "camera-video"
0264         //                        text: i18n("Video")
0265         //                        checked: cameraPage.state === "VideoCapture"
0266         //                        onTriggered: cameraPage.state = "VideoCapture"
0267         //                    }
0268 
0269         //                }
0270 
0271         headBar.leftContent: [
0272 
0273             Maui.ToolButtonMenu
0274             {
0275                 icon.name: "application-menu"
0276 
0277                 MenuItem
0278                 {
0279                     text: i18n("Settings")
0280                     icon.name: "settings-configure"
0281                     onTriggered: openConfigDialog()
0282                 }
0283 
0284                 MenuItem
0285                 {
0286                     text: i18n("About")
0287                     icon.name: "documentinfo"
0288                     onTriggered: root.about()
0289                 }
0290             }
0291 
0292         ]
0293 
0294         footBar.middleContent:AbstractButton
0295         {
0296             id: _shutterButton
0297             Layout.alignment: Qt.AlignCenter
0298             implicitHeight: Maui.Style.iconSizes.big
0299             implicitWidth: height
0300 
0301             property color m_color : pressed ? Maui.Theme.highlightColor : Maui.Theme.textColor
0302 
0303             ColorAnimation on m_color
0304             {
0305                 running: _timerShot.running
0306 
0307                 from: Maui.Theme.textColor
0308                 to:  Maui.Theme.highlightColor
0309                 duration: 1000
0310                 loops: Animation.Infinite
0311 
0312                 onFinished:  _shutterButton.m_color = Maui.Theme.textColor
0313             }
0314             background: null
0315 
0316             contentItem: Rectangle
0317             {
0318 
0319                 radius: height
0320                 border.color: _shutterButton.m_color
0321                 border.width: 2
0322                 color: "transparent"
0323 
0324 
0325                 Rectangle
0326                 {
0327                     anchors.fill: parent
0328                     anchors.margins: Maui.Style.space.tiny
0329                     color: _cameraPage.state === "PhotoCapture" ? _shutterButton.m_color : "red"
0330                     radius: parent.radius
0331                 }
0332             }
0333 
0334             onClicked:
0335             {
0336                 if(_timer.checked)
0337                 {
0338                     _timerShot.restart()
0339                     return
0340                 }
0341 
0342                 _cameraPage.capture()
0343             }
0344         }
0345 
0346         footerColumn: [
0347 
0348             Maui.ToolBar
0349             {
0350                 visible: _cameraPage.camera.maximumDigitalZoom > 1 && !Maui.Handy.isTouch
0351                 width: parent.width
0352 
0353                 background: Rectangle
0354                 {
0355                     color: Maui.Theme.backgroundColor
0356                     opacity: 0.5
0357                 }
0358 
0359                 rightContent: Label
0360                 {
0361                     text: "x" + Math.round(_cameraPage.camera.digitalZoom)
0362                 }
0363 
0364                 middleContent: Slider
0365                 {
0366                     id: _zoomSlider
0367                     Layout.fillWidth: true
0368                     Layout.alignment: Qt.AlignCenter
0369                     stepSize: _cameraPage.camera.maximumDigitalZoom/10
0370                     from:0
0371                     to: _cameraPage.camera.maximumDigitalZoom
0372 
0373                     onMoved:
0374                     {
0375                         _cameraPage.camera.setDigitalZoom(value)
0376                     }
0377                 }
0378             },
0379 
0380             Maui.ToolBar
0381             {
0382                 visible: _cameraPage.manualMode
0383                 width: parent.width
0384 
0385                 background: Rectangle
0386                 {
0387                     color: Maui.Theme.backgroundColor
0388                     opacity: 0.5
0389                 }
0390 
0391                 ToolButton
0392                 {
0393                     text: i18n("Aperture")
0394                 }
0395 
0396                 ToolButton
0397                 {
0398                     text: i18n("ISO")
0399                 }
0400 
0401                 ToolButton
0402                 {
0403                     text: i18n("Shutter")
0404                 }
0405 
0406                 ToolButton
0407                 {
0408                     text: i18n("Modes")
0409                 }
0410 
0411                 ToolButton
0412                 {
0413                     text: i18n("Brightness")
0414                 }
0415 
0416                 ToolButton
0417                 {
0418                     text: i18n("White Balance")
0419                 }
0420 
0421 
0422                 ToolButton
0423                 {
0424                     text: i18n("Contrast")
0425                 }
0426 
0427                 ToolButton
0428                 {
0429                     text: i18n("Saturation")
0430                 }
0431 
0432                 ToolButton
0433                 {
0434                     text: i18n("Filters")
0435                 }
0436             }
0437         ]
0438 
0439         CameraPage
0440         {
0441             id: _cameraPage
0442             anchors.fill: parent
0443         }
0444     }
0445 
0446     Timer
0447     {
0448         id: _timerShot
0449         interval: _timer.secs * 1000
0450         repeat: false
0451         onTriggered:
0452         {
0453             _cameraPage.capture()
0454         }
0455     }
0456 
0457 
0458     Component.onCompleted:
0459     {
0460         setAndroidStatusBarColor()
0461     }
0462 
0463     function setAndroidStatusBarColor()
0464     {
0465         if(Maui.Handy.isAndroid)
0466         {
0467             Maui.Android.statusbarColor( Maui.Theme.backgroundColor, false)
0468             Maui.Android.navBarColor( Maui.Theme.backgroundColor, false)
0469         }
0470     }
0471 
0472 
0473 }