blob: de34e1ab0c6c0be41fd4f19c6594ab131bd4634a (
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
|
import QtQuick 2.10
import QtQuick.Templates 2.1 as T
T.Button {
id: control
implicitWidth: Math.max(
background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(
background ? background.implicitHeight : 0,
contentItem.implicitHeight + topPadding + bottomPadding)
leftPadding: 4
rightPadding: 4
text: "My Button"
background: Item {
implicitWidth: buttonNormal.width
implicitHeight: buttonNormal.height
opacity: enabled ? 1 : 0.3
Rectangle {
id: buttonNormal
color: "#d4d4d4"
width: 100 //Bit of black magic to define the default size
height: 40
border.color: "gray"
border.width: 1
radius: 2
anchors.fill: parent //binding has to be preserved
Text {
id: normalText
x: 26
y: 14 //id only required to preserve binding
text: control.text //binding has to be preserved
//anchors.fill: parent
color: "gray"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
Rectangle {
id: buttonPressed
color: "#d4d4d4"
width: 100 //Bit of black magic to define the default size
height: 40
border.color: "gray"
border.width: 1
radius: 2
anchors.fill: parent //binding has to be preserved
Text {
x: 26
y: 14
id: pressedText //id only required to preserve binding
text: control.text //binding has to be preserved
//anchors.fill: parent
color: "black"
horizontalAlignment: Text.AlignHCenter // should not be preserved
verticalAlignment: Text.AlignVCenter // should not be preserved
elide: Text.ElideRight // should not be preserved
}
}
}
contentItem: Item {}
states: [
State {
name: "normal"
when: !control.down
PropertyChanges {
target: buttonPressed
visible: false
}
PropertyChanges {
target: buttonNormal
visible: true
}
},
State {
name: "down"
when: control.down
PropertyChanges {
target: buttonPressed
visible: true
}
PropertyChanges {
target: buttonNormal
visible: false
}
}
]
QtObject {
id: qds_stylesheet_merger_options
property bool preserveTextAlignment: true
}
}
|