Reply
Thread Tools
Posts: 34 | Thanked: 30 times | Joined on Nov 2011
#71
mm, related, both, property binding and "onAboutToChange" signal does not actually work completely. Thing is, both react "too soon". I had Assigned Theme.highlightColor to my property, problem is, there is actually "old" stuff in that property, so my property changes to what was there before the change of Ambience. I can bind property highlightColor and on that it reacts better but I suppose it might screw me if I would need to use any other Theme properties.. I need reaction on Ambience already changed, it might be through property binding, but I would need to know, which is "last in list". Or can I get status of changing the ambience?
 

The Following 2 Users Say Thank You to bobsikus For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#72
in the example above os handling ambience change with 600ms timer: https://github.com/CODeRUS/better-sa...indow.qml#L234
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following 3 Users Say Thank You to coderus For This Useful Post:
Posts: 34 | Thanked: 30 times | Joined on Nov 2011
#73
thanks, Timer then, I did not need Timer yet, I will look at it I could wrap some animation with it
Code:
    Timer {
        id: ambiencetimer
        interval: 1
        onTriggered: {applyAmbienceThemeColors();}
    }
It actually does not need bigger time, i put only 1ms and it works properly.
EDIT: for the record, as "ThemeChanger" property bindind I have used Theme._homeBackgroundImage , because it changes everytime you change the ambience, even if the actual background image is the same picture (tested )

Last edited by bobsikus; 2020-01-11 at 19:28.
 

The Following 3 Users Say Thank You to bobsikus For This Useful Post:
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, España
#74
Hi,

I have made a fully functioning UI for my LED RGBW lighting strip (10 rows / 4 buttons per row).

I have used a MouseArea for each button, but this makes the code bulky.

I would like to know how to call each IR code from another page within my app, but I don't really know where to start.

Currently, I have this for each button on my first page;

Code:
    Row { id: row1; ........
        Rectangle { id: brightUp; width: 60; height: 60; radius: 30 .......
            MouseArea {
                anchors.fill: brightUp
                onClicked: {
                    var xmlhttp = new XMLHttpRequest()
                    xmlhttp.onreadystatechange = function() {
                        if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
                            console.log("Brightness UP")
                        }
                    }
                    xmlhttp.open("POST", "http://192.168.0.222/lightup")
                    xmlhttp.send()
                }
            }
I was thinking that a matrix of all 40 codes could be listed on the second page, but how would this look?, how do I call each code when a button is clicked on my first page?

Thanks,
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..

Last edited by Markkyboy; 2020-03-16 at 12:26.
 

The Following User Says Thank You to Markkyboy For This Useful Post:
Halftux's Avatar
Posts: 862 | Thanked: 2,511 times | Joined on Feb 2012 @ Germany
#75
Originally Posted by Markkyboy View Post
I was thinking that a matrix of all 40 codes could be listed on the second page, but how would this look?, how do I call each code when a button is clicked on my first page?
When I get it right, you will also do it with signals:

https://doc-snapshots.qt.io/qt5-5.9/...x-signals.html
https://stackoverflow.com/questions/...qml-to-another
https://forum.qt.io/topic/103891/qml...-another-qml/6
 

The Following 2 Users Say Thank You to Halftux For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#76
inside main.qml declare:
Code:
function controlLamp(endpoint) {
  var xmlhttp = new XMLHttpRequest()
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
      console.log(endpoint)
    }
  }
  xmlhttp.open("POST", "http://192.168.0.222/" + endpoint)
  xmlhttp.send()
}
and call anywhere you want like:
Code:
MouseArea {
    anchors.fill: brightUp
    onClicked: {
        controlLamp("lightup")
    }
}
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following 5 Users Say Thank You to coderus For This Useful Post:
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, España
#77
Originally Posted by coderus View Post
inside main.qml declare:
Code:
function controlLamp(endpoint) {
  var xmlhttp = new XMLHttpRequest()
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
      console.log(endpoint)
    }
  }
  xmlhttp.open("POST", "http://192.168.0.222/" + endpoint)
  xmlhttp.send()
}
and call anywhere you want like:
Code:
MouseArea {
    anchors.fill: brightUp
    onClicked: {
        controlLamp("lightup")
    }
}
Thanks coderus, this works nicely, much appreciated!

I now have only one mouse area per row of 4 buttons, this is much better
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..

Last edited by Markkyboy; 2020-03-17 at 09:47.
 

The Following User Says Thank You to Markkyboy For This Useful Post:
Posts: 5 | Thanked: 5 times | Joined on Apr 2020 @ Biskupová, Slovakia
#78
Hi, I've been thinking of adding auto refresh interval to my app and also to add settings for that auto refresh and also for other things. Are there any simple code examples for C++ or JavaScript?
 

The Following User Says Thank You to Morc For This Useful Post:
Posts: 479 | Thanked: 1,284 times | Joined on Jan 2012 @ Enschede, The Netherlands
#79
Originally Posted by Morc View Post
Hi, I've been thinking of adding auto refresh interval to my app and also to add settings for that auto refresh and also for other things. Are there any simple code examples for C++ or JavaScript?
Guess we'd need a bit more than that. What language(s) is the app? QML has the Timer object, of which you can see an example earlier on this very page.

To store settings, SailishOS has the Configuration API for QML. I must say the documentation isn't very clear and lacking of any examples...
 

The Following 2 Users Say Thank You to Fuzzillogic For This Useful Post:
Posts: 5 | Thanked: 5 times | Joined on Apr 2020 @ Biskupová, Slovakia
#80
Originally Posted by Fuzzillogic View Post
Guess we'd need a bit more than that. What language(s) is the app? QML has the Timer object, of which you can see an example earlier on this very page.

To store settings, SailishOS has the Configuration API for QML. I must say the documentation isn't very clear and lacking of any examples...
I checked it again, and I actually made it as QML-only without C++ because I was not planning to use any C++ code in the time of making it. It's my mistake that i missed and i haven't seen that Timer object and example, I tried it and it's working flawlessly. So now only to figure out how to make those settings
 

The Following User Says Thank You to Morc For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 15:38.