← Back to team overview

ubuntu-phone team mailing list archive

Re: ContentHub, upstart: detecting launch reason

 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Mardy,

On 13.04.2015 23:02, Alberto Mardegan wrote:
> Hi all! I'm writing an app which can be a source of pictures for
> other apps. I understand that I need to handle the
> exportRequested() signal from the content hub, but it's not clear
> to me what to do after the transfer has been completed or
> canceled. I would like to: - if the app was started by the content
> hub for providing content: quit - if the app was started by the
> user: continue running
> 
> which leads to the question: how to detect whether the app was
> launched by the user or by the content hub?

I'm not sure if there's a better way but I do it like this:

* My app has an empty page stack

* There's a

Connection {
  target: ContentHub
  onExportRequested: pageStack.push(SomePage.qml, {shareMode: true})
}

* And a

Timer {
  interval: 1
  running: true
  repeat: false
  onTriggered: {
    if (pageStack.depth == 0)
      pageStack.push(SomePage.qml, {shareMode: false})
  }
}

This is everything else but elegant, but seems to do. I've talked to
Ken about this already some time back. IMO there should be a property
on the ContentHub object that indicates the state.

Anyhow, this above solution words reasonably well for me.

Here's the code:
http://bazaar.launchpad.net/~mzanetti/tagger/trunk/view/head:/app/qml/ta
gger.qml#L55

Hope this helps,
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlUszroACgkQXJwWsxE5x7gVQwCfY+UewWOBJNnjYRV5VX3UJh8H
KVkAnittg6breKC/5V+fFsJKJENkmjqR
=k/jZ
-----END PGP SIGNATURE-----


Follow ups

References