Is it possible to know when a PlasmaCore IconItem is ready?

Michail Vourlakos mvourlakos at gmail.com
Thu Jul 28 11:43:19 UTC 2016


    Image {
        id: iconImageBuffer

        property int newTempSize: Math.floor(panel.iconSize *
wrapper.scale * wrapper.appearScale)
        width: newTempSize
        height: newTempSize

        anchors.centerIn: parent

        source: (wrapper.containsMouse === true)  ? activeIcon.source
: simpleIcon.source
        opacity: 0

        onSourceChanged: {
            opacity = 1;
        }

        Behavior on opacity {
            NumberAnimation { duration: 200 }
        }

    }

    Image{
        id:activeIcon
        visible:false
    }

    Component.onCompleted: {
        helper.createObject(this);
    }

//////////////////

    // Buffers an active icon into Image, activeIcon
    Component {
         id: helper
         Item {
             id: yourImageWithLoadedIconContainer
             anchors.fill: parent

             PlasmaCore.IconItem {
                 id: iconImage
                 width: 2 * panel.iconSize - 8
                 height: 2 * panel.iconSize - 8

                 active: true
                 enabled: true
                 usesPlasmaTheme: false

                 source: decoration

                 visible: false

                // timer taking the appearance of the image with shadow in it
                 Timer{
                     id:ttt
                     repeat:false
                     interval: 1
                     onTriggered: {
                         shadowImageNoActive.grabToImage(function(result) {
                             activeIcon.source = result.url;
                         }, Qt.size(iconImage.width,iconImage.height) );
                         ttt2.start();
                     }
                 }

                 // timer destroying the component
                 Timer{
                     id:ttt2
                     repeat:false
                     interval: 100
                     onTriggered: {
                         yourImageWithLoadedIconContainer.destroy();
                     }
                 }

                // starting the first timer
                Component.onCompleted: {
                     ttt.start();
                 }
             }
             DropShadow {
                 id:shadowImageNoActive
                 visible:false
                 width: 2 * panel.iconSize
                 height: 2 * panel.iconSize
                 anchors.centerIn: iconImage


                 radius: 7.0
                 samples: 10
                 color: "#aa080808"
                 source: iconImage
             }
         } // to be destoyed
     } // helper Component


On 7/28/16, Sebastian Kügler <sebas at kde.org> wrote:
> On donderdag 28 juli 2016 14:03:24 CEST Michail Vourlakos wrote:
>> is it possible to know when a PlasmaCore IconItem in QML is ready?
>> I am trying to use the grabToImage for that element and the only way
>> to achieve this until now, is after Component.OnCompleted to use a
>> timer element.
>>
>> I use a shadereffect to drop a shadow under various IconItems and
>> after that I animate them on hovering. By buffering them into Images
>> and animating these Images instead of the IconItems the interface
>> improves its respovinesss almost to double or even more.
>>
>> So is there a way to drop the Timer for these IconItems by creating
>> the needed buffers when the IconItem is ready? With Images this can be
>> done with onStatusChanged: if (status==Image.Ready)
>
> Could you post some code illustrating what you're trying to do? This makes
> it
> a bit easier to understand and more concrete to propose a solution. (Not
> that
> I know one, off-hand.)
>
> Cheers,
> --
> sebas
>
> http://www.kde.org | http://vizZzion.org
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>


More information about the Plasma-devel mailing list