Quit dialog was added
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<message>
|
||||
<location filename="qml/Components/MainMenu.qml" line="34"/>
|
||||
<source>BeerLog v0.1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@@ -17,20 +17,26 @@
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/main.qml" line="66"/>
|
||||
<location filename="qml/main.qml" line="64"/>
|
||||
<source>BeerLog v0.1</source>
|
||||
<oldsource>BeerLog v1.0.0</oldsource>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/main.qml" line="70"/>
|
||||
<location filename="qml/main.qml" line="68"/>
|
||||
<source>Settings</source>
|
||||
<translation>Настройки</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/main.qml" line="74"/>
|
||||
<location filename="qml/main.qml" line="72"/>
|
||||
<location filename="qml/main.qml" line="108"/>
|
||||
<source>Quit</source>
|
||||
<translation>Выход</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/main.qml" line="112"/>
|
||||
<source>Realy quit the application?</source>
|
||||
<translation>Действительно выйти из приложения?</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
||||
12
qml/Views/OrdersView.qml
Normal file
12
qml/Views/OrdersView.qml
Normal file
@@ -0,0 +1,12 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
|
||||
Page {
|
||||
|
||||
Label {
|
||||
anchors.centerIn: parent
|
||||
|
||||
text: "Orders"
|
||||
}
|
||||
|
||||
}
|
||||
11
qml/Views/SettingsView.qml
Normal file
11
qml/Views/SettingsView.qml
Normal file
@@ -0,0 +1,11 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
|
||||
Page {
|
||||
|
||||
Label {
|
||||
anchors.centerIn: parent
|
||||
text: "Settings"
|
||||
}
|
||||
|
||||
}
|
||||
62
qml/main.qml
62
qml/main.qml
@@ -17,11 +17,9 @@ ApplicationWindow {
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
MenuBackButton {
|
||||
state: "menu"//stackView.depth > 1 ? "back" : "menu"
|
||||
state: stackView.depth > 1 ? "back" : "menu"
|
||||
onClicked: mainMenu.open()
|
||||
onBack: {
|
||||
state = "menu"
|
||||
}
|
||||
onBack: stackView.pop()
|
||||
}
|
||||
ToolButton {
|
||||
text: usersModel.selectedUserName
|
||||
@@ -55,7 +53,7 @@ ApplicationWindow {
|
||||
id: mainMenu
|
||||
|
||||
readonly property var actions: {
|
||||
"settings": () => { stackView.openPage("SettingsForm.qml") },
|
||||
"settings": () => { stackView.openPage("Views/SettingsView.qml") },
|
||||
"quit": () => { Qt.quit() }
|
||||
}
|
||||
|
||||
@@ -78,4 +76,58 @@ ApplicationWindow {
|
||||
|
||||
onActionSelected: (action) => actions[action]()
|
||||
}
|
||||
|
||||
StackView {
|
||||
id: stackView
|
||||
initialItem: "Views/OrdersView.qml"
|
||||
anchors.fill: parent
|
||||
|
||||
function openPage(page) {
|
||||
if (depth > 1) {
|
||||
pop()
|
||||
}
|
||||
|
||||
push(page)
|
||||
mainMenu.close()
|
||||
}
|
||||
|
||||
function showError(text) {
|
||||
ToolTip.show(text, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
Dialog {
|
||||
id: quitDialog
|
||||
|
||||
property bool quitAccepted: false
|
||||
|
||||
anchors.centerIn: parent
|
||||
parent: Overlay.overlay
|
||||
|
||||
modal: true
|
||||
title: qsTr("Quit")
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
|
||||
Label {
|
||||
text: qsTr("Realy quit the application?")
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
quitAccepted = true
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
|
||||
onClosing: (close) => {
|
||||
if (stackView.depth > 1) {
|
||||
close.accepted = false
|
||||
stackView.pop()
|
||||
return
|
||||
}
|
||||
|
||||
if (!quitDialog.quitAccepted) {
|
||||
close.accepted = false
|
||||
quitDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
<file>logo.png</file>
|
||||
<file>beerlog_ru_RU.qm</file>
|
||||
<file>Components/MainMenu.qml</file>
|
||||
<file>Views/OrdersView.qml</file>
|
||||
<file>Views/SettingsView.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user