From 51e8aad0d957a6a1c4af6cede33259c4e070b928 Mon Sep 17 00:00:00 2001 From: Stefano Moretti Date: Thu, 29 Jun 2023 13:52:51 +0200 Subject: [PATCH] Update --- CMakeLists.txt | 21 --------------------- example/main.qml | 16 ++++++++-------- qml/DatePicker.qml | 8 ++++++-- src/icons.h | 1 + 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7efd3aa..c103c0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.19) project(BaseUI VERSION 1.0 LANGUAGES CXX) -include(GNUInstallDirs) - set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -89,19 +87,6 @@ set_target_properties(baseui PROPERTIES target_compile_definitions(baseui PRIVATE $<$,$>:QT_QML_DEBUG>) -target_compile_options(baseui - PRIVATE - $<$,$>: - -Wall - -Wextra - -Wpedantic - > - - $<$: - /W4 - > -) - target_link_libraries(baseui PRIVATE Qt::Core @@ -110,9 +95,3 @@ target_link_libraries(baseui Qt::Quick Qt::QuickControls2 ) - -install(TARGETS baseui - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - BUNDLE DESTINATION "." - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) diff --git a/example/main.qml b/example/main.qml index a761e95..4df1a23 100644 --- a/example/main.qml +++ b/example/main.qml @@ -13,8 +13,8 @@ UI.App { property string primary: Material.primary property string accent: Material.accent - property bool theme: Material.theme === Material.Dark - property string themeStyle: "System" + property bool isDarkTheme: Material.theme === Material.Dark + property string theme: "System" initialPage: UI.AppStackPage { id: homePage @@ -196,7 +196,7 @@ UI.App { UI.SettingsItem { title: "Theme" - subtitle: root.themeStyle + subtitle: root.theme onClicked: themeDialog.open() Layout.fillWidth: true } @@ -299,13 +299,13 @@ UI.App { spacing: 0 RadioButton { - checked: modelData === root.themeStyle + checked: modelData === root.theme text: modelData Layout.leftMargin: 4 onClicked: { themeDialog.close() - root.themeStyle = modelData - root.theme = root.Material.theme === Material.Dark + root.theme = modelData + root.isDarkTheme = root.Material.theme === Material.Dark } } } @@ -389,7 +389,7 @@ UI.App { Component.onCompleted: { UI.Style.primaryColor = Qt.binding(function() { return root.primary }) UI.Style.accentColor = Qt.binding(function() { return root.accent }) - UI.Style.isDarkTheme = Qt.binding(function() { return root.theme }) - UI.Style.theme = Qt.binding(function() { return root.themeStyle }) + UI.Style.isDarkTheme = Qt.binding(function() { return root.isDarkTheme }) + UI.Style.theme = Qt.binding(function() { return root.theme }) } } diff --git a/qml/DatePicker.qml b/qml/DatePicker.qml index 5a56730..fdd5756 100644 --- a/qml/DatePicker.qml +++ b/qml/DatePicker.qml @@ -9,6 +9,7 @@ Item { id: root property string locale: "en_US" + property bool selected: false property date selectedDate: new Date() readonly property int day: selectedDate.getDate() @@ -16,6 +17,8 @@ Item { readonly property int year: selectedDate.getFullYear() readonly property string dateString: year + "-" + _zeroPad(month + 1) + "-" + _zeroPad(day) + signal tappedOnADate() + function _zeroPad(n) { return n > 9 ? n : '0' + n } implicitHeight: column.implicitHeight @@ -113,7 +116,7 @@ Item { // Important: check the month to avoid clicking on days outside where opacity 0 if (d.getMonth() === monthGrid.month) { root.selectedDate = d - console.log("tapped on a date ") + root.tappedOnADate() } else { console.log("outside valid month " + d.getMonth()) } @@ -123,7 +126,8 @@ Item { id: dayLabel readonly property bool selected: - model.day === root.day + root.selected + && model.day === root.day && model.month === root.month && model.year === root.year diff --git a/src/icons.h b/src/icons.h index 1435c70..906400f 100644 --- a/src/icons.h +++ b/src/icons.h @@ -21,6 +21,7 @@ public: static void registerIcons(QQmlEngine *engine, const QString &fontPath, const QString &fontName, const QString &codesPath); + protected: template explicit Icons(DerivedType *derived, QObject *parent = nullptr)