@@ -643,8 +643,8 @@ ApplicationWindow {
643643
644644 onClosing: function(closeEvent) {
645645 if (mobilePlatform) {
646- closeEvent.accepted = false
647- root.handleMobileBackPressed()
646+ const handled = root.handleMobileBackPressed()
647+ closeEvent.accepted = !handled
648648 return
649649 }
650650 if (allowCloseExit) {
@@ -674,21 +674,13 @@ ApplicationWindow {
674674 settingsFlick.contentY = 0
675675 }
676676
677- Shortcut {
678- enabled: root.mobilePlatform
679- context: Qt.ApplicationShortcut
680- sequences: [StandardKey.Back, "Back", "Escape"]
681- onActivated: {
682- if (root.handleMobileBackPressed())
683- return
684- Qt.quit()
685- }
686- }
687-
688677 function handleMobileBackPressed() {
689678 if (!mobilePlatform)
690679 return false
691680
681+ if (root.closeTopOverlaySurface())
682+ return true
683+
692684 const popupStack = [
693685 walletPickerPopup,
694686 speedTestPopup,
@@ -713,10 +705,32 @@ ApplicationWindow {
713705 }
714706 }
715707
716- // Keep Home screen alive on Android: do not let back terminate the app.
717- if (compactDashboard.visible)
718- return true
708+ // On mobile home screen, consume native Back to keep the app alive in background.
709+ return true
710+ }
711+
712+ function closeTopOverlaySurface() {
713+ const overlay = Overlay.overlay
714+ if (!overlay || !overlay.children)
715+ return false
716+
717+ const children = overlay.children
718+ for (let i = children.length - 1; i >= 0; --i) {
719+ const item = children[i]
720+ if (!item)
721+ continue
722+
723+ const canClose = typeof item.close === "function"
724+ if (!canClose)
725+ continue
719726
727+ const isOpen = (item.opened === true) || (item.visible === true)
728+ if (!isOpen)
729+ continue
730+
731+ item.close()
732+ return true
733+ }
720734 return false
721735 }
722736
@@ -2758,7 +2772,7 @@ ApplicationWindow {
27582772 height: donationSuggestContent.implicitHeight + 28 + (root.mobilePlatform ? Math.max(20, root.safeBottomInset + 20) : 0)
27592773 x: (root.width - width) * 0.5
27602774 y: root.compact
2761- ? root.height - height - (root.mobilePlatform ? 12 : 0)
2775+ ? root.height - height
27622776 : root.drawerY(height)
27632777 z: 210
27642778
@@ -8891,6 +8905,7 @@ ApplicationWindow {
88918905 if (success) {
88928906 root.importDraft = ""
88938907 importTextArea.text = ""
8908+ importPopup.close()
88948909 }
88958910 }
88968911 }
@@ -9576,6 +9591,7 @@ ApplicationWindow {
95769591 root.importStatusText = "Imported " + imported + " profile(s)."
95779592 root.importDraft = ""
95789593 importTextArea.text = ""
9594+ importPopup.close()
95799595 } else {
95809596 root.importStatusKind = "error"
95819597 root.importStatusText = vpnController.lastError || "No profiles were imported."
0 commit comments