Переход на использование модуля с компонентами
This commit is contained in:
@@ -24,6 +24,14 @@ if (ANDROID)
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/android)
|
${CMAKE_CURRENT_SOURCE_DIR}/android)
|
||||||
endif()
|
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.
|
# 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
|
# 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
|
target_link_libraries(appnooLight
|
||||||
PRIVATE Qt6::Quick
|
PRIVATE Qt6::Quick componentsplugin
|
||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
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 QtQuick.Controls 2.2
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
|
|
||||||
|
import ru.ded.components 1.0
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: window
|
id: window
|
||||||
|
|
||||||
@@ -34,13 +36,10 @@ ApplicationWindow {
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 8
|
anchors.leftMargin: 8
|
||||||
|
|
||||||
width: 24
|
|
||||||
height: 24
|
|
||||||
|
|
||||||
state: stackView.depth > 1 ? "back" : "menu"
|
state: stackView.depth > 1 ? "back" : "menu"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
drawer.open()
|
mainMenu.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
onBack: {
|
onBack: {
|
||||||
@@ -54,56 +53,34 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawer {
|
MainMenu {
|
||||||
id: drawer
|
id: mainMenu
|
||||||
width: window.width * 0.66
|
|
||||||
height: window.height
|
|
||||||
|
|
||||||
Column {
|
readonly property var actions: {
|
||||||
anchors.fill: parent
|
"service": () => { stackView.openPage("ServiceForm.qml") },
|
||||||
|
"settings": () => { stackView.openPage("SettingsForm.qml") },
|
||||||
|
"quit": () => { Qt.quit() }
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
logo: "qrc:/lamp.png"
|
||||||
width: parent.width
|
appName: qsTr("nooLight v1.0")
|
||||||
height: 100
|
|
||||||
|
|
||||||
Image {
|
model: ListModel {
|
||||||
anchors.top: parent.top
|
ListElement {
|
||||||
anchors.bottom: parent.bottom
|
title: qsTr("Service")
|
||||||
anchors.margins: 10
|
action: "service"
|
||||||
source: "lamp.png"
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
font.pointSize: 20
|
|
||||||
text: qsTr("nooLight v0.1")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ListElement {
|
||||||
ItemDelegate {
|
title: qsTr("Settings")
|
||||||
text: qsTr("Service")
|
action: "settings"
|
||||||
width: parent.width
|
|
||||||
onClicked: {
|
|
||||||
stackView.openPage("ServiceForm.qml")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ListElement {
|
||||||
ItemDelegate {
|
title: qsTr("Quit")
|
||||||
text: qsTr("Settings")
|
action: "quit"
|
||||||
width: parent.width
|
|
||||||
onClicked: {
|
|
||||||
stackView.openPage("SettingsForm.qml")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemDelegate {
|
|
||||||
text: qsTr("Quit")
|
|
||||||
width: parent.width
|
|
||||||
onClicked: {
|
|
||||||
Qt.quit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onActionSelected: (action) => actions[action]()
|
||||||
}
|
}
|
||||||
|
|
||||||
StackView {
|
StackView {
|
||||||
@@ -117,7 +94,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
push(page)
|
push(page)
|
||||||
drawer.close()
|
mainMenu.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
function showError(text) {
|
function showError(text) {
|
||||||
|
|||||||
1
qml.qrc
1
qml.qrc
@@ -4,7 +4,6 @@
|
|||||||
<file>qtquickcontrols2.conf</file>
|
<file>qtquickcontrols2.conf</file>
|
||||||
<file>HomeForm.qml</file>
|
<file>HomeForm.qml</file>
|
||||||
<file>SettingsForm.qml</file>
|
<file>SettingsForm.qml</file>
|
||||||
<file>MenuBackButton.qml</file>
|
|
||||||
<file>SubtitledItemDelegate.qml</file>
|
<file>SubtitledItemDelegate.qml</file>
|
||||||
<file>LightsModel.qml</file>
|
<file>LightsModel.qml</file>
|
||||||
<file>LightGroup.qml</file>
|
<file>LightGroup.qml</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user