From 161f5681eee2fa32217c035173282ab71bf3097a Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Sun, 6 Mar 2016 21:33:37 +0100 Subject: [PATCH] Add empty QML app --- .gitignore | 3 +++ qt/MainForm.ui.qml | 23 ++++++++++++++++++++++ qt/deployment.pri | 13 ++++++++++++ qt/main.cpp | 12 ++++++++++++ qt/main.qml | 49 ++++++++++++++++++++++++++++++++++++++++++++++ qt/oboy.pro | 15 ++++++++++++++ qt/qml.qrc | 6 ++++++ 7 files changed, 121 insertions(+) create mode 100644 qt/MainForm.ui.qml create mode 100644 qt/deployment.pri create mode 100644 qt/main.cpp create mode 100644 qt/main.qml create mode 100644 qt/oboy.pro create mode 100644 qt/qml.qrc diff --git a/.gitignore b/.gitignore index 13acd80..368d237 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ _build # Game Boy *.gb + +# Qt +*.pro.user diff --git a/qt/MainForm.ui.qml b/qt/MainForm.ui.qml new file mode 100644 index 0000000..facbad8 --- /dev/null +++ b/qt/MainForm.ui.qml @@ -0,0 +1,23 @@ +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 + +Item { + + property alias button1: button1 + property alias button2: button2 + + RowLayout { + anchors.centerIn: parent + + Button { + id: button1 + text: qsTr("Open ROM...") + } + + Button { + id: button2 + text: qsTr("Press Me 2") + } + } +} diff --git a/qt/deployment.pri b/qt/deployment.pri new file mode 100644 index 0000000..265ce71 --- /dev/null +++ b/qt/deployment.pri @@ -0,0 +1,13 @@ +unix:!android { + isEmpty(target.path) { + qnx { + target.path = /tmp/$${TARGET}/bin + } else { + target.path = /opt/$${TARGET}/bin + } + export(target.path) + } + INSTALLS += target +} + +export(INSTALLS) diff --git a/qt/main.cpp b/qt/main.cpp new file mode 100644 index 0000000..1e5bf58 --- /dev/null +++ b/qt/main.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/qt/main.qml b/qt/main.qml new file mode 100644 index 0000000..bb57182 --- /dev/null +++ b/qt/main.qml @@ -0,0 +1,49 @@ +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Dialogs 1.2 + +ApplicationWindow { + visible: true + width: 256 + height: 128 + title: qsTr("OBoy") + + menuBar: MenuBar { + Menu { + title: qsTr("File") + MenuItem { + text: qsTr("&Open") + onTriggered: console.log("Open action triggered"); + } + MenuItem { + text: qsTr("Exit") + onTriggered: Qt.quit(); + } + } + + Menu { + title: qsTr("View") + MenuItem { + text: qsTr("Background maps") + onTriggered: console.log("Background maps"); + } + } + + } + + MainForm { + anchors.fill: parent + button1.onClicked: messageDialog.show(qsTr("Button 1 pressed")) + button2.onClicked: messageDialog.show(qsTr("Button 2 pressed")) + } + + MessageDialog { + id: messageDialog + title: qsTr("May I have your attention, please?") + + function show(caption) { + messageDialog.text = caption; + messageDialog.open(); + } + } +} diff --git a/qt/oboy.pro b/qt/oboy.pro new file mode 100644 index 0000000..0b0dfb7 --- /dev/null +++ b/qt/oboy.pro @@ -0,0 +1,15 @@ +TEMPLATE = app + +QT += qml quick widgets + +CONFIG += c++11 + +SOURCES += main.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Default rules for deployment. +include(deployment.pri) diff --git a/qt/qml.qrc b/qt/qml.qrc new file mode 100644 index 0000000..7684346 --- /dev/null +++ b/qt/qml.qrc @@ -0,0 +1,6 @@ + + + main.qml + MainForm.ui.qml + +