TestsTab.qml
changeset 34 f2c87f0cfabe
parent 33 cf5eba52cb1d
child 35 2868107ea71d
     1.1 --- a/TestsTab.qml	Wed Jun 04 18:30:37 2014 +0200
     1.2 +++ b/TestsTab.qml	Wed Jun 04 19:30:54 2014 +0200
     1.3 @@ -3,6 +3,8 @@
     1.4  import QtQuick.Window 2.1
     1.5  import MiniDisplay 1.0
     1.6  import QtQuick.Layouts 1.1
     1.7 +import QtQuick.Dialogs 1.1
     1.8 +import Qt.labs.settings 1.0
     1.9  
    1.10  
    1.11  Item {
    1.12 @@ -13,6 +15,12 @@
    1.13      clip: true
    1.14      //anchors.fill:parent
    1.15  
    1.16 +    Settings {
    1.17 +        //property alias fontLineTop: marqueeLineTop.font;
    1.18 +        //property alias fontLineBottom: marqueeLineBottom.font;
    1.19 +    }
    1.20 +
    1.21 +
    1.22  
    1.23      //This window is our VFD frame
    1.24      Window {
    1.25 @@ -52,79 +60,48 @@
    1.26              smooth: false
    1.27          }
    1.28  
    1.29 -        MarqueeText {
    1.30 -            width: 256
    1.31 -            pixelsPerSeconds:50
    1.32 -            anchors.verticalCenter: parent.verticalCenter
    1.33 -            anchors.horizontalCenter: parent.horizontalCenter
    1.34 -            text: "start ---- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---- end"
    1.35 -            separator: " | "
    1.36 -        }
    1.37 +        ColumnLayout {
    1.38  
    1.39 -        GridLayout {
    1.40 -            anchors.fill:parent
    1.41 -            anchors.margins: 6
    1.42 -            //spacing: 4
    1.43 -            columns: 4
    1.44 -
    1.45 -            Label {
    1.46 -                text: "Frames:"
    1.47 -                antialiasing: false
    1.48 +            MarqueeText {
    1.49 +                id: marqueeLineTop
    1.50 +                width: 256
    1.51 +                pixelsPerSeconds:50
    1.52 +                //anchors.verticalCenter: parent.verticalCenter
    1.53 +                //anchors.horizontalCenter: parent.horizontalCenter
    1.54 +                text: "start ---- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---- end"
    1.55 +                separator: " | "
    1.56              }
    1.57  
    1.58 -            Label {
    1.59 -                text: "Time (s):"
    1.60 -                antialiasing: false
    1.61 +            MarqueeText {
    1.62 +                id: marqueeLineBottom
    1.63 +                width: 256
    1.64 +                pixelsPerSeconds:50
    1.65 +                //anchors.verticalCenter: parent.verticalCenter
    1.66 +                //anchors.horizontalCenter: parent.horizontalCenter
    1.67 +                text: "start ---- abcdefghijklmnopqrstuvwxyz-1234567890 ---- end"
    1.68 +                separator: " | "
    1.69              }
    1.70  
    1.71 -            Label {
    1.72 -                text: "Time/Frame (ms):"
    1.73 -                antialiasing: false
    1.74 -            }
    1.75 -
    1.76 -            Label {
    1.77 -                text: "FPS:"
    1.78 -                antialiasing: false
    1.79 -            }
    1.80 -
    1.81 -            Label {
    1.82 -                id: labelFrameCount
    1.83 -                text: "Frame Count"
    1.84 -                antialiasing: false
    1.85 -            }
    1.86 -
    1.87 -            Label {
    1.88 -                id: labelTime
    1.89 -                text: "Time"
    1.90 -                antialiasing: false
    1.91 -            }
    1.92 -
    1.93 -            Label {
    1.94 -                id: labelTimePerFrame
    1.95 -                text: "Time/Frame"
    1.96 -                antialiasing: false
    1.97 -            }
    1.98 -
    1.99 -            Label {
   1.100 -                id: labelFps
   1.101 -                text: "FPS"
   1.102 -                antialiasing: false
   1.103 -            }
   1.104 -
   1.105 -            //onA: {}
   1.106  
   1.107          }
   1.108  
   1.109 +
   1.110 +
   1.111          //This function is called from C++ afterAnimating.
   1.112 +
   1.113 +
   1.114          //It means it is called in sync with Qt render loop.
   1.115          //Qt render loop tries to run at 60 FPS.
   1.116 +        //We should not modify the content of our display window from here as will cause UI lags when runing 60 times per second.
   1.117          function doFrame(frameCount)
   1.118          {
   1.119              //Skip every second frame otherwise our UI lags.
   1.120              if (frameCount%2!=0)
   1.121              {
   1.122 -                return;
   1.123 +                //labelFrameTick.text="-";
   1.124 +                //return;
   1.125              }
   1.126 +            //labelFrameTick.text="+";
   1.127  
   1.128              var current = new Date();
   1.129              var milliseconds = (current.getTime() - startTime.getTime());
   1.130 @@ -190,76 +167,163 @@
   1.131  
   1.132      }
   1.133  
   1.134 -    Column {
   1.135 -        anchors.fill: parent
   1.136 -        anchors.margins: 8
   1.137 -        spacing: 8
   1.138  
   1.139 -        Button {
   1.140 -            text: qsTr("Render Window")
   1.141 -            onClicked: {
   1.142 -                display.renderWindow(frameWindow);
   1.143 -                display.swapBuffers();
   1.144 +    FontDialog {
   1.145 +        id: fontDialog
   1.146 +        visible: false
   1.147 +        modality: Qt.WindowModal
   1.148 +        scalableFonts: true
   1.149 +        nonScalableFonts: true
   1.150 +        monospacedFonts: true
   1.151 +        proportionalFonts: true
   1.152 +        title: qsTr("Choose a font")
   1.153 +        font: marqueeLineTop.font
   1.154 +        currentFont: marqueeLineTop.font
   1.155 +        //onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) }
   1.156 +        //onFontChanged: { console.log("FontChanged: " + font) }
   1.157 +        onAccepted: {
   1.158 +            //console.log("Accepted: " + font);
   1.159 +            marqueeLineTop.font = currentFont;
   1.160 +            marqueeLineBottom.font = currentFont;
   1.161 +        }
   1.162 +        //onRejected: { console.log("Rejected") }
   1.163 +    }
   1.164 +
   1.165 +
   1.166 +    GridLayout {
   1.167 +        //anchors.fill:parent
   1.168 +        anchors.centerIn: parent
   1.169 +        anchors.margins: 6
   1.170 +        //width:parent.width/2
   1.171 +        height:parent.height/2
   1.172 +
   1.173 +        //spacing: 4
   1.174 +        columns: 4
   1.175 +
   1.176 +            Button {
   1.177 +                text: qsTr("Render Window")
   1.178 +                onClicked: {
   1.179 +                    display.renderWindow(frameWindow);
   1.180 +                    display.swapBuffers();
   1.181 +                }
   1.182              }
   1.183 -        }
   1.184  
   1.185 -        Button {
   1.186 -            text: qsTr("Reset stats")
   1.187 -            onClicked: {
   1.188 -                frameWindow.startTime = new Date();
   1.189 -                //frameWindow.frameCounter = 0;
   1.190 -                frameWindow.firstFrame = -1;
   1.191 +            Button {
   1.192 +                text: qsTr("Reset stats")
   1.193 +                onClicked: {
   1.194 +                    frameWindow.startTime = new Date();
   1.195 +                    //frameWindow.frameCounter = 0;
   1.196 +                    frameWindow.firstFrame = -1;
   1.197 +                }
   1.198              }
   1.199 -        }
   1.200  
   1.201 -        CheckBox {
   1.202 -            text: qsTr("Run timer")
   1.203 -            checked: true
   1.204 -            onCheckedChanged: {
   1.205 -                (checked?timer.start():timer.stop())
   1.206 +            CheckBox {
   1.207 +                id: checkBoxDoClear
   1.208 +                text: qsTr("Do clear")
   1.209 +                checked: true
   1.210              }
   1.211 -        }
   1.212  
   1.213 -        CheckBox {
   1.214 -            id: checkBoxDoClear
   1.215 -            text: qsTr("Do clear")
   1.216 -            checked: true
   1.217 -        }
   1.218 +            CheckBox {
   1.219 +                id: checkBoxRenderToDisplay
   1.220 +                text: qsTr("Render to display")
   1.221 +                checked: true
   1.222 +            }
   1.223  
   1.224 -        CheckBox {
   1.225 -            id: checkBoxRenderToDisplay
   1.226 -            text: qsTr("Render to display")
   1.227 -            checked: true
   1.228 -        }
   1.229 +            CheckBox {
   1.230 +                id: checkBoxFillAndClearOnly
   1.231 +                text: qsTr("Only fill and clear")
   1.232 +                checked: false
   1.233 +            }
   1.234  
   1.235 -        CheckBox {
   1.236 -            id: checkBoxFillAndClearOnly
   1.237 -            text: qsTr("Only fill and clear")
   1.238 -            checked: false
   1.239 -        }
   1.240 +            CheckBox {
   1.241 +                id: checkBoxNoSwapBuffers
   1.242 +                text: qsTr("No swap buffers")
   1.243 +                checked: false
   1.244 +            }
   1.245  
   1.246 -        CheckBox {
   1.247 -            id: checkBoxNoSwapBuffers
   1.248 -            text: qsTr("No swap buffers")
   1.249 -            checked: false
   1.250 -        }
   1.251 +            CheckBox {
   1.252 +                id: checkBoxOnePixelOnly
   1.253 +                text: qsTr("One pixel only")
   1.254 +                checked: false
   1.255 +            }
   1.256  
   1.257 -        CheckBox {
   1.258 -            id: checkBoxOnePixelOnly
   1.259 -            text: qsTr("One pixel only")
   1.260 -            checked: false
   1.261 -        }
   1.262 +            CheckBox {
   1.263 +                text: qsTr("Off-Screen")
   1.264 +                checked: true
   1.265 +                onCheckedChanged: {display.offScreenMode = checked;}
   1.266 +            }
   1.267  
   1.268 -        CheckBox {
   1.269 -            text: qsTr("Off-Screen")
   1.270 -            checked: true
   1.271 -            onCheckedChanged: {display.offScreenMode = checked;}
   1.272 -        }
   1.273 +            CheckBox {
   1.274 +                text: qsTr("Frame differencing")
   1.275 +                checked: true
   1.276 +                onCheckedChanged: {display.frameDifferencing = checked;}
   1.277 +            }
   1.278  
   1.279 -        CheckBox {
   1.280 -            text: qsTr("Frame differencing")
   1.281 -            checked: true
   1.282 -            onCheckedChanged: {display.frameDifferencing = checked;}
   1.283 -        }
   1.284 +            Button {
   1.285 +                text: qsTr("Change font")
   1.286 +                onClicked: {
   1.287 +                    //We had to do this double magic cause otherwise our font list
   1.288 +                    //would not reflect our options.
   1.289 +                    fontDialog.setVisible(true);
   1.290 +                    fontDialog.open();
   1.291 +                }
   1.292 +            }
   1.293 +
   1.294 +            Label {
   1.295 +                text: ""
   1.296 +                antialiasing: false
   1.297 +            }
   1.298 +
   1.299 +            Label {
   1.300 +                text: ""
   1.301 +                antialiasing: false
   1.302 +            }
   1.303 +
   1.304 +
   1.305 +            Label {
   1.306 +                id: labelFrameTick
   1.307 +                text: "Frames:"
   1.308 +                antialiasing: false
   1.309 +            }
   1.310 +
   1.311 +            Label {
   1.312 +                text: "Time (s):"
   1.313 +                antialiasing: false
   1.314 +            }
   1.315 +
   1.316 +            Label {
   1.317 +                text: "Time/Frame (ms):"
   1.318 +                antialiasing: false
   1.319 +            }
   1.320 +
   1.321 +            Label {
   1.322 +                text: "FPS:"
   1.323 +                antialiasing: false
   1.324 +            }
   1.325 +
   1.326 +            Label {
   1.327 +                id: labelFrameCount
   1.328 +                text: "Frame Count"
   1.329 +                antialiasing: false
   1.330 +            }
   1.331 +
   1.332 +            Label {
   1.333 +                id: labelTime
   1.334 +                text: "Time"
   1.335 +                antialiasing: false
   1.336 +            }
   1.337 +
   1.338 +            Label {
   1.339 +                id: labelTimePerFrame
   1.340 +                text: "Time/Frame"
   1.341 +                antialiasing: false
   1.342 +            }
   1.343 +
   1.344 +            Label {
   1.345 +                id: labelFps
   1.346 +                text: "FPS"
   1.347 +                antialiasing: false
   1.348 +            }
   1.349 +
   1.350      }
   1.351  }