diff options
-rw-r--r-- | .clang-format | 51 | ||||
-rw-r--r-- | .clang-tidy | 0 | ||||
-rw-r--r-- | CMakeLists.txt | 30 | ||||
-rw-r--r-- | qml/MainWindow.qml (renamed from source/qml/main.qml) | 0 | ||||
-rw-r--r-- | source/main.cpp | 31 | ||||
-rw-r--r-- | src/QCplt/Qml/NodeCanvas.cpp | 1 | ||||
-rw-r--r-- | src/QCplt/Qml/NodeCanvas.hpp | 1 | ||||
-rw-r--r-- | src/QCplt/Qml/README.md | 1 | ||||
-rw-r--r-- | src/main.cpp | 35 |
9 files changed, 109 insertions, 41 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3290fe2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,51 @@ +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignOperands: false +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowAllArgumentsOnNextLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterClass: true + AfterControlStatement: MultiLine + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +ColumnLimit: 0 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +IncludeCategories: + - Regex: '".*"' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 + - Regex: '^<.*' + Priority: 3 +IndentCaseLabels: true +IndentPPDirectives: AfterHash +IndentWidth: 4 +NamespaceIndentation: Inner +PointerAlignment: Left +TabWidth: 4 +UseTab: Always diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.clang-tidy diff --git a/CMakeLists.txt b/CMakeLists.txt index 07d4d08..8f217ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.16) - project(QCplt VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) @@ -8,17 +7,23 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 6.2 COMPONENTS Quick REQUIRED) -qt_add_executable(AppQCplt - source/main.cpp +file(GLOB_RECURSE appQCplt_SRC_HPP_FILES src/*.hpp) +file(GLOB_RECURSE appQCplt_SRC_CPP_FILES src/*.cpp) +qt_add_executable(appQCplt + ${appQCplt_SRC_HPP_FILES} + ${appQCplt_SRC_CPP_FILES} ) -qt_add_qml_module(AppQCplt +file(GLOB_RECURSE appQCplt_QML_CPPMODULE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/QCplt/Qml/*.hpp src/QCplt/Qml/*.cpp) +file(GLOB_RECURSE appQCplt_QML_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} qml/*.qml) +qt_add_qml_module(appQCplt URI QCplt VERSION 1.0 - QML_FILES source/qml/main.qml + SOURCES ${appQCplt_QML_CPPMODULE_FILES} + QML_FILES ${appQCplt_QML_FILES} ) -set_target_properties(AppQCplt PROPERTIES +set_target_properties(appQCplt PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER rtk0c.github.io MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} @@ -26,7 +31,12 @@ set_target_properties(AppQCplt PROPERTIES WIN32_EXECUTABLE TRUE ) -target_compile_definitions(AppQCplt - PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) -target_link_libraries(AppQCplt - PRIVATE Qt6::Quick) +target_include_directories(appQCplt PUBLIC src) +target_compile_definitions(appQCplt +PRIVATE + $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG> +) +target_link_libraries(appQCplt +PRIVATE + Qt6::Quick +) diff --git a/source/qml/main.qml b/qml/MainWindow.qml index 41424f8..41424f8 100644 --- a/source/qml/main.qml +++ b/qml/MainWindow.qml diff --git a/source/main.cpp b/source/main.cpp deleted file mode 100644 index 699e881..0000000 --- a/source/main.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include <QGuiApplication> -#include <QQmlApplicationEngine> - -#include <QLocale> -#include <QTranslator> - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - QTranslator translator; - const QStringList uiLanguages = QLocale::system().uiLanguages(); - for (const QString &locale : uiLanguages) { - const QString baseName = "qcplt_" + QLocale(locale).name(); - if (translator.load(":/i18n/" + baseName)) { - app.installTranslator(&translator); - break; - } - } - - QQmlApplicationEngine engine; - const QUrl url(u"qrc:/qcplt/main.qml"_qs); - QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, - &app, [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) - QCoreApplication::exit(-1); - }, Qt::QueuedConnection); - engine.load(url); - - return app.exec(); -} diff --git a/src/QCplt/Qml/NodeCanvas.cpp b/src/QCplt/Qml/NodeCanvas.cpp new file mode 100644 index 0000000..4c53a5e --- /dev/null +++ b/src/QCplt/Qml/NodeCanvas.cpp @@ -0,0 +1 @@ +#include "NodeCanvas.hpp" diff --git a/src/QCplt/Qml/NodeCanvas.hpp b/src/QCplt/Qml/NodeCanvas.hpp new file mode 100644 index 0000000..6f70f09 --- /dev/null +++ b/src/QCplt/Qml/NodeCanvas.hpp @@ -0,0 +1 @@ +#pragma once diff --git a/src/QCplt/Qml/README.md b/src/QCplt/Qml/README.md new file mode 100644 index 0000000..379e257 --- /dev/null +++ b/src/QCplt/Qml/README.md @@ -0,0 +1 @@ +All .hpp and .cpp files in this folder are passed to Qt's buildsystem as QML source files, using CMake `file(GLOB_RECURSE)` diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..c8fb06f --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,35 @@ +#include <QGuiApplication> +#include <QQmlApplicationEngine> +#include <QLocale> +#include <QTranslator> + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + + QTranslator translator; + QStringList uiLanguages = QLocale::system().uiLanguages(); + for (const QString& locale : uiLanguages) { + const QString baseName = "qcplt_" + QLocale(locale).name(); + if (translator.load(":/i18n/" + baseName)) { + app.installTranslator(&translator); + break; + } + } + + QQmlApplicationEngine engine; + QUrl url(u"qrc:/QCplt/qml/MainWindow.qml"_qs); + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreated, + &app, + [url](QObject* obj, const QUrl& objUrl) { + if (!obj && url == objUrl) { + QCoreApplication::exit(-1); + } + }, + Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} |