Ver código fonte

General cleanup.

Neal Wilson 12 anos atrás
pai
commit
d42375d587
2 arquivos alterados com 125 adições e 127 exclusões
  1. 68
    70
      qml/BrewPlot/ColorPicker.qml
  2. 57
    57
      qml/BrewPlot/main.qml

+ 68
- 70
qml/BrewPlot/ColorPicker.qml Ver arquivo

@@ -1,74 +1,72 @@
1 1
 import QtQuick 1.0
2 2
 
3 3
 Rectangle {
4
-	id: colorpicker
5
-	
6
-	color: "red"
7
-	Rectangle {
8
-		id: pickControl
9
-		
10
-		x: 40
11
-		y: 0
12
-		z: 10
13
-		width: 260
14
-		height: 50
15
-		color: "white"
16
-		border.color: "black"
17
-		border.width: 3
18
-		radius: 5
19
-		opacity: 0
20
-		
21
-		Behavior on opacity {
22
-			PropertyAnimation {
23
-				duration: 250
24
-			}
25
-		}
26
-		Repeater {
27
-			model: ListModel {
28
-			
29
-				ListElement {
30
-					theColor: "red"
31
-				}
32
-				ListElement {
33
-					theColor: "orange"
34
-				}
35
-				ListElement {
36
-					theColor: "yellow"
37
-				}
38
-				ListElement {
39
-					theColor: "green"
40
-				}
41
-				ListElement {
42
-					theColor: "blue"
43
-				}
44
-				ListElement {
45
-					theColor: "indigo"
46
-				}
47
-				ListElement {
48
-					theColor: "violet"
49
-				}
50
-			}
51
-			Rectangle {
52
-				width: 30
53
-				height: 30
54
-				x: (35*index)+10
55
-				y: 10
56
-				color: theColor
57
-				opacity: 1
58
-				MouseArea {
59
-					anchors.fill: parent
60
-					onClicked: {
61
-						pickControl.opacity = 0
62
-						colorpicker.color = parent.color
63
-					}
64
-				}
65
-			}
66
-		}
67
-	}
68
-	MouseArea {
69
-		anchors.fill: parent
70
-		onClicked: {
71
-			pickControl.opacity = 1
72
-		}
73
-	}
4
+    id: colorpicker
5
+
6
+    color: "red"
7
+    Rectangle {
8
+        id: pickControl
9
+
10
+        x: 40; y: 0; z: 10
11
+        width: 260; height: 50
12
+        color: "white"
13
+        border {color: "black"; width: 3}
14
+        radius: 5
15
+        opacity: 0
16
+
17
+        Repeater {
18
+            model: ListModel {
19
+
20
+                ListElement {
21
+                    theColor: "red"
22
+                }
23
+                ListElement {
24
+                    theColor: "orange"
25
+                }
26
+                ListElement {
27
+                    theColor: "yellow"
28
+                }
29
+                ListElement {
30
+                    theColor: "green"
31
+                }
32
+                ListElement {
33
+                    theColor: "blue"
34
+                }
35
+                ListElement {
36
+                    theColor: "indigo"
37
+                }
38
+                ListElement {
39
+                    theColor: "violet"
40
+                }
41
+            }
42
+            Rectangle {
43
+                width: 30; height: 30
44
+                x: (35*index)+10; y: 10
45
+                color: theColor
46
+                opacity: 1
47
+
48
+                MouseArea {
49
+                    anchors.fill: parent
50
+
51
+                    onClicked: {
52
+                        pickControl.opacity = 0
53
+                        colorpicker.color = parent.color
54
+                    }
55
+                }
56
+            }
57
+        }
58
+
59
+        Behavior on opacity {
60
+            PropertyAnimation {
61
+                duration: 250
62
+            }
63
+        }
64
+    }
65
+    MouseArea {
66
+        anchors.fill: parent
67
+
68
+        onClicked: {
69
+            pickControl.opacity = 1
70
+        }
71
+    }
74 72
 }

+ 57
- 57
qml/BrewPlot/main.qml Ver arquivo

@@ -12,49 +12,22 @@ Rectangle {
12 12
 
13 13
     width: 720
14 14
     height: 680
15
-    Component.onCompleted: {
16
-        var quitItem = window.addMenuItem("File", "Quit");
17
-        quitItem.shortcut = "Ctrl+Q";
18
-        quitItem.triggered.connect(function() {
19
-                                       Qt.quit();
20
-                                   });
21
-        var clearItem = window.addMenuItem("Plotting", "Clear Data");
22
-        clearItem.triggered.connect(function() {
23
-                                        graph.clear();
24
-                                        dataViewModel.clear();
25
-                                        root.sumy = 0;
26
-                                        root.sumxsq = 0;
27
-                                        root.sumx = 0;
28
-                                        root.sumxy = 0;
29
-                                        root.n = 0;
30
-                                        graph.setFit(0, 0, 0, 0);
31
-                                    });
32
-        var showLeastSquares = window.addMenuItem("Plotting", "Least Squares Fit");
33
-        showLeastSquares.checkable = true;
34
-        showLeastSquares.triggered.connect(function() {
35
-                                               graph.setFitVisible(showLeastSquares.checked);
36
-                                               lsfrow.visible = showLeastSquares.checked;
37
-                                           });
38
-    }
15
+
39 16
     BrewingControlChart {
40 17
         id: graph
41 18
 
42
-        width: 450
43
-        height: 600
44
-        anchors.right: parent.right
45
-        anchors.rightMargin: 20
46
-        anchors.top: parent.top
47
-        anchors.topMargin: 20
19
+        width: 450; height: 600
20
+        anchors {right: parent.right; rightMargin: 20; top: parent.top; topMargin: 20}
48 21
     }
49 22
     Item {
50
-        anchors.left: parent.left
51
-        anchors.leftMargin: 10
52
-        anchors.top: parent.top
53
-        anchors.topMargin: 10
23
+        anchors {left: parent.left; leftMargin: 10; top: parent.top; topMargin: 10}
24
+
54 25
         Column {
55 26
             spacing: 8
27
+
56 28
             Row {
57 29
                 spacing: 5
30
+
58 31
                 Text {
59 32
                     text: "Mass of ground coffee: "
60 33
                 }
@@ -69,10 +42,8 @@ Rectangle {
69 42
                     }
70 43
 
71 44
                     Line {
72
-                        x1: -3
73
-                        x2: 33
74
-                        y1: groundMass.height
75
-                        y2: y1
45
+                        x1: -3; y1: groundMass.height
46
+                        x2: 33; y2: y1
76 47
                         penWidth: 1
77 48
                         color: "black"
78 49
                     }
@@ -80,6 +51,7 @@ Rectangle {
80 51
             }
81 52
             Row {
82 53
                 spacing: 5
54
+
83 55
                 Text {
84 56
                     text: "Mass of brewed coffee:"
85 57
                 }
@@ -94,10 +66,8 @@ Rectangle {
94 66
                     }
95 67
 
96 68
                     Line {
97
-                        x1: -3
98
-                        x2: 33
99
-                        y1: brewedMass.height
100
-                        y2: y1
69
+                        x1: -3; y1: brewedMass.height
70
+                        x2: 33; y2: y1
101 71
                         penWidth: 1
102 72
                         color: "black"
103 73
                     }
@@ -105,11 +75,13 @@ Rectangle {
105 75
             }
106 76
             Row {
107 77
                 spacing: 56
78
+
108 79
                 Text {
109 80
                     text: "Percent TDS:"
110 81
                 }
111 82
                 TextInput {
112 83
                     id: ptds
84
+
113 85
                     width: 30
114 86
                     validator: DoubleValidator {
115 87
                         bottom: 0
@@ -117,11 +89,10 @@ Rectangle {
117 89
                         decimals: 2
118 90
                         notation: DoubleValidator.StandardNotation
119 91
                     }
92
+
120 93
                     Line {
121
-                        x1: -3
122
-                        x2: 33
123
-                        y1: ptds.height
124
-                        y2: y1
94
+                        x1: -3; y1: ptds.height
95
+                        x2: 33; y2: y1
125 96
                         penWidth: 1
126 97
                         color: "black"
127 98
                     }
@@ -129,29 +100,34 @@ Rectangle {
129 100
             }
130 101
             Row {
131 102
                 spacing: 87
103
+
132 104
                 Text {
133 105
                     id: colorlabel
106
+
134 107
                     text: "Color:"
135 108
                 }
136 109
                 ColorPicker {
137 110
                     id: colorpicker
138
-                    width: 37
139
-                    height: colorlabel.height
111
+
112
+                    width: 37; height: colorlabel.height
140 113
                 }
141 114
             }
142 115
             Row {
143 116
                 id: lsfrow
144
-                visible: false
145 117
 
118
+                visible: false
146 119
                 spacing: 1
120
+
147 121
                 Text {
148 122
                     id: fitcolorlabel
123
+
149 124
                     text: "Least Squares Fit Color:"
150 125
                 }
151 126
                 ColorPicker {
152 127
                     id: fitcolorpicker
153
-                    width: 37
154
-                    height: colorlabel.height
128
+
129
+                    width: 37; height: colorlabel.height
130
+
155 131
                     onColorChanged: {
156 132
                         graph.setFitColor(color)
157 133
                     }
@@ -160,19 +136,19 @@ Rectangle {
160 136
             Rectangle {
161 137
                 z: 0
162 138
                 anchors.horizontalCenter: parent.horizontalCenter
163
-                height: buttonText.height + 20
164
-                width: buttonText.width + 40
139
+                height: buttonText.height + 20; width: buttonText.width + 40
165 140
                 border.color: "black"
166 141
                 radius: 10
142
+
167 143
                 Text {
168 144
                     id: buttonText
169 145
 
170 146
                     text: "Plot This Brew"
171
-                    anchors.horizontalCenter: parent.horizontalCenter
172
-                    anchors.verticalCenter: parent.verticalCenter
147
+                    anchors {horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter}
173 148
                 }
174 149
                 MouseArea {
175 150
                     anchors.fill: parent
151
+
176 152
                     onClicked: {
177 153
                         var extraction = (brewedMass.text * (ptds.text / 100)) / groundMass.text
178 154
                         graph.plotPoint(extraction, (ptds.text / 100), colorpicker.color)
@@ -218,9 +194,9 @@ Rectangle {
218 194
                 }
219 195
                 delegate: Row {
220 196
                     spacing: 3
197
+
221 198
                     Rectangle {
222
-                        width: 30
223
-                        height: 30
199
+                        width: 30; height: 30
224 200
                         color: dataViewModel.get(index).color
225 201
                     }
226 202
                     Column {
@@ -235,4 +211,28 @@ Rectangle {
235 211
             }
236 212
         }
237 213
     }
214
+    Component.onCompleted: {
215
+        var quitItem = window.addMenuItem("File", "Quit");
216
+        quitItem.shortcut = "Ctrl+Q";
217
+        quitItem.triggered.connect(function() {
218
+            Qt.quit();
219
+        });
220
+        var clearItem = window.addMenuItem("Plotting", "Clear Data");
221
+        clearItem.triggered.connect(function() {
222
+            graph.clear();
223
+            dataViewModel.clear();
224
+            root.sumy = 0;
225
+            root.sumxsq = 0;
226
+            root.sumx = 0;
227
+            root.sumxy = 0;
228
+            root.n = 0;
229
+            graph.setFit(0, 0, 0, 0);
230
+        });
231
+        var showLeastSquares = window.addMenuItem("Plotting", "Least Squares Fit");
232
+        showLeastSquares.checkable = true;
233
+        showLeastSquares.triggered.connect(function() {
234
+            graph.setFitVisible(showLeastSquares.checked);
235
+            lsfrow.visible = showLeastSquares.checked;
236
+        });
237
+    }
238 238
 }

Carregando…
Cancelar
Salvar