From 365706e43a2e0020d817e8626313742c772c15f1 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 8 Jun 2022 12:06:44 -0400 Subject: [PATCH] Add placeholder for future QML interface, change startup options --- CMakeLists.txt | 10 +++++++--- include/tabletinterface.h | 17 +++++++++++++++++ qml/main.qml | 19 +++++++++++++++++++ qml/qml.qrc | 5 +++++ src/main.cpp | 20 ++++++++++++++------ src/tabletinterface.cpp | 7 +++++++ 6 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 include/tabletinterface.h create mode 100644 qml/main.qml create mode 100644 qml/qml.qrc create mode 100644 src/tabletinterface.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 445f963..c4e0673 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 3.0) project(Astra) set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) -find_package(Qt5 COMPONENTS Core Widgets Network CONFIG REQUIRED) +find_package(Qt5 COMPONENTS Core Widgets Network Quick CONFIG REQUIRED) option(ENABLE_WATCHDOG "Build with Tesseract support (needed for Watchdog)" OFF) option(USE_OWN_LIBRARIES "Build with own libraries" OFF) @@ -44,7 +45,10 @@ set(SRC include/desktopinterface.h include/cmdinterface.h src/cmdinterface.cpp - src/desktopinterface.cpp) + src/desktopinterface.cpp + include/tabletinterface.h + src/tabletinterface.cpp + qml/qml.qrc) include(FetchContent) @@ -130,7 +134,7 @@ endif() add_subdirectory(external) set(LIBRARIES - Qt5::Core Qt5::Widgets Qt5::Network ${LIBRARIES}) + Qt5::Core Qt5::Widgets Qt5::Network Qt5::Quick ${LIBRARIES}) if(ENABLE_WATCHDOG) set(LIBRARIES ${LIBRARIES} ${TESSERACT_LIBRARIES} ${LEPTONICA_LIBRARIES}) diff --git a/include/tabletinterface.h b/include/tabletinterface.h new file mode 100644 index 0000000..e8f5187 --- /dev/null +++ b/include/tabletinterface.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +#include "launchercore.h" + +/* + * The tablet-oriented (name to change), touch and gamepad-driven interface for Astra. The interface is + * simpler due to size constraints. + */ +class TabletInterface { +public: + TabletInterface(LauncherCore& core); + +private: + QQmlApplicationEngine* applicationEngine = nullptr; +}; \ No newline at end of file diff --git a/qml/main.qml b/qml/main.qml new file mode 100644 index 0000000..4f8ab63 --- /dev/null +++ b/qml/main.qml @@ -0,0 +1,19 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.1 +import QtQuick.Window 2.0 + +ApplicationWindow { + id: window + + width: 640 + height: 480 + + visible: true + + Label { + text: "Hello, world!" + + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } +} \ No newline at end of file diff --git a/qml/qml.qrc b/qml/qml.qrc new file mode 100644 index 0000000..dc7d52f --- /dev/null +++ b/qml/qml.qrc @@ -0,0 +1,5 @@ + + + main.qml + + \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index a5d3523..8290d80 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,7 @@ #include "config.h" #include "desktopinterface.h" #include "cmdinterface.h" +#include "tabletinterface.h" int main(int argc, char* argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); @@ -38,8 +39,14 @@ int main(int argc, char* argv[]) { auto helpOption = parser.addHelpOption(); auto versionOption = parser.addVersionOption(); - QCommandLineOption noguiOption("nogui", "Don't open a main window."); - parser.addOption(noguiOption); + QCommandLineOption desktopOption("desktop", "Open a desktop interface."); + parser.addOption(desktopOption); + + QCommandLineOption tabletOption("tablet", "Open a tablet interface."); + parser.addOption(tabletOption); + + QCommandLineOption cliOption("cli", "Don't open a main window, and use the cli interface."); + parser.addOption(cliOption); auto cmd = new CMDInterface(parser); @@ -54,12 +61,13 @@ int main(int argc, char* argv[]) { } LauncherCore c; - LauncherWindow w(c); - if(!parser.isSet(noguiOption)) { - new DesktopInterface(c); - } else { + if(parser.isSet(tabletOption)) { + new TabletInterface(c); + } else if(parser.isSet(cliOption)) { if(!cmd->parse(parser, c)) return -1; + } else { + new DesktopInterface(c); } return app.exec(); diff --git a/src/tabletinterface.cpp b/src/tabletinterface.cpp new file mode 100644 index 0000000..185c4db --- /dev/null +++ b/src/tabletinterface.cpp @@ -0,0 +1,7 @@ +#include "tabletinterface.h" + +TabletInterface::TabletInterface(LauncherCore &core) { + applicationEngine = new QQmlApplicationEngine(); + + applicationEngine->load("qrc:/main.qml"); +}