TestsTab.qml
author sl
Thu, 29 May 2014 14:27:08 +0200
changeset 15 737f8bb110be
parent 0 c0e13d2503b9
child 16 35f01a0d460a
permissions -rw-r--r--
Adding MiniDisplay methods to display image and window.
Using our test tab to render our display frame in QML and send it to our display.
Using a timer and frame counter to profile our performance.
     1 import QtQuick 2.2
     2 import QtQuick.Controls 1.2
     3 import QtQuick.Window 2.1
     4 import MiniDisplay 1.0
     5 import QtQuick.Layouts 1.1
     6 
     7 
     8 Item {
     9     //width: 100
    10     //height: 62
    11     //SystemPalette { id: palette }
    12     clip: true
    13     //anchors.fill:parent
    14 
    15 
    16 
    17     Window {
    18         //parent: appWindow
    19         id: splash
    20         color: "transparent"
    21         title: "Splash Window"
    22         modality: Qt.NonModal
    23         flags: Qt.SplashScreen
    24         property int timeoutInterval: 41
    25         signal timeout
    26     //! [splash-properties]
    27     //! [screen-properties]
    28         x: (Screen.width - rectangleScreen.width) / 2
    29         y: (Screen.height - rectangleScreen.height) / 2
    30     //! [screen-properties]
    31         width: rectangleScreen.width
    32         height: rectangleScreen.height
    33         property int frameCounter:0;
    34         property var startTime:new Date();
    35 
    36         Rectangle {
    37             id: rectangleScreen
    38             anchors.centerIn: parent
    39             width: 256
    40             height: 64
    41             color: "white"
    42             border.width:1
    43             border.color: "black"
    44             smooth: false
    45         }
    46 
    47         ColumnLayout {
    48             anchors.fill:parent
    49             anchors.margins: 6
    50             spacing: 4
    51 
    52             Label {
    53                 id: labelFrameCount
    54                 //anchors.centerIn: parent
    55                 text: "Frame Count"
    56                 antialiasing: false
    57             }
    58 
    59             Label {
    60                 id: labelTime
    61                 //anchors.centerIn: parent
    62                 text: "Time"
    63                 antialiasing: false
    64             }
    65 
    66         }
    67 
    68 
    69 
    70 
    71 
    72         //! [timer]
    73         Timer {
    74             interval: splash.timeoutInterval; running: true; repeat: true
    75             onTriggered: {
    76                 //visible = false
    77 
    78                 var current = new Date();
    79                 var seconds = (current.getTime() - splash.startTime.getTime())/1000;
    80 
    81                 splash.frameCounter++;
    82                 labelFrameCount.text=splash.frameCounter;
    83                 labelTime.text=seconds;
    84                 display.renderWindow(splash);
    85                 display.swapBuffers();
    86                 splash.timeout()
    87             }
    88         }
    89         //! [timer]
    90         Component.onCompleted: {
    91             visible = true
    92         }
    93 
    94     }
    95 
    96     Column {
    97         anchors.fill: parent
    98         anchors.margins: 8
    99         spacing: 8
   100 
   101         Button {
   102             text: qsTr("Render Window")
   103             onClicked: {
   104                 display.renderWindow(splash);
   105                 display.swapBuffers();
   106             }
   107         }
   108     }
   109 }