Skip to content
JoystickConfig.qml 3.02 KiB
Newer Older
/****************************************************************************
 *
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
import QtQuick                      2.11
import QtQuick.Controls             2.4
import QtQuick.Dialogs              1.3
import QtQuick.Layouts              1.11
import QGroundControl               1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controllers   1.0
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0

/// Joystick Config
Don Gagne's avatar
Don Gagne committed
SetupPage {
    id:                 joystickPage
    pageComponent:      pageComponent
    pageName:           qsTr("Joystick")
    pageDescription:    "" // qsTr("Joystick Setup is used to configure and calibrate joysticks.")
Don Gagne's avatar
Don Gagne committed

    readonly property real  _maxButtons:         64
    readonly property real  _attitudeLabelWidth: ScreenTools.defaultFontPixelWidth * 12
Jacob Walser's avatar
Jacob Walser committed
    Connections {
        target: joystickManager
        onAvailableJoysticksChanged: {
            if(joystickManager.joysticks.length === 0) {
Jacob Walser's avatar
Jacob Walser committed
                summaryButton.checked = true
                setupView.showSummaryPanel()
            }
        }
    }

Don Gagne's avatar
Don Gagne committed
    Component {
        id: pageComponent
        Item {
            width:  availableWidth
            height: bar.height + joyLoader.height
Don Gagne's avatar
Don Gagne committed

            readonly property real  labelToMonitorMargin:   ScreenTools.defaultFontPixelWidth * 3
            property var            _activeJoystick:        joystickManager.activeJoystick
Don Gagne's avatar
Don Gagne committed

            function setupPageCompleted() {
                controller.start()
            }
Don Gagne's avatar
Don Gagne committed

            JoystickConfigController {
                id:             controller
            QGCTabBar {
                id:             bar
                width:          parent.width
                Component.onCompleted: {
                    currentIndex = _activeJoystick && _activeJoystick.calibrated ? 0 : 2
                anchors.top:    parent.top
                QGCTabButton {
                    text:       qsTr("General")
                QGCTabButton {
                    text:       qsTr("Button Assigment")
                QGCTabButton {
                    text:       qsTr("Calibration")
                QGCTabButton {
                    text:       qsTr("Advanced")
Don Gagne's avatar
Don Gagne committed
                }
            property var pages:  ["JoystickConfigGeneral.qml", "JoystickConfigButtons.qml", "JoystickConfigCalibration.qml", "JoystickConfigAdvanced.qml"]
            Loader {
                id:             joyLoader
                source:         pages[bar.currentIndex]
                width:          parent.width
                anchors.top:    bar.bottom
            }
        }
    }
}