Skip to content

Commit

Permalink
fix closing on back in android
Browse files Browse the repository at this point in the history
  • Loading branch information
mgn-norm committed Aug 27, 2022
1 parent 0689a85 commit 696683c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/qml/ApplicationContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ Item {
}

function back() {
stack.item.depth <= 1 ? stack.item.canClose = true : stack.item.canClose = false
stack.item.depth() <= 1 ? stack.item.canClose = true : stack.item.canClose = false
stack.item.pop()
stack.item.depth > 1 ? stack.item.navigationVisible = false : stack.item.navigationVisible = true
stack.item.depth() > 1 ? stack.item.navigationVisible = false : stack.item.navigationVisible = true
}

function canExit() {
return stack.item.canClose
}

Loader {
Expand Down
5 changes: 4 additions & 1 deletion src/qml/NavigationStack.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Item {
stack.pop()
}

function depth() {
return stack.depth
}

function navigateHome() {
if (stack.currentItem.url.toString() !== stack.initialItem.toString()) {
stack.replace(null, stack.initialItem, {
Expand All @@ -22,7 +26,6 @@ Item {
}

function navigatePage(source, properties) {
canClose = false
if (stack.currentItem && stack.currentItem.url
&& Qt.resolvedUrl(stack.currentItem.url) === Qt.resolvedUrl(source))
{
Expand Down
6 changes: 3 additions & 3 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ ApplicationWindow {
}

onClosing: (close) => {
if (Qt.platform.os != "android" || ac.canClose) {
if (Qt.platform.os != "android" || ac.canExit()) {
close.accepted = true
Qt.quit()
} else {
close.accepted = false
return
}
close.accepted = false
}

ApplicationContent {
Expand Down

0 comments on commit 696683c

Please sign in to comment.