• File: C_blinking_rect.qml
  • Full Path: /home/insbudnet/domains/insbud.net/public_html/download/software/qml/sieniczno_nowak/qml/pl/commons/C_blinking_rect.qml
  • File size: 1.76 KB
  • MIME-type: text/plain
  • Charset: utf-8
 
Open Back
import QtQuick 2.3
import QtQuick.Layouts 1.1

Rectangle {
    property string prop_color: "red"
    property string prop_border_color: "gray"
    property int prop_radius: 5
    property int prop_change_time: 1000
    property int prop_blinking: 0
    property double prop_opacity_from: 1
    property double prop_opacity_to: 0

    id: main
    width: 100
    height: 200
    color: "transparent"
    state: "min"

    Timer {
        interval: prop_change_time
        running: true
        repeat: true
        onTriggered: state == "max" ? state = "min" : state = "max";
    }
    
    Rectangle {
        id: my_recangle
        x: 0
        y: 0
        width: parent.width
        height: parent.height
        color: prop_color
        border.color: prop_border_color
        radius: prop_radius
    }

    Rectangle {
        id: my_recangle2
        x: 0
        y: 0
        width: parent.width
        height: parent.height
        color: prop_color
        border.color: prop_border_color
        radius: prop_radius
        opacity: !prop_blinking
    }

    states: [
        State {
            name: "max"
            PropertyChanges { target: my_recangle; opacity: prop_opacity_to }
        },
        State {
            name: "min"
            PropertyChanges { target: my_recangle; opacity: prop_opacity_from }
        }
    ]


    transitions: [
        Transition {
            from: "max"; to: "min"; reversible: true
            PropertyAnimation { target: my_recangle; properties: "opacity"; duration: 200 }
        },
        Transition {
            from: "min"; to: "max"; reversible: true
            PropertyAnimation { target: my_recangle; properties: "opacity"; duration: 200 }
        }
    ]
}