[Interest] Modal busyIndicator in Android
Federico Buti
bacarozzo at gmail.com
Wed Jun 3 14:20:08 CEST 2015
Thanks for the insight. I've solved as you suggested:
Dialog {
property alias text: labelWorking.text
contentItem: Rectangle {
radius: 3 * Params.scaleFactor
width: layout.implicitWidth * 1.2
height: busy.implicitHeight * 1.2
RowLayout {
id: layout
anchors.centerIn: parent
BusyIndicator {
id:busy
opacity: 0.85
Layout.alignment: Qt.AlignLeft
}
Text {
id: labelWorking
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Layout.alignment: Qt.AlignRight
color: "#454343"
styleColor: "#777777"
style: Text.Sunken
}
}
Keys.onPressed: { // devours back button events!
if (event.key == Qt.Key_Back)
event.accepted = true
}
}
}
Now the busy indicator correctly blocks the GUI while the background tasks
are executed.
Thanks again!
Cheers,
---
Federico Buti
On 3 June 2015 at 10:04, Rutledge Shawn <Shawn.Rutledge at theqtcompany.com>
wrote:
> On 3 Jun 2015, at 04:07, Federico Buti <bacarozzo at gmail.com> wrote:
>
> > Hi list,
> >
> > in the attempt to look as native as possible, I've defined a QML busy
> indicator for Android as follows:
> >
> > Dialog {
> > property alias text: labelWorking.text
> > standardButtons: StandardButton.NoButton
> ...
> > Keys.onPressed: {
> > if (event.key == Qt.Key_Back) {
> > console.log("Back button captured - wunderbar !")
> > event.accepted = true
> > }
> > }
> > }
> >
> > As you can see it is quite simple but works perfectly fine for my needs.
> However, the dialog should be "fully modal" and It should be dismiss ONLY
> when the related background task is terminated. As it is now, the dialog is
> dismiss as soon as the Android back button is pressed, which is wrong for
> my use case. How can I handle it?
>
> There is still a surrounding key handler in DefaultDialogWrapper.qml,
> because we wouldn’t want it to be too easy to break the default behavior:
> most dialogs should be dismissed when you hit the back button. So content
> which is merely added to the Dialog’s default property does not get the
> chance to break it.
>
> Instead you can override the Dialog’s contentItem, which is also another
> way to get rid of the buttons.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150603/ccf5bb8b/attachment.html>
More information about the Interest
mailing list