diff --git a/examples/thermo/CMakeLists.txt b/examples/thermo/CMakeLists.txt index 38551171b157834aee44f6986534ffc40673d74f..f5ec3d6a665507604ba55a64564a68f6de5ee659 100644 --- a/examples/thermo/CMakeLists.txt +++ b/examples/thermo/CMakeLists.txt @@ -1,289 +1,25 @@ -cmake_minimum_required (VERSION 3.15) +cmake_minimum_required (VERSION 3.21.1) project(thermo VERSION 0.0.1 LANGUAGES C CXX ASM) + if (NOT TARGET Qul::Core) find_package(Qul) endif() -qul_add_target(thermo_small) - -set(UNIT_SYSTEM "metric" CACHE STRING "Thermostat Demo Unit System") -set(FONT_ENGINE "Static" CACHE STRING "Thermostat Demo Font Engine") - -set(COMMON_QML_FILES - thermo.ui.qml TopBar.qml BottomBarButton.ui.qml BottomBar.qml PlacesDotIndicator.ui.qml - PlacesView.ui.qml Card.ui.qml CardRow.ui.qml PowerSwitch.qml - ScheduleView.ui.qml RoomSchedule.qml StatsView.ui.qml RoomView.qml RoomControlButton.qml - AnimatedDigit.qml WeatherStatus.qml ThermoView.qml StatsContents.ui.qml - TimeIntervalSlider.qml TimeIntervalSliderHandle.ui.qml FanControlButton.qml LanguageDialog.qml - LanguageButton.qml) -set(MODULE_QML_FILES - imports/Thermo/ColorStyle.qml - imports/Thermo/Rooms.qml - imports/Thermo/Room.qml) - -set(TRANSLATION_FILES - thermo.de_DE.ts - thermo.ja_JP.ts) -set(DEFAULT_FONT_FAMILY "Roboto") -set(FONT_FILES - NotoSansArabic-Regular.ttf - NotoSansJP-Regular.otf - NotoSansThai-Regular.ttf - Roboto-Regular.ttf -) -list(TRANSFORM FONT_FILES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/fonts/) - -qul_add_resource(thermo_small - PREFIX assets - BASE assets - FILES - assets/qt-logo.png - assets/JAPAN.png - assets/temp-down-pressed.png - assets/switch-handle.png - assets/popup-bg.png - assets/scrollbar-temperature-track.png - assets/radiobutton-checked-pressed.png - assets/digitMaskBottom.png - assets/switch-i.png - assets/btn-bg-big-on.png - assets/radiobutton-pressed.png - assets/pressed-bg-up.png - assets/selected.png - assets/eco-on.png - assets/streamer-on-small.png - assets/page-indicator.png - assets/jog-off.png - assets/status-small.png - assets/dryer-on-small.png - assets/dryer-on.png - assets/close.png - assets/auto-card.png - assets/toggle-year.png - assets/eco-on-small.png - assets/separator-line.png - assets/radiobutton-checked.png - assets/streamer-on.png - assets/btn-bg-down.png - assets/slider-handle.png - assets/thermo-handle.png - assets/switch-bg.png - assets/pressed-bg-down.png - assets/auto-on.png - assets/place-back.png - assets/UK.png - assets/radiobutton.png - assets/baseline-arrow-back.png - assets/digitMaskTop.png - assets/switch-o.png - assets/power-on.png - assets/temp-up-pressed.png - assets/btn-bg-big-off.png - assets/toggle-month.png - assets/jog.png - assets/GERMANY.png - assets/change-language.png - assets/scrollbar-off-track.png - assets/weather/w_06.png - assets/weather/w_01.png - assets/weather/w_02.png - assets/weather/w_07.png - assets/weather/w_05.png - assets/weather/w_04.png - assets/weather/w_03.png - assets/stats-month.png - assets/stats-year.png -) - -qul_add_resource(thermo_small - FILES - images/inner-circle.png - images/card-back-topleft.png - images/card-back-bottomleft.png - images/card-back-topright.png - images/card-back-bottomright.png -) - -qul_add_resource(thermo_small - PREFIX assets - BASE assets - FILES - assets/main-bg.png -) -list(APPEND COMMON_QML_FILES "BackgroundImage.ui.qml") - -qul_target_qml_sources(thermo_small ${COMMON_QML_FILES}) - -qul_add_qml_module(thermo_small_module - URI Thermo - QML_FILES - ${MODULE_QML_FILES} - imports/Thermo/Theme.qml - imports/Thermo/+${UNIT_SYSTEM}/Units.qml - OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_small_module -) -qul_add_resource(thermo_small_module - PREFIX assets - BASE assets - FILES - assets/fan-off.png - assets/fan-off-small.png - assets/fan-1-on.png - assets/fan-1-on-small.png - assets/fan-2-on.png - assets/fan-2-on-small.png - assets/fan-3-on.png - assets/fan-3-on-small.png - assets/fan-4-on.png - assets/fan-4-on-small.png -) - -set_target_properties(thermo_small - PROPERTIES - QUL_DEFAULT_FONT_FAMILY "${DEFAULT_FONT_FAMILY}" - QUL_FONT_ENGINE "${FONT_ENGINE}" - QUL_FONT_FILES "${FONT_FILES}" -) - -qul_add_qml_module(thermo_configuration_small_module - URI - ThermoConfiguration - QML_FILES - imports/ThermoConfiguration/Configuration.qml - OUTPUT_DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}/thermo_configuration_small_module -) - -qul_target_embed_translations(thermo_configuration_small_module ${TRANSLATION_FILES}) -qul_target_embed_translations(thermo_small_module ${TRANSLATION_FILES}) -qul_target_embed_translations(thermo_small ${TRANSLATION_FILES}) - -target_link_libraries(thermo_small PRIVATE thermo_configuration_small_module thermo_small_module Qul::ControlsTemplates) -app_target_setup_os(thermo_small) -app_target_default_entrypoint(thermo_small thermo) - -if(QUL_PLATFORM STREQUAL "qt") - qul_add_target(thermo_big) - - qul_add_resource(thermo_big - PREFIX assets - BASE assets/+big - FILES - assets/+big/qt-logo.png - assets/+big/JAPAN.png - assets/+big/temp-down-pressed.png - assets/+big/switch-handle.png - assets/+big/popup-bg.png - assets/+big/scrollbar-temperature-track.png - assets/+big/radiobutton-checked-pressed.png - assets/+big/digitMaskBottom.png - assets/+big/switch-i.png - assets/+big/btn-bg-big-on.png - assets/+big/radiobutton-pressed.png - assets/+big/pressed-bg-up.png - assets/+big/selected.png - assets/+big/eco-on.png - assets/+big/streamer-on-small.png - assets/+big/page-indicator.png - assets/+big/jog-off.png - assets/+big/status-small.png - assets/+big/dryer-on-small.png - assets/+big/dryer-on.png - assets/+big/close.png - assets/+big/auto-card.png - assets/+big/toggle-year.png - assets/+big/eco-on-small.png - assets/+big/separator-line.png - assets/+big/radiobutton-checked.png - assets/+big/streamer-on.png - assets/+big/radiobutton-disabled.png - assets/+big/btn-bg-down.png - assets/+big/slider-handle.png - assets/+big/thermo-handle.png - assets/+big/switch-bg.png - assets/+big/pressed-bg-down.png - assets/+big/main-bg.png - assets/+big/auto-on.png - assets/+big/place-back.png - assets/+big/UK.png - assets/+big/radiobutton.png - assets/+big/baseline-arrow-back.png - assets/+big/digitMaskTop.png - assets/+big/switch-o.png - assets/+big/power-on.png - assets/+big/temp-up-pressed.png - assets/+big/btn-bg-big-off.png - assets/+big/toggle-month.png - assets/+big/jog.png - assets/+big/GERMANY.png - assets/+big/change-language.png - assets/+big/scrollbar-off-track.png - assets/+big/weather/w_06.png - assets/+big/weather/w_01.png - assets/+big/weather/w_02.png - assets/+big/weather/w_07.png - assets/+big/weather/w_05.png - assets/+big/weather/w_04.png - assets/+big/weather/w_03.png - assets/+big/stats-month.png - assets/+big/stats-year.png - ) - - qul_add_resource(thermo_big - FILES - images/inner-circle.png - images/card-back-topleft.png - images/card-back-bottomleft.png - images/card-back-topright.png - images/card-back-bottomright.png - ) - - qul_target_qml_sources(thermo_big ${COMMON_QML_FILES} ${ADDITIONAL_QML_FILES_BIG}) - - qul_add_qml_module(thermo_big_module - URI Thermo - QML_FILES - ${MODULE_QML_FILES} - imports/Thermo/+big/Theme.qml - imports/Thermo/+${UNIT_SYSTEM}/Units.qml - OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_big_module - ) - qul_add_resource(thermo_big_module - PREFIX assets - BASE assets/+big - FILES - assets/+big/fan-off.png - assets/+big/fan-off-small.png - assets/+big/fan-1-on.png - assets/+big/fan-1-on-small.png - assets/+big/fan-2-on.png - assets/+big/fan-2-on-small.png - assets/+big/fan-3-on.png - assets/+big/fan-3-on-small.png - assets/+big/fan-4-on.png - assets/+big/fan-4-on-small.png - ) - - set_target_properties(thermo_big - PROPERTIES - QUL_DEFAULT_FONT_FAMILY "${DEFAULT_FONT_FAMILY}" - QUL_FONT_ENGINE "${FONT_ENGINE}" - QUL_FONT_FILES "${FONT_FILES}" - ) +if (Qul_VERSION LESS "2.4") + message(WARNING "The current Qt for MCUs version is '${Qul_VERSION}'." + "This CMake project was made for Qt for MCUs 2.4 and newer, " + "and might not work as expected.") +endif() - qul_add_qml_module(thermo_configuration_big_module - URI ThermoConfiguration - QML_FILES - imports/ThermoConfiguration/Configuration.qml - OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_configuration_big_module - ) +qul_add_target(thermo_small + QML_PROJECT thermo.qmlproject + GENERATE_ENTRYPOINT + SELECTORS metric) - qul_target_embed_translations(thermo_configuration_big_module ${TRANSLATION_FILES}) - qul_target_embed_translations(thermo_big_module ${TRANSLATION_FILES}) - qul_target_embed_translations(thermo_big ${TRANSLATION_FILES}) +qul_add_target(thermo_big + QML_PROJECT thermo.qmlproject + GENERATE_ENTRYPOINT + SELECTORS metric big) - target_link_libraries(thermo_big PRIVATE thermo_configuration_big_module thermo_big_module Qul::ControlsTemplates) - app_target_setup_os(thermo_big) - app_target_default_entrypoint(thermo_big thermo) -endif() +app_target_setup_os(thermo) diff --git a/examples/thermo/LanguageDialog.qml b/examples/thermo/LanguageDialog.qml index 8e357342e635d2cb7697e7d8e7f0729620c1e885..99a429134c54a9fa2577790249c4888b38377c94 100644 --- a/examples/thermo/LanguageDialog.qml +++ b/examples/thermo/LanguageDialog.qml @@ -126,7 +126,7 @@ Rectangle { id: english text: "English" flag: "assets/UK.png" - checked: Qt.uiLanguage == "" + checked: Qt.uiLanguage == "" || Qt.uiLanguage == "en-150" enabled: !checked Connections { diff --git a/examples/thermo/ScheduleView.ui.qml b/examples/thermo/ScheduleView.ui.qml index cda0e7dc865a35e47f6492bf40e06f7ce6d34adf..6c64debd1b6e4d82de9708a1d591e78422fc4880 100644 --- a/examples/thermo/ScheduleView.ui.qml +++ b/examples/thermo/ScheduleView.ui.qml @@ -95,8 +95,8 @@ ThermoView { Rectangle { id: scrollBar - y: -(roomList.height - scrollBar.height) * roomList.contentItem.y - / (roomList.contentItem.height - roomList.height) + y: Math.min(Math.max(0, -(roomList.height - scrollBar.height) * roomList.contentItem.y + / (roomList.contentItem.height - roomList.height)), roomList.height - scrollBar.height) anchors.horizontalCenter: separator.horizontalCenter implicitWidth: 4 implicitHeight: 30 diff --git a/examples/thermo/i18n/qml_de_DE.qm b/examples/thermo/i18n/qml_de_DE.qm new file mode 100644 index 0000000000000000000000000000000000000000..a7154649a3de20d2ce49bf85a10e22f9332b96de Binary files /dev/null and b/examples/thermo/i18n/qml_de_DE.qm differ diff --git a/examples/thermo/thermo.de_DE.ts b/examples/thermo/i18n/qml_de_DE.ts similarity index 97% rename from examples/thermo/thermo.de_DE.ts rename to examples/thermo/i18n/qml_de_DE.ts index 4ab857551256fa4692c7d9be8f70f564c8a82f10..a14aedeeade75c7272bd6cb28d084b8e701c2cf6 100644 --- a/examples/thermo/thermo.de_DE.ts +++ b/examples/thermo/i18n/qml_de_DE.ts @@ -17,7 +17,7 @@ </message> </context> <context> - <name>Card</name> + <name>Card.ui</name> <message> <source>Heating</source> <translation>Heizen</translation> @@ -100,7 +100,7 @@ </message> </context> <context> - <name>StatsContents</name> + <name>StatsContents.ui</name> <message> <source>Jan</source> <translation>Jan</translation> @@ -151,7 +151,7 @@ </message> </context> <context> - <name>StatsView</name> + <name>StatsView.ui</name> <message> <source>Month</source> <translation>Monat</translation> diff --git a/examples/thermo/i18n/qml_ja_JP.qm b/examples/thermo/i18n/qml_ja_JP.qm new file mode 100644 index 0000000000000000000000000000000000000000..0784a359cf5eeb8668f61c2298d09445eed0805f Binary files /dev/null and b/examples/thermo/i18n/qml_ja_JP.qm differ diff --git a/examples/thermo/thermo.ja_JP.ts b/examples/thermo/i18n/qml_ja_JP.ts similarity index 97% rename from examples/thermo/thermo.ja_JP.ts rename to examples/thermo/i18n/qml_ja_JP.ts index 9662c6d595e2e98ed73445fc9fcf28629263dc59..dca4de05f85614e070eab6f87c76db2130454d10 100644 --- a/examples/thermo/thermo.ja_JP.ts +++ b/examples/thermo/i18n/qml_ja_JP.ts @@ -17,7 +17,7 @@ </message> </context> <context> - <name>Card</name> + <name>Card.ui</name> <message> <source>Heating</source> <translation>暖房</translation> @@ -100,7 +100,7 @@ </message> </context> <context> - <name>StatsContents</name> + <name>StatsContents.ui</name> <message> <source>Jan</source> <translation>1月</translation> @@ -151,7 +151,7 @@ </message> </context> <context> - <name>StatsView</name> + <name>StatsView.ui</name> <message> <source>Month</source> <translation>月分</translation> diff --git a/examples/thermo/imports/Thermo/Thermo.qmlproject b/examples/thermo/imports/Thermo/Thermo.qmlproject new file mode 100644 index 0000000000000000000000000000000000000000..9f480f648e68cbf521b56441cb10078b0045afb6 --- /dev/null +++ b/examples/thermo/imports/Thermo/Thermo.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.3 + +Project { + MCU.Module { + uri: "Thermo" + } + QmlFiles { + files: [ + "ColorStyle.qml", + "Room.qml", + "Rooms.qml", + "Theme.qml", + "Units.qml" + ] + } +} diff --git a/examples/thermo/imports/ThermoConfiguration/ThermoConfiguration.qmlproject b/examples/thermo/imports/ThermoConfiguration/ThermoConfiguration.qmlproject new file mode 100644 index 0000000000000000000000000000000000000000..4fc73755666fd47396a0ab4e01a7b0e1a7cd9d39 --- /dev/null +++ b/examples/thermo/imports/ThermoConfiguration/ThermoConfiguration.qmlproject @@ -0,0 +1,12 @@ +import QmlProject 1.3 + +Project { + MCU.Module { + uri: "ThermoConfiguration" + } + QmlFiles { + files: [ + "Configuration.qml" + ] + } +} diff --git a/examples/thermo/thermo.qmlproject b/examples/thermo/thermo.qmlproject index 7250b7b1dd102a3da933c4093e777a32e92f4136..021116a73727d692bdb42b3ef7f3e504fc1988ff 100644 --- a/examples/thermo/thermo.qmlproject +++ b/examples/thermo/thermo.qmlproject @@ -1,62 +1,147 @@ /* File generated by Qt Creator */ -import QmlProject 1.1 +import QmlProject 1.3 Project { mainFile: "thermo.ui.qml" - /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { directory: "." } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." + files: [ + "assets/qt-logo.png", + "assets/JAPAN.png", + "assets/temp-down-pressed.png", + "assets/switch-handle.png", + "assets/popup-bg.png", + "assets/scrollbar-temperature-track.png", + "assets/radiobutton-checked-pressed.png", + "assets/digitMaskBottom.png", + "assets/switch-i.png", + "assets/btn-bg-big-on.png", + "assets/radiobutton-pressed.png", + "assets/pressed-bg-up.png", + "assets/selected.png", + "assets/eco-on.png", + "assets/streamer-on-small.png", + "assets/page-indicator.png", + "assets/jog-off.png", + "assets/status-small.png", + "assets/dryer-on-small.png", + "assets/dryer-on.png", + "assets/close.png", + "assets/auto-card.png", + "assets/toggle-year.png", + "assets/eco-on-small.png", + "assets/separator-line.png", + "assets/radiobutton-checked.png", + "assets/streamer-on.png", + "assets/btn-bg-down.png", + "assets/slider-handle.png", + "assets/thermo-handle.png", + "assets/switch-bg.png", + "assets/pressed-bg-down.png", + "assets/auto-on.png", + "assets/place-back.png", + "assets/UK.png", + "assets/radiobutton.png", + "assets/baseline-arrow-back.png", + "assets/digitMaskTop.png", + "assets/switch-o.png", + "assets/power-on.png", + "assets/temp-up-pressed.png", + "assets/btn-bg-big-off.png", + "assets/toggle-month.png", + "assets/jog.png", + "assets/GERMANY.png", + "assets/change-language.png", + "assets/scrollbar-off-track.png", + "assets/weather/w_06.png", + "assets/weather/w_01.png", + "assets/weather/w_02.png", + "assets/weather/w_07.png", + "assets/weather/w_05.png", + "assets/weather/w_04.png", + "assets/weather/w_03.png", + "assets/stats-month.png", + "assets/stats-year.png", + "assets/main-bg.png", + "assets/fan-off.png", + "assets/fan-off-small.png", + "assets/fan-1-on.png", + "assets/fan-1-on-small.png", + "assets/fan-2-on.png", + "assets/fan-2-on-small.png", + "assets/fan-3-on.png", + "assets/fan-3-on-small.png", + "assets/fan-4-on.png", + "assets/fan-4-on-small.png" + ] } - Files { - filter: "*.conf" - files: ["qtquickcontrols2.conf"] - } - - Files { - filter: "qmldir" - directory: "." - } - - Files { - filter: "*.qm" - directory: "i18n" + ImageFiles { + files: [ + "images/inner-circle.png", + "images/card-back-topleft.png", + "images/card-back-bottomleft.png", + "images/card-back-topright.png", + "images/card-back-bottomright.png" + ] } - Files { - filter: "*.ts" + FontFiles { + files: [ + "fonts/NotoSansArabic-Regular.ttf", + "fonts/NotoSansJP-Regular.otf", + "fonts/NotoSansThai-Regular.ttf", + "fonts/Roboto-Regular.ttf" + ] } - Files { - filter: "*.ttf;*.otf" + TranslationFiles { + files: [ + "i18n/qml_de_DE.ts", + "i18n/qml_ja_JP.ts" + ] } Environment { QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" QT_AUTO_SCREEN_SCALE_FACTOR: "1" QT_LOGGING_RULES: "qt.qml.connections=false" + QML_COMPAT_RESOLVE_URLS_ON_ASSIGNMENT: "1" } /* List of plugin directories passed to QML runtime */ - importPaths: [ "imports", "asset_imports", "i18n" ] + importPaths: [ "imports" ] + + ModuleFiles { + files: [ + "imports/Thermo/Thermo.qmlproject", + "imports/ThermoConfiguration/ThermoConfiguration.qmlproject" + ] + + MCU.qulModules: [ + "Controls", + "ControlsTemplates", + "Timeline" + ] + } /* Required for deployment */ targetDirectory: "/opt/thermo" //selectors: "metric" or "imperial", "big", "static" - fileSelectors: [ "metric" ] + QDS.fileSelectors: [ "metric", "big" ] + MCU.Config { + defaultFontFamily: "Roboto" + } qtForMCUs: true qt6Project: true + + supportedLanguages: [ "de_DE", "ja_JP" ] } diff --git a/examples/thermo/thermo.ui.qml b/examples/thermo/thermo.ui.qml index deb4bc16d3228691cc7a70d5109ee1398f0950b8..f5405b025defea3cb69f8ec30ddd5bb32bfac77d 100644 --- a/examples/thermo/thermo.ui.qml +++ b/examples/thermo/thermo.ui.qml @@ -55,7 +55,8 @@ Item { Item { id: mainItem - width: parent.width + anchors.left: parent.left + anchors.right: parent.right anchors.top: topBar.bottom height: parent.height - topBar.height - bottomBar.height @@ -65,8 +66,7 @@ Item { id: places enabled: appWindow.selectedView === 0 && showMain visible: opacity > 0.01 - width: parent.width - height: parent.height + anchors.fill: parent showMain: true Connections { target: places @@ -81,14 +81,11 @@ Item { RoomView { id: roomView - anchors.top: parent.top - anchors.bottom: parent.bottom + anchors.fill: parent anchors.bottomMargin: -Theme.bottomBarHeight // No BottomBar in the RoomView visible: opacity > 0.01 currentRoom: places.currentRoom - width: parent.width - selectedView: appWindow.selectedView index: 5 } @@ -119,11 +116,17 @@ Item { width: parent.width height: Theme.bottomBarHeight selected: appWindow.selectedView - onViewSwitched: appWindow.selectedView = index anchors.bottom: parent.bottom anchors.bottomMargin: shift showMainOption: places.showMain + + Connections { + target: bottomBar + function onViewSwitched(index: int) { + appWindow.selectedView = index + } + } } LanguageDialog {