StartupWizard.qml 2.64 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
import QtQuick 2.11
import QtQuick.Layouts 1.11

import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl 1.0
import QGroundControl.Specific 1.0


Item {
    id: _root

    implicitWidth: contentColumn.implicitWidth + contentColumn.anchors.margins * 2.5
    implicitHeight: contentColumn.implicitHeight + contentColumn.anchors.margins * 2 + contentColumn.spacing * 3

    property bool forceKeepingOpen: _pageReady && pageLoader.item.forceConfirmation && !_armed

    signal closeView()

    property bool _pageReady: pageLoader.status === Loader.Ready
    property int _currentIndex: 0
    property int _pagesCount: QGroundControl.corePlugin.startupPages.length
    property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
    property bool _armed: _activeVehicle && _activeVehicle.armed

    function doneOrJumpToNext() {
        if(_currentIndex < _pagesCount - 1)
            _currentIndex += 1
        else {
            _root.closeView()
            QGroundControl.settingsManager.appSettings.firstTimeStart.value = false
        }
    }

    Connections {
        target: _pageReady ? pageLoader.item : null
        onCloseView: doneOrJumpToNext()
    }

    ColumnLayout {
        id: contentColumn
        anchors.fill: parent
        anchors.margins: ScreenTools.defaultFontPixelHeight
        spacing: ScreenTools.defaultFontPixelHeight * 0.5

        QGCLabel {
            id: titleLabel
            text: qsTr("Welcome to " + QGroundControl.appName)
            color: qgcPal.text
            font.family: ScreenTools.demiboldFontFamily
            font.pointSize: ScreenTools.mediumFontPointSize
        }

        Rectangle {
            id: separatorRect
            height: 1
            color: qgcPal.windowShade
            Layout.fillWidth: true
        }

        Flickable {
            id: flickablePage
            clip: true

            contentWidth: pageLoader.item ? pageLoader.item.width : 0
            contentHeight: pageLoader.item ? pageLoader.item.height : 0

            Layout.fillHeight: true
            Layout.preferredWidth: contentWidth
            Layout.preferredHeight: contentHeight

            Loader {
                id: pageLoader
                source: QGroundControl.corePlugin.startupPages[_currentIndex]
            }
        }

        QGCButton {
            id: confirmButton
            property string _acknowledgeText: _pagesCount <= 1 ? qsTr("Next") : qsTr("Done")

            text: (_pageReady && pageLoader.item && pageLoader.item.doneText) ? pageLoader.item.doneText : _acknowledgeText
            onClicked: doneOrJumpToNext()
        }
    }
}