Notices


Reply
Thread Tools
Posts: 86 | Thanked: 156 times | Joined on Jan 2012
#1
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.
 

The Following User Says Thank You to anig For This Useful Post:
Markkyboy's Avatar
Posts: 321 | Thanked: 445 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#2
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!
__________________
| Openrepos | T.J.C. |

Don't just sit there standing around, pick up a shovel and sweep up!

Last edited by Markkyboy; 2018-07-23 at 12:30.
 

The Following User Says Thank You to Markkyboy For This Useful Post:
Posts: 86 | Thanked: 156 times | Joined on Jan 2012
#3
Originally Posted by Markkyboy View Post
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.
 

The Following 2 Users Say Thank You to anig For This Useful Post:
Markkyboy's Avatar
Posts: 321 | Thanked: 445 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#4
Originally Posted by anig View Post
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! :-/
__________________
| Openrepos | T.J.C. |

Don't just sit there standing around, pick up a shovel and sweep up!
 

The Following User Says Thank You to Markkyboy For This Useful Post:
Posts: 587 | Thanked: 1,615 times | Joined on Feb 2012 @ Germany
#5
Originally Posted by anig View Post
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}
            ]);
 

The Following User Says Thank You to Halftux For This Useful Post:
Posts: 303 | Thanked: 1,400 times | Joined on Oct 2013 @ France
#6
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:
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.
 

The Following User Says Thank You to Zeta For This Useful Post:
Posts: 86 | Thanked: 156 times | Joined on Jan 2012
#7
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.
 

The Following User Says Thank You to anig For This Useful Post:
Posts: 587 | Thanked: 1,615 times | Joined on Feb 2012 @ Germany
#8
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.
 

The Following User Says Thank You to Halftux For This Useful Post:
coderus's Avatar
Posts: 6,158 | Thanked: 11,661 times | Joined on Nov 2011 @ Open Mobile Platform, Innopolis, Russia
#9
Originally Posted by anig View Post
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.
__________________
Twitter | Openrepos | GitHub | PayPal.Me
 

The Following 2 Users Say Thank You to coderus For This Useful Post:
Posts: 86 | Thanked: 156 times | Joined on Jan 2012
#10
Originally Posted by Halftux View Post
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.
 

The Following 3 Users Say Thank You to anig For This Useful Post:
Reply

Tags
ambience, dbus-qml

Thread Tools

 
Forum Jump


All times are GMT. The time now is 08:44.