Skip to content
JoystickConfig.qml 3.02 KiB
Newer Older
/****************************************************************************
 *
 *   (c) 2009-2016 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.
 *
 ****************************************************************************/
Gus Grubba's avatar
Gus Grubba committed
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")
Gus Grubba's avatar
Gus Grubba committed
    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 {
Gus Grubba's avatar
Gus Grubba committed
            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() {
Don Gagne's avatar
Don Gagne committed
            JoystickConfigController {
                id:             controller
            }
            QGCTabBar {
Gus Grubba's avatar
Gus Grubba committed
                id:             bar
                width:          parent.width
Gus Grubba's avatar
Gus Grubba committed
                Component.onCompleted: {
                    currentIndex = _activeJoystick && _activeJoystick.calibrated ? 0 : 2
                }
Gus Grubba's avatar
Gus Grubba committed
                anchors.top:    parent.top
                QGCTabButton {
Gus Grubba's avatar
Gus Grubba committed
                    text:       qsTr("General")
                QGCTabButton {
Gus Grubba's avatar
Gus Grubba committed
                    text:       qsTr("Button Assigment")
                QGCTabButton {
Gus Grubba's avatar
Gus Grubba committed
                    text:       qsTr("Calibration")
                QGCTabButton {
Gus Grubba's avatar
Gus Grubba committed
                    text:       qsTr("Advanced")
Gus Grubba's avatar
Gus Grubba committed
            property var pages:  ["JoystickConfigGeneral.qml", "JoystickConfigButtons.qml", "JoystickConfigCalibration.qml", "JoystickConfigAdvanced.qml"]
Gus Grubba's avatar
Gus Grubba committed
            Loader {
                id:             joyLoader
                source:         pages[bar.currentIndex]
                width:          parent.width
                anchors.top:    bar.bottom
            }
        }
    }
}