esc and back button support

This commit is contained in:
pokamest 2021-09-13 17:36:48 +03:00
parent 542f363e92
commit e920d9cdf3

View file

@ -18,7 +18,9 @@ Window {
visible: true visible: true
width: GC.screenWidth width: GC.screenWidth
height: GC.isDesktop() ? GC.screenHeight + titleBar.height : GC.screenHeight height: GC.isDesktop() ? GC.screenHeight + titleBar.height : GC.screenHeight
Keys.enabled: true
onClosing: { onClosing: {
console.debug("QML onClosing signal")
UiLogic.onCloseWindow() UiLogic.onCloseWindow()
} }
@ -239,8 +241,6 @@ Window {
Rectangle { Rectangle {
y: GC.isDesktop() ? titleBar.height : 0 y: GC.isDesktop() ? titleBar.height : 0
// width: GC.screenWidth
// height: GC.screenHeight
anchors.fill: parent anchors.fill: parent
color: "white" color: "white"
} }
@ -248,15 +248,34 @@ Window {
StackView { StackView {
id: pageLoader id: pageLoader
y: GC.isDesktop() ? titleBar.height : 0 y: GC.isDesktop() ? titleBar.height : 0
// width: GC.screenWidth
// height: GC.screenHeight
anchors.fill: parent anchors.fill: parent
focus: true
// initialItem: page_servers // initialItem: page_servers
onCurrentItemChanged: { onCurrentItemChanged: {
let pageEnum = root.getPageEnum(currentItem) let pageEnum = root.getPageEnum(currentItem)
UiLogic.currentPageValue = pageEnum UiLogic.currentPageValue = pageEnum
} }
Keys.onReleased: {
if (event.key === Qt.Key_Back || event.key === Qt.Key_Escape) {
console.debug("Back button captured")
if (UiLogic.currentPageValue !== PageEnum.VPN &&
UiLogic.currentPageValue !== PageEnum.ServerConfiguring &&
!(UiLogic.currentPageValue === PageEnum.Start && pageLoader.depth < 2)) {
close_page();
}
// TODO: fix
//if (ui->stackedWidget_main->currentWidget()->isEnabled()) {
// closePage();
//}
event.accepted = true
}
}
} }
Component { Component {
id: page_start id: page_start
@ -452,5 +471,4 @@ Window {
text: UiLogic.dialogConnectErrorText text: UiLogic.dialogConnectErrorText
visible: false visible: false
} }
} }