Переход на использование модуля с компонентами
This commit is contained in:
@@ -24,6 +24,14 @@ if (ANDROID)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/android)
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
components
|
||||
GIT_REPOSITORY https://gogs.dended.keenetic.pro/ded/components.git
|
||||
GIT_TAG master
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(components)
|
||||
|
||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
||||
# If you are developing for iOS or macOS you should consider setting an
|
||||
@@ -37,7 +45,7 @@ set_target_properties(appnooLight PROPERTIES
|
||||
)
|
||||
|
||||
target_link_libraries(appnooLight
|
||||
PRIVATE Qt6::Quick
|
||||
PRIVATE Qt6::Quick componentsplugin
|
||||
)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
id: root
|
||||
signal clicked()
|
||||
signal back()
|
||||
|
||||
SystemPalette {
|
||||
id: palette
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: ma
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: -8
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: bar1
|
||||
x: 0
|
||||
y: root.height / 6
|
||||
width: root.height
|
||||
height: root.height / 9
|
||||
antialiasing: true
|
||||
|
||||
color: palette.button
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: bar2
|
||||
x: 0
|
||||
y: root.height / 2 - height / 2
|
||||
width: root.height
|
||||
height: root.height / 9
|
||||
antialiasing: true
|
||||
|
||||
color: palette.button
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: bar3
|
||||
x: 0
|
||||
y: root.height / 2 + height * 2
|
||||
width: root.height
|
||||
height: root.height / 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.height / 3 * 2; x: root.height / 2; y: root.height / 4 }
|
||||
PropertyChanges { target: bar2; width: root.height / 6 * 5 + 1; x: root.height / 9 }
|
||||
PropertyChanges { target: bar3; rotation: -45; width: root.height / 3 * 2; x: root.height / 2; y: root.height / 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 }
|
||||
}
|
||||
]
|
||||
}
|
||||
73
main.qml
73
main.qml
@@ -2,6 +2,8 @@ import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import Qt.labs.settings 1.0
|
||||
|
||||
import ru.ded.components 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
id: window
|
||||
|
||||
@@ -34,13 +36,10 @@ ApplicationWindow {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 8
|
||||
|
||||
width: 24
|
||||
height: 24
|
||||
|
||||
state: stackView.depth > 1 ? "back" : "menu"
|
||||
|
||||
onClicked: {
|
||||
drawer.open()
|
||||
mainMenu.open()
|
||||
}
|
||||
|
||||
onBack: {
|
||||
@@ -54,56 +53,34 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Drawer {
|
||||
id: drawer
|
||||
width: window.width * 0.66
|
||||
height: window.height
|
||||
MainMenu {
|
||||
id: mainMenu
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
readonly property var actions: {
|
||||
"service": () => { stackView.openPage("ServiceForm.qml") },
|
||||
"settings": () => { stackView.openPage("SettingsForm.qml") },
|
||||
"quit": () => { Qt.quit() }
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
height: 100
|
||||
logo: "qrc:/lamp.png"
|
||||
appName: qsTr("nooLight v1.0")
|
||||
|
||||
Image {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 10
|
||||
source: "lamp.png"
|
||||
}
|
||||
|
||||
Label {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.pointSize: 20
|
||||
text: qsTr("nooLight v0.1")
|
||||
}
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
title: qsTr("Service")
|
||||
action: "service"
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
text: qsTr("Service")
|
||||
width: parent.width
|
||||
onClicked: {
|
||||
stackView.openPage("ServiceForm.qml")
|
||||
}
|
||||
ListElement {
|
||||
title: qsTr("Settings")
|
||||
action: "settings"
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
text: qsTr("Settings")
|
||||
width: parent.width
|
||||
onClicked: {
|
||||
stackView.openPage("SettingsForm.qml")
|
||||
}
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
text: qsTr("Quit")
|
||||
width: parent.width
|
||||
onClicked: {
|
||||
Qt.quit()
|
||||
}
|
||||
ListElement {
|
||||
title: qsTr("Quit")
|
||||
action: "quit"
|
||||
}
|
||||
}
|
||||
|
||||
onActionSelected: (action) => actions[action]()
|
||||
}
|
||||
|
||||
StackView {
|
||||
@@ -117,7 +94,7 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
push(page)
|
||||
drawer.close()
|
||||
mainMenu.close()
|
||||
}
|
||||
|
||||
function showError(text) {
|
||||
|
||||
Reference in New Issue
Block a user