JoystickConfig.qml 3.02 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
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


Gus Grubba's avatar
Gus Grubba committed
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")
Gus Grubba's avatar
Gus Grubba committed
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
    Component {
        id: pageComponent
        Item {
Gus Grubba's avatar
Gus Grubba committed
47 48
            width:  availableWidth
            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
            function setupPageCompleted() {
54 55 56
                controller.start()
            }

Don Gagne's avatar
Don Gagne committed
57 58 59
            JoystickConfigController {
                id:             controller
            }
60

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

Gus Grubba's avatar
Gus Grubba committed
82
            property var pages:  ["JoystickConfigGeneral.qml", "JoystickConfigButtons.qml", "JoystickConfigCalibration.qml", "JoystickConfigAdvanced.qml"]
83

Gus Grubba's avatar
Gus Grubba committed
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