aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandra Betouni <ABetouni@luxoft.com>2018-11-20 12:49:37 +0100
committerAntti Hölttä <AHoelttae@luxoft.com>2019-03-18 16:32:22 +0100
commitd87734d37a0c9689647b4eaaef1eeda318c3f8be (patch)
tree59e61cc9e9ddbf888bd0ab5964185cace219eb6a
parent4e53c46500bdbe9f6fd7228f14b27fb7262b0350 (diff)
Demo application clean up
Minor improvements in pro file for demo app Also update .gitignore to ignore DS_Store files Removed unecessary code and files
-rw-r--r--.gitignore1
-rw-r--r--DemoApplication/CNButton.qml18
-rw-r--r--DemoApplication/DemoApplication.pro14
-rw-r--r--DemoApplication/HomeForm.qml14
-rw-r--r--DemoApplication/Page1Form.qml84
-rw-r--r--DemoApplication/Page2Form.qml116
-rw-r--r--DemoApplication/controls/CNButton.qml38
-rw-r--r--DemoApplication/main.qml81
-rw-r--r--DemoApplication/pages/Page1.qml78
-rw-r--r--DemoApplication/pages/Page2.qml122
-rw-r--r--DemoApplication/pages/Page3.qml (renamed from DemoApplication/Page3Form.qml)59
-rw-r--r--DemoApplication/qml.qrc11
-rw-r--r--DemoApplication/qtquickcontrols2.conf6
-rw-r--r--DemoApplication/src/main.cpp (renamed from DemoApplication/main.cpp)2
14 files changed, 300 insertions, 344 deletions
diff --git a/.gitignore b/.gitignore
index 72587da..0bf39a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.user
*.qmlc
+*.DS_Store
diff --git a/DemoApplication/CNButton.qml b/DemoApplication/CNButton.qml
deleted file mode 100644
index b4b28bf..0000000
--- a/DemoApplication/CNButton.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 2.0
-import QtQuick.Controls 2.2
-import CursorNavigation 1.0
-
-Button {
- id: button
- CursorNavigation.acceptsCursor: true
- property bool hasCursor: CursorNavigation.hasCursor
-
- Rectangle {
- border.width: 2
- border.color: "red"
- anchors.fill: parent
- visible: button.hasCursor
- color: "transparent"
- }
-
-}
diff --git a/DemoApplication/DemoApplication.pro b/DemoApplication/DemoApplication.pro
index 6ad5a8e..736fb47 100644
--- a/DemoApplication/DemoApplication.pro
+++ b/DemoApplication/DemoApplication.pro
@@ -8,20 +8,24 @@ CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
TARGET = demo
-DESTDIR = ..
+DESTDIR = $$OUT_PWD/
+macos:CONFIG -= app_bundle
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
- main.cpp
+ src/main.cpp
-RESOURCES += qml.qrc
+qml.files = main.qml $$PWD/controls $$PWD/pages
+qml.path = $$OUT_PWD
+INSTALLS += qml
+
+OTHER_FILES += $$files($$PWD/*.qml, true)
+OTHER_FILES += $$files($$PWD/*.qmldir, true)
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
-# Additional import path used to resolve QML modules just for Qt Quick Designer
-QML_DESIGNER_IMPORT_PATH =
diff --git a/DemoApplication/HomeForm.qml b/DemoApplication/HomeForm.qml
deleted file mode 100644
index 83412a6..0000000
--- a/DemoApplication/HomeForm.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.2
-
-Page {
- width: 600
- height: 400
-
- title: qsTr("Home")
-
- Label {
- text: qsTr("You are on the home page.")
- anchors.centerIn: parent
- }
-}
diff --git a/DemoApplication/Page1Form.qml b/DemoApplication/Page1Form.qml
deleted file mode 100644
index fb7f09e..0000000
--- a/DemoApplication/Page1Form.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.2
-import QtQuick.Layouts 1.3
-import CursorNavigation 1.0
-
-Page {
- width: 600
- height: 400
-
- title: qsTr("Page 1")
-
- FocusScope {
- CursorNavigation.acceptsCursor: true
-
- anchors.fill: parent
-
- //this seems to be the way to force focus on a newly opened dialog?
- Component.onCompleted: forceActiveFocus()
-
- Label {
- text: qsTr("You are on Page 1.")
- anchors.centerIn: parent
- }
-
- CNButton {
- id: button
- x: 52
- y: 50
- text: qsTr("Button")
- }
-
- CNButton {
- id: button1
- x: 110
- y: 138
- text: qsTr("Button")
- }
-
- CNButton {
- id: button2
- x: 202
- y: 241
- text: qsTr("Button with default focus")
- focus: true
- }
-
- CNButton {
- id: button3
- x: 383
- y: 241
- text: qsTr("Button")
- }
-
- CNButton {
- id: button4
- x: 383
- y: 322
- text: qsTr("Button")
- }
-
- CNButton {
- id: button5
- x: 383
- y: 138
- text: qsTr("Button")
- }
-
- CNButton {
- id: button6
- x: 383
- y: 50
- text: qsTr("Button")
- }
-
- CNButton {
- id: button7
- x: 62
- y: 241
- text: qsTr("Button")
- }
-
- }
-
-}
diff --git a/DemoApplication/Page2Form.qml b/DemoApplication/Page2Form.qml
deleted file mode 100644
index 891f8cc..0000000
--- a/DemoApplication/Page2Form.qml
+++ /dev/null
@@ -1,116 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.2
-import CursorNavigation 1.0
-
-Page {
- width: 600
- height: 400
-
- title: qsTr("Page 2")
-
- Label {
- text: qsTr("You are on Page 2.")
- anchors.centerIn: parent
- }
-
- FocusScope {
- CursorNavigation.acceptsCursor: true
- x: 385
- y: 19
- width: 198
- height: 359
- ListView {
- id: listView
- anchors.fill: parent
- spacing: 4
- focus: true
-
- Rectangle {
- border.width: 2
- border.color: "red"
- anchors.fill: parent
- visible: listView.activeFocus
- color: "transparent"
- }
-
- highlight: Rectangle {
- border.width: 2
- border.color: "red"
- color: "grey"
- }
-
- delegate: Item {
- x: 5
- width: listView.width
- height: 40
-
- Row {
- id: row1
- Rectangle {
- width: 40
- height: 40
- color: colorCode
- }
-
- Text {
- text: name
- anchors.verticalCenter: parent.verticalCenter
- font.bold: true
- }
- spacing: 10
- }
- }
-
- model: ListModel {
- ListElement {
- name: "Grey"
- colorCode: "grey"
- }
-
- ListElement {
- name: "Red"
- colorCode: "red"
- }
-
- ListElement {
- name: "Blue"
- colorCode: "blue"
- }
-
- ListElement {
- name: "Green"
- colorCode: "green"
- }
- }
- }
- }
-
- CNButton {
- id: button
- x: 95
- y: 54
- text: qsTr("Button")
- }
-
- CNButton {
- id: button1
- x: 95
- y: 158
- text: qsTr("Button")
- }
-
- CNButton {
- id: button2
- x: 95
- y: 266
- text: qsTr("Button")
- }
-
- CNButton {
- id: button3
- x: 400
- y: 400
- text: qsTr("Button")
- }
-
-}
diff --git a/DemoApplication/controls/CNButton.qml b/DemoApplication/controls/CNButton.qml
new file mode 100644
index 0000000..33299d1
--- /dev/null
+++ b/DemoApplication/controls/CNButton.qml
@@ -0,0 +1,38 @@
+import QtQuick 2.0
+import QtQuick.Controls 2.2
+import CursorNavigation 1.0
+
+Button {
+ id: root
+ implicitWidth: (textLabel.contentWidth + 40)
+ implicitHeight: 40
+
+ CursorNavigation.acceptsCursor: true
+ property bool hasCursor: CursorNavigation.hasCursor
+
+ background: Rectangle {
+ anchors.fill: parent
+ radius: 40
+ opacity: root.pressed ? 0.6 : 0.4
+ color: "grey"
+ }
+
+ contentItem: Item {
+ anchors.fill: parent
+ Label {
+ id: textLabel
+ anchors.centerIn: parent
+ font.pixelSize: 14
+ color: "blue"
+ text: root.text
+ }
+
+ Rectangle {
+ border.width: 2
+ border.color: "red"
+ anchors.fill: parent
+ visible: root.hasCursor
+ color: "transparent"
+ }
+ }
+}
diff --git a/DemoApplication/main.qml b/DemoApplication/main.qml
index b408923..b0e54cb 100644
--- a/DemoApplication/main.qml
+++ b/DemoApplication/main.qml
@@ -1,74 +1,39 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+
import CursorNavigation 1.0
+import "pages"
ApplicationWindow {
id: window
- visible: true
width: 800
height: 600
- title: qsTr("Stack")
-
- header: ToolBar {
- contentHeight: toolButton.implicitHeight
-
- ToolButton {
- id: toolButton
- text: stackView.depth > 1 ? "\u25C0" : "\u2630"
- font.pixelSize: Qt.application.font.pixelSize * 1.6
- onClicked: {
- if (stackView.depth > 1) {
- stackView.pop()
- } else {
- drawer.open()
- }
- }
+ visible: true
+ title: qsTr("Cursor Navigation Demo Application")
+
+ header: TabBar {
+ id: tabBar
+ width: parent.width
+ TabButton {
+ CursorNavigation.acceptsCursor: true
+ text: qsTr("Page 1")
}
-
- Label {
- text: stackView.currentItem.title
- anchors.centerIn: parent
+ TabButton {
+ CursorNavigation.acceptsCursor: true
+ text: qsTr("Page 2")
}
- }
-
- Drawer {
- id: drawer
- width: window.width * 0.66
- height: window.height
-
- Column {
- anchors.fill: parent
-
- ItemDelegate {
- text: qsTr("Page 1")
- width: parent.width
- onClicked: {
- stackView.push("Page1Form.qml")
- drawer.close()
- }
- }
- ItemDelegate {
- text: qsTr("Page 2")
- width: parent.width
- onClicked: {
- stackView.push("Page2Form.qml")
- drawer.close()
- }
- }
- ItemDelegate {
- text: qsTr("Page 3")
- width: parent.width
- onClicked: {
- stackView.push("Page3Form.qml")
- drawer.close()
- }
- }
+ TabButton {
+ CursorNavigation.acceptsCursor: true
+ text: qsTr("Page 3")
}
}
- StackView {
- id: stackView
- initialItem: "HomeForm.qml"
+ contentData: StackLayout {
anchors.fill: parent
+ currentIndex: tabBar.currentIndex
+ Page1 { }
+ Page2 { }
+ Page3 { }
}
}
diff --git a/DemoApplication/pages/Page1.qml b/DemoApplication/pages/Page1.qml
new file mode 100644
index 0000000..b73be48
--- /dev/null
+++ b/DemoApplication/pages/Page1.qml
@@ -0,0 +1,78 @@
+import QtQuick 2.9
+
+import CursorNavigation 1.0
+import "../controls"
+
+Item {
+ width: parent.width
+ height: parent.height
+
+ FocusScope {
+ anchors.fill: parent
+
+ Item {
+ width: 500
+ height: 400
+ anchors.centerIn: parent
+
+ CNButton {
+ id: button
+ x: 52
+ y: 50
+ text: qsTr("Button")
+ }
+
+ CNButton {
+ id: button1
+ x: 110
+ y: 138
+ text: qsTr("Button")
+ }
+
+ CNButton {
+ id: button2
+ x: 160
+ y: 241
+ text: qsTr("Button with default focus")
+ focus: true
+ }
+
+ CNButton {
+ id: button3
+ x: 383
+ y: 241
+ text: qsTr("Button")
+ }
+
+ CNButton {
+ id: button4
+ x: 383
+ y: 322
+ text: qsTr("Button")
+ }
+
+ CNButton {
+ id: button5
+ x: 383
+ y: 138
+ text: qsTr("Button")
+ }
+
+ CNButton {
+ id: button6
+ x: 383
+ y: 50
+ text: qsTr("Button")
+ }
+
+ CNButton {
+ id: button7
+ x: 62
+ y: 241
+ text: qsTr("Button")
+ }
+ }
+ //this seems to be the way to force focus on a newly opened dialog?
+ Component.onCompleted: { forceActiveFocus(); }
+ }
+}
diff --git a/DemoApplication/pages/Page2.qml b/DemoApplication/pages/Page2.qml
new file mode 100644
index 0000000..c655170
--- /dev/null
+++ b/DemoApplication/pages/Page2.qml
@@ -0,0 +1,122 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.4
+
+import CursorNavigation 1.0
+import "../controls"
+
+Item {
+ width: parent.width
+ height: parent.height
+
+ Item {
+ width: 580
+ height: 450
+ anchors.centerIn: parent
+ FocusScope {
+ id: focusScope
+ width: 198
+ height: 359
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.topMargin: 20
+
+ CursorNavigation.acceptsCursor: true
+ ListView {
+ id: listView
+ anchors.fill: parent
+ spacing: 4
+ focus: true
+
+ Rectangle {
+ anchors.fill: parent
+ visible: listView.activeFocus
+ border.width: 2
+ border.color: "red"
+ 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: "Grey"
+ colorCode: "grey"
+ }
+
+ ListElement {
+ name: "Red"
+ colorCode: "red"
+ }
+
+ ListElement {
+ name: "Blue"
+ colorCode: "blue"
+ }
+
+ ListElement {
+ name: "Green"
+ colorCode: "green"
+ }
+ }
+ }
+ }
+ CNButton {
+ id: button3
+ anchors.top: focusScope.bottom
+ anchors.topMargin: 20
+ anchors.right: parent.right
+ anchors.rightMargin: 60
+ text: qsTr("Button")
+ }
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.leftMargin: 50
+ spacing: 30
+ CNButton {
+ text: qsTr("Button")
+ }
+
+ CNButton {
+ text: qsTr("Button")
+ }
+
+ CNButton {
+ text: qsTr("Button")
+ }
+ }
+ }
+}
diff --git a/DemoApplication/Page3Form.qml b/DemoApplication/pages/Page3.qml
index f7d65e8..ece6975 100644
--- a/DemoApplication/Page3Form.qml
+++ b/DemoApplication/pages/Page3.qml
@@ -1,61 +1,58 @@
import QtQuick 2.0
+
import CursorNavigation 1.0
+import "../controls"
Item {
+ width: parent.width
+ height: parent.height
+
FocusScope {
id: rootScope
+ anchors.fill: parent
Row {
+ anchors.centerIn: parent
spacing: 10
-
CNButton {
width: 100
height: 100
text: "alone!"
}
- Rectangle {
-
- width: 250
- height: 200
-
- Grid {
- spacing: 5
- columns: 2
- rows: 2
-
- CNButton {
- text: "b1"
- }
-
- CNButton {
- text: "b2 (default focus)"
- focus: true
- }
+ Grid {
+ columns: 2
+ rows: 2
+ spacing: 5
- CNButton {
- id: defaultButton
- text: "b3 (escape target)"
- }
+ CNButton {
+ text: "b1"
+ }
- CNButton {
- text: "b4"
- }
+ CNButton {
+ text: "b2 (default focus)"
+ focus: true
+ }
+ CNButton {
+ id: defaultButton
+ text: "b3 (escape target)"
}
+ CNButton {
+ text: "b4"
+ }
}
Rectangle {
-
width: 250
height: 200
border.width: 2
- border.color: "gray"
+ border.color: "grey"
FocusScope {
- CursorNavigation.acceptsCursor: true
anchors.fill: parent
+ CursorNavigation.acceptsCursor: true
CursorNavigation.escapeTarget: defaultButton
//redefine the controls for this scope
@@ -86,11 +83,11 @@ Item {
text: "sb4 (default focus)"
focus: true
}
-
}
}
-
}
}
+ //this seems to be the way to force focus on a newly opened dialog?
+ Component.onCompleted: { forceActiveFocus(); }
}
}
diff --git a/DemoApplication/qml.qrc b/DemoApplication/qml.qrc
deleted file mode 100644
index 058589b..0000000
--- a/DemoApplication/qml.qrc
+++ /dev/null
@@ -1,11 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>main.qml</file>
- <file>HomeForm.qml</file>
- <file>Page1Form.qml</file>
- <file>Page2Form.qml</file>
- <file>qtquickcontrols2.conf</file>
- <file>CNButton.qml</file>
- <file>Page3Form.qml</file>
- </qresource>
-</RCC>
diff --git a/DemoApplication/qtquickcontrols2.conf b/DemoApplication/qtquickcontrols2.conf
deleted file mode 100644
index 75b2cb8..0000000
--- a/DemoApplication/qtquickcontrols2.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-; This file can be edited to change the style of the application
-; Read "Qt Quick Controls 2 Configuration File" for details:
-; http://doc.qt.io/qt-5/qtquickcontrols2-configuration.html
-
-[Controls]
-Style=Default
diff --git a/DemoApplication/main.cpp b/DemoApplication/src/main.cpp
index 0635536..b8b24cb 100644
--- a/DemoApplication/main.cpp
+++ b/DemoApplication/src/main.cpp
@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ engine.load(QUrl(QStringLiteral("main.qml")));
if (engine.rootObjects().isEmpty())
return -1;