forked from benlau/quickios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBarButtonItem.qml
77 lines (60 loc) · 2.06 KB
/
BarButtonItem.qml
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
import QtQuick 2.0
import QtQuick.Controls 1.2
import QtGraphicalEffects 1.0
import "./def"
MouseArea {
id : barButtonItem
property alias title : textItem.text
property alias image : imageItem.source
property alias imageSourceSize : imageItem.sourceSize
/// Set it to true to ignore the tintColor and use the original image.
property bool renderOriginalImage : false
/// The font size of title
property alias fontSize : textItem.font.pixelSize
/// Set the font and related information via QML's font object.
property alias font : textItem.font
/// The tintColor for this component
property color tintColor : parent && parent.tintColor ? parent.tintColor : Constant.tintColor
property BarButtonItemStyle style : BarButtonItemStyle {}
width: Math.max(textItem.contentWidth,imageItem.width) + 16
height: textItem.contentHeight * (title !== "" ) + imageItem.height
Column {
width: parent.width
anchors.verticalCenter: parent.verticalCenter
Item {
width: imageItem.width
height: imageItem.height
anchors.horizontalCenter: parent.horizontalCenter
Image {
id : imageItem
visible: renderOriginalImage
}
ColorOverlay {
id : overlay
source: imageItem
anchors.fill: parent
color: tintColor
visible: image !== undefined && !renderOriginalImage
}
}
Text {
id: textItem
anchors.horizontalCenter: parent.horizontalCenter
font.family: "Helvetica Neue"
renderType: Text.NativeRendering
font.pixelSize: 16
color: barButtonItem.tintColor
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
states: [
State {
when: pressed
PropertyChanges {
target: barButtonItem
opacity : style.pressedOpacity
}
}
]
}