ControlItem.qml 2.54 KB
Newer Older
Leander Schulten's avatar
Leander Schulten committed
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtGraphicalEffects 1.0
import custom.licht.template 1.0
import custom.licht 1.0

ControlItemTemplate{

    moveable: UserManagment.currentUser.havePermission(Permission.MOVE_CONTROL_ITEM);
    id:item
    property bool pressed: false
    onPressedChanged:{
        if(pressed){
            rectangle.color="#C7C7FF";
        }else{
            rectangle.color="white";
        }
    }

    Rectangle{
        id:rectangle
        anchors.fill: parent
        border.width: 1
        border.color: "blue"
        radius: 3
        layer.enabled: true;
        layer.effect: FastBlur{
            id: meinBlur
            radius: 8
        }
        Behavior on color{

            ColorAnimation {
                duration: 200
            }
        }
    }
    onSettingVisibleChange: settings.opacity = visible

    Image {
        opacity: 0
        id: settings
        width: 18
        height: 18
        anchors.top: parent.top
        anchors.right: parent.right
        source: "icons/ic_settings_black_24px.svg"
        visible: popup!==null

        Behavior on rotation{
            NumberAnimation{
            }
        }
        Behavior on opacity{
            NumberAnimation{
            }
        }

        MouseArea{
            anchors.fill: parent
            hoverEnabled: true
            onEntered: settings.rotation=90
            onExited: settings.rotation=0
            onClicked: {
                var pos = mapToItem(parent.parent,mouse.x,mouse.y);
                popup.x = pos.x;
                popup.y = pos.y;
                popup.open();
            }
        }
    }
    Item {
        x:0;
        y:0;
    }

    Behavior on x{
        NumberAnimation{
            easing.type: Easing.OutExpo
        }
    }

    Behavior on y{
        NumberAnimation{
            easing.type: Easing.OutExpo
        }
    }
    onOpenPopup: {
        menu.x = x;
        menu.y = y;
        menu.open();
    }
    Menu{
        id: menu
        MenuItem{
            visible: popup!==null
            height: visible*implicitHeight
            text: "Settings"
            onClicked: {
                popup.x = menu.x;
                popup.y = menu.y;
                popup.open();
            }
        }
        MenuItem{
107
            enabled: UserManagment.currentUser.havePermission(Permission.REMOVE_CONTROL_ITEM);
Leander Schulten's avatar
Leander Schulten committed
108
109
110
111
112
113
114
115
116
117
            text: "Delete"
            onClicked: {
                item.parent=null;
                delete item;
            }

        }
    }
    property Popup popup;
}