Settings page was added
This commit is contained in:
@@ -5,6 +5,7 @@ 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)
|
||||
|
||||
@@ -26,12 +27,23 @@ Drawer {
|
||||
anchors.margins: 10
|
||||
}
|
||||
|
||||
Label {
|
||||
id: appNameLabel
|
||||
|
||||
Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.pointSize: 20
|
||||
text: qsTr("BeerLog v0.1")
|
||||
|
||||
Label {
|
||||
id: appNameLabel
|
||||
|
||||
font.pointSize: 20
|
||||
}
|
||||
|
||||
Label {
|
||||
id: connectionLabel
|
||||
|
||||
property bool connected: false
|
||||
|
||||
text: connected ? qsTr("Online") : qsTr("Offline")
|
||||
color: connected ? "green" : "red"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
24
qml/Components/SubtitledItemDelegate.qml
Normal file
24
qml/Components/SubtitledItemDelegate.qml
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
5
qml/Components/qmldir
Normal file
5
qml/Components/qmldir
Normal file
@@ -0,0 +1,5 @@
|
||||
module Components
|
||||
|
||||
MainMenu 1.0 MainMenu.qml
|
||||
MenuBackButton 1.0 MenuBackButton.qml
|
||||
SubtitledItemDelegate 1.0 SubtitledItemDelegate.qml
|
||||
@@ -1,11 +1,74 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import Components 1.0
|
||||
|
||||
Page {
|
||||
id: root
|
||||
|
||||
Label {
|
||||
anchors.centerIn: parent
|
||||
text: "Settings"
|
||||
title: qsTr("Settings")
|
||||
|
||||
ListModel {
|
||||
id: settingsModel
|
||||
|
||||
ListElement {
|
||||
title: qsTr("BeerLog service address")
|
||||
name: "serverAddress"
|
||||
}
|
||||
|
||||
ListElement {
|
||||
title: qsTr("Selected user id")
|
||||
name: "selectedUserId"
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
anchors.fill: parent
|
||||
|
||||
model: settingsModel
|
||||
|
||||
delegate: SubtitledItemDelegate {
|
||||
width: parent.width
|
||||
|
||||
text: model.title
|
||||
subtitle: settingsService[model.name]
|
||||
|
||||
onClicked: {
|
||||
inputDialog.title = model.title
|
||||
inputDialog.name = model.name
|
||||
inputDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dialog {
|
||||
id: inputDialog
|
||||
|
||||
property string name: ""
|
||||
|
||||
width: root.width * 0.8
|
||||
|
||||
anchors.centerIn: parent
|
||||
parent: ApplicationWindow.overlay
|
||||
|
||||
modal: true
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
|
||||
Column {
|
||||
spacing: 20
|
||||
anchors.fill: parent
|
||||
|
||||
TextField {
|
||||
id: textField
|
||||
|
||||
width: parent.width
|
||||
inputMethodHints: Qt.ImhNoAutoUppercase
|
||||
placeholderText: inputDialog.title
|
||||
text: settingsService[inputDialog.name] || ""
|
||||
}
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
settingsService[inputDialog.name] = textField.text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
qml/main.qml
17
qml/main.qml
@@ -5,7 +5,7 @@ import QtQuick.Layouts 1.15
|
||||
import QtWebSockets
|
||||
|
||||
import ru.ded.beerlog 1.0
|
||||
import "Components"
|
||||
import Components 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
width: 640
|
||||
@@ -16,15 +16,23 @@ ApplicationWindow {
|
||||
header: ToolBar {
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
MenuBackButton {
|
||||
state: stackView.depth > 1 ? "back" : "menu"
|
||||
onClicked: mainMenu.open()
|
||||
onBack: stackView.pop()
|
||||
}
|
||||
ToolButton {
|
||||
text: usersModel.selectedUserName
|
||||
|
||||
Label {
|
||||
text: stackView.currentItem.title || usersModel.selectedUserName
|
||||
Layout.fillWidth: true
|
||||
onClicked: usersMenu.open()
|
||||
horizontalAlignment: Qt.AlignCenter
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: stackView.depth === 1
|
||||
onClicked: usersMenu.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +70,7 @@ ApplicationWindow {
|
||||
|
||||
logo: "qrc:/logo.png"
|
||||
appName: qsTr("BeerLog v0.1")
|
||||
connected: beerService.connected
|
||||
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
|
||||
@@ -8,5 +8,8 @@
|
||||
<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>qt_ru.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user