We have moved to a new Sailfish OS Forum. Please start new discussions there.
0

How to open apps programmatically?

asked 2019-09-07 23:14:20 +0300

jsommer gravatar image

Unfortunately it is not possible any more to open apps with Qt.openUrlExternally() like

Qt.openUrlExternally("/usr/share/applications/jolla-gallery.desktop")

These API changes are annoying. Has someone a solution? Maybe with some DBus stuff?

edit retag flag offensive close delete

Comments

@jsommer

On a different note, but within the scope of what you are asking, I'd like to ask why you have opened practically the same question you posed just a few months back?; https://together.jolla.com/question/186475/how-to-launch-any-app-programmatically/

I answered you there as well, please close this question, there really is no point in posting duplicates.

Spam Hunter ( 2019-09-08 00:25:14 +0300 )edit

The reason, why I have posted this question was, that the previous solution with Qt.openUrlExternally() doesn't work any more.

I think, last time I struggled with the import statement of the second option with a LauncherItem. Now I tried several imports:

  • import org.nemomobile.lipstick 0.1
  • import com.jolla.lipstick 0.1
  • import Sailfish.Lipstick 1.0

The first one works to create a LauncherItem:

import org.nemomobile.lipstick 0.1 
...
LauncherItem {
    id: galleryApp
    filePath: "/usr/share/applications/jolla-gallery.desktop"
}
...
galleryApp.launchApplication()

For any reasons, the system complains now about aNotificationdefinition like this:

Notification {
     id: notification
     category: "x-nemo.example"
     summary: "Notification summary"
     body: "Notification body"
     previewSummary: "Preview summary"
     previewBody: "Preview body"
     expireTimeout: 2000
 }

This worked before I have used the import statement. The log output says:

Invalid property assignment: "expireTimeout" is a read-only property

If I remove the last property, the log says:

Invalid property assignment: "previewBody" is a read-only property

In the end I have to remove each property in the definition. There seem to be a conflict after the import of Lipstick

jsommer ( 2019-09-08 00:44:04 +0300 )edit

This was due to an actual bug fixing on the libcontentaction (some time back in july). It wasnt supposed to be workable at all. .desktops are "special" kind of files, which are not supposed to be opened as executables, for instance

tortoisedoc ( 2019-09-08 12:11:14 +0300 )edit

The idea is you edit the old question, you've been here long enough to know this is how it works.

Spam Hunter ( 2019-09-08 12:40:13 +0300 )edit

@tortoisedoc Thanks for the background information

@Edz Thank you for referring to the forum rules. Sometimes I confuse the many forums a bit. Community members in the UBports forum for example recommend to create new posts instead of editing old ones.

jsommer ( 2019-09-08 17:57:12 +0300 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2019-09-08 00:18:58 +0300

Spam Hunter gravatar image

updated 2019-09-08 00:21:54 +0300

Why would you open jolla-gallery externally?, use Qt.openUrlExternally ONLY for opening external URL sources like a webpage;

Button {
    text: "Main website"
    onClicked: Qt.openUrlExternally("http://m.nationalrail.co.uk/")
}

Here's an example for opening the alarm dialog outside of jolla-clock

import Nemo.Dbus 2.0

MouseArea {
    onClicked: jollaClock.newAlarm

LauncherItem {
    id: jollaClock
    filePath: "/usr/share/applications/jolla-clock.desktop"
}

DBusInterface {
    id: jollaClock
    service: "com.jolla.clock"
    path: "/"
    iface: "com.jolla.clock"
    function newAlarm() {
        call("newAlarm", [])
    }
edit flag offensive delete publish link more

Comments

Thia alternative with D-Bus is very interesting because of a specific part of the app, that is called. I use this approach several times in my app, but without a LauncherItem. For a LauncherItem you need to import import org.nemomobile.lipstick 0.1, needn't you?

jsommer ( 2019-09-08 00:48:36 +0300 )edit

I don't know. My SDK is playing up, so I can't even test. In reality, I rarely use the SDK as development for me is so much quicker on the device via SSH, but of course, if you are looking to place your app in Jolla Store then your app has to qualify. I am amazed at the total lack of slow progress with getting ANYTHING done with SDK, no doubt others will speak differently and praise the SDK, personally, I think it's a pile of bug ridden shit and am getting fed up with even trying to use it.....it's just another sucky thing about Jolla I guess.

Spam Hunter ( 2019-09-08 14:07:53 +0300 )edit

@Edz It is indeed a bit surprising that the SDK for Sailfish does not even resolve silica components and displays PageHeader as unknown.

jsommer ( 2019-09-08 17:59:09 +0300 )edit

hmm, weird, I have no problems with PageHeader in my few projects, although I did see it briefly underlined in red last time I compiled my app, but the red line went and the app compiled as expected and worked fine on my device, strange indeed.

Spam Hunter ( 2019-09-08 18:15:02 +0300 )edit
Login/Signup to Answer

Question tools

Follow
3 followers

Stats

Asked: 2019-09-07 23:14:20 +0300

Seen: 311 times

Last updated: Sep 08 '19