diff options
-rw-r--r-- | DemoApplication/controls/CNCheckBox.qml | 14 | ||||
-rw-r--r-- | DemoApplication/controls/CNRadioButton.qml | 14 | ||||
-rw-r--r-- | DemoApplication/controls/CNSwitch.qml | 14 | ||||
-rw-r--r-- | DemoApplication/controls/CNToolButton.qml | 14 | ||||
-rw-r--r-- | DemoApplication/controls/qmldir | 6 | ||||
-rw-r--r-- | DemoApplication/main.qml | 8 | ||||
-rw-r--r-- | DemoApplication/pages/Page1.qml | 2 | ||||
-rw-r--r-- | DemoApplication/pages/Page2.qml | 2 | ||||
-rw-r--r-- | DemoApplication/pages/Page3.qml | 2 | ||||
-rw-r--r-- | DemoApplication/pages/Page4.qml | 1 | ||||
-rw-r--r-- | DemoApplication/pages/Page5.qml | 189 |
11 files changed, 259 insertions, 7 deletions
diff --git a/DemoApplication/controls/CNCheckBox.qml b/DemoApplication/controls/CNCheckBox.qml new file mode 100644 index 0000000..d411d32 --- /dev/null +++ b/DemoApplication/controls/CNCheckBox.qml @@ -0,0 +1,14 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.2 +import CursorNavigation 1.0 + +CheckBox { + CursorNavigation.acceptsCursor: true + Rectangle { + anchors.fill: parent + color: "transparent" + border.width: 2 + border.color: "red" + visible: parent.CursorNavigation.hasCursor + } +} diff --git a/DemoApplication/controls/CNRadioButton.qml b/DemoApplication/controls/CNRadioButton.qml new file mode 100644 index 0000000..1f649b3 --- /dev/null +++ b/DemoApplication/controls/CNRadioButton.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.2 +import CursorNavigation 1.0 + +RadioButton { + CursorNavigation.acceptsCursor: true + Rectangle { + anchors.fill: parent + color: "transparent" + border.width: 2 + border.color: "red" + visible: parent.CursorNavigation.hasCursor + } +} diff --git a/DemoApplication/controls/CNSwitch.qml b/DemoApplication/controls/CNSwitch.qml new file mode 100644 index 0000000..e3f0e01 --- /dev/null +++ b/DemoApplication/controls/CNSwitch.qml @@ -0,0 +1,14 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.2 +import CursorNavigation 1.0 + +Switch { + CursorNavigation.acceptsCursor: true + Rectangle { + border.width: 2 + border.color: "red" + anchors.fill: parent + visible: parent.CursorNavigation.hasCursor + color: "transparent" + } +} diff --git a/DemoApplication/controls/CNToolButton.qml b/DemoApplication/controls/CNToolButton.qml new file mode 100644 index 0000000..65f2338 --- /dev/null +++ b/DemoApplication/controls/CNToolButton.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.2 +import CursorNavigation 1.0 + +ToolButton { + CursorNavigation.acceptsCursor: true + Rectangle { + anchors.fill: parent + color: "transparent" + border.width: 2 + border.color: "red" + visible: parent.CursorNavigation.hasCursor + } +} diff --git a/DemoApplication/controls/qmldir b/DemoApplication/controls/qmldir new file mode 100644 index 0000000..b1ec146 --- /dev/null +++ b/DemoApplication/controls/qmldir @@ -0,0 +1,6 @@ +CNButton 1.0 CNButton.qml +CNTabButton 1.0 CNTabButton.qml +CNToolButton 1.0 CNToolButton.qml +CNRadioButton 1.0 CNRadioButton.qml +CNSwitch 1.0 CNSwitch.qml +CNCheckBox 1.0 CNCheckBox.qml diff --git a/DemoApplication/main.qml b/DemoApplication/main.qml index 32829d9..c638e86 100644 --- a/DemoApplication/main.qml +++ b/DemoApplication/main.qml @@ -3,8 +3,8 @@ import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import CursorNavigation 1.0 +import controls 1.0 import "pages" -import "controls" ApplicationWindow { id: window @@ -24,11 +24,12 @@ ApplicationWindow { } CNTabButton { text: qsTr("Page 3") - } CNTabButton { text: qsTr("Page 4") - + } + CNTabButton { + text: qsTr("Page 5") } } @@ -39,5 +40,6 @@ ApplicationWindow { Page2 { } Page3 { } Page4 { } + Page5 { } } } diff --git a/DemoApplication/pages/Page1.qml b/DemoApplication/pages/Page1.qml index b73be48..a140c6e 100644 --- a/DemoApplication/pages/Page1.qml +++ b/DemoApplication/pages/Page1.qml @@ -1,7 +1,7 @@ import QtQuick 2.9 import CursorNavigation 1.0 -import "../controls" +import controls 1.0 Item { width: parent.width diff --git a/DemoApplication/pages/Page2.qml b/DemoApplication/pages/Page2.qml index c655170..396f6ce 100644 --- a/DemoApplication/pages/Page2.qml +++ b/DemoApplication/pages/Page2.qml @@ -2,7 +2,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.4 import CursorNavigation 1.0 -import "../controls" +import controls 1.0 Item { width: parent.width diff --git a/DemoApplication/pages/Page3.qml b/DemoApplication/pages/Page3.qml index ece6975..e9c47e1 100644 --- a/DemoApplication/pages/Page3.qml +++ b/DemoApplication/pages/Page3.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import CursorNavigation 1.0 -import "../controls" +import controls 1.0 Item { width: parent.width diff --git a/DemoApplication/pages/Page4.qml b/DemoApplication/pages/Page4.qml index a8f3e68..cc74876 100644 --- a/DemoApplication/pages/Page4.qml +++ b/DemoApplication/pages/Page4.qml @@ -84,4 +84,3 @@ Item { } } - diff --git a/DemoApplication/pages/Page5.qml b/DemoApplication/pages/Page5.qml new file mode 100644 index 0000000..9ab75c6 --- /dev/null +++ b/DemoApplication/pages/Page5.qml @@ -0,0 +1,189 @@ +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.3 + +import CursorNavigation 1.0 +import controls 1.0 + +Item { + width: parent.width + height: parent.height + + Component { + id: delegate + Text { + id: nameText + width: contentWidth + text: index + font.pixelSize: 24 + color: index%2 == 0 ? "green" : "black" + } + } + + FocusScope { + id: leftMenu + width: 199 + height: (parent.height - toolBar.height) + property string bgColor: "#800080" + Rectangle { + id: rect + anchors.fill: parent + color: leftMenu.bgColor + opacity: 0.6 + } + Column { + width: parent.width + height: 300 + anchors.verticalCenter: parent.verticalCenter + CNSwitch { + width: 180 + anchors.horizontalCenter: parent.horizontalCenter + text: "Enable 2nd player" + } + CNRadioButton { + width: 120 + anchors.horizontalCenter: parent.horizontalCenter + text: "Purple" + checked: (leftMenu.bgColor === "#800080") + onClicked: { leftMenu.bgColor = "#800080"; } + } + CNRadioButton { + width: 120 + anchors.horizontalCenter: parent.horizontalCenter + text: "Orange" + checked: (leftMenu.bgColor === "#ffa500") + onClicked: { leftMenu.bgColor = "#ffa500"; } + } + } + } + FocusScope { + width: 400 + height: parent.height + anchors.centerIn: parent + CursorNavigation.acceptsCursor: true + //TODO should this work? it didn't either this way or + //by setting just listView + CursorNavigation.escapeTarget: listViewFocusScope + //TODO it would be handy to have a way of implementing + //the moveUp/Down/Right/Left functions of the cursor manager + //as many times addtional view-specific actions need to + //be done when those are triggered + Keys.onDigit1Pressed: { pathView.decrementCurrentIndex(); } + Keys.onDigit2Pressed: { pathView.incrementCurrentIndex(); } + Rectangle { + anchors.fill: parent + border.width: 1 + border.color: pathView.activeFocus ? "red" : "transparent" + color: "transparent" + } + PathView { + id: pathView + anchors.fill: parent + model: 20 + delegate: delegate + focus: true + path: Path { + startX: 50; startY: 200 + PathArc { + x: (pathView.width - 50); y: 200 + radiusX: 100; radiusY: 90 + useLargeArc: true + } + PathArc { + x: 50; y: 200 + radiusX: 100; radiusY: 90 + useLargeArc: true + } + } + } + } + + FocusScope { + id: listViewFocusScope + width: 200 + height: ((listView.count*40)+40) + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: -toolBar.height + CursorNavigation.acceptsCursor: true + ListView { + id: listView + anchors.fill: parent + spacing: 4 + focus: true + + Rectangle { + anchors.fill: parent + border.width: 1 + border.color: listView.activeFocus ? "red" : "black" + color: "transparent" + } + + highlight: Rectangle { + width: listView.width + height: 40 + color: "lightgrey" + opacity: 0.3 + } + + delegate: ItemDelegate { + width: listView.width + height: 40 + + contentItem: Row { + width: (parent.width - x) + height: 35 + x: 5 + anchors.verticalCenter: parent.verticalCenter + spacing: 10 + Rectangle { + width: parent.height + height: parent.height + radius: width/2 + color: colorCode + } + Text { + height: parent.height + font.bold: true + verticalAlignment: Text.AlignVCenter + text: name + } + } + onClicked: { + listView.currentIndex = index; + } + } + + model: ListModel { + ListElement { name: "Joe"; colorCode: "grey" } + ListElement { name: "Hillary"; colorCode: "red" } + ListElement { name: "Norton"; colorCode: "blue" } + ListElement { name: "Hans"; colorCode: "green" } + ListElement { name: "Ivan"; colorCode: "green" } + ListElement { name: "Alex"; colorCode: "blue" } + ListElement { name: "Erika"; colorCode: "red" } + } + } + } + FocusScope { + width: parent.width + height: 50 + anchors.bottom: parent.bottom + ToolBar { + id: toolBar + anchors.fill: parent + RowLayout { + anchors.fill: parent + CNToolButton { text: "Menu" } + CNToolButton { text: "Undo Table" } + CNToolButton { text: "Rise Bet" } + CNToolButton { text: "Start" } + Item { Layout.fillWidth: true } + CNCheckBox { + text: "Outside bet" + Layout.alignment: Qt.AlignRight + } + } + } + } +} |