]> git.basschouten.com Git - qthomecontrol.git/commitdiff
Revert "Downgrade to Qt5 for Pi0 compatibility."
authorBas Schouten <bas@basschouten.com>
Mon, 14 Aug 2023 20:22:59 +0000 (22:22 +0200)
committerBas Schouten <bas@basschouten.com>
Mon, 14 Aug 2023 20:22:59 +0000 (22:22 +0200)
This reverts commit a4f496d259796c277cf5abcd0d53c7fa10972d01.

CMakeLists.txt
main.cpp
main.qml
mqttinterface.h
qml.qrc [deleted file]

index 6f09178f5718b912b0a648dab45589065b145170..ff02d94715e8d985b04828925d71d27a8459ba8a 100644 (file)
@@ -1,53 +1,29 @@
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
 
-project(test VERSION 0.1 LANGUAGES CXX)
+project(qthomecontrol VERSION 0.1 LANGUAGES CXX)
 
-set(CMAKE_AUTOUIC ON)
 set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-
-set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
+find_package(Qt6 6.2 COMPONENTS Quick REQUIRED)
+
 if (UNIX)
     add_subdirectory ("paho.mqtt.c")
 endif(UNIX)
 
-find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick)
-find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick)
-
-set(PROJECT_SOURCES
-        main.cpp
-        qml.qrc
-        mqttinterface.cpp
-        mqttinterface.h
+qt_add_executable(appqthomecontrol
+    main.cpp
+    mqttinterface.cpp
+    mqttinterface.h
 )
 
-if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
-    qt_add_executable(appqthomecontrol
-        MANUAL_FINALIZATION
-        ${PROJECT_SOURCES}
-    )
-# Define target properties for Android with Qt 6 as:
-#    set_property(TARGET test APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
-#                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
-# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
-else()
-    if(ANDROID)
-        add_library(appqthomecontrol SHARED
-            ${PROJECT_SOURCES}
-        )
-# Define properties for Android with Qt 5 after find_package() calls as:
-#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
-    else()
-        add_executable(appqthomecontrol
-          ${PROJECT_SOURCES}
-        )
-    endif()
-endif()
-
-target_link_libraries(appqthomecontrol
-  PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick)
+qt_add_qml_module(appqthomecontrol
+    URI qthomecontrol
+    VERSION 1.0
+    QML_FILES main.qml 
+    SOURCES
+      mqttinterface.h mqttinterface.cpp
+)
 
 set_target_properties(appqthomecontrol PROPERTIES
     MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
@@ -59,6 +35,9 @@ set_target_properties(appqthomecontrol PROPERTIES
 
 target_include_directories (appqthomecontrol PRIVATE paho.mqtt.c/src)
 
+target_link_libraries(appqthomecontrol
+    PRIVATE Qt6::Quick)
+
 if (WIN32)
     target_link_libraries (appqthomecontrol PRIVATE ${CMAKE_SOURCE_DIR}/paho.mqtt.c/src/Release/paho-mqtt3a.lib ${CMAKE_SOURCE_DIR}/paho.mqtt.c/src/Release/paho-mqtt3c.lib)
 endif (WIN32)
@@ -69,8 +48,3 @@ endif(UNIX)
 install(TARGETS appqthomecontrol
     BUNDLE DESTINATION .
     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-
-if(QT_VERSION_MAJOR EQUAL 6)
-    qt_import_qml_plugins(qthomecontrol)
-    qt_finalize_executable(qthomecontrol)
-endif()
index 2124962813aaad56622593328566bf7cac020f9a..e4ddce2dfc9f8d6e15ec1b62bfcab8523c9fa068 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -1,19 +1,13 @@
 #include <QGuiApplication>
 #include <QQmlApplicationEngine>
 
-#include "mqttinterface.h"
 
 int main(int argc, char *argv[])
 {
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-#endif
     QGuiApplication app(argc, argv);
 
-    qmlRegisterType<MQTTInterface>("QtHomeControl", 1, 0, "MQTTInterface");
-
     QQmlApplicationEngine engine;
-    const QUrl url(QStringLiteral("qrc:/main.qml"));
+    const QUrl url(u"qrc:/qthomecontrol/main.qml"_qs);
     QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                      &app, [url](QObject *obj, const QUrl &objUrl) {
         if (!obj && url == objUrl)
index b761750c52869fb99f5e03cce0e4c8902d5a8e87..b5b938da869713f6d6946795828cebd9a7f4a132 100644 (file)
--- a/main.qml
+++ b/main.qml
@@ -1,6 +1,7 @@
-import QtQuick 2.15
-import QtQuick.Window 2.15
-import QtHomeControl 1.0
+import QtQuick
+import QtQuick.Controls 6.3
+import QtQuick.Layouts 6.3
+import qthomecontrol
 
 Window {
     width: 720
@@ -13,6 +14,22 @@ Window {
         id: mqttinterface
     }
 
+    Slider {
+        id: slider
+        x: 13
+        y: 534
+        width: 695
+        height: 178
+        live: true
+        antialiasing: false
+        topPadding: 0
+        orientation: Qt.Horizontal
+        snapMode: RangeSlider.SnapOnRelease
+        stepSize: 1
+        to: 100
+        value: 0
+    }
+
     Text {
         id: text1
         x: 206
index e2e4340f18d9083d373c715c1c91b183bdb4d0cd..1b54a9aafedf8bb341dbecf9ed09884521c234f2 100644 (file)
@@ -2,7 +2,7 @@
 #define MQTTINTERFACE_H
 
 #include <QObject>
-#include <qqml.h>
+#include <QtQml/qqmlregistration.h>
 #include <mutex>
 
 #include "MQTTClient.h"
diff --git a/qml.qrc b/qml.qrc
deleted file mode 100644 (file)
index 5f6483a..0000000
--- a/qml.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
-    <qresource prefix="/">
-        <file>main.qml</file>
-    </qresource>
-</RCC>