summaryrefslogtreecommitdiff
path: root/components/custom/Button.qml
blob: ec01d9aab2469c2ccf45528e15d9b43c30309f6c (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
import QtQuick 1.1

BasicButton {
    id: button

    property string text
    property url iconSource

    property Component label: null

    property int leftMargin: 0
    property int topMargin: 0
    property int rightMargin: 0
    property int bottomMargin: 0

    // implementation

    implicitWidth: Math.max(minimumWidth, labelLoader.item ? labelLoader.item.implicitWidth : 0 + leftMargin + rightMargin)
    implicitHeight: Math.max(minimumHeight, labelLoader.item ? labelLoader.item.implicitHeight : 0 + topMargin + bottomMargin)

    minimumWidth: 0
    minimumHeight: 0

    background: defaultStyle.background

    Loader {
        id: labelLoader
        anchors.fill: parent
        anchors.leftMargin: leftMargin
        anchors.rightMargin: rightMargin
        anchors.topMargin: topMargin
        anchors.bottomMargin: bottomMargin
        property alias styledItem: button
        sourceComponent: label
    }
}