Testing our double marquee.
2 import QtQuick.Controls 1.2
3 import QtQuick.Window 2.1
5 import QtQuick.Layouts 1.1
6 import QtQuick.Dialogs 1.1
7 import Qt.labs.settings 1.0
14 //SystemPalette { id: palette }
19 property alias fontLineTop: marqueeLineTop.font;
20 property alias fontLineBottom: marqueeLineBottom.font;
25 //This window is our VFD frame
31 //Splash screen type do not have any border which is what we want
32 flags: Qt.SplashScreen
34 //property int timeoutInterval: 41
36 //! [splash-properties]
37 //! [screen-properties]
38 //Here comes some trick to keep our display frame within our app.
39 //This make sure this window follows our app window.
40 x: appWindow.x+appWindow.width-256-13
41 y: appWindow.y+appWindow.height-64-30
43 //! [screen-properties]
44 width: rectangleScreen.width
45 height: rectangleScreen.height
46 //property int frameCounter:0;
47 property int firstFrame:-1;
48 property var startTime:new Date();
52 anchors.centerIn: parent
68 //anchors.verticalCenter: parent.verticalCenter
69 //anchors.horizontalCenter: parent.horizontalCenter
70 text: "start ---- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---- end"
79 //anchors.verticalCenter: parent.verticalCenter
80 //anchors.horizontalCenter: parent.horizontalCenter
81 text: "start ---- abcdefghijklmnopqrstuvwxyz-1234567890 ---- end"
90 //This function is called from C++ afterAnimating.
93 //It means it is called in sync with Qt render loop.
94 //Qt render loop tries to run at 60 FPS.
95 //We should not modify the content of our display window from here as will cause UI lags when runing 60 times per second.
96 function doFrame(frameCount)
98 //Skip every second frame otherwise our UI lags.
101 //labelFrameTick.text="-";
104 //labelFrameTick.text="+";
106 var current = new Date();
107 var milliseconds = (current.getTime() - startTime.getTime());
111 firstFrame=frameCount
115 var frameCounter=(frameCount-firstFrame)/4;
116 labelFrameCount.text=frameCounter;
117 labelTime.text=milliseconds/1000;
118 labelTimePerFrame.text=(milliseconds/frameCounter).toFixed(3);
119 labelFps.text=(1000/(milliseconds/frameCounter)).toFixed(0);
121 if (checkBoxDoClear.checked)
126 if (checkBoxRenderToDisplay.checked)
128 if (checkBoxFillAndClearOnly.checked)
130 //Trying to make it a worse case scenario for our frame diff algo
145 else if (checkBoxOnePixelOnly.checked)
147 display.setPixel(0,0,frameCounter%2);
151 display.renderWindow(frameWindow);
154 if (!checkBoxNoSwapBuffers.checked)
156 display.swapBuffers();
163 Component.onCompleted: {
165 display.connectRenderLoop(frameWindow,doFrame);
174 modality: Qt.WindowModal
176 nonScalableFonts: true
177 monospacedFonts: true
178 proportionalFonts: true
179 title: qsTr("Choose a font")
180 font: marqueeLineTop.font
181 currentFont: marqueeLineTop.font
182 //onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) }
183 //onFontChanged: { console.log("FontChanged: " + font) }
185 //console.log("Accepted: " + font);
186 marqueeLineTop.font = currentFont;
187 marqueeLineBottom.font = currentFont;
189 //onRejected: { console.log("Rejected") }
194 //anchors.fill:parent
195 anchors.centerIn: parent
197 //width:parent.width/2
198 height:parent.height/2
204 text: qsTr("Render Window")
206 display.renderWindow(frameWindow);
207 display.swapBuffers();
212 text: qsTr("Reset stats")
214 frameWindow.startTime = new Date();
215 //frameWindow.frameCounter = 0;
216 frameWindow.firstFrame = -1;
222 text: qsTr("Do clear")
227 id: checkBoxRenderToDisplay
228 text: qsTr("Render to display")
233 id: checkBoxFillAndClearOnly
234 text: qsTr("Only fill and clear")
239 id: checkBoxNoSwapBuffers
240 text: qsTr("No swap buffers")
245 id: checkBoxOnePixelOnly
246 text: qsTr("One pixel only")
251 text: qsTr("Off-Screen")
253 onCheckedChanged: {display.offScreenMode = checked;}
257 text: qsTr("Frame differencing")
259 onCheckedChanged: {display.frameDifferencing = checked;}
263 text: qsTr("Change font")
265 //We had to do this double magic cause otherwise our font list
266 //would not reflect our options.
267 fontDialog.setVisible(true);
295 text: "Time/Frame (ms):"
317 id: labelTimePerFrame