author | sl |
Sun, 01 Jun 2014 21:15:33 +0200 | |
changeset 23 | 1f607fa8542f |
parent 22 | ca9e48af31e6 |
child 24 | 783a937d3eb3 |
permissions | -rw-r--r-- |
sl@0 | 1 |
import QtQuick 2.2 |
sl@0 | 2 |
import QtQuick.Controls 1.2 |
sl@15 | 3 |
import QtQuick.Window 2.1 |
sl@15 | 4 |
import MiniDisplay 1.0 |
sl@15 | 5 |
import QtQuick.Layouts 1.1 |
sl@15 | 6 |
|
sl@0 | 7 |
|
sl@0 | 8 |
Item { |
sl@17 | 9 |
id: testTab |
sl@15 | 10 |
//width: 100 |
sl@15 | 11 |
//height: 62 |
sl@0 | 12 |
//SystemPalette { id: palette } |
sl@0 | 13 |
clip: true |
sl@15 | 14 |
//anchors.fill:parent |
sl@0 | 15 |
|
sl@15 | 16 |
|
sl@18 | 17 |
//This window is our VFD frame |
sl@15 | 18 |
Window { |
sl@15 | 19 |
//parent: appWindow |
sl@15 | 20 |
id: splash |
sl@15 | 21 |
color: "transparent" |
sl@15 | 22 |
title: "Splash Window" |
sl@15 | 23 |
modality: Qt.NonModal |
sl@15 | 24 |
flags: Qt.SplashScreen |
sl@21 | 25 |
//24 FPS |
sl@21 | 26 |
//property int timeoutInterval: 41 |
sl@21 | 27 |
//32 FPS |
sl@21 | 28 |
property int timeoutInterval: 33 |
sl@15 | 29 |
signal timeout |
sl@15 | 30 |
//! [splash-properties] |
sl@15 | 31 |
//! [screen-properties] |
sl@17 | 32 |
//x: (Screen.width - rectangleScreen.width) / 2 |
sl@17 | 33 |
//y: (Screen.height - rectangleScreen.height) / 2 |
sl@17 | 34 |
x: appWindow.x+appWindow.width-256-13 |
sl@17 | 35 |
y: appWindow.y+appWindow.height-64-30 |
sl@17 | 36 |
|
sl@15 | 37 |
//! [screen-properties] |
sl@15 | 38 |
width: rectangleScreen.width |
sl@15 | 39 |
height: rectangleScreen.height |
sl@15 | 40 |
property int frameCounter:0; |
sl@15 | 41 |
property var startTime:new Date(); |
sl@15 | 42 |
|
sl@15 | 43 |
Rectangle { |
sl@15 | 44 |
id: rectangleScreen |
sl@15 | 45 |
anchors.centerIn: parent |
sl@15 | 46 |
width: 256 |
sl@15 | 47 |
height: 64 |
sl@15 | 48 |
color: "white" |
sl@15 | 49 |
border.width:1 |
sl@15 | 50 |
border.color: "black" |
sl@15 | 51 |
smooth: false |
sl@15 | 52 |
} |
sl@15 | 53 |
|
sl@16 | 54 |
GridLayout { |
sl@15 | 55 |
anchors.fill:parent |
sl@15 | 56 |
anchors.margins: 6 |
sl@16 | 57 |
//spacing: 4 |
sl@16 | 58 |
columns: 4 |
sl@16 | 59 |
|
sl@16 | 60 |
Label { |
sl@16 | 61 |
text: "Frames:" |
sl@16 | 62 |
antialiasing: false |
sl@16 | 63 |
} |
sl@16 | 64 |
|
sl@16 | 65 |
Label { |
sl@16 | 66 |
text: "Time (s):" |
sl@16 | 67 |
antialiasing: false |
sl@16 | 68 |
} |
sl@16 | 69 |
|
sl@16 | 70 |
Label { |
sl@16 | 71 |
text: "Time/Frame (ms):" |
sl@16 | 72 |
antialiasing: false |
sl@16 | 73 |
} |
sl@16 | 74 |
|
sl@16 | 75 |
Label { |
sl@16 | 76 |
text: "FPS:" |
sl@16 | 77 |
antialiasing: false |
sl@16 | 78 |
} |
sl@15 | 79 |
|
sl@15 | 80 |
Label { |
sl@15 | 81 |
id: labelFrameCount |
sl@15 | 82 |
text: "Frame Count" |
sl@15 | 83 |
antialiasing: false |
sl@15 | 84 |
} |
sl@15 | 85 |
|
sl@15 | 86 |
Label { |
sl@15 | 87 |
id: labelTime |
sl@15 | 88 |
text: "Time" |
sl@15 | 89 |
antialiasing: false |
sl@15 | 90 |
} |
sl@15 | 91 |
|
sl@16 | 92 |
Label { |
sl@16 | 93 |
id: labelTimePerFrame |
sl@16 | 94 |
text: "Time/Frame" |
sl@16 | 95 |
antialiasing: false |
sl@16 | 96 |
} |
sl@16 | 97 |
|
sl@16 | 98 |
Label { |
sl@16 | 99 |
id: labelFps |
sl@16 | 100 |
text: "FPS" |
sl@16 | 101 |
antialiasing: false |
sl@16 | 102 |
} |
sl@16 | 103 |
|
sl@15 | 104 |
} |
sl@15 | 105 |
|
sl@15 | 106 |
|
sl@15 | 107 |
|
sl@15 | 108 |
|
sl@15 | 109 |
|
sl@15 | 110 |
//! [timer] |
sl@15 | 111 |
Timer { |
sl@16 | 112 |
id: timer |
sl@15 | 113 |
interval: splash.timeoutInterval; running: true; repeat: true |
sl@22 | 114 |
property bool doFill: true |
sl@15 | 115 |
onTriggered: { |
sl@15 | 116 |
//visible = false |
sl@15 | 117 |
|
sl@15 | 118 |
var current = new Date(); |
sl@16 | 119 |
var milliseconds = (current.getTime() - splash.startTime.getTime()); |
sl@15 | 120 |
|
sl@15 | 121 |
splash.frameCounter++; |
sl@15 | 122 |
labelFrameCount.text=splash.frameCounter; |
sl@16 | 123 |
labelTime.text=milliseconds/1000; |
sl@16 | 124 |
labelTimePerFrame.text=(milliseconds/splash.frameCounter).toFixed(3); |
sl@16 | 125 |
labelFps.text=(1000/(milliseconds/splash.frameCounter)).toFixed(0); |
sl@16 | 126 |
|
sl@16 | 127 |
if (checkBoxDoClear.checked) |
sl@16 | 128 |
{ |
sl@16 | 129 |
display.clear(); |
sl@16 | 130 |
} |
sl@16 | 131 |
|
sl@16 | 132 |
if (checkBoxRenderToDisplay.checked) |
sl@16 | 133 |
{ |
sl@23 | 134 |
if (checkBoxFillAndClearOnly.checked) |
sl@16 | 135 |
{ |
sl@22 | 136 |
//Trying to make it a worse case scenario for our frame diff algo |
sl@22 | 137 |
if (doFill) |
sl@22 | 138 |
{ |
sl@22 | 139 |
display.fill(); |
sl@22 | 140 |
} |
sl@22 | 141 |
else |
sl@22 | 142 |
{ |
sl@22 | 143 |
display.clear(); |
sl@22 | 144 |
} |
sl@22 | 145 |
|
sl@22 | 146 |
if (splash.frameCounter%2) |
sl@22 | 147 |
{ |
sl@22 | 148 |
doFill=!doFill; |
sl@22 | 149 |
} |
sl@16 | 150 |
} |
sl@16 | 151 |
else if (checkBoxOnePixelOnly.checked) |
sl@16 | 152 |
{ |
sl@18 | 153 |
display.setPixel(0,0,splash.frameCounter%2); |
sl@16 | 154 |
} |
sl@16 | 155 |
else |
sl@16 | 156 |
{ |
sl@16 | 157 |
display.renderWindow(splash); |
sl@16 | 158 |
} |
sl@16 | 159 |
|
sl@16 | 160 |
if (!checkBoxNoSwapBuffers.checked) |
sl@16 | 161 |
{ |
sl@16 | 162 |
display.swapBuffers(); |
sl@16 | 163 |
} |
sl@16 | 164 |
|
sl@16 | 165 |
} |
sl@16 | 166 |
|
sl@16 | 167 |
|
sl@16 | 168 |
|
sl@16 | 169 |
splash.timeout(); |
sl@15 | 170 |
} |
sl@15 | 171 |
} |
sl@15 | 172 |
//! [timer] |
sl@15 | 173 |
Component.onCompleted: { |
sl@15 | 174 |
visible = true |
sl@15 | 175 |
} |
sl@15 | 176 |
|
sl@15 | 177 |
} |
sl@15 | 178 |
|
sl@15 | 179 |
Column { |
sl@15 | 180 |
anchors.fill: parent |
sl@15 | 181 |
anchors.margins: 8 |
sl@15 | 182 |
spacing: 8 |
sl@15 | 183 |
|
sl@15 | 184 |
Button { |
sl@15 | 185 |
text: qsTr("Render Window") |
sl@15 | 186 |
onClicked: { |
sl@15 | 187 |
display.renderWindow(splash); |
sl@15 | 188 |
display.swapBuffers(); |
sl@15 | 189 |
} |
sl@15 | 190 |
} |
sl@16 | 191 |
|
sl@16 | 192 |
Button { |
sl@16 | 193 |
text: qsTr("Reset stats") |
sl@16 | 194 |
onClicked: { |
sl@16 | 195 |
splash.startTime = new Date(); |
sl@16 | 196 |
splash.frameCounter = 0; |
sl@16 | 197 |
} |
sl@16 | 198 |
} |
sl@16 | 199 |
|
sl@16 | 200 |
CheckBox { |
sl@16 | 201 |
text: qsTr("Run timer") |
sl@16 | 202 |
checked: true |
sl@16 | 203 |
onCheckedChanged: { |
sl@16 | 204 |
(checked?timer.start():timer.stop()) |
sl@16 | 205 |
} |
sl@16 | 206 |
} |
sl@16 | 207 |
|
sl@16 | 208 |
CheckBox { |
sl@16 | 209 |
id: checkBoxDoClear |
sl@16 | 210 |
text: qsTr("Do clear") |
sl@16 | 211 |
checked: true |
sl@16 | 212 |
} |
sl@16 | 213 |
|
sl@16 | 214 |
CheckBox { |
sl@16 | 215 |
id: checkBoxRenderToDisplay |
sl@16 | 216 |
text: qsTr("Render to display") |
sl@16 | 217 |
checked: true |
sl@16 | 218 |
} |
sl@16 | 219 |
|
sl@16 | 220 |
CheckBox { |
sl@23 | 221 |
id: checkBoxFillAndClearOnly |
sl@21 | 222 |
text: qsTr("Only fill and clear") |
sl@16 | 223 |
checked: false |
sl@16 | 224 |
} |
sl@16 | 225 |
|
sl@16 | 226 |
CheckBox { |
sl@16 | 227 |
id: checkBoxNoSwapBuffers |
sl@16 | 228 |
text: qsTr("No swap buffers") |
sl@16 | 229 |
checked: false |
sl@16 | 230 |
} |
sl@16 | 231 |
|
sl@16 | 232 |
CheckBox { |
sl@16 | 233 |
id: checkBoxOnePixelOnly |
sl@16 | 234 |
text: qsTr("One pixel only") |
sl@16 | 235 |
checked: false |
sl@16 | 236 |
} |
sl@18 | 237 |
|
sl@18 | 238 |
CheckBox { |
sl@18 | 239 |
text: qsTr("Off-Screen") |
sl@18 | 240 |
checked: true |
sl@18 | 241 |
onCheckedChanged: {display.offScreenMode = checked;} |
sl@18 | 242 |
} |
sl@23 | 243 |
|
sl@23 | 244 |
CheckBox { |
sl@23 | 245 |
text: qsTr("Frame differencing") |
sl@23 | 246 |
checked: true |
sl@23 | 247 |
onCheckedChanged: {display.frameDifferencing = checked;} |
sl@23 | 248 |
} |
sl@23 | 249 |
|
sl@15 | 250 |
} |
sl@0 | 251 |
} |