A couple of questions about QML Plasma bindings

Marco Martin notmart at gmail.com
Sat Mar 19 11:05:27 CET 2011


On Friday 18 March 2011, Diego Casella ([Po]lentino) wrote:
> Hello guys,
> as you should've seen in my latest posts in planetkde, I'm working on a
> plasmoid version of the standard KMix applet.
> I coded it in QML and of course I've taken advantage of the Plasma QML
> bindings (they _really_ rocks!!), and now I've got some questions for you:
> 
> * I want to give a more elegant and pleasant look to KMix applet, and I
> need to access the monochrome svg audio-* icons, but I have no idea about
> how to do it.
>   In C++ this is veeeery easy: a simple call
> to Plasma::Theme::defaultTheme()->imagePath(svg) and, if the returned path
> is not empty I can use it, otherwise I will fallback to
>   the standard icon. So, is it possible to expose something similar to the
> existing QML Theme component?

in the mobile systray applet i did:

    PlasmaCore.Svg{
        id: iconSvg
        imagePath: "icons/"+String(IconName).split('-')[0]
        Component.onCompleted: {
            var hasSvg = iconSvg.hasElement(IconName)
            normalIcon.visible = !hasSvg
            svgItemIcon.visible = hasSvg
        }
    }

    QtExtra.QIconItem {
        id: normalIcon
        anchors.fill: parent
        icon: Icon
    }
    PlasmaCore.SvgItem {
        id: svgItemIcon
        anchors.fill: parent
        svg: iconSvg
        elementId: IconName
    }

this way fallback can be done
(it could be made more sophisticated by using a Loader to load the actual icon 
and the svg, so they won't all get loaded)

perhaps there could be interest in doing an importable component that does 
that...


> 
> * I'd like to show a tooltip when the applet is collapsed into an icon in
> the panel but, still, there are no QML bindings to Plasma::ToolTipContent
> and ToolTipManager classes.
>   Is there any chances to get it exposed to QML?

hm, no, unfortunately at the moment there isn't any way..
i should come up with something
I *think* tha writing a ToolTipData element (just a qobject) that has the 
usual tooltip data as properties, it could then register its parent if it't a 
qgraphicsitem to the plasma tooltip manager.
it would remain the unpretty thing of being possible to put two or more 
tooltip datas as child of any given item and this kinda sucks

(or the tooltip data could be registered in the qscriptengine and 
created/assigned in an imperative way)

opinions on it?

Cheers,
Marco Martin


More information about the Plasma-devel mailing list