We have moved to a new Sailfish OS Forum. Please start new discussions there.
2

HighlightImage doesn't support "image://theme/" [not relevant]

asked 2019-09-18 09:01:31 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2019-09-18 09:01:31 +0200

Tanghus gravatar image

When trying to set source on a HighlightImage with a path like image://theme/icon-m-transfer it builds a path like /user/share/harbour-<appname>/icon-m-transfer, which of course doesn't work.

edit retag flag offensive reopen delete

The question has been closed for the following reason "question is not relevant or outdated" by Tanghus
close date 2019-09-18 13:34:57.622251

Comments

1

Paste a snippet of your code here, seems like you're using it incorrectly, but I'm not sure.

Spam Hunter ( 2019-09-18 13:03:49 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-09-18 13:29:08 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2019-09-18 13:29:08 +0200

Tanghus gravatar image

I was indeed using it incorrectly. Originally I had done something like:

        HighlightImage {
            source: "image://theme/" + !Env.isOnline
                    ? "icon-m-wlan-no-signal"
                    : "icon-m-wlan"
            anchors.horizontalCenter: parent.horizontalCenter
        }

Which gave [W] unknown:343 - file:///usr/share/harbour-currencyconverter/qml/pages/FrontPage.qml:343:13: QML HighlightImageBase: Cannot open: file:///usr/share/harbour-currencyconverter/qml/pages/icon-m-wlan-no-signal

Doing this it works:

        HighlightImage {
            source: !Env.isOnline || workOffline
                    ? "image://theme/icon-m-wlan-no-signal"
                    : "image://theme/icon-m-wlan"
            anchors.horizontalCenter: parent.horizontalCenter
            width: 64
            height: 64
        }
edit flag offensive delete publish link more

Comments

I'll add yet another annoying thing about the documentation: What announces itself as "This is the complete list of members for HighlightImage, including inherited members" doesn't show anything from Image.

Tanghus ( 2019-09-18 13:33:43 +0200 )edit
1

Documentation on the whole, is pretty poor, especially for those new to coding. Even some of the examples given, don't work or are out of date, a pretty poor show really.

When I'm not sure about usage or syntax, I use grep to search my phone for that particular module. Usually there are a few examples to be found buried apps already.

Spam Hunter ( 2019-09-18 14:07:38 +0200 )edit

I've been wanting to sum it up in a better way, than "it sucks" ;)

Tanghus ( 2019-09-18 14:11:53 +0200 )edit
1

you using ternary operator wrong.

your example is same with

    source: ("image://theme/" + !Env.isOnline)
            ? "icon-m-wlan-no-signal"
            : "icon-m-wlan"

but you actually want

    source: "image://theme/" + (!Env.isOnline
                    ? "icon-m-wlan-no-signal"
                    : "icon-m-wlan")
coderus ( 2019-09-18 16:11:20 +0200 )edit

ah, I so didn't see that. Thanks.

Tanghus ( 2019-09-20 00:00:51 +0200 )edit

Question tools

Follow
2 followers

Stats

Asked: 2019-09-18 09:01:31 +0200

Seen: 170 times

Last updated: Sep 18 '19