From d152eb52d7a64d228729ab466b9b032af1e527e4 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Wed, 15 Aug 2018 17:06:32 -0400 Subject: [PATCH] Experiment with Qt Quick 2 controls. --- Menu.qml | 15 +++++++++++++-- MenuButton.qml | 9 +++++++-- justcheckers.pro | 4 +++- main.qml | 5 +++-- qml.qrc | 1 + qtquickcontrols2.conf | 9 +++++++++ 6 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 qtquickcontrols2.conf diff --git a/Menu.qml b/Menu.qml index 7b4bc83..1923fc7 100644 --- a/Menu.qml +++ b/Menu.qml @@ -1,5 +1,7 @@ import QtQuick 2.0 import QtMultimedia 5.8 +import QtQuick.Controls 2.2 +import QtQuick.Controls.Material 2.2 Rectangle { anchors.fill: parent @@ -43,12 +45,12 @@ Rectangle { MenuButton { buttonText: "Open Game" -// disabled: true + enabled: false } MenuButton { buttonText: "Save Game" -// disabled: true + enabled: false function actionOnClick() { pingSound.seek(0) pingSound.play() @@ -70,6 +72,15 @@ Rectangle { buttonText: "Settings" } + Button { + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 50 + height: parent.parent.height * 0.1 + text: "Quit" + onPressed: Qt.quit() + Material.accent: Material.Orange + } + MenuButton { buttonText: "Quit" function actionOnClick() { diff --git a/MenuButton.qml b/MenuButton.qml index dcc3699..975252c 100644 --- a/MenuButton.qml +++ b/MenuButton.qml @@ -6,8 +6,8 @@ Rectangle { property color backgroundAtRest: "#9e9e9e" property color backgroundActive: "#555555" - property string buttonText: "Button" + property bool enabled: true function actionOnClick() { } @@ -17,7 +17,12 @@ Rectangle { height: parent.parent.height * 0.1 radius: 10 - color: backgroundAtRest + color: { + if (enabled) + backgroundActive + else + backgroundAtRest + } border.color: "#333333" border.width: 2 diff --git a/justcheckers.pro b/justcheckers.pro index 00d8da3..5b1c45e 100644 --- a/justcheckers.pro +++ b/justcheckers.pro @@ -1,4 +1,4 @@ -QT += quick multimedia multimediawidgets +QT += quick multimedia multimediawidgets svg quickcontrols2 CONFIG += c++11 # The following define makes your compiler emit warnings if you use @@ -22,6 +22,8 @@ QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = +QT_QUICK_CONTROLS_STYLE=universal + # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin diff --git a/main.qml b/main.qml index 978f0ef..bdd09f6 100644 --- a/main.qml +++ b/main.qml @@ -1,7 +1,8 @@ import QtQuick 2.9 -import QtQuick.Window 2.2 +import QtQuick.Controls 2.1 -Window { + +ApplicationWindow { id: mainWindow property var appVersion: "0.4.0" diff --git a/qml.qrc b/qml.qrc index 478ba79..f0b2469 100644 --- a/qml.qrc +++ b/qml.qrc @@ -16,5 +16,6 @@ images/splash.jpg MenuButton.qml assets/ping.wav + qtquickcontrols2.conf diff --git a/qtquickcontrols2.conf b/qtquickcontrols2.conf new file mode 100644 index 0000000..7a09e22 --- /dev/null +++ b/qtquickcontrols2.conf @@ -0,0 +1,9 @@ +[Controls] +Style=Material + +[Material] +Theme=Dark + +[Material\Font] +Family=Open Sans +PixelSize=32