Android "Back" button handling
This commit is contained in:
parent
cadcd5ddcf
commit
5b256bbeec
4 changed files with 18 additions and 4 deletions
|
@ -28,7 +28,11 @@ Rectangle {
|
|||
|
||||
color: Constants.colors.dialogBackground
|
||||
|
||||
Component.onCompleted: pgst.dialogsVisible = pgst.dialogsVisible + 1;
|
||||
Component.onCompleted: {
|
||||
pgst.dialogsVisible = pgst.dialogsVisible + 1;
|
||||
pgst.topOfStackChanged();
|
||||
}
|
||||
|
||||
Component.onDestruction: pgst.dialogsVisible = pgst.dialogsVisible - 1;
|
||||
|
||||
default property alias children: contents.children
|
||||
|
|
|
@ -48,6 +48,7 @@ Item {
|
|||
|
||||
function startFadeOut() {
|
||||
fadeOut.start();
|
||||
pgst.topOfStackChanged(-1);
|
||||
page.destroy(500);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,11 @@ Item {
|
|||
break;
|
||||
case Qt.Key_Escape:
|
||||
case Qt.Key_Backspace:
|
||||
backButton.clicked();
|
||||
case Qt.Key_Back:
|
||||
if (backButton.enabled) {
|
||||
backButton.clicked();
|
||||
event.accepted = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -102,7 +106,7 @@ Item {
|
|||
|
||||
var page = children[children.length+offset-1];
|
||||
|
||||
pgst.hasBackButton = Qt.binding(function () { return (!page.isDialog && page.canClose); });
|
||||
pgst.hasBackButton = Qt.binding(function () { return page.isDialog || page.canClose; });
|
||||
pgst.hasMenuButton = Qt.binding(function () { return page.hasMenuButton; });
|
||||
pgst.menuButtonLabel = Qt.binding(function () { return pgst.hasMenuButton ? page.menuButtonLabel : 'Menu'; });
|
||||
pgst.menuButtonIcon = Qt.binding(function () { return pgst.hasMenuButton ? page.menuButtonIcon : Icons.vellipsis; });
|
||||
|
@ -191,6 +195,9 @@ Item {
|
|||
text: 'Back'
|
||||
icon: Icons.arrow_left
|
||||
|
||||
// Don't show back button on Android (Android has its own)
|
||||
visible: (typeof(gpodderAndroid) === 'undefined')
|
||||
|
||||
enabled: pgst.hasBackButton
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
|
|
|
@ -39,7 +39,9 @@ Rectangle {
|
|||
signal menuButtonClicked()
|
||||
|
||||
function closePage() {
|
||||
stacking.startFadeOut();
|
||||
if (canClose) {
|
||||
stacking.startFadeOut();
|
||||
}
|
||||
}
|
||||
|
||||
onXChanged: pgst.update(page, x)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue