Trying to get fonts working with marquee.
1.1 --- a/MarqueeText.qml Wed Jun 04 18:30:37 2014 +0200
1.2 +++ b/MarqueeText.qml Wed Jun 04 19:30:54 2014 +0200
1.3 @@ -9,6 +9,7 @@
1.4 property int pixelsPerSeconds:25
1.5 property alias text: scrollingText.text
1.6 property alias separator: separatorText.text
1.7 + property alias font: scrollingText.font
1.8
1.9 Label {
1.10 id:scrollingText
1.11 @@ -18,6 +19,7 @@
1.12 Label {
1.13 id:separatorText
1.14 text:" || "
1.15 + font: scrollingText.font
1.16 x:scrollingText.x+scrollingText.width
1.17 antialiasing: item.antialiasing
1.18 }
1.19 @@ -25,6 +27,7 @@
1.20 Label {
1.21 id:followingText
1.22 text:scrollingText.text
1.23 + font: scrollingText.font
1.24 x:scrollingText.x+scrollingText.width+separatorText.width
1.25 antialiasing: item.antialiasing
1.26 }
2.1 --- a/TestsTab.qml Wed Jun 04 18:30:37 2014 +0200
2.2 +++ b/TestsTab.qml Wed Jun 04 19:30:54 2014 +0200
2.3 @@ -3,6 +3,8 @@
2.4 import QtQuick.Window 2.1
2.5 import MiniDisplay 1.0
2.6 import QtQuick.Layouts 1.1
2.7 +import QtQuick.Dialogs 1.1
2.8 +import Qt.labs.settings 1.0
2.9
2.10
2.11 Item {
2.12 @@ -13,6 +15,12 @@
2.13 clip: true
2.14 //anchors.fill:parent
2.15
2.16 + Settings {
2.17 + //property alias fontLineTop: marqueeLineTop.font;
2.18 + //property alias fontLineBottom: marqueeLineBottom.font;
2.19 + }
2.20 +
2.21 +
2.22
2.23 //This window is our VFD frame
2.24 Window {
2.25 @@ -52,79 +60,48 @@
2.26 smooth: false
2.27 }
2.28
2.29 - MarqueeText {
2.30 - width: 256
2.31 - pixelsPerSeconds:50
2.32 - anchors.verticalCenter: parent.verticalCenter
2.33 - anchors.horizontalCenter: parent.horizontalCenter
2.34 - text: "start ---- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---- end"
2.35 - separator: " | "
2.36 - }
2.37 + ColumnLayout {
2.38
2.39 - GridLayout {
2.40 - anchors.fill:parent
2.41 - anchors.margins: 6
2.42 - //spacing: 4
2.43 - columns: 4
2.44 -
2.45 - Label {
2.46 - text: "Frames:"
2.47 - antialiasing: false
2.48 + MarqueeText {
2.49 + id: marqueeLineTop
2.50 + width: 256
2.51 + pixelsPerSeconds:50
2.52 + //anchors.verticalCenter: parent.verticalCenter
2.53 + //anchors.horizontalCenter: parent.horizontalCenter
2.54 + text: "start ---- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---- end"
2.55 + separator: " | "
2.56 }
2.57
2.58 - Label {
2.59 - text: "Time (s):"
2.60 - antialiasing: false
2.61 + MarqueeText {
2.62 + id: marqueeLineBottom
2.63 + width: 256
2.64 + pixelsPerSeconds:50
2.65 + //anchors.verticalCenter: parent.verticalCenter
2.66 + //anchors.horizontalCenter: parent.horizontalCenter
2.67 + text: "start ---- abcdefghijklmnopqrstuvwxyz-1234567890 ---- end"
2.68 + separator: " | "
2.69 }
2.70
2.71 - Label {
2.72 - text: "Time/Frame (ms):"
2.73 - antialiasing: false
2.74 - }
2.75 -
2.76 - Label {
2.77 - text: "FPS:"
2.78 - antialiasing: false
2.79 - }
2.80 -
2.81 - Label {
2.82 - id: labelFrameCount
2.83 - text: "Frame Count"
2.84 - antialiasing: false
2.85 - }
2.86 -
2.87 - Label {
2.88 - id: labelTime
2.89 - text: "Time"
2.90 - antialiasing: false
2.91 - }
2.92 -
2.93 - Label {
2.94 - id: labelTimePerFrame
2.95 - text: "Time/Frame"
2.96 - antialiasing: false
2.97 - }
2.98 -
2.99 - Label {
2.100 - id: labelFps
2.101 - text: "FPS"
2.102 - antialiasing: false
2.103 - }
2.104 -
2.105 - //onA: {}
2.106
2.107 }
2.108
2.109 +
2.110 +
2.111 //This function is called from C++ afterAnimating.
2.112 +
2.113 +
2.114 //It means it is called in sync with Qt render loop.
2.115 //Qt render loop tries to run at 60 FPS.
2.116 + //We should not modify the content of our display window from here as will cause UI lags when runing 60 times per second.
2.117 function doFrame(frameCount)
2.118 {
2.119 //Skip every second frame otherwise our UI lags.
2.120 if (frameCount%2!=0)
2.121 {
2.122 - return;
2.123 + //labelFrameTick.text="-";
2.124 + //return;
2.125 }
2.126 + //labelFrameTick.text="+";
2.127
2.128 var current = new Date();
2.129 var milliseconds = (current.getTime() - startTime.getTime());
2.130 @@ -190,76 +167,163 @@
2.131
2.132 }
2.133
2.134 - Column {
2.135 - anchors.fill: parent
2.136 - anchors.margins: 8
2.137 - spacing: 8
2.138
2.139 - Button {
2.140 - text: qsTr("Render Window")
2.141 - onClicked: {
2.142 - display.renderWindow(frameWindow);
2.143 - display.swapBuffers();
2.144 + FontDialog {
2.145 + id: fontDialog
2.146 + visible: false
2.147 + modality: Qt.WindowModal
2.148 + scalableFonts: true
2.149 + nonScalableFonts: true
2.150 + monospacedFonts: true
2.151 + proportionalFonts: true
2.152 + title: qsTr("Choose a font")
2.153 + font: marqueeLineTop.font
2.154 + currentFont: marqueeLineTop.font
2.155 + //onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) }
2.156 + //onFontChanged: { console.log("FontChanged: " + font) }
2.157 + onAccepted: {
2.158 + //console.log("Accepted: " + font);
2.159 + marqueeLineTop.font = currentFont;
2.160 + marqueeLineBottom.font = currentFont;
2.161 + }
2.162 + //onRejected: { console.log("Rejected") }
2.163 + }
2.164 +
2.165 +
2.166 + GridLayout {
2.167 + //anchors.fill:parent
2.168 + anchors.centerIn: parent
2.169 + anchors.margins: 6
2.170 + //width:parent.width/2
2.171 + height:parent.height/2
2.172 +
2.173 + //spacing: 4
2.174 + columns: 4
2.175 +
2.176 + Button {
2.177 + text: qsTr("Render Window")
2.178 + onClicked: {
2.179 + display.renderWindow(frameWindow);
2.180 + display.swapBuffers();
2.181 + }
2.182 }
2.183 - }
2.184
2.185 - Button {
2.186 - text: qsTr("Reset stats")
2.187 - onClicked: {
2.188 - frameWindow.startTime = new Date();
2.189 - //frameWindow.frameCounter = 0;
2.190 - frameWindow.firstFrame = -1;
2.191 + Button {
2.192 + text: qsTr("Reset stats")
2.193 + onClicked: {
2.194 + frameWindow.startTime = new Date();
2.195 + //frameWindow.frameCounter = 0;
2.196 + frameWindow.firstFrame = -1;
2.197 + }
2.198 }
2.199 - }
2.200
2.201 - CheckBox {
2.202 - text: qsTr("Run timer")
2.203 - checked: true
2.204 - onCheckedChanged: {
2.205 - (checked?timer.start():timer.stop())
2.206 + CheckBox {
2.207 + id: checkBoxDoClear
2.208 + text: qsTr("Do clear")
2.209 + checked: true
2.210 }
2.211 - }
2.212
2.213 - CheckBox {
2.214 - id: checkBoxDoClear
2.215 - text: qsTr("Do clear")
2.216 - checked: true
2.217 - }
2.218 + CheckBox {
2.219 + id: checkBoxRenderToDisplay
2.220 + text: qsTr("Render to display")
2.221 + checked: true
2.222 + }
2.223
2.224 - CheckBox {
2.225 - id: checkBoxRenderToDisplay
2.226 - text: qsTr("Render to display")
2.227 - checked: true
2.228 - }
2.229 + CheckBox {
2.230 + id: checkBoxFillAndClearOnly
2.231 + text: qsTr("Only fill and clear")
2.232 + checked: false
2.233 + }
2.234
2.235 - CheckBox {
2.236 - id: checkBoxFillAndClearOnly
2.237 - text: qsTr("Only fill and clear")
2.238 - checked: false
2.239 - }
2.240 + CheckBox {
2.241 + id: checkBoxNoSwapBuffers
2.242 + text: qsTr("No swap buffers")
2.243 + checked: false
2.244 + }
2.245
2.246 - CheckBox {
2.247 - id: checkBoxNoSwapBuffers
2.248 - text: qsTr("No swap buffers")
2.249 - checked: false
2.250 - }
2.251 + CheckBox {
2.252 + id: checkBoxOnePixelOnly
2.253 + text: qsTr("One pixel only")
2.254 + checked: false
2.255 + }
2.256
2.257 - CheckBox {
2.258 - id: checkBoxOnePixelOnly
2.259 - text: qsTr("One pixel only")
2.260 - checked: false
2.261 - }
2.262 + CheckBox {
2.263 + text: qsTr("Off-Screen")
2.264 + checked: true
2.265 + onCheckedChanged: {display.offScreenMode = checked;}
2.266 + }
2.267
2.268 - CheckBox {
2.269 - text: qsTr("Off-Screen")
2.270 - checked: true
2.271 - onCheckedChanged: {display.offScreenMode = checked;}
2.272 - }
2.273 + CheckBox {
2.274 + text: qsTr("Frame differencing")
2.275 + checked: true
2.276 + onCheckedChanged: {display.frameDifferencing = checked;}
2.277 + }
2.278
2.279 - CheckBox {
2.280 - text: qsTr("Frame differencing")
2.281 - checked: true
2.282 - onCheckedChanged: {display.frameDifferencing = checked;}
2.283 - }
2.284 + Button {
2.285 + text: qsTr("Change font")
2.286 + onClicked: {
2.287 + //We had to do this double magic cause otherwise our font list
2.288 + //would not reflect our options.
2.289 + fontDialog.setVisible(true);
2.290 + fontDialog.open();
2.291 + }
2.292 + }
2.293 +
2.294 + Label {
2.295 + text: ""
2.296 + antialiasing: false
2.297 + }
2.298 +
2.299 + Label {
2.300 + text: ""
2.301 + antialiasing: false
2.302 + }
2.303 +
2.304 +
2.305 + Label {
2.306 + id: labelFrameTick
2.307 + text: "Frames:"
2.308 + antialiasing: false
2.309 + }
2.310 +
2.311 + Label {
2.312 + text: "Time (s):"
2.313 + antialiasing: false
2.314 + }
2.315 +
2.316 + Label {
2.317 + text: "Time/Frame (ms):"
2.318 + antialiasing: false
2.319 + }
2.320 +
2.321 + Label {
2.322 + text: "FPS:"
2.323 + antialiasing: false
2.324 + }
2.325 +
2.326 + Label {
2.327 + id: labelFrameCount
2.328 + text: "Frame Count"
2.329 + antialiasing: false
2.330 + }
2.331 +
2.332 + Label {
2.333 + id: labelTime
2.334 + text: "Time"
2.335 + antialiasing: false
2.336 + }
2.337 +
2.338 + Label {
2.339 + id: labelTimePerFrame
2.340 + text: "Time/Frame"
2.341 + antialiasing: false
2.342 + }
2.343 +
2.344 + Label {
2.345 + id: labelFps
2.346 + text: "FPS"
2.347 + antialiasing: false
2.348 + }
2.349 +
2.350 }
2.351 }