From e625776302d15358ed37d602d6ef081d0d86fef7 Mon Sep 17 00:00:00 2001 From: John Janus Date: Tue, 14 Aug 2018 23:13:17 +0200 Subject: [PATCH] project definition good, view files created --- .gitignore | 3 +- cm-lib/cm-lib.pro | 12 +++++ cm-lib/src/controllers/master-controller.h | 3 ++ cm-tests/cm-tests.pro | 13 +++++ cm-ui/cm-ui.pro | 15 +++++- cm-ui/src/main.cpp | 5 ++ cm-ui/views.qrc | 5 ++ cm-ui/views/CreateClientView.qml | 5 ++ cm-ui/views/DashboardView.qml | 5 ++ cm-ui/views/EditClientView.qml | 5 ++ cm-ui/views/FindClientView.qml | 5 ++ cm-ui/views/MasterView.qml | 6 ++- cm-ui/views/SplashView.qml | 5 ++ learnqt-cm.pro | 2 + qmake-destination-path.pri | 45 +++++++++++++++++ qmake-target-platform.pri | 57 ++++++++++++++++++++++ 16 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 cm-ui/views/CreateClientView.qml create mode 100644 cm-ui/views/DashboardView.qml create mode 100644 cm-ui/views/EditClientView.qml create mode 100644 cm-ui/views/FindClientView.qml create mode 100644 cm-ui/views/SplashView.qml create mode 100644 qmake-destination-path.pri create mode 100644 qmake-target-platform.pri diff --git a/.gitignore b/.gitignore index 444078f..122c233 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pro.user - +binaries/ +build/ diff --git a/cm-lib/cm-lib.pro b/cm-lib/cm-lib.pro index f49eda2..e7987f6 100644 --- a/cm-lib/cm-lib.pro +++ b/cm-lib/cm-lib.pro @@ -4,6 +4,9 @@ # #------------------------------------------------- +include(../qmake-target-platform.pri) +include(../qmake-destination-path.pri) + QT -= gui TARGET = cm-lib @@ -39,3 +42,12 @@ unix { target.path = /usr/lib INSTALLS += target } + +DESTDIR = $$PWD/../binaries/$$DESTINATION_PATH +OBJECTS_DIR = $$PWD/build/$$DESTINATION_PATH/.obj +MOC_DIR = $$PWD/build/$$DESTINATION_PATH/.moc +RCC_DIR = $$PWD/build/$$DESTINATION_PATH/.qrc +UI_DIR = $$PWD/build/$$DESTINATION_PATH/.ui + +message(cm-lib output dir: $${DESTDIR}) +message(cm-lib project dir: $${PWD}) diff --git a/cm-lib/src/controllers/master-controller.h b/cm-lib/src/controllers/master-controller.h index 52a2f6c..791dc5c 100644 --- a/cm-lib/src/controllers/master-controller.h +++ b/cm-lib/src/controllers/master-controller.h @@ -2,6 +2,7 @@ #define MASTERCONTROLLER_H #include +#include #include @@ -10,8 +11,10 @@ namespace cm::controllers { class CMLIBSHARED_EXPORT MasterController : public QObject { Q_OBJECT + Q_PROPERTY(QString ui_welcomeMessage MEMBER welcomeMessage CONSTANT) public: explicit MasterController(QObject *parent = nullptr); + QString welcomeMessage = "This is MasterController to Major Tom"; signals: diff --git a/cm-tests/cm-tests.pro b/cm-tests/cm-tests.pro index 4b775be..4f90cb8 100644 --- a/cm-tests/cm-tests.pro +++ b/cm-tests/cm-tests.pro @@ -4,6 +4,9 @@ # #------------------------------------------------- +include(../qmake-target-platform.pri) +include(../qmake-destination-path.pri) + QT += testlib QT -= gui @@ -31,4 +34,14 @@ INCLUDEPATH += src SOURCES += \ src/models/client-tests.cpp +LIBS += -L$$PWD/../binaries/$$DESTINATION_PATH -lcm-lib + + DEFINES += SRCDIR=\\\"$$PWD/\\\" + +DESTDIR = $$PWD/../binaries/$$DESTINATION_PATH +OBJECTS_DIR = $$PWD/build/$$DESTINATION_PATH/.obj +MOC_DIR = $$PWD/build/$$DESTINATION_PATH/.moc +RCC_DIR = $$PWD/build/$$DESTINATION_PATH/.qrc +UI_DIR = $$PWD/build/$$DESTINATION_PATH/.ui + diff --git a/cm-ui/cm-ui.pro b/cm-ui/cm-ui.pro index e10d5fe..bc98612 100644 --- a/cm-ui/cm-ui.pro +++ b/cm-ui/cm-ui.pro @@ -1,3 +1,6 @@ +include(../qmake-target-platform.pri) +include(../qmake-destination-path.pri) + QT += qml quick CONFIG += c++17 @@ -12,12 +15,15 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -INCLUDEPATH += src +INCLUDEPATH += src \ + ../cm-lib/src SOURCES += src/main.cpp RESOURCES += views.qrc +LIBS += -L$$PWD/../binaries/$$DESTINATION_PATH -lcm-lib + # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = $$PWD @@ -28,3 +34,10 @@ QML_DESIGNER_IMPORT_PATH = qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target + +DESTDIR = $$PWD/../binaries/$$DESTINATION_PATH +OBJECTS_DIR = $$PWD/build/$$DESTINATION_PATH/.obj +MOC_DIR = $$PWD/build/$$DESTINATION_PATH/.moc +RCC_DIR = $$PWD/build/$$DESTINATION_PATH/.qrc +UI_DIR = $$PWD/build/$$DESTINATION_PATH/.ui + diff --git a/cm-ui/src/main.cpp b/cm-ui/src/main.cpp index 93604f7..e390e7e 100644 --- a/cm-ui/src/main.cpp +++ b/cm-ui/src/main.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include int main(int argc, char *argv[]) { @@ -8,8 +10,11 @@ int main(int argc, char *argv[]) #endif QGuiApplication app(argc, argv); + qmlRegisterType("CM", 1, 0, "MasterController"); + cm::controllers::MasterController masterController; QQmlApplicationEngine engine; + engine.rootContext()->setContextProperty("masterController", &masterController); engine.load(QUrl(QStringLiteral("qrc:/views/MasterView.qml"))); if (engine.rootObjects().isEmpty()) return -1; diff --git a/cm-ui/views.qrc b/cm-ui/views.qrc index 08d094a..260da15 100644 --- a/cm-ui/views.qrc +++ b/cm-ui/views.qrc @@ -1,5 +1,10 @@ views/MasterView.qml + views/SplashView.qml + views/DashboardView.qml + views/CreateClientView.qml + views/EditClientView.qml + views/FindClientView.qml diff --git a/cm-ui/views/CreateClientView.qml b/cm-ui/views/CreateClientView.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/cm-ui/views/CreateClientView.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/cm-ui/views/DashboardView.qml b/cm-ui/views/DashboardView.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/cm-ui/views/DashboardView.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/cm-ui/views/EditClientView.qml b/cm-ui/views/EditClientView.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/cm-ui/views/EditClientView.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/cm-ui/views/FindClientView.qml b/cm-ui/views/FindClientView.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/cm-ui/views/FindClientView.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/cm-ui/views/MasterView.qml b/cm-ui/views/MasterView.qml index a0fca36..efb366b 100644 --- a/cm-ui/views/MasterView.qml +++ b/cm-ui/views/MasterView.qml @@ -5,5 +5,9 @@ Window { visible: true width: 640 height: 480 - title: qsTr("Hello World") + title: qsTr("Client Management") + + Text { + text: masterController.ui_welcomeMessage + } } diff --git a/cm-ui/views/SplashView.qml b/cm-ui/views/SplashView.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/cm-ui/views/SplashView.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/learnqt-cm.pro b/learnqt-cm.pro index d5d407e..b0ddb3a 100644 --- a/learnqt-cm.pro +++ b/learnqt-cm.pro @@ -4,3 +4,5 @@ SUBDIRS += \ cm-ui \ cm-lib \ cm-tests + +message(cm project dir: $${PWD}) diff --git a/qmake-destination-path.pri b/qmake-destination-path.pri new file mode 100644 index 0000000..9d942d6 --- /dev/null +++ b/qmake-destination-path.pri @@ -0,0 +1,45 @@ +platform_path = unknown-platform +compiler_path = unknown-compiler +processor_path = unknown-processor +build_path = unknown-build + +PLATFORM_WIN { + platform_path = windows +} + +PLATFORM_OSX { + platform_path = osx +} + +PLATFORM_LINUX { + platform_path = linux +} + +COMPILER_GCC { + compiler_path = gcc +} + +COMPILER_MSVC2017 { + compiler_path = msvc2017 +} + +COMPILER_CLANG { + compiler_path = clang +} + +PROCESSOR_x64 { + processor_path = x64 +} + +PROCESSOR_x86 { + processor_path = x86 +} + +BUILD_DEBUG { + build_path = debug +} else { + build_path = release +} +DESTINATION_PATH = $$platform_path/$$compiler_path/$$processor_path/$$build_path + +message(Dest path: $${DESTINATION_PATH}) diff --git a/qmake-target-platform.pri b/qmake-target-platform.pri new file mode 100644 index 0000000..b3aeba2 --- /dev/null +++ b/qmake-target-platform.pri @@ -0,0 +1,57 @@ +win32 { + CONFIG += PLATFORM_WIN + message(PLATFORM_WIN) + win32-g++ { + CONFIG += COMPILER_GCC + message(COMPILER_GCC) + } + win32-msvc2017 { + CONFIG += COMPILER_MSVC2017 + message(COMPILER_MSVC2017) + win32-msvc2017:QMAKE_TARGET.arch = x86_64 + } +} + +linux { + CONFIG += PLATFORM_LINUX + message(PLATFORM_LINUX) + # Make QMAKE_TARGET arch available for Linux + !contains(QT_ARCH, x86_64){ + QMAKE_TARGET.arch = x86 + } else { + QMAKE_TARGET.arch = x86_64 + } + linux-g++{ + CONFIG += COMPILER_GCC + message(COMPILER_GCC) + } +} + +macx { + CONFIG += PLATFORM_OSX + message(PLATFORM_OSX) + macx-clang { + CONFIG += COMPILER_CLANG + message(COMPILER_CLANG) + QMAKE_TARGET.arch = x86_64 + } + macx-clang-32{ + CONFIG += COMPILER_CLANG + message(COMPILER_CLANG) + QMAKE_TARGET.arch = x86 + } +} +contains(QMAKE_TARGET.arch, x86_64) { + CONFIG += PROCESSOR_x64 + message(PROCESSOR_x64) +} else { + CONFIG += PROCESSOR_x86 + message(PROCESSOR_x86) +} +CONFIG(debug, release|debug) { + CONFIG += BUILD_DEBUG + message(BUILD_DEBUG) +} else { + CONFIG += BUILD_RELEASE + message(BUILD_RELEASE) +} -- 2.47.1