From 49b2c035ad301c389526e7b8a159cc790c9afbfa Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Sat, 14 Dec 2024 01:19:20 +0100 Subject: [PATCH] Add skeleton for a QML application --- .gitignore | 3 +++ CMakeLists.txt | 16 ++++++++++++++++ src/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ src/Main.qml | 9 +++++++++ src/main.cpp | 21 +++++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/Main.qml create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore index 3e494a9..ce06f87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ /.idea/ +/build/ /locale/ /po/*.pot /demo.sql +CMakeLists.txt.user* +.qmlls.ini diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fecbfc5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.16) + +project(camper VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Qt6 REQUIRED COMPONENTS + Quick + QuickControls2 +) + +qt_standard_project_setup(REQUIRES 6.5) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..1522f1b --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,31 @@ +qt_add_executable(${PROJECT_NAME} + main.cpp +) + +qt_add_qml_module(${PROJECT_NAME} + URI Camper + VERSION 1.0 + DEPENDENCIES QtCore + QML_FILES + Main.qml +) + +set_target_properties(${PROJECT_NAME} PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER ws.tandem.${PROJECT_NAME} + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE Qt6::Quick + PRIVATE Qt6::QuickControls2 +) + +include(GNUInstallDirs) +install(TARGETS ${PROJECT_NAME} + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/src/Main.qml b/src/Main.qml new file mode 100644 index 0000000..53feddc --- /dev/null +++ b/src/Main.qml @@ -0,0 +1,9 @@ +import QtQuick +import QtQuick.Controls + +ApplicationWindow { + height: 480 + title: qsTr("Camper") + visible: true + width: 640 +} diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..abd3739 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,21 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication::setApplicationName("Camper"); + QCoreApplication::setOrganizationName("Tandem"); + + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreationFailed, + &app, + []() { QCoreApplication::exit(-1); }, + Qt::QueuedConnection); + engine.loadFromModule("Camper", "Main"); + + return app.exec(); +}