aboutsummaryrefslogtreecommitdiff
path: root/components/ContextMenuItem.qml
blob: 64279b92c9097ae7c4a28507aef1acf2a5d565f4 (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
53
54
55
56
57
58
59
60
61
62
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.1

import FontAwesome 1.0
import "../components" as MonzeroComponents

MenuItem {
    id: menuItem

    property bool glyphIconSolid: true
    property alias glyphIcon: glyphIcon.text

    background: Rectangle {
        color: MonzeroComponents.Style.buttonBackgroundColorDisabledHover
        opacity: 0

        MouseArea {
            id: mouse

            anchors.fill: parent
            hoverEnabled: true
            onEntered: {
                parent.opacity = 1;
            }
            onExited: {
                parent.opacity = 0;
            }
            onClicked: {
                if (menuItem.enabled) {
                    menuItem.triggered();
                    parent.opacity = 0;
                }
            }
        }
    }

    contentItem: RowLayout {
        anchors.fill: parent
        anchors.leftMargin: 20
        anchors.rightMargin: 10
        opacity: menuItem.enabled ? 1 : 0.4
        spacing: 8

        Text {
            id: glyphIcon

            color: MonzeroComponents.Style.buttonTextColor
            font.family: glyphIconSolid ? FontAwesome.fontFamilySolid : FontAwesome.fontFamily
            font.pixelSize: 14
            font.styleName: glyphIconSolid ? "Solid" : "Regular"
        }

        Text {
            color: MonzeroComponents.Style.blackTheme ? MonzeroComponents.Style.buttonTextColor : MonzeroComponents.Style.defaultFontColor
            font.family: MonzeroComponents.Style.fontRegular.name
            font.pixelSize: 14
            Layout.fillWidth: true
            text: menuItem.text
        }
    }
}