1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-23 12:57:45 +00:00

Add placeholder for future QML interface, change startup options

This commit is contained in:
Joshua Goins 2022-06-08 12:06:44 -04:00
parent 5307304c57
commit 365706e43a
6 changed files with 69 additions and 9 deletions

View file

@ -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})

17
include/tabletinterface.h Normal file
View file

@ -0,0 +1,17 @@
#pragma once
#include <QQmlApplicationEngine>
#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;
};

19
qml/main.qml Normal file
View file

@ -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
}
}

5
qml/qml.qrc Normal file
View file

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View file

@ -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();

7
src/tabletinterface.cpp Normal file
View file

@ -0,0 +1,7 @@
#include "tabletinterface.h"
TabletInterface::TabletInterface(LauncherCore &core) {
applicationEngine = new QQmlApplicationEngine();
applicationEngine->load("qrc:/main.qml");
}