Unverified Commit 124f9ec9 authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #7622 from mavlink/joystickButtons

Joystick Work
parents e71da845 4d3620dc
...@@ -6,6 +6,7 @@ Note: This file only contains high level features or important fixes. ...@@ -6,6 +6,7 @@ Note: This file only contains high level features or important fixes.
### 3.6.0 - Daily Build ### 3.6.0 - Daily Build
* Added ability to set a joystick button to be single action or repeated action while the button is held down.
* Rework joysticks. Fixed several issues and updated setup UI. * Rework joysticks. Fixed several issues and updated setup UI.
* Adding support for UDP RTP h.265 video streams * Adding support for UDP RTP h.265 video streams
* For text to speech engine on Linux to English (all messages are in English) * For text to speech engine on Linux to English (all messages are in English)
......
This diff is collapsed.
This diff is collapsed.
...@@ -32,6 +32,14 @@ QmlObjectListModel::~QmlObjectListModel() ...@@ -32,6 +32,14 @@ QmlObjectListModel::~QmlObjectListModel()
} }
QObject* QmlObjectListModel::get(int index)
{
if (index < 0 || index >= _objectList.count()) {
return nullptr;
}
return _objectList[index];
}
int QmlObjectListModel::rowCount(const QModelIndex& parent) const int QmlObjectListModel::rowCount(const QModelIndex& parent) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
...@@ -160,19 +168,17 @@ void QmlObjectListModel::insert(int i, QObject* object) ...@@ -160,19 +168,17 @@ void QmlObjectListModel::insert(int i, QObject* object)
if (i < 0 || i > _objectList.count()) { if (i < 0 || i > _objectList.count()) {
qWarning() << "Invalid index index:count" << i << _objectList.count(); qWarning() << "Invalid index index:count" << i << _objectList.count();
} }
if(object) {
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
// Look for a dirtyChanged signal on the object
// Look for a dirtyChanged signal on the object if (object->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("dirtyChanged(bool)")) != -1) {
if (object->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("dirtyChanged(bool)")) != -1) { if (!_skipDirtyFirstItem || i != 0) {
if (!_skipDirtyFirstItem || i != 0) { QObject::connect(object, SIGNAL(dirtyChanged(bool)), this, SLOT(_childDirtyChanged(bool)));
QObject::connect(object, SIGNAL(dirtyChanged(bool)), this, SLOT(_childDirtyChanged(bool))); }
} }
} }
_objectList.insert(i, object); _objectList.insert(i, object);
insertRows(i, 1); insertRows(i, 1);
setDirty(true); setDirty(true);
} }
......
...@@ -27,7 +27,7 @@ public: ...@@ -27,7 +27,7 @@ public:
/// a dirty property and dirtyChanged signal. /// a dirty property and dirtyChanged signal.
Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged) Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged)
Q_INVOKABLE QObject* get(int index) { return _objectList[index]; } Q_INVOKABLE QObject* get(int index);
// Property accessors // Property accessors
......
...@@ -61,6 +61,9 @@ SetupPage { ...@@ -61,6 +61,9 @@ SetupPage {
QGCTabBar { QGCTabBar {
id: bar id: bar
width: parent.width width: parent.width
Component.onCompleted: {
currentIndex = _activeJoystick && _activeJoystick.calibrated ? 0 : 2
}
anchors.top: parent.top anchors.top: parent.top
QGCTabButton { QGCTabButton {
text: qsTr("General") text: qsTr("General")
......
...@@ -144,20 +144,38 @@ Item { ...@@ -144,20 +144,38 @@ Item {
visible: advancedSettings.checked visible: advancedSettings.checked
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Message Frequency //-- Axis Message Frequency
QGCLabel { QGCLabel {
text: qsTr("Message frequency (Hz):") text: qsTr("Axis frequency (Hz):")
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked visible: advancedSettings.checked
} }
QGCTextField { QGCTextField {
text: _activeJoystick.frequency text: _activeJoystick.axisFrequency
enabled: advancedSettings.checked enabled: advancedSettings.checked
validator: DoubleValidator { bottom: 0.25; top: 100.0; } validator: DoubleValidator { bottom: 0.25; top: 50.0; }
inputMethodHints: Qt.ImhFormattedNumbersOnly inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onEditingFinished: { onEditingFinished: {
_activeJoystick.frequency = parseFloat(text) _activeJoystick.axisFrequency = parseFloat(text)
}
visible: advancedSettings.checked
}
//-----------------------------------------------------------------
//-- Button Repeat Frequency
QGCLabel {
text: qsTr("Button repeat frequency (Hz):")
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
QGCTextField {
text: _activeJoystick.buttonFrequency
enabled: advancedSettings.checked
validator: DoubleValidator { bottom: 0.25; top: 50.0; }
inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.alignment: Qt.AlignVCenter
onEditingFinished: {
_activeJoystick.buttonFrequency = parseFloat(text)
} }
visible: advancedSettings.checked visible: advancedSettings.checked
} }
......
...@@ -46,11 +46,7 @@ Item { ...@@ -46,11 +46,7 @@ Item {
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
property bool pressed property bool pressed
QGCCheckBox { property var currentAssignableAction: _activeJoystick ? _activeJoystick.assignableActions.get(buttonActionCombo.currentIndex) : null
anchors.verticalCenter: parent.verticalCenter
checked: _activeJoystick ? _activeJoystick.buttonActions[modelData] !== "" : false
onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "")
}
Rectangle { Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: ScreenTools.defaultFontPixelHeight * 1.5 width: ScreenTools.defaultFontPixelHeight * 1.5
...@@ -69,9 +65,35 @@ Item { ...@@ -69,9 +65,35 @@ Item {
QGCComboBox { QGCComboBox {
id: buttonActionCombo id: buttonActionCombo
width: ScreenTools.defaultFontPixelWidth * 26 width: ScreenTools.defaultFontPixelWidth * 26
model: _activeJoystick ? _activeJoystick.actions : 0 model: _activeJoystick ? _activeJoystick.assignableActionTitles : []
onActivated: _activeJoystick.setButtonAction(modelData, textAt(index)) onActivated: {
Component.onCompleted: currentIndex = find(_activeJoystick.buttonActions[modelData]) _activeJoystick.setButtonAction(modelData, textAt(index))
}
Component.onCompleted: {
if(_activeJoystick) {
var i = find(_activeJoystick.buttonActions[modelData])
if(i < 0) i = 0
currentIndex = i
}
}
}
QGCCheckBox {
id: repeatCheck
text: qsTr("Repeat")
enabled: currentAssignableAction && _activeJoystick.calibrated && currentAssignableAction.canRepeat
onClicked: {
_activeJoystick.setButtonRepeat(modelData, checked)
}
Component.onCompleted: {
if(_activeJoystick) {
checked = _activeJoystick.getButtonRepeat(modelData)
}
}
anchors.verticalCenter: parent.verticalCenter
}
Item {
width: ScreenTools.defaultFontPixelWidth * 2
height: 1
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment