From 8d4c076acf4cbcf1d2683c21f4b3a740ab68391c Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 29 Nov 2023 11:56:23 +0100 Subject: [PATCH] Trying to use singleton in Gallery app on Android --- gallery/CMakeLists.txt | 17 ++++++++++++++ gallery/hotreload.cpp | 10 ++++----- gallery/qml.qrc | 28 ----------------------- gallery/qml/pages/ToolbarPage.qml | 4 ++-- gallery/qmlV2/CMakeLists.txt | 37 +++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 35 deletions(-) create mode 100644 gallery/qmlV2/CMakeLists.txt diff --git a/gallery/CMakeLists.txt b/gallery/CMakeLists.txt index 634927f10..2cff81a0b 100644 --- a/gallery/CMakeLists.txt +++ b/gallery/CMakeLists.txt @@ -65,6 +65,23 @@ qt_add_qml_module( qml.qrc ) +add_subdirectory(qmlV2) +set_source_files_properties(qmlV2/StyleV2.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE) + +set(MM_QMLV2_SRCS) +foreach (src ${MM_QMLV2}) + set(MM_QMLV2_SRCS ${MM_QMLV2_SRCS} qmlV2/${src}) + set_source_files_properties(qmlV2/${src} PROPERTIES QT_RESOURCE_ALIAS ${src}) +endforeach () + +qt_add_qml_module( + MerginMapsGallery + URI mmqmlv2 + VERSION 1.0 + QML_FILES ${MM_QMLV2_SRCS} + RESOURCE_PREFIX /com.merginmaps/imports NO_GENERATE_QMLTYPES +) + qt_add_resources(fonts.qrc) set_target_properties( diff --git a/gallery/hotreload.cpp b/gallery/hotreload.cpp index 25ae73402..54a67df22 100644 --- a/gallery/hotreload.cpp +++ b/gallery/hotreload.cpp @@ -21,7 +21,7 @@ QString HotReload::syncScript() const echo running hot reload sync directories ... \n\ while true; do \n\ rsync -ra ../../../../gallery/qml/ HotReload/qml/ \n\ - rsync -ra ../../../../app/qmlV2/ HotReload/app/qmlV2/ \n\ + rsync -ra ../../../../qmlV2/ HotReload/qmlV2/ \n\ sleep 1 \n\ done"; } @@ -32,8 +32,8 @@ HotReload::HotReload( QQmlApplicationEngine &engine, QObject *parent ): // create dirs for sync (near the app) if ( !QDir( "HotReload/qml/" ).exists() ) QDir().mkpath( QGuiApplication::applicationDirPath() + "/HotReload/qml/" ); - if ( !QDir( "HotReload/app/qmlV2/" ).exists() ) - QDir().mkpath( QGuiApplication::applicationDirPath() + "/HotReload/app/qmlV2/" ); + if ( !QDir( "HotReload/qmlV2/" ).exists() ) + QDir().mkpath( QGuiApplication::applicationDirPath() + "/HotReload/qmlV2/" ); // create runnable sync script (near the app) QString scriptFilename = QGuiApplication::applicationDirPath() + "/syncGallery.sh"; @@ -69,8 +69,8 @@ void HotReload::startHotReload() { _watcher = new QFileSystemWatcher( this ); _watcher->addPath( "HotReload/qml/Pages" ); - _watcher->addPath( "HotReload/app/qmlV2" ); - _watcher->addPath( "HotReload/app/qmlV2/component" ); + _watcher->addPath( "HotReload/qmlV2" ); + _watcher->addPath( "HotReload/qmlV2/component" ); // send signal for hot reloading connect( _watcher, &QFileSystemWatcher::directoryChanged, this, [this]( const QString & path ) diff --git a/gallery/qml.qrc b/gallery/qml.qrc index 5c78a5d05..c37073fd5 100644 --- a/gallery/qml.qrc +++ b/gallery/qml.qrc @@ -4,40 +4,12 @@ qml/pages/InitialGalleryPage.qml qml/pages/InputsPage.qml qml/pages/ButtonsPage.qml - ../app/qmlV2/component/MMInput.qml - ../app/qmlV2/StyleV2.qml - ../app/qmlV2/component/MMButton.qml - ../app/qmlV2/component/MMLinkButton.qml - ../app/qmlV2/component/MMLink.qml - ../app/qmlV2/component/MMIcon.qml - ../app/qmlV2/component/MMRoundButton.qml - ../app/qmlV2/component/MMRoundLinkButton.qml qml/pages/TextAreaPage.qml - ../app/qmlV2/component/MMTextArea.qml qml/pages/ComboBoxPage.qml - ../app/qmlV2/component/MMComboBox.qml - ../app/qmlV2/component/MMCheckBox.qml - ../app/qmlV2/component/MMRadioButton.qml - ../app/qmlV2/component/MMSwitch.qml qml/pages/NotificationPage.qml - ../app/qmlV2/component/MMNotification.qml - ../app/qmlV2/component/MMNotificationView.qml - ../app/qmlV2/component/MMDrawer.qml qml/pages/DrawerPage.qml qml/pages/ChecksPage.qml - ../app/qmlV2/component/MMComponent_reachedDataLimit.qml - ../app/qmlV2/component/MMProgressBar.qml qml/pages/MapPage.qml - ../app/qmlV2/component/MMMapButton.qml - ../app/qmlV2/component/MMShadow.qml - ../app/qmlV2/component/MMMapLabel.qml - ../app/qmlV2/component/MMPasswordInput.qml - ../app/qmlV2/component/MMButtonInput.qml - ../app/qmlV2/component/MMToolbarButton.qml - ../app/qmlV2/component/MMToolbar.qml qml/pages/ToolbarPage.qml - ../app/qmlV2/component/MMMenuDrawer.qml - ../app/qmlV2/component/MMToolbarMenuButton.qml - ../app/qmlV2/component/MMToolbarLongButton.qml diff --git a/gallery/qml/pages/ToolbarPage.qml b/gallery/qml/pages/ToolbarPage.qml index f0ad0a502..20c4fbb8a 100644 --- a/gallery/qml/pages/ToolbarPage.qml +++ b/gallery/qml/pages/ToolbarPage.qml @@ -10,8 +10,8 @@ import QtQuick import QtQuick.Controls -import "../../app/qmlV2/component" -import "../../app/qmlV2/" +import "qmlV2/component" +import "qmlV2" Page { id: pane diff --git a/gallery/qmlV2/CMakeLists.txt b/gallery/qmlV2/CMakeLists.txt new file mode 100644 index 000000000..a57ea7f22 --- /dev/null +++ b/gallery/qmlV2/CMakeLists.txt @@ -0,0 +1,37 @@ +set(MM_QMLV2 + StyleV2.qml + component/MMButtonInput.qml + component/MMMenuDrawer.qml + component/MMRoundLinkButton.qml + component/MMNumberInput.qml + component/MMMapScaleLabel.qml + component/MMNotification.qml + component/MMTextArea.qml + component/MMCheckBox.qml + component/MMLabel.qml + component/MMRoundButton.qml + component/MMRadioButton.qml + component/MMDrawer.qml + component/MMMapButton.qml + component/MMLink.qml + component/MMToolbarLongButton.qml + component/MMToolbar.qml + component/map/MMPositionMarker.qml + component/MMSwitch.qml + component/MMLinkButton.qml + component/MMProgressBar.qml + component/MMMapLabel.qml + component/MMIcon.qml + component/MMToolbarMenuButton.qml + component/MMToolbarButton.qml + component/MMPasswordInput.qml + component/MMButton.qml + component/MMIconInputEditor.qml + component/MMComponent_reachedDataLimit.qml + component/MMNotificationView.qml + component/MMComboBox.qml + component/MMInput.qml + component/MMSliderInput.qml + component/MMShadow.qml + PARENT_SCOPE +)