Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Changing ambience favorites using dbus in qml

    Reply
    Page 1 of 2 | 1   2   | Next
    anig | # 1 | 2018-07-23, 05:35 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to anig For This Useful Post:
    juiceme

     
    Markkyboy | # 2 | 2018-07-23, 10:11 | Report

    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!

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by Markkyboy; 2018-07-23 at 12:30.
    The Following User Says Thank You to Markkyboy For This Useful Post:
    juiceme

     
    anig | # 3 | 2018-07-23, 13:21 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to anig For This Useful Post:
    juiceme, taixzo

     
    Markkyboy | # 4 | 2018-07-23, 14:50 | Report

    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! :-/

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Markkyboy For This Useful Post:
    juiceme

     
    Halftux | # 5 | 2018-07-23, 15:42 | Report

    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}
                ]);

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Halftux For This Useful Post:
    juiceme

     
    Zeta | # 6 | 2018-07-23, 19:28 | Report

    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:
    Originally Posted by
    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Zeta For This Useful Post:
    juiceme

     
    anig | # 7 | 2018-07-24, 06:42 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to anig For This Useful Post:
    juiceme

     
    Halftux | # 8 | 2018-07-24, 07:55 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Halftux For This Useful Post:
    juiceme

     
    coderus | # 9 | 2018-07-24, 10:23 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to coderus For This Useful Post:
    juiceme, taixzo

     
    anig | # 10 | 2018-07-26, 05:20 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 3 Users Say Thank You to anig For This Useful Post:
    imaginaryenemy, juiceme, meloferz

     
    Page 1 of 2 | 1   2   | Next
vBulletin® Version 3.8.8
Normal Logout