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
|
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;
|
Component.onDestruction: pgst.dialogsVisible = pgst.dialogsVisible - 1;
|
||||||
|
|
||||||
default property alias children: contents.children
|
default property alias children: contents.children
|
||||||
|
|
|
@ -48,6 +48,7 @@ Item {
|
||||||
|
|
||||||
function startFadeOut() {
|
function startFadeOut() {
|
||||||
fadeOut.start();
|
fadeOut.start();
|
||||||
|
pgst.topOfStackChanged(-1);
|
||||||
page.destroy(500);
|
page.destroy(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,11 @@ Item {
|
||||||
break;
|
break;
|
||||||
case Qt.Key_Escape:
|
case Qt.Key_Escape:
|
||||||
case Qt.Key_Backspace:
|
case Qt.Key_Backspace:
|
||||||
|
case Qt.Key_Back:
|
||||||
|
if (backButton.enabled) {
|
||||||
backButton.clicked();
|
backButton.clicked();
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -102,7 +106,7 @@ Item {
|
||||||
|
|
||||||
var page = children[children.length+offset-1];
|
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.hasMenuButton = Qt.binding(function () { return page.hasMenuButton; });
|
||||||
pgst.menuButtonLabel = Qt.binding(function () { return pgst.hasMenuButton ? page.menuButtonLabel : 'Menu'; });
|
pgst.menuButtonLabel = Qt.binding(function () { return pgst.hasMenuButton ? page.menuButtonLabel : 'Menu'; });
|
||||||
pgst.menuButtonIcon = Qt.binding(function () { return pgst.hasMenuButton ? page.menuButtonIcon : Icons.vellipsis; });
|
pgst.menuButtonIcon = Qt.binding(function () { return pgst.hasMenuButton ? page.menuButtonIcon : Icons.vellipsis; });
|
||||||
|
@ -191,6 +195,9 @@ Item {
|
||||||
text: 'Back'
|
text: 'Back'
|
||||||
icon: Icons.arrow_left
|
icon: Icons.arrow_left
|
||||||
|
|
||||||
|
// Don't show back button on Android (Android has its own)
|
||||||
|
visible: (typeof(gpodderAndroid) === 'undefined')
|
||||||
|
|
||||||
enabled: pgst.hasBackButton
|
enabled: pgst.hasBackButton
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|
|
@ -39,8 +39,10 @@ Rectangle {
|
||||||
signal menuButtonClicked()
|
signal menuButtonClicked()
|
||||||
|
|
||||||
function closePage() {
|
function closePage() {
|
||||||
|
if (canClose) {
|
||||||
stacking.startFadeOut();
|
stacking.startFadeOut();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onXChanged: pgst.update(page, x)
|
onXChanged: pgst.update(page, x)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue