Kaynağa Gözat

Components moved to self project

Denis V. Dedkov 2 yıl önce
ebeveyn
işleme
e9fc872466

+ 6 - 1
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}

+ 16 - 19
beerlog_ru_RU.ts

@@ -1,19 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
 <TS version="2.1" language="ru_RU">
-<context>
-    <name>MainMenu</name>
-    <message>
-        <location filename="qml/Components/MainMenu.qml" line="44"/>
-        <source>Online</source>
-        <translation>В сети</translation>
-    </message>
-    <message>
-        <location filename="qml/Components/MainMenu.qml" line="44"/>
-        <source>Offline</source>
-        <translation>Не в сети</translation>
-    </message>
-</context>
 <context>
     <name>OrdersView</name>
     <message>
@@ -43,7 +30,7 @@
 <context>
     <name>SettingsView</name>
     <message>
-        <location filename="qml/Views/SettingsView.qml" line="9"/>
+        <location filename="qml/Views/SettingsView.qml" line="10"/>
         <source>Settings</source>
         <translation>Настройки</translation>
     </message>
@@ -79,23 +66,33 @@
         <translation></translation>
     </message>
     <message>
-        <location filename="qml/main.qml" line="96"/>
+        <location filename="qml/main.qml" line="93"/>
+        <source>Online</source>
+        <translation>В сети</translation>
+    </message>
+    <message>
+        <location filename="qml/main.qml" line="93"/>
+        <source>Offline</source>
+        <translation>Не в сети</translation>
+    </message>
+    <message>
+        <location filename="qml/main.qml" line="99"/>
         <source>Orders</source>
         <translation>Заказы</translation>
     </message>
     <message>
-        <location filename="qml/main.qml" line="100"/>
+        <location filename="qml/main.qml" line="103"/>
         <source>Settings</source>
         <translation>Настройки</translation>
     </message>
     <message>
-        <location filename="qml/main.qml" line="104"/>
-        <location filename="qml/main.qml" line="140"/>
+        <location filename="qml/main.qml" line="107"/>
+        <location filename="qml/main.qml" line="143"/>
         <source>Quit</source>
         <translation>Выход</translation>
     </message>
     <message>
-        <location filename="qml/main.qml" line="144"/>
+        <location filename="qml/main.qml" line="147"/>
         <source>Realy quit the application?</source>
         <translation>Действительно выйти из приложения?</translation>
     </message>

+ 0 - 61
qml/Components/MainMenu.qml

@@ -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)
-            }
-        }
-    }
-}

+ 0 - 84
qml/Components/MenuBackButton.qml

@@ -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 }
-        }
-    ]
-}

+ 0 - 24
qml/Components/SubtitledItemDelegate.qml

@@ -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
-        }
-    }
-}

+ 0 - 5
qml/Components/qmldir

@@ -1,5 +0,0 @@
-module Components
-
-MainMenu 1.0 MainMenu.qml
-MenuBackButton 1.0 MenuBackButton.qml
-SubtitledItemDelegate 1.0 SubtitledItemDelegate.qml

+ 2 - 1
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

+ 5 - 2
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 {

+ 0 - 4
qml/qml.qrc

@@ -1,14 +1,10 @@
 <RCC>
     <qresource prefix="/">
         <file>main.qml</file>
-        <file>Components/MenuBackButton.qml</file>
         <file>qtquickcontrols2.conf</file>
         <file>logo.png</file>
-        <file>Components/MainMenu.qml</file>
         <file>Views/OrdersView.qml</file>
         <file>Views/SettingsView.qml</file>
-        <file>Components/SubtitledItemDelegate.qml</file>
-        <file>Components/qmldir</file>
         <file>Views/ProductsView.qml</file>
     </qresource>
 </RCC>