JoystickConfig.qml 3.02 KB
Newer Older
1 2
/****************************************************************************
 *
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10


11 12 13 14
import QtQuick                      2.11
import QtQuick.Controls             2.4
import QtQuick.Dialogs              1.3
import QtQuick.Layouts              1.11
15

16
import QGroundControl               1.0
17 18 19 20
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controllers   1.0
21
import QGroundControl.FactSystem    1.0
22
import QGroundControl.FactControls  1.0
23 24

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

31 32
    readonly property real  _maxButtons:         64
    readonly property real  _attitudeLabelWidth: ScreenTools.defaultFontPixelWidth * 12
dheideman's avatar
dheideman committed
33

Jacob Walser's avatar
Jacob Walser committed
34 35 36
    Connections {
        target: joystickManager
        onAvailableJoysticksChanged: {
37
            if(joystickManager.joysticks.length === 0) {
Jacob Walser's avatar
Jacob Walser committed
38 39 40 41 42 43
                summaryButton.checked = true
                setupView.showSummaryPanel()
            }
        }
    }

Don Gagne's avatar
Don Gagne committed
44 45 46 47
    Component {
        id: pageComponent
        Item {
            width:  availableWidth
48
            height: bar.height + joyLoader.height
Don Gagne's avatar
Don Gagne committed
49

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

53 54 55
            function setupPageCompleted() {
                controller.start()
            }
Don Gagne's avatar
Don Gagne committed
56 57 58

            JoystickConfigController {
                id:             controller
59 60
            }

61 62 63 64 65
            QGCTabBar {
                id:             bar
                width:          parent.width
                Component.onCompleted: {
                    currentIndex = _activeJoystick && _activeJoystick.calibrated ? 0 : 2
66
                }
67 68 69
                anchors.top:    parent.top
                QGCTabButton {
                    text:       qsTr("General")
70
                }
71 72
                QGCTabButton {
                    text:       qsTr("Button Assigment")
73
                }
74 75
                QGCTabButton {
                    text:       qsTr("Calibration")
76
                }
77 78
                QGCTabButton {
                    text:       qsTr("Advanced")
Don Gagne's avatar
Don Gagne committed
79
                }
80
            }
81

82
            property var pages:  ["JoystickConfigGeneral.qml", "JoystickConfigButtons.qml", "JoystickConfigCalibration.qml", "JoystickConfigAdvanced.qml"]
83

84 85 86 87 88 89 90 91 92
            Loader {
                id:             joyLoader
                source:         pages[bar.currentIndex]
                width:          parent.width
                anchors.top:    bar.bottom
            }
        }
    }
}
Gregory Dymarek's avatar
Gregory Dymarek committed
93 94