maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Changing ambience favorites using dbus in qml (https://talk.maemo.org/showthread.php?t=100407)

anig 2018-07-23 05:35

Changing ambience favorites using dbus in qml
 
I'm trying to use dbus in qml to change the favorite ambience. I tried using the setFavorite method using the url to the ambience but it returns false. I used dbus monitor and found that the saveAttributes method is called when a favorite is changed in settings:

method call time=1532323566.490406 sender=:1.384 -> d
estination=com.jolla.ambienced serial=27 path=/com/jo
lla/ambienced; interface=com.jolla.ambienced; member=
saveAttributes
int32 1
int64 7
array [
dict entry(
string "favorite"
variant boolean true
)
]

The last argument is an array of dicts, a{sv}, how can I send that using the typedcall method in qml?

Thanks.

Markkyboy 2018-07-23 10:11

Re: Changing ambience favorites using dbus in qml
 
This has already been partially answered but on TJC; https://together.jolla.com/question/...mbient-change/

Example (assumes you have "Flow" ambience installed and set as a favourite);

Code:

dbus-send --session --dest=com.jolla.ambienced --type=method_call /com/jolla/ambienced com.jolla.ambienced.setAmbience string:"file:///usr/share/ambience/flow/flow.ambience"
But I have no idea how to incorporate this into QML, not without some research!

anig 2018-07-23 13:21

Re: Changing ambience favorites using dbus in qml
 
Quote:

Originally Posted by Markkyboy (Post 1546468)
This has already been partially answered but on TJC; https://together.jolla.com/question/...mbient-change/

Example (assumes you have "Flow" ambience installed and set as a favourite);

Code:

dbus-send --session --dest=com.jolla.ambienced --type=method_call /com/jolla/ambienced com.jolla.ambienced.setAmbience string:"file:///usr/share/ambience/flow/flow.ambience"
But I have no idea how to incorporate this into QML, not without some research!

Thanks but that is to set an ambience. Which I can do. What I want to do is change the favorites. This defines which ambiences are available when you swipe down to lock the screen.

Markkyboy 2018-07-23 14:50

Re: Changing ambience favorites using dbus in qml
 
Quote:

Originally Posted by anig (Post 1546470)
Thanks but that is to set an ambience. Which I can do. What I want to do is change the favorites. This defines which ambiences are available when you swipe down to lock the screen.

I see, sorry, I misunderstood, ...again! :-/

Halftux 2018-07-23 15:42

Re: Changing ambience favorites using dbus in qml
 
Quote:

Originally Posted by anig (Post 1546459)
The last argument is an array of dicts, a{sv}, how can I send that using the typedcall method in qml?

Thanks.


Maybe something similar to this?

Code:

var valueVariant = true;
dbif.typedCall('SetProperty', [
                {'type':'s', 'value': 'favorite'},
                {'type':'v', 'value': valueVariant}
            ]);


Zeta 2018-07-23 19:28

Re: Changing ambience favorites using dbus in qml
 
Not answering directly your question, but looking for ambience in /usr/share where all the qml files of Sailfish are stored, I found this file:
/usr/share/lipstick-jolla-home-qt5/powerkey/PowerKeyMenu.qml

In which you can find the following line to remove from favorites:
Quote:

onClicked: ambienceModel.setProperty(powerMenu.currentIndex, "favorite", false)
Obviously, setting the property to true should also make it a favorite.

It uses the object "AmbienceModel", that should come from the import Sailfish.Ambience.

Some other files are related to the AmbienceModel too, which could give you some other examples.

Hope this can help.

anig 2018-07-24 06:42

Re: Changing ambience favorites using dbus in qml
 
Thanks for the responses. I've tried many different permutations including the one above but they don't work.

I initially did try using AmbienceModel but it kept giving me an qsqlerror about could not open database, out of memory. I don't think it is a genuine out of memory issue but actually because the ambience database is a priviliged one. That is why I tried to then use dbus.

Halftux 2018-07-24 07:55

Re: Changing ambience favorites using dbus in qml
 
I can try to write qt code which you maybe could implement in your qml code or I could make a binary with parameter input which you could call from you qml code.
But this could take a bit because I am overloaded with jobs to get done.
Sadly I can't "speak" qml.

coderus 2018-07-24 10:23

Re: Changing ambience favorites using dbus in qml
 
Quote:

Originally Posted by anig (Post 1546494)
Thanks for the responses. I've tried many different permutations including the one above but they don't work.

I initially did try using AmbienceModel but it kept giving me an qsqlerror about could not open database, out of memory. I don't think it is a genuine out of memory issue but actually because the ambience database is a priviliged one. That is why I tried to then use dbus.

your app should be running with privileged group to do this.

anig 2018-07-26 05:20

Re: Changing ambience favorites using dbus in qml
 
Quote:

Originally Posted by Halftux (Post 1546499)
I can try to write qt code which you maybe could implement in your qml code or I could make a binary with parameter input which you could call from you qml code.
But this could take a bit because I am overloaded with jobs to get done.
Sadly I can't "speak" qml.

Thanks for the offer. This is for my kids mode application which is a combination of qml and python. I should be able to make this work using dbus in python. I'll post the solution here once I have it working.


All times are GMT. The time now is 22:11.

vBulletin® Version 3.8.8