Cleanup Examples

Change-Id: I36de0a3ba85b6b89547792badaa06c50f0e4ccc3
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Andy Nichols 2017-02-01 13:27:41 +01:00 committed by Laszlo Agocs
parent 7aceda1389
commit 9c7ed97cf9
9 changed files with 689 additions and 645 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ examples/tutorials/*/*/*
!examples/tutorials/* !examples/tutorials/*
!examples/tutorials/*/* !examples/tutorials/*/*
!examples/ja_JP/*/* !examples/ja_JP/*/*
!examples/*/*/qml/*
demos/*/* demos/*/*
!demos/spectrum/* !demos/spectrum/*
demos/spectrum/bin demos/spectrum/bin

View File

@ -35,10 +35,7 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Controls 1.4 import QtQuick.Controls 2.1
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtGamepad 1.0 import QtGamepad 1.0
@ -47,6 +44,8 @@ import QtGamepad 1.0
ApplicationWindow { ApplicationWindow {
visible: true visible: true
title: qsTr("Configure gamepad") title: qsTr("Configure gamepad")
width: 400
height: 600
Component.onCompleted: { Component.onCompleted: {
if (Qt.platform.os === "android") if (Qt.platform.os === "android")
@ -74,46 +73,75 @@ ApplicationWindow {
onConfigurationCanceled: pressButton(null) onConfigurationCanceled: pressButton(null)
} }
Rectangle {
id: headerRectangle
anchors.top: parent.top
anchors.right: parent.right
anchors.left: parent.left
height: headerLayout.implicitHeight + 16
color: "white"
z: 1
ColumnLayout { ColumnLayout {
anchors.fill: parent id: headerLayout
anchors.top: parent.top
anchors.right: parent.right
anchors.left: parent.left
anchors.margins: 8
Label {
text: qsTr("Gamepad configuration Utility")
font.pointSize: 16
}
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Connected gamepads") text: qsTr("Connected gamepads")
} }
ComboBox { ComboBox {
Layout.fillWidth: true
model: GamepadManager.connectedGamepads model: GamepadManager.connectedGamepads
onCurrentIndexChanged: gamepad.deviceId[GamepadManager.connectedGamepads[currentIndex]] onCurrentIndexChanged: gamepad.deviceId[GamepadManager.connectedGamepads[currentIndex]]
} }
} }
Text { Label {
Layout.fillWidth: true
text: qsTr("Start button cancel's current configuration") text: qsTr("Start button cancel's current configuration")
Layout.fillWidth: true
}
}
} }
RowLayout { Flickable {
Layout.fillWidth: true id: scrollArea
Layout.fillHeight: true 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 { GroupBox {
title: qsTr("Configure Gamepad Buttons") title: qsTr("Configure Gamepad Buttons")
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("ButtonA") text: qsTr("ButtonA")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonA ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonA ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
@ -129,14 +157,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("ButtonB") text: qsTr("ButtonB")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonB ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonB ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -151,14 +179,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("ButtonX") text: qsTr("ButtonX")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonX ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonX ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -173,14 +201,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("ButtonY") text: qsTr("ButtonY")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonY ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonY ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -195,14 +223,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("ButtonStart") text: qsTr("ButtonStart")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonStart ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonStart ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -217,14 +245,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("ButtonSelect") text: qsTr("ButtonSelect")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonSelect ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonSelect ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -239,14 +267,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button L1") text: qsTr("Button L1")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonL1 ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonL1 ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -261,14 +289,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button R1") text: qsTr("Button R1")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonR1 ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonR1 ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -283,14 +311,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button L2") text: qsTr("Button L2")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonL2 ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonL2 ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -305,14 +333,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button R2") text: qsTr("Button R2")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonR2 ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonR2 ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -327,14 +355,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button L3") text: qsTr("Button L3")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonL3 ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonL3 ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -349,14 +377,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button R3") text: qsTr("Button R3")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonR3 ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonR3 ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -371,14 +399,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button Up") text: qsTr("Button Up")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonUp ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonUp ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -393,14 +421,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button Down") text: qsTr("Button Down")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.buttonDown ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonDown ? qsTr("DOWN") : qsTr("UP")
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -415,14 +443,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button Left") text: qsTr("Button Left")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
Layout.fillWidth: true Layout.fillWidth: true
text: gamepad.buttonLeft ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonLeft ? qsTr("DOWN") : qsTr("UP")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -437,14 +465,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button Right") text: qsTr("Button Right")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
Layout.fillWidth: true Layout.fillWidth: true
text: gamepad.buttonRight ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonRight ? qsTr("DOWN") : qsTr("UP")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -459,14 +487,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button Center") text: qsTr("Button Center")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
Layout.fillWidth: true Layout.fillWidth: true
text: gamepad.buttonCenter ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonCenter ? qsTr("DOWN") : qsTr("UP")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -481,14 +509,14 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("Button Guide") text: qsTr("Button Guide")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
Layout.fillWidth: true Layout.fillWidth: true
text: gamepad.buttonGuide ? qsTr("DOWN") : qsTr("UP") text: gamepad.buttonGuide ? qsTr("DOWN") : qsTr("UP")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
text: qsTr("Configure") text: qsTr("Configure")
@ -506,21 +534,20 @@ ApplicationWindow {
GroupBox { GroupBox {
title: qsTr("Gamepad Axies") title: qsTr("Gamepad Axies")
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("AxisLeftX") text: qsTr("AxisLeftX")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.axisLeftX text: gamepad.axisLeftX
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
@ -536,15 +563,15 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("AxisLeftY") text: qsTr("AxisLeftY")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.axisLeftY text: gamepad.axisLeftY
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
@ -560,15 +587,15 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("AxisRightX") text: qsTr("AxisRightX")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.axisRightX text: gamepad.axisRightX
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
@ -584,15 +611,15 @@ ApplicationWindow {
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Text { Label {
text: qsTr("AxisRightY") text: qsTr("AxisRightY")
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Text { Label {
text: gamepad.axisRightY text: gamepad.axisRightY
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignRight
} }
Button { Button {
@ -615,3 +642,4 @@ ApplicationWindow {
} }
} }
} }
}

View File

@ -3,11 +3,13 @@ TEMPLATE = subdirs
SUBDIRS += simple SUBDIRS += simple
qtHaveModule(quick) { qtHaveModule(quick) {
SUBDIRS += configureButtons SUBDIRS += \
mouseItem \
keyNavigation
qtHaveModule(widgets) { qtHaveModule(quickcontrols2) {
SUBDIRS += quickGamepad \ SUBDIRS += \
keyNavigation \ configureButtons \
mouseItem quickGamepad
} }
} }

View File

@ -1,6 +1,6 @@
TEMPLATE = app TEMPLATE = app
QT += qml quick widgets QT += qml quick
SOURCES += main.cpp SOURCES += main.cpp

View File

@ -40,10 +40,10 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Window 2.0
import QtGamepad 1.0 import QtGamepad 1.0
ApplicationWindow { Window {
visible: true visible: true
width: 640 width: 640
height: 480 height: 480

View File

@ -39,12 +39,12 @@
****************************************************************************/ ****************************************************************************/
#include <QApplication> #include <QGuiApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QGuiApplication app(argc, argv);
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));

View File

@ -1,6 +1,6 @@
TEMPLATE = app TEMPLATE = app
QT += qml quick widgets QT += qml quick
SOURCES += main.cpp SOURCES += main.cpp

View File

@ -38,16 +38,27 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Window 2.0
import QtGamepad 1.0 import QtGamepad 1.0
ApplicationWindow { Window {
visible: true visible: true
width: 640 width: 640
height: 480 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 { Connections {
target: GamepadManager target: GamepadManager
@ -61,9 +72,10 @@ ApplicationWindow {
onButtonAChanged: { onButtonAChanged: {
if (value == true) { if (value == true) {
gamepadMouse.mouseButtonPressed(Qt.LeftButton); 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 { } else {
gamepadMouse.mouseButtonReleased(Qt.LeftButton); gamepadMouse.mouseButtonReleased(Qt.LeftButton);
outputLabel.text = "";
} }
} }
} }
@ -76,18 +88,36 @@ ApplicationWindow {
Rectangle { Rectangle {
id: cursor id: cursor
width: 4 width: 9
height: 4 height: 9
radius: 4.5
x: gamepadMouse.mousePosition.x x: gamepadMouse.mousePosition.x
y: gamepadMouse.mousePosition.y 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 { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
console.log("clicked qt: " + mouse.x + "," + mouse.y); console.log("clicked at: " + mouse.x + "," + mouse.y);
} }
} }
} }

View File

@ -39,99 +39,49 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.2 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 import QtGamepad 1.0
ApplicationWindow { Window {
id: applicationWindow1 id: applicationWindow1
visible: true visible: true
width: 800 width: 800
height: 600 height: 600
title: qsTr("QtGamepad Example") title: qsTr("QtGamepad Example")
Rectangle {
id: background
color: "#363330" color: "#363330"
anchors.fill: parent
Item { Item {
id: buttonL2Item id: background
height: leftTrigger.height anchors.fill: parent
width: leftTrigger.width + buttonL2Value.width
anchors.left: parent.left
anchors.leftMargin: 8
anchors.top: parent.top
anchors.topMargin: 8
ColumnLayout {
anchors.fill: parent
anchors.margins: 8
RowLayout {
id: topRow
width: parent.width
ColumnLayout {
id: buttonL2Item
Layout.alignment: Qt.AlignLeft
ButtonImage { ButtonImage {
id: leftTrigger id: leftTrigger
anchors.top: parent.top Layout.alignment: Qt.AlignCenter
anchors.left: parent.left
anchors.bottom: parent.bottom
source: "xboxControllerLeftTrigger.png" source: "xboxControllerLeftTrigger.png"
active: gamepad.buttonL2 != 0 active: gamepad.buttonL2 != 0
} }
ProgressBar { ProgressBar {
id: buttonL2Value id: buttonL2Value
anchors.top: parent.top width: leftTrigger.width
anchors.bottom: parent.bottom
anchors.left: leftTrigger.right
orientation: 0
value: gamepad.buttonL2 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 { Item {
id: centerButtons id: centerButtons
anchors.horizontalCenter: parent.horizontalCenter Layout.alignment: Qt.AlignCenter
anchors.top: parent.top Layout.fillWidth: true
anchors.topMargin: 8
height: guideButton.height height: guideButton.height
width: guideButton.width + 16 + backButton.width + startButton.width width: guideButton.width + 16 + backButton.width + startButton.width
ButtonImage { ButtonImage {
@ -159,41 +109,73 @@ ApplicationWindow {
} }
ColumnLayout {
id: buttonR2Item
DPad { Layout.alignment: Qt.AlignRight
id: dPad ButtonImage {
gamepad: gamepad id: rightTrigger
anchors.left: parent.left Layout.alignment: Qt.AlignCenter
anchors.bottom: parent.bottom source: "xboxControllerRightTrigger.png"
anchors.margins: 8 active: gamepad.buttonR2 != 0
} }
Row { ProgressBar {
anchors.horizontalCenter: parent.horizontalCenter id: buttonR2Value
anchors.bottom: parent.bottom width: rightTrigger.width
anchors.margins: 8 value: gamepad.buttonR2
spacing: 16 }
}
}
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
}
}
RowLayout {
id: bottomRow
width: parent.width
DPad {
id: dPad
Layout.alignment: Qt.AlignLeft
gamepad: gamepad
}
LeftThumbstick { LeftThumbstick {
id: leftThumbstick id: leftThumbstick
Layout.alignment: Qt.AlignLeft
gamepad: gamepad gamepad: gamepad
} }
Item {
id: spacer2
Layout.fillWidth: true
}
RightThumbstick { RightThumbstick {
id: rightThumbstick id: rightThumbstick
Layout.alignment: Qt.AlignRight
gamepad: gamepad gamepad: gamepad
} }
}
Item { Item {
width: 200 width: 200
height: 200 height: 200
anchors.right: parent.right Layout.alignment: Qt.AlignRight
anchors.rightMargin: 8
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
ButtonImage { ButtonImage {
id: buttonA id: buttonA
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@ -223,7 +205,8 @@ ApplicationWindow {
active: gamepad.buttonY active: gamepad.buttonY
} }
} }
}
}
} }
Connections { Connections {