summaryrefstree
path: root/usr/bin/qml_link/AppLink/Com/HMIRoundCover.qml
blob: 8ef03ec862d91ac9c08640750cd4cade67017573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import QtQuick 2.0
//import QtQuick.Controls 1.1
//import QtQuick.Window 2.0
//import QtQuick.Controls.Styles 1.1
//import QtGraphicalEffects 1.0


Item {
    id:mainRect
    property string
    source: ""
    property color color: "black"
    property int border: 2
    Canvas {
          id: canvas
          width: parent.width;
          height: parent.height
          property real hue: 0.0

          onPaint: {
              var ctx = getContext("2d")
              ctx.lineWidth = border

              ctx.save()
              ctx.strokeStyle = color;
              ctx.beginPath()
              ctx.arc(mainRect.width/2, mainRect.height/2, mainRect.width/2, 0, Math.PI * 2, true);
              ctx.closePath()
              ctx.clip()

              ctx.drawImage(source, 0, 0,canvas.width,canvas.height)

              ctx.closePath()
              ctx.stroke()

              ctx.restore()
          }

          onImageLoaded: {
              mainRect.repaintUI();
          }
    }
    onSourceChanged:{
        canvas.requestPaint();
    }

    function repaintUI() {
        canvas.requestPaint();
    }
}