Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CategoryButton.qml « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 049ca032f04a848b00bccb7a68f8e203cdc6755e (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
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
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) 2022 Ultimaker B.V.
// Uranium is released under the terms of the LGPLv3 or higher.

// Button used to collapse and de-collapse group, or a category, of settings
// the button contains
//   - the title of the category,
//   - an optional icon and
//   - a chevron button to display the colapsetivity of the settings
// Mainly used for the collapsable categories in the settings pannel

import QtQuick 2.2
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1

import UM 1.5 as UM

Button
{
    id: base

    height: UM.Theme.getSize("section_header").height

    property var expanded: false
    property bool indented: false
    property alias arrow: categoryArrow
    property alias categoryIcon: icon.source
    property alias labelText: categoryLabel.text
    property alias labelFont: categoryLabel.font
    leftPadding: UM.Theme.getSize("narrow_margin").width
    rightPadding: UM.Theme.getSize("narrow_margin").width
    states:
    [
        State
        {
            name: "disabled"
            when: !base.enabled
            PropertyChanges { target: categoryLabel; color: UM.Theme.getColor("setting_category_disabled_text") }
            PropertyChanges { target: icon; color: UM.Theme.getColor("setting_category_disabled_text") }
            PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_category_disabled") }
        },
        State
        {
            name: "hovered"
            when: base.hovered
            PropertyChanges { target: categoryLabel; color: UM.Theme.getColor("setting_category_active_text") }
            PropertyChanges { target: icon; color: UM.Theme.getColor("setting_category_active_text") }
            PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_category_hover") }
        },
        State
        {
            name: "active"
            when: base.pressed || base.activeFocus
            PropertyChanges { target: categoryLabel; color: UM.Theme.getColor("setting_category_active_text") }
            PropertyChanges { target: icon; color: UM.Theme.getColor("setting_category_active_text") }
            PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_category") }
        }
    ]

    background: Rectangle
    {
        id: backgroundRectangle

        color: UM.Theme.getColor("setting_category")
        Behavior on color { ColorAnimation { duration: 50 } }

        // Lining on top
        Rectangle
        {
            anchors.top: parent.top
            color: UM.Theme.getColor("border_main")
            height: UM.Theme.getSize("default_lining").height
            width: parent.width
        }
    }

    contentItem: Item
    {
        id: content
        //spacing: UM.Theme.getSize("narrow_margin").width

        UM.ColorImage
        {
            id: icon
            source: ""
            visible: icon.source != ""
            anchors.verticalCenter: parent.verticalCenter
            color: UM.Theme.getColor("setting_category_text")
            width: visible ? UM.Theme.getSize("section_icon").width: 0
            height: UM.Theme.getSize("section_icon").height
            anchors.leftMargin: base.indented ? UM.Theme.getSize("default_margin").width: 0
        }

        UM.Label
        {
            id: categoryLabel
            Layout.fillWidth: true
            anchors.right: categoryArrow.left
            anchors.left: icon.right
            anchors.leftMargin: base.indented ? UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width: UM.Theme.getSize("narrow_margin").width
            anchors.verticalCenter: parent.verticalCenter
            elide: Text.ElideRight
            wrapMode: Text.NoWrap
            font: UM.Theme.getFont("medium_bold")
            color: UM.Theme.getColor("setting_category_text")
        }

        UM.ColorImage
        {
            id: categoryArrow
            anchors.right: parent.right
            width: UM.Theme.getSize("standard_arrow").width
            height: UM.Theme.getSize("standard_arrow").height
            anchors.verticalCenter: parent.verticalCenter
            color: UM.Theme.getColor("setting_control_button")
            source: expanded ? UM.Theme.getIcon("ChevronSingleDown") : UM.Theme.getIcon("ChevronSingleLeft")
        }
    }
}