From e9fc872466f01e7ddccd67f67961d575f75788b2 Mon Sep 17 00:00:00 2001 From: "Denis V. Dedkov" Date: Wed, 12 Apr 2023 18:56:14 +0200 Subject: [PATCH] Components moved to self project --- CMakeLists.txt | 7 +- beerlog_ru_RU.ts | 35 +++++----- qml/Components/MainMenu.qml | 61 ----------------- qml/Components/MenuBackButton.qml | 84 ------------------------ qml/Components/SubtitledItemDelegate.qml | 24 ------- qml/Components/qmldir | 5 -- qml/Views/SettingsView.qml | 3 +- qml/main.qml | 7 +- qml/qml.qrc | 4 -- 9 files changed, 29 insertions(+), 201 deletions(-) delete mode 100644 qml/Components/MainMenu.qml delete mode 100644 qml/Components/MenuBackButton.qml delete mode 100644 qml/Components/SubtitledItemDelegate.qml delete mode 100644 qml/Components/qmldir diff --git a/CMakeLists.txt b/CMakeLists.txt index 4661eae..62b1099 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,10 +56,15 @@ else() qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) endif() - target_link_libraries(beerlog PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::WebSockets) +if (ANDROID) + set_property(TARGET beerlog APPEND PROPERTY QT_ANDROID_EXTRA_LIBS ${COMPONENTS_LIB}) +endif() + +target_link_libraries(beerlog PRIVATE ${COMPONENTS_LIB}) + set_target_properties(beerlog PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} diff --git a/beerlog_ru_RU.ts b/beerlog_ru_RU.ts index 0756bcc..d76162e 100644 --- a/beerlog_ru_RU.ts +++ b/beerlog_ru_RU.ts @@ -1,19 +1,6 @@ - - MainMenu - - - Online - В сети - - - - Offline - Не в сети - - OrdersView @@ -43,7 +30,7 @@ SettingsView - + Settings Настройки @@ -79,23 +66,33 @@ - + + Online + В сети + + + + Offline + Не в сети + + + Orders Заказы - + Settings Настройки - - + + Quit Выход - + Realy quit the application? Действительно выйти из приложения? diff --git a/qml/Components/MainMenu.qml b/qml/Components/MainMenu.qml deleted file mode 100644 index 5346d01..0000000 --- a/qml/Components/MainMenu.qml +++ /dev/null @@ -1,61 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 - -Drawer { - property alias logo: logoImage.source - property alias appName: appNameLabel.text - property alias model: menuRepeater.model - property alias connected: connectionLabel.connected - - signal actionSelected(var action) - - width: parent.width * 0.66 - height: parent.height - - Column { - anchors.fill: parent - - Row { - width: parent.width - height: 100 - - Image { - id: logoImage - - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.margins: 10 - } - - Column { - anchors.verticalCenter: parent.verticalCenter - - Label { - id: appNameLabel - - font.pointSize: 20 - } - - Label { - id: connectionLabel - - property bool connected: false - - text: connected ? qsTr("Online") : qsTr("Offline") - color: connected ? "green" : "red" - } - } - } - - Repeater { - id: menuRepeater - - delegate: ItemDelegate { - width: parent.width - - text: model.title - onClicked: actionSelected(model.action) - } - } - } -} diff --git a/qml/Components/MenuBackButton.qml b/qml/Components/MenuBackButton.qml deleted file mode 100644 index 97313db..0000000 --- a/qml/Components/MenuBackButton.qml +++ /dev/null @@ -1,84 +0,0 @@ -import QtQuick 2.15 - -Item { - id: root - - width: 40 - height: 40 - - property double iconMarigns: 8 - property double iconHeight: width - iconMarigns * 2 - signal clicked() - signal back() - - SystemPalette { - id: palette - } - - MouseArea { - id: ma - - anchors.fill: parent - } - - Rectangle { - id: bar1 - x: root.iconMarigns - y: root.iconMarigns + root.iconHeight / 6 - width: root.iconHeight - height: root.iconHeight / 9 - antialiasing: true - - color: palette.button - } - - Rectangle { - id: bar2 - x: root.iconMarigns - y: root.iconMarigns + root.iconHeight / 2 - height / 2 - width: root.iconHeight - height: root.iconHeight / 9 - antialiasing: true - - color: palette.button - } - - Rectangle { - id: bar3 - x: root.iconMarigns - y: root.iconMarigns + root.iconHeight / 2 + height * 2 - width: root.iconHeight - height: root.iconHeight / 9 - antialiasing: true - - color: palette.button - } - - property int animationDuration: 450 - - state: "menu" - states: [ - State { - name: "menu" - PropertyChanges { target: ma; onClicked: root.clicked() } - }, - - State { - name: "back" - PropertyChanges { target: root; rotation: 180 } - PropertyChanges { target: bar1; rotation: 45; width: root.iconHeight / 3 * 2; x: root.iconMarigns + root.iconHeight / 2; y: root.iconMarigns + root.iconHeight / 4 } - PropertyChanges { target: bar2; width: root.iconHeight / 6 * 5 + 1; x: root.iconMarigns + root.iconHeight / 9 } - PropertyChanges { target: bar3; rotation: -45; width: root.iconHeight / 3 * 2; x: root.iconMarigns + root.iconHeight / 2; y: root.iconMarigns + root.iconHeight / 3 * 2 } - PropertyChanges { target: ma; onClicked: root.back() } - } - ] - - transitions: [ - Transition { - RotationAnimation { target: root; direction: RotationAnimation.Clockwise; duration: animationDuration; easing.type: Easing.InOutQuad } - PropertyAnimation { target: bar1; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad } - PropertyAnimation { target: bar2; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad } - PropertyAnimation { target: bar3; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad } - } - ] -} diff --git a/qml/Components/SubtitledItemDelegate.qml b/qml/Components/SubtitledItemDelegate.qml deleted file mode 100644 index df5d8d0..0000000 --- a/qml/Components/SubtitledItemDelegate.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.2 - -ItemDelegate { - id: root - - property string subtitle: "" - - contentItem: Column { - Label { - id: titleLabel - - width: parent.width - text: root.text - } - - Label { - width: parent.width - font.pixelSize: titleLabel.font.pixelSize - 2 - text: root.subtitle - opacity: 0.8 - } - } -} diff --git a/qml/Components/qmldir b/qml/Components/qmldir deleted file mode 100644 index 5c956d0..0000000 --- a/qml/Components/qmldir +++ /dev/null @@ -1,5 +0,0 @@ -module Components - -MainMenu 1.0 MainMenu.qml -MenuBackButton 1.0 MenuBackButton.qml -SubtitledItemDelegate 1.0 SubtitledItemDelegate.qml diff --git a/qml/Views/SettingsView.qml b/qml/Views/SettingsView.qml index 19d9855..f4a34f6 100644 --- a/qml/Views/SettingsView.qml +++ b/qml/Views/SettingsView.qml @@ -1,7 +1,8 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import Components 1.0 + import ru.ded.beerlog 1.0 +import ru.ded.components 1.0 Page { id: root diff --git a/qml/main.qml b/qml/main.qml index a320826..d751a1f 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -5,7 +5,7 @@ import QtQuick.Layouts 1.15 import QtWebSockets import ru.ded.beerlog 1.0 -import Components 1.0 +import ru.ded.components 1.0 ApplicationWindow { width: 640 @@ -89,7 +89,10 @@ ApplicationWindow { logo: "qrc:/logo.png" appName: qsTr("BeerLog v0.1") - connected: beerService.connected + additional: Label { + text: beerService.connected ? qsTr("Online") : qsTr("Offline") + color: beerService.connected ? "green" : "red" + } model: ListModel { ListElement { diff --git a/qml/qml.qrc b/qml/qml.qrc index 2794452..a582786 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,14 +1,10 @@ main.qml - Components/MenuBackButton.qml qtquickcontrols2.conf logo.png - Components/MainMenu.qml Views/OrdersView.qml Views/SettingsView.qml - Components/SubtitledItemDelegate.qml - Components/qmldir Views/ProductsView.qml