diff options
author | Andy Nichols <andy.nichols@qt.io> | 2017-02-01 13:27:41 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-02-03 13:46:51 +0000 |
commit | 9c7ed97cf9f01fd08183c8e4918c9f95286ac11c (patch) | |
tree | ea3cbb4c99f63283b4533c688aa00c187dcfd9ec | |
parent | 7aceda138944c3dec11937147a8a51f22539bc5a (diff) |
Cleanup Examples
Change-Id: I36de0a3ba85b6b89547792badaa06c50f0e4ccc3
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | examples/gamepad/configureButtons/main.qml | 944 | ||||
-rw-r--r-- | examples/gamepad/gamepad.pro | 12 | ||||
-rw-r--r-- | examples/gamepad/keyNavigation/keyNavigation.pro | 2 | ||||
-rw-r--r-- | examples/gamepad/keyNavigation/qml/main.qml | 4 | ||||
-rw-r--r-- | examples/gamepad/mouseItem/main.cpp | 4 | ||||
-rw-r--r-- | examples/gamepad/mouseItem/mouseItem.pro | 2 | ||||
-rw-r--r-- | examples/gamepad/mouseItem/qml/main.qml | 48 | ||||
-rw-r--r-- | examples/gamepad/quickGamepad/qml/main.qml | 317 |
9 files changed, 689 insertions, 645 deletions
@@ -14,6 +14,7 @@ examples/tutorials/*/*/* !examples/tutorials/* !examples/tutorials/*/* !examples/ja_JP/*/* +!examples/*/*/qml/* demos/*/* !demos/spectrum/* demos/spectrum/bin diff --git a/examples/gamepad/configureButtons/main.qml b/examples/gamepad/configureButtons/main.qml index c93ddf2..6522631 100644 --- a/examples/gamepad/configureButtons/main.qml +++ b/examples/gamepad/configureButtons/main.qml @@ -35,10 +35,7 @@ ****************************************************************************/ import QtQuick 2.5 -import QtQuick.Controls 1.4 - -import QtQuick 2.5 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.1 import QtQuick.Layouts 1.2 import QtQuick.Window 2.0 import QtGamepad 1.0 @@ -47,6 +44,8 @@ import QtGamepad 1.0 ApplicationWindow { visible: true title: qsTr("Configure gamepad") + width: 400 + height: 600 Component.onCompleted: { if (Qt.platform.os === "android") @@ -74,541 +73,570 @@ ApplicationWindow { onConfigurationCanceled: pressButton(null) } - ColumnLayout { - anchors.fill: parent + Rectangle { + id: headerRectangle + anchors.top: parent.top + anchors.right: parent.right + anchors.left: parent.left + height: headerLayout.implicitHeight + 16 + color: "white" + z: 1 - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Connected gamepads") - } - ComboBox { - model: GamepadManager.connectedGamepads - onCurrentIndexChanged: gamepad.deviceId[GamepadManager.connectedGamepads[currentIndex]] - } - } + ColumnLayout { + id: headerLayout + anchors.top: parent.top + anchors.right: parent.right + anchors.left: parent.left + anchors.margins: 8 - Text { - Layout.fillWidth: true - text: qsTr("Start button cancel's current configuration") - } + Label { + text: qsTr("Gamepad configuration Utility") + font.pointSize: 16 + } - RowLayout { - Layout.fillWidth: true - Layout.fillHeight: true - GroupBox { - title: qsTr("Configure Gamepad Buttons") + RowLayout { Layout.fillWidth: true - Layout.fillHeight: true + Label { + text: qsTr("Connected gamepads") + } + ComboBox { + Layout.fillWidth: true + model: GamepadManager.connectedGamepads + onCurrentIndexChanged: gamepad.deviceId[GamepadManager.connectedGamepads[currentIndex]] + } + } - ColumnLayout { - anchors.fill: parent - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonA") - horizontalAlignment: Text.AlignRight - } + Label { + text: qsTr("Start button cancel's current configuration") + Layout.fillWidth: true + } + } + } - Text { - text: gamepad.buttonA ? qsTr("DOWN") : qsTr("UP") + Flickable { + id: scrollArea + anchors.top: headerRectangle.bottom + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 8 + contentHeight: contentLayout.implicitHeight + ScrollIndicator.vertical: ScrollIndicator { } + ColumnLayout { + id: contentLayout + width: parent.width + ColumnLayout { + GroupBox { + title: qsTr("Configure Gamepad Buttons") + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } + Label { + text: qsTr("ButtonA") + horizontalAlignment: Text.AlignRight + } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonA); + Label { + text: gamepad.buttonA ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonA); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonB") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonB ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonB); + Label { + text: qsTr("ButtonB") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonB ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonB); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonX") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonX ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonX); + Label { + text: qsTr("ButtonX") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonX ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonX); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonY") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonY ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonY); + Label { + text: qsTr("ButtonY") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonY ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonY); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonStart") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonStart ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonStart); + Label { + text: qsTr("ButtonStart") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonStart ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonStart); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonSelect") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonSelect ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonSelect); + Label { + text: qsTr("ButtonSelect") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonSelect ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonSelect); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button L1") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonL1 ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL1); + Label { + text: qsTr("Button L1") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonL1 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL1); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button R1") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonR1 ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR1); + Label { + text: qsTr("Button R1") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonR1 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR1); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button L2") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonL2 ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL2); + Label { + text: qsTr("Button L2") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonL2 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL2); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button R2") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonR2 ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR2); + Label { + text: qsTr("Button R2") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonR2 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR2); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button L3") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonL3 ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL3); + Label { + text: qsTr("Button L3") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonL3 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL3); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button R3") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonR3 ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR3); + Label { + text: qsTr("Button R3") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonR3 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR3); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Up") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonUp ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonUp); + Label { + text: qsTr("Button Up") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonUp ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonUp); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Down") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonDown ? qsTr("DOWN") : qsTr("UP") + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonDown ); + Label { + text: qsTr("Button Down") + horizontalAlignment: Text.AlignRight + } + Label { + text: gamepad.buttonDown ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonDown ); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Left") - horizontalAlignment: Text.AlignRight - } - Text { + RowLayout { Layout.fillWidth: true - text: gamepad.buttonLeft ? qsTr("DOWN") : qsTr("UP") - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonLeft); + Label { + text: qsTr("Button Left") + horizontalAlignment: Text.AlignRight + } + Label { + Layout.fillWidth: true + text: gamepad.buttonLeft ? qsTr("DOWN") : qsTr("UP") + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonLeft); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Right") - horizontalAlignment: Text.AlignRight - } - Text { + RowLayout { Layout.fillWidth: true - text: gamepad.buttonRight ? qsTr("DOWN") : qsTr("UP") - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonRight); + Label { + text: qsTr("Button Right") + horizontalAlignment: Text.AlignRight + } + Label { + Layout.fillWidth: true + text: gamepad.buttonRight ? qsTr("DOWN") : qsTr("UP") + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonRight); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Center") - horizontalAlignment: Text.AlignRight - } - Text { + RowLayout { Layout.fillWidth: true - text: gamepad.buttonCenter ? qsTr("DOWN") : qsTr("UP") - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonCenter); + Label { + text: qsTr("Button Center") + horizontalAlignment: Text.AlignRight + } + Label { + Layout.fillWidth: true + text: gamepad.buttonCenter ? qsTr("DOWN") : qsTr("UP") + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonCenter); + } } } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Guide") - horizontalAlignment: Text.AlignRight - } - Text { + RowLayout { Layout.fillWidth: true - text: gamepad.buttonGuide ? qsTr("DOWN") : qsTr("UP") - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonGuide); + Label { + text: qsTr("Button Guide") + horizontalAlignment: Text.AlignRight + } + Label { + Layout.fillWidth: true + text: gamepad.buttonGuide ? qsTr("DOWN") : qsTr("UP") + horizontalAlignment: Text.AlignRight + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonGuide); + } } } } } - } - GroupBox { - title: qsTr("Gamepad Axies") - Layout.fillWidth: true - Layout.fillHeight: true + GroupBox { + title: qsTr("Gamepad Axies") + Layout.fillWidth: true - ColumnLayout { - anchors.fill: parent - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("AxisLeftX") - horizontalAlignment: Text.AlignRight - } - - Text { - text: gamepad.axisLeftX + ColumnLayout { + anchors.fill: parent + RowLayout { Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } + Label { + text: qsTr("AxisLeftX") + horizontalAlignment: Text.AlignRight + } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisLeftX); + Label { + text: gamepad.axisLeftX + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("AxisLeftY") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.axisLeftY - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisLeftX); + } + } } + RowLayout { + Layout.fillWidth: true + Label { + text: qsTr("AxisLeftY") + horizontalAlignment: Text.AlignRight + } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisLeftY); + Label { + text: gamepad.axisLeftY + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("AxisRightX") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.axisRightX - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisLeftY); + } + } } + RowLayout { + Layout.fillWidth: true + Label { + text: qsTr("AxisRightX") + horizontalAlignment: Text.AlignRight + } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisRightX); + Label { + text: gamepad.axisRightX + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("AxisRightY") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.axisRightY - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisRightX); + } + } } + RowLayout { + Layout.fillWidth: true + Label { + text: qsTr("AxisRightY") + horizontalAlignment: Text.AlignRight + } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisRightY); + Label { + text: gamepad.axisRightY + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisRightY); + } } } - } - Item { - Layout.fillHeight: true + Item { + Layout.fillHeight: true + } } } } diff --git a/examples/gamepad/gamepad.pro b/examples/gamepad/gamepad.pro index aa36739..5622954 100644 --- a/examples/gamepad/gamepad.pro +++ b/examples/gamepad/gamepad.pro @@ -3,11 +3,13 @@ TEMPLATE = subdirs SUBDIRS += simple qtHaveModule(quick) { - SUBDIRS += configureButtons + SUBDIRS += \ + mouseItem \ + keyNavigation - qtHaveModule(widgets) { - SUBDIRS += quickGamepad \ - keyNavigation \ - mouseItem + qtHaveModule(quickcontrols2) { + SUBDIRS += \ + configureButtons \ + quickGamepad } } diff --git a/examples/gamepad/keyNavigation/keyNavigation.pro b/examples/gamepad/keyNavigation/keyNavigation.pro index 6091e39..65f9ce3 100644 --- a/examples/gamepad/keyNavigation/keyNavigation.pro +++ b/examples/gamepad/keyNavigation/keyNavigation.pro @@ -1,6 +1,6 @@ TEMPLATE = app -QT += qml quick widgets +QT += qml quick SOURCES += main.cpp diff --git a/examples/gamepad/keyNavigation/qml/main.qml b/examples/gamepad/keyNavigation/qml/main.qml index d58bfc5..6b72142 100644 --- a/examples/gamepad/keyNavigation/qml/main.qml +++ b/examples/gamepad/keyNavigation/qml/main.qml @@ -40,10 +40,10 @@ import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Window 2.0 import QtGamepad 1.0 -ApplicationWindow { +Window { visible: true width: 640 height: 480 diff --git a/examples/gamepad/mouseItem/main.cpp b/examples/gamepad/mouseItem/main.cpp index ab95334..c853d2c 100644 --- a/examples/gamepad/mouseItem/main.cpp +++ b/examples/gamepad/mouseItem/main.cpp @@ -39,12 +39,12 @@ ****************************************************************************/ -#include <QApplication> +#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { - QApplication app(argc, argv); + QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); diff --git a/examples/gamepad/mouseItem/mouseItem.pro b/examples/gamepad/mouseItem/mouseItem.pro index 05f1c2c..95d667d 100644 --- a/examples/gamepad/mouseItem/mouseItem.pro +++ b/examples/gamepad/mouseItem/mouseItem.pro @@ -1,6 +1,6 @@ TEMPLATE = app -QT += qml quick widgets +QT += qml quick SOURCES += main.cpp diff --git a/examples/gamepad/mouseItem/qml/main.qml b/examples/gamepad/mouseItem/qml/main.qml index 4c05e90..c6e9de5 100644 --- a/examples/gamepad/mouseItem/qml/main.qml +++ b/examples/gamepad/mouseItem/qml/main.qml @@ -38,16 +38,27 @@ ** ****************************************************************************/ - import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Window 2.0 import QtGamepad 1.0 -ApplicationWindow { +Window { visible: true width: 640 height: 480 - title: qsTr("Hello World") + title: qsTr("Gamepad Mouse Item") + + Text { + id: instructionLabel + anchors.centerIn: parent + text: qsTr("Simulate mouse input using a Gamepad") + } + Text { + id: outputLabel + anchors.horizontalCenter: instructionLabel.horizontalCenter + anchors.top: instructionLabel.bottom + text: "" + } Connections { target: GamepadManager @@ -61,9 +72,10 @@ ApplicationWindow { onButtonAChanged: { if (value == true) { gamepadMouse.mouseButtonPressed(Qt.LeftButton); - console.log("fake clicked qt: " + gamepadMouse.mousePosition.x + "," + gamepadMouse.mousePosition.y); + outputLabel.text = "Mouse click at: " + gamepadMouse.mousePosition.x + "," + gamepadMouse.mousePosition.y; } else { gamepadMouse.mouseButtonReleased(Qt.LeftButton); + outputLabel.text = ""; } } } @@ -76,18 +88,36 @@ ApplicationWindow { Rectangle { id: cursor - width: 4 - height: 4 + width: 9 + height: 9 + radius: 4.5 x: gamepadMouse.mousePosition.x y: gamepadMouse.mousePosition.y - color: "red" + color: "transparent" + border.color: "red" + Rectangle { + x: cursor.width * 0.5 - 0.5 + y: 1 + width: 1 + height: cursor.height - 2 + color: "black" + } + Rectangle { + x: 1 + y: cursor.height * 0.5 - 0.5 + height: 1 + width: cursor.width - 2 + color: "black" + } } } + + MouseArea { anchors.fill: parent onClicked: { - console.log("clicked qt: " + mouse.x + "," + mouse.y); + console.log("clicked at: " + mouse.x + "," + mouse.y); } } } diff --git a/examples/gamepad/quickGamepad/qml/main.qml b/examples/gamepad/quickGamepad/qml/main.qml index 049e72b..70ea5ec 100644 --- a/examples/gamepad/quickGamepad/qml/main.qml +++ b/examples/gamepad/quickGamepad/qml/main.qml @@ -39,191 +39,174 @@ ****************************************************************************/ import QtQuick 2.2 -import QtQuick.Controls 1.1 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.0 import QtGamepad 1.0 -ApplicationWindow { +Window { id: applicationWindow1 visible: true width: 800 height: 600 title: qsTr("QtGamepad Example") + color: "#363330" - Rectangle { + Item { id: background - color: "#363330" anchors.fill: parent - Item { - id: buttonL2Item - height: leftTrigger.height - width: leftTrigger.width + buttonL2Value.width - anchors.left: parent.left - anchors.leftMargin: 8 - anchors.top: parent.top - anchors.topMargin: 8 - - ButtonImage { - id: leftTrigger - anchors.top: parent.top - anchors.left: parent.left - anchors.bottom: parent.bottom - source: "xboxControllerLeftTrigger.png" - active: gamepad.buttonL2 != 0 - } - - ProgressBar { - id: buttonL2Value - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: leftTrigger.right - orientation: 0 - value: gamepad.buttonL2 - } - } - ButtonImage { - id: buttonL1 - anchors.left: buttonL2Item.left - anchors.top: buttonL2Item.bottom - anchors.topMargin: 8 - source: "xboxControllerLeftShoulder.png" - active: gamepad.buttonL1 - } - - - Item { - id: buttonR2Item - height: rightTrigger.height - width: rightTrigger.width + buttonR2Value.width - anchors.right: parent.right - anchors.rightMargin: 8 - anchors.top: parent.top - anchors.topMargin: 8 - - ButtonImage { - id: rightTrigger - anchors.top: parent.top - anchors.right: parent.right - anchors.bottom: parent.bottom - source: "xboxControllerRightTrigger.png" - active: gamepad.buttonR2 != 0 - } - - ProgressBar { - id: buttonR2Value - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: rightTrigger.left - orientation: 0 - value: gamepad.buttonR2 - } - } - ButtonImage { - id: buttonR1 - anchors.right: buttonR2Item.right - anchors.top: buttonR2Item.bottom - anchors.topMargin: 8 - source: "xboxControllerRightShoulder.png" - active: gamepad.buttonR1 - } - - Item { - id: centerButtons - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - anchors.topMargin: 8 - height: guideButton.height - width: guideButton.width + 16 + backButton.width + startButton.width - ButtonImage { - id: backButton - anchors.verticalCenter: parent.verticalCenter - anchors.right: guideButton.left - anchors.rightMargin: 8 - source: "xboxControllerBack.png" - active: gamepad.buttonSelect - } - ButtonImage { - id: guideButton - anchors.centerIn: parent - source: "xboxControllerButtonGuide.png" - active: gamepad.buttonGuide - } - ButtonImage { - anchors.verticalCenter: parent.verticalCenter - anchors.left: guideButton.right - anchors.leftMargin: 8 - id: startButton - source: "xboxControllerStart.png" - active: gamepad.buttonStart - } - } - - - - - DPad { - id: dPad - gamepad: gamepad - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.margins: 8 - } - - Row { - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom + ColumnLayout { + anchors.fill: parent anchors.margins: 8 - spacing: 16 - - LeftThumbstick { - id: leftThumbstick - gamepad: gamepad + RowLayout { + id: topRow + width: parent.width + ColumnLayout { + id: buttonL2Item + Layout.alignment: Qt.AlignLeft + ButtonImage { + id: leftTrigger + Layout.alignment: Qt.AlignCenter + source: "xboxControllerLeftTrigger.png" + active: gamepad.buttonL2 != 0 + } + ProgressBar { + id: buttonL2Value + width: leftTrigger.width + value: gamepad.buttonL2 + } + } + + Item { + id: centerButtons + Layout.alignment: Qt.AlignCenter + Layout.fillWidth: true + height: guideButton.height + width: guideButton.width + 16 + backButton.width + startButton.width + ButtonImage { + id: backButton + anchors.verticalCenter: parent.verticalCenter + anchors.right: guideButton.left + anchors.rightMargin: 8 + source: "xboxControllerBack.png" + active: gamepad.buttonSelect + } + ButtonImage { + id: guideButton + anchors.centerIn: parent + source: "xboxControllerButtonGuide.png" + active: gamepad.buttonGuide + } + ButtonImage { + anchors.verticalCenter: parent.verticalCenter + anchors.left: guideButton.right + anchors.leftMargin: 8 + id: startButton + source: "xboxControllerStart.png" + active: gamepad.buttonStart + } + } + + + ColumnLayout { + id: buttonR2Item + Layout.alignment: Qt.AlignRight + ButtonImage { + id: rightTrigger + Layout.alignment: Qt.AlignCenter + source: "xboxControllerRightTrigger.png" + active: gamepad.buttonR2 != 0 + } + + ProgressBar { + id: buttonR2Value + width: rightTrigger.width + value: gamepad.buttonR2 + } + } } - RightThumbstick { - id: rightThumbstick - gamepad: gamepad + RowLayout { + id: middleRow + ButtonImage { + id: buttonL1 + source: "xboxControllerLeftShoulder.png" + active: gamepad.buttonL1 + } + Item { + id: spacer1 + Layout.fillWidth: true + } + + ButtonImage { + id: buttonR1 + source: "xboxControllerRightShoulder.png" + active: gamepad.buttonR1 + } } - } - - Item { - width: 200 - height: 200 - anchors.right: parent.right - anchors.rightMargin: 8 - anchors.bottom: parent.bottom - anchors.bottomMargin: 8 - ButtonImage { - id: buttonA - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - source: "xboxControllerButtonA.png"; - active: gamepad.buttonA - } - ButtonImage { - id: buttonB - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - source: "xboxControllerButtonB.png"; - active: gamepad.buttonB - } - ButtonImage { - id: buttonX - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - source: "xboxControllerButtonX.png"; - active: gamepad.buttonX - } - ButtonImage { - id: buttonY - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - source: "xboxControllerButtonY.png"; - active: gamepad.buttonY + RowLayout { + id: bottomRow + width: parent.width + DPad { + id: dPad + Layout.alignment: Qt.AlignLeft + gamepad: gamepad + } + + LeftThumbstick { + id: leftThumbstick + Layout.alignment: Qt.AlignLeft + gamepad: gamepad + } + + Item { + id: spacer2 + Layout.fillWidth: true + } + + RightThumbstick { + id: rightThumbstick + Layout.alignment: Qt.AlignRight + gamepad: gamepad + } + + Item { + width: 200 + height: 200 + Layout.alignment: Qt.AlignRight + ButtonImage { + id: buttonA + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + source: "xboxControllerButtonA.png"; + active: gamepad.buttonA + } + ButtonImage { + id: buttonB + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + source: "xboxControllerButtonB.png"; + active: gamepad.buttonB + } + ButtonImage { + id: buttonX + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + source: "xboxControllerButtonX.png"; + active: gamepad.buttonX + } + ButtonImage { + id: buttonY + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + source: "xboxControllerButtonY.png"; + active: gamepad.buttonY + } + } } } - } Connections { |