PageView.qml 3.03 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Layouts          1.2

import QGroundControl               1.0
import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0

Rectangle {
    id:     _root
    height: pageFlickable.y + pageFlickable.height + _margins
    color:  qgcPal.window
Gus Grubba's avatar
Gus Grubba committed
13
    radius: ScreenTools.defaultFontPixelWidth * 0.5
14 15 16 17 18 19

    property real   maxHeight       ///< Maximum height that should be taken, smaller than this is ok

    property real   _margins:           ScreenTools.defaultFontPixelWidth / 2
    property real   _pageWidth:         _root.width
    property var    _instrumentPages:   QGroundControl.corePlugin.instrumentPages
20
    property bool   _settingsUnlocked:  false
21 22 23 24 25 26 27 28 29 30

    QGCPalette { id:qgcPal; colorGroupEnabled: parent.enabled }

    QGCComboBox {
        id:             pageCombo
        anchors.left:   parent.left
        anchors.right:  parent.right
        model:          _instrumentPages
        textRole:       "title"
        centeredLabel:  true
31
        font.pointSize: ScreenTools.smallFontPointSize
32

33 34
        onCurrentIndexChanged: _settingsUnlocked = false

DonLakeFlyer's avatar
DonLakeFlyer committed
35
        QGCColoredImage {
36 37 38
            anchors.leftMargin:     _margins
            anchors.left:           parent.left
            anchors.verticalCenter: parent.verticalCenter
39
            source:                 pageWidgetLoader.item.showLockIcon ? (_settingsUnlocked ? "/res/LockOpen.svg" : "/res/LockClosed.svg") : "/res/gear-black.svg"
40
            mipmap:                 true
DonLakeFlyer's avatar
DonLakeFlyer committed
41 42 43 44
            height:                 parent.height * 0.7
            width:                  height
            sourceSize.height:      height
            color:                  qgcPal.text
45
            fillMode:               Image.PreserveAspectFit
Gus Grubba's avatar
Gus Grubba committed
46
            visible:                pageWidgetLoader.item ? (pageWidgetLoader.item.showSettingsIcon ? pageWidgetLoader.item.showSettingsIcon : false) : false
47 48 49

            QGCMouseArea {
                fillItem:   parent
50 51 52 53 54 55 56 57
                onClicked: {
                    if (pageWidgetLoader.item.showLockIcon) {
                        _settingsUnlocked = !_settingsUnlocked
                        pageWidgetLoader.item.showSettings(_settingsUnlocked)
                    } else {
                        pageWidgetLoader.item.showSettings()
                    }
                }
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
            }
        }
    }

    QGCFlickable {
        id:                 pageFlickable
        anchors.margins:    _margins
        anchors.top:        pageCombo.bottom
        anchors.left:       parent.left
        anchors.right:      parent.right
        height:             Math.min(_maxHeight, pageWidgetLoader.height)
        contentHeight:      pageWidgetLoader.height
        flickableDirection: Flickable.VerticalFlick
        clip:               true

        property real _maxHeight: maxHeight - y - _margins

        Loader {
            id:     pageWidgetLoader
            source: _instrumentPages[pageCombo.currentIndex].url
78
            property real pageWidth:  parent.width
79 80 81
        }
    }
}