Skip to content

Commit c512acd

Browse files
Added font property to flat button style
1 parent 3832776 commit c512acd

7 files changed

+84
-264
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
build
22
/src/virtualkeyboard.pro.user
3+
/examples/qmlapp/qmlappdemo.pro.user.3.3-pre1
4+
/examples/qmlapp/*.exe
5+
/examples/qmlapp/qmlappdemo.pro.user

examples/qmlapp/ButtonFlatStyle.qml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import QtQuick 2.3
2+
import QtQuick.Controls 1.2
3+
import QtQuick.Controls.Styles 1.2
4+
5+
ButtonStyle {
6+
id: textfieldstyle
7+
property font font
8+
9+
background: Rectangle {
10+
id: bg
11+
color: !control.pressed ? "#00FFFFFF" : "#5caa15"
12+
radius: 6
13+
border.color: "#5caa15"
14+
border.width: 1.4
15+
}
16+
17+
label: Text {
18+
id: textLabel
19+
renderType: Text.NativeRendering
20+
verticalAlignment: Text.AlignVCenter
21+
horizontalAlignment: Text.AlignHCenter
22+
color: control.pressed ? "white" : "#5caa15"
23+
text: control.text
24+
font: textfieldstyle.font
25+
}
26+
27+
padding.left: 20
28+
padding.right: 20
29+
padding.top: 10
30+
padding.bottom: 10
31+
}

examples/qmlapp/FontAwesome.otf

83.9 KB
Binary file not shown.

examples/qmlapp/MainQuickControls.qml

+42-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Rectangle {
99
height: parent.height
1010
color: "white"
1111

12+
FontLoader {
13+
source: "FontAwesome.otf"
14+
}
15+
1216
Flickable {
1317
id: flickable
1418
anchors.fill: parent
@@ -24,10 +28,35 @@ Rectangle {
2428
width: flickable.width - 26
2529
height: syringe.implicitHeight
2630

27-
Syringe {
31+
Row {
2832
id: syringe
29-
anchors.horizontalCenter: parent.horizontalCenter
30-
width: parent.width * 0.7
33+
anchors.left: content.left
34+
anchors.right: content.right
35+
Button {
36+
id: emptyButton
37+
text: "\uf049"
38+
width: content.width * 0.1
39+
height: parent.height
40+
style: ButtonFlatStyle {
41+
font.family: "FontAwesome"
42+
font.pixelSize: 40
43+
}
44+
}
45+
46+
Syringe {
47+
width: content.width * 0.8
48+
}
49+
50+
Button {
51+
id: refillButton
52+
text: "\uf050"
53+
width: content.width * 0.1
54+
height: parent.height
55+
style: ButtonFlatStyle {
56+
font.family: "FontAwesome"
57+
font.pixelSize: 40
58+
}
59+
}
3160
}
3261

3362

@@ -54,6 +83,7 @@ Rectangle {
5483
width: grid.width - x
5584
placeholderText: "Volume (ml)"
5685
inputMethodHints: Qt.ImhFormattedNumbersOnly
86+
text: "0"
5787
validator: DoubleValidator {
5888
bottom: 0;
5989
top: 2000;
@@ -73,6 +103,12 @@ Rectangle {
73103
width: grid.width - x
74104
placeholderText: "Flow (ml/s)"
75105
inputMethodHints: Qt.ImhFormattedNumbersOnly
106+
validator: DoubleValidator {
107+
bottom: 0;
108+
top: 2000;
109+
notation: DoubleValidator.StandardNotation
110+
decimals: 3
111+
}
76112
}
77113

78114
// 3rd row ----------------------
@@ -88,6 +124,9 @@ Rectangle {
88124
maximumValue: 100
89125
value: 30
90126
style: SliderFlatStyle {}
127+
onValueChanged: {
128+
flowTextField.text = value
129+
}
91130
}
92131
}
93132
}

examples/qmlapp/Syringe.qml

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ Item {
1818
ProgressBar {
1919
id: progressBar
2020
anchors.left: parent.left
21-
anchors.leftMargin: 70
21+
anchors.leftMargin: Math.round(
22+
(syringeImage.width - syringeImage.paintedWidth) / 2 + syringeImage.paintedWidth * 0.125)
2223
anchors.right: parent.right
23-
anchors.rightMargin: 70
24+
anchors.rightMargin: Math.round(
25+
(syringeImage.width - syringeImage.paintedWidth) / 2 + syringeImage.paintedWidth * 0.13)
2426
anchors.verticalCenter: parent.verticalCenter
25-
height: 80
27+
height: syringeImage.height * 0.65
2628
minimumValue: 0
2729
maximumValue: 100
28-
value: 70
30+
value: 100
2931
style: syringeProgressBarStyle
3032
z: 0
3133
}

0 commit comments

Comments
 (0)