maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Help me to code for Sailfish OS (https://talk.maemo.org/showthread.php?t=100817)

rob_kouw 2019-12-26 19:37

Re: Help me to code for Sailfish OS
 
Unfortunately, I couldn't manage to bind the C++ and QML properly. In the end, I did all the RegExp work in php, and made it available at a web server. So then I could just work with QML-only code. I'm happy I got something working, and submitted it to Harbour just before Christmas.
Thanks for the help!

rob_kouw 2020-01-05 20:59

Re: Help me to code for Sailfish OS
 
I am struggling with some icons, shown in the PhotoDelegate. Do you have experience with the behaviour of icons in light Ambiences vs. dark Ambiences?

Thanks, Rob

Below: the problem.

Bottom layer is a rectangle. With a light Ambience, the rectangle must be darker to show a nice photo. Works properly.
Code:

    Rectangle {
        id: photoRect
        anchors {
            fill: parent
        }
        color: "black"
        opacity: Theme.colorScheme == 0  ? 0.65 : 0.9
    }

On top of this rectangle is the photo, works fine too.

Then in the upper right corner I show the logo of the broadcasting company as an IconButton. For dark Ambiences, it works fine. But for light Ambiences, something strange happens. Basically, I want to show the same logo. But a svg file with a white image, 0.40 opacity, will be shown as very dark grey, so like the inverse of the normal svg.

Code:

        IconButton {
            id: showBroadcast
            icon.source: (site === "NOS")
                            ? ( Theme.colorScheme == 0  ? Qt.resolvedUrl("images/icon-nos.svg") : Qt.resolvedUrl("images/icon-nos-light.svg") )
                            : ( Theme.colorScheme == 0  ? Qt.resolvedUrl("images/icon-the-guardian.svg") : Qt.resolvedUrl("images/icon-the-guardian-light.svg") )
            anchors {
                top: parent.top
                right: parent.right
            }

            onClicked: ExternalLinks.browse(link)
        }

Other tests performed: a logo of black with 1.0 opacity goes black. A logo of white with 1.0 opacity goes black. A logo with some red in it will show as grey.

As a workaround I could work with rectangle, mousearea and image, I guess...

coderus 2020-01-05 21:03

Re: Help me to code for Sailfish OS
 
Nowadays Icon* stuff in sfos using HighlightImage magic underneath to properly adjust monochrome icons for dark/light ambiences. Try using just monochrome white image and check if it magically convert to black in light ambience?

bobsikus 2020-01-09 20:27

Re: Help me to code for Sailfish OS
 
hello guys, maybe stupid question, maybe I did not judt find it.. is there proper reaction/signal on change of the OS's ambience?

rob_kouw 2020-01-09 21:41

Re: Help me to code for Sailfish OS
 
Might be somewhere in Theme...
Theme.colorScheme == 0 stands for a dark Ambience.

coderus 2020-01-09 21:45

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by rob_kouw (Post 1564259)
Might be somewhere in Theme...
Theme.colorScheme == 0 stands for a dark Ambience.

there are constants available:
Code:

Theme.LightOnDark
Theme.DarkOnLight

https://github.com/CODeRUS/better-sa...qmltypes#L1472

But if initial question was about actual ambience change, there is an example in sailfish code: https://github.com/CODeRUS/better-sa...indow.qml#L225

bobsikus 2020-01-10 07:37

Re: Help me to code for Sailfish OS
 
coderus: yes exactly, I have found that colorScheme is defined, only the reaction to that I had not found. Thanks a lot, I will look at it :)

EDIT: Thanks a lot, works :)

Code:

    import Sailfish.Silica.private 1.0

    ThemeTransaction {
        onAmbienceAboutToChange: doStuff() ;
    }


coderus 2020-01-10 09:14

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by bobsikus (Post 1564266)
coderus: yes exactly, I have found that colorScheme is defined, only the reaction to that I had not found. Thanks a lot, I will look at it :)

if you want to detect color scheme change then bind it to property and watch onPropertyChanged

bobsikus 2020-01-10 09:33

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1564270)
if you want to detect color scheme change then bind it to property and watch onPropertyChanged

I needed reaction of ambience change to do stuff I need it to do (change some colors based on if the ambience is actually dark or light, because buttons and text to buttons were based on that), If I will do it by binding, it would probably be a little bit less needy for system resources (don't do it everytime, do it only if this changes), so good point :)

EDIT: works!
Code:

    property real themeType: Theme.colorScheme

    onThemeTypeChanged: console.log ("AmbienceChange");


rob_kouw 2020-01-10 13:19

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1564260)
there are constants available:
Code:

Theme.LightOnDark
Theme.DarkOnLight

https://github.com/CODeRUS/better-sa...qmltypes#L1472

Ooh, nice. Thanks, it will clarify my code some more.


All times are GMT. The time now is 05:54.

vBulletin® Version 3.8.8