# HG changeset patch # User sl # Date 1401903054 -7200 # Node ID f2c87f0cfabef2296b923048d07f36e426bd5016 # Parent cf5eba52cb1d07ddf1f9743c28a32396e4db2bb5 Trying to get fonts working with marquee. diff -r cf5eba52cb1d -r f2c87f0cfabe MarqueeText.qml --- a/MarqueeText.qml Wed Jun 04 18:30:37 2014 +0200 +++ b/MarqueeText.qml Wed Jun 04 19:30:54 2014 +0200 @@ -9,6 +9,7 @@ property int pixelsPerSeconds:25 property alias text: scrollingText.text property alias separator: separatorText.text + property alias font: scrollingText.font Label { id:scrollingText @@ -18,6 +19,7 @@ Label { id:separatorText text:" || " + font: scrollingText.font x:scrollingText.x+scrollingText.width antialiasing: item.antialiasing } @@ -25,6 +27,7 @@ Label { id:followingText text:scrollingText.text + font: scrollingText.font x:scrollingText.x+scrollingText.width+separatorText.width antialiasing: item.antialiasing } diff -r cf5eba52cb1d -r f2c87f0cfabe TestsTab.qml --- a/TestsTab.qml Wed Jun 04 18:30:37 2014 +0200 +++ b/TestsTab.qml Wed Jun 04 19:30:54 2014 +0200 @@ -3,6 +3,8 @@ import QtQuick.Window 2.1 import MiniDisplay 1.0 import QtQuick.Layouts 1.1 +import QtQuick.Dialogs 1.1 +import Qt.labs.settings 1.0 Item { @@ -13,6 +15,12 @@ clip: true //anchors.fill:parent + Settings { + //property alias fontLineTop: marqueeLineTop.font; + //property alias fontLineBottom: marqueeLineBottom.font; + } + + //This window is our VFD frame Window { @@ -52,79 +60,48 @@ smooth: false } - MarqueeText { - width: 256 - pixelsPerSeconds:50 - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - text: "start ---- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---- end" - separator: " | " - } + ColumnLayout { - GridLayout { - anchors.fill:parent - anchors.margins: 6 - //spacing: 4 - columns: 4 - - Label { - text: "Frames:" - antialiasing: false + MarqueeText { + id: marqueeLineTop + width: 256 + pixelsPerSeconds:50 + //anchors.verticalCenter: parent.verticalCenter + //anchors.horizontalCenter: parent.horizontalCenter + text: "start ---- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---- end" + separator: " | " } - Label { - text: "Time (s):" - antialiasing: false + MarqueeText { + id: marqueeLineBottom + width: 256 + pixelsPerSeconds:50 + //anchors.verticalCenter: parent.verticalCenter + //anchors.horizontalCenter: parent.horizontalCenter + text: "start ---- abcdefghijklmnopqrstuvwxyz-1234567890 ---- end" + separator: " | " } - Label { - text: "Time/Frame (ms):" - antialiasing: false - } - - Label { - text: "FPS:" - antialiasing: false - } - - Label { - id: labelFrameCount - text: "Frame Count" - antialiasing: false - } - - Label { - id: labelTime - text: "Time" - antialiasing: false - } - - Label { - id: labelTimePerFrame - text: "Time/Frame" - antialiasing: false - } - - Label { - id: labelFps - text: "FPS" - antialiasing: false - } - - //onA: {} } + + //This function is called from C++ afterAnimating. + + //It means it is called in sync with Qt render loop. //Qt render loop tries to run at 60 FPS. + //We should not modify the content of our display window from here as will cause UI lags when runing 60 times per second. function doFrame(frameCount) { //Skip every second frame otherwise our UI lags. if (frameCount%2!=0) { - return; + //labelFrameTick.text="-"; + //return; } + //labelFrameTick.text="+"; var current = new Date(); var milliseconds = (current.getTime() - startTime.getTime()); @@ -190,76 +167,163 @@ } - Column { - anchors.fill: parent - anchors.margins: 8 - spacing: 8 - Button { - text: qsTr("Render Window") - onClicked: { - display.renderWindow(frameWindow); - display.swapBuffers(); + FontDialog { + id: fontDialog + visible: false + modality: Qt.WindowModal + scalableFonts: true + nonScalableFonts: true + monospacedFonts: true + proportionalFonts: true + title: qsTr("Choose a font") + font: marqueeLineTop.font + currentFont: marqueeLineTop.font + //onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) } + //onFontChanged: { console.log("FontChanged: " + font) } + onAccepted: { + //console.log("Accepted: " + font); + marqueeLineTop.font = currentFont; + marqueeLineBottom.font = currentFont; + } + //onRejected: { console.log("Rejected") } + } + + + GridLayout { + //anchors.fill:parent + anchors.centerIn: parent + anchors.margins: 6 + //width:parent.width/2 + height:parent.height/2 + + //spacing: 4 + columns: 4 + + Button { + text: qsTr("Render Window") + onClicked: { + display.renderWindow(frameWindow); + display.swapBuffers(); + } } - } - Button { - text: qsTr("Reset stats") - onClicked: { - frameWindow.startTime = new Date(); - //frameWindow.frameCounter = 0; - frameWindow.firstFrame = -1; + Button { + text: qsTr("Reset stats") + onClicked: { + frameWindow.startTime = new Date(); + //frameWindow.frameCounter = 0; + frameWindow.firstFrame = -1; + } } - } - CheckBox { - text: qsTr("Run timer") - checked: true - onCheckedChanged: { - (checked?timer.start():timer.stop()) + CheckBox { + id: checkBoxDoClear + text: qsTr("Do clear") + checked: true } - } - CheckBox { - id: checkBoxDoClear - text: qsTr("Do clear") - checked: true - } + CheckBox { + id: checkBoxRenderToDisplay + text: qsTr("Render to display") + checked: true + } - CheckBox { - id: checkBoxRenderToDisplay - text: qsTr("Render to display") - checked: true - } + CheckBox { + id: checkBoxFillAndClearOnly + text: qsTr("Only fill and clear") + checked: false + } - CheckBox { - id: checkBoxFillAndClearOnly - text: qsTr("Only fill and clear") - checked: false - } + CheckBox { + id: checkBoxNoSwapBuffers + text: qsTr("No swap buffers") + checked: false + } - CheckBox { - id: checkBoxNoSwapBuffers - text: qsTr("No swap buffers") - checked: false - } + CheckBox { + id: checkBoxOnePixelOnly + text: qsTr("One pixel only") + checked: false + } - CheckBox { - id: checkBoxOnePixelOnly - text: qsTr("One pixel only") - checked: false - } + CheckBox { + text: qsTr("Off-Screen") + checked: true + onCheckedChanged: {display.offScreenMode = checked;} + } - CheckBox { - text: qsTr("Off-Screen") - checked: true - onCheckedChanged: {display.offScreenMode = checked;} - } + CheckBox { + text: qsTr("Frame differencing") + checked: true + onCheckedChanged: {display.frameDifferencing = checked;} + } - CheckBox { - text: qsTr("Frame differencing") - checked: true - onCheckedChanged: {display.frameDifferencing = checked;} - } + Button { + text: qsTr("Change font") + onClicked: { + //We had to do this double magic cause otherwise our font list + //would not reflect our options. + fontDialog.setVisible(true); + fontDialog.open(); + } + } + + Label { + text: "" + antialiasing: false + } + + Label { + text: "" + antialiasing: false + } + + + Label { + id: labelFrameTick + text: "Frames:" + antialiasing: false + } + + Label { + text: "Time (s):" + antialiasing: false + } + + Label { + text: "Time/Frame (ms):" + antialiasing: false + } + + Label { + text: "FPS:" + antialiasing: false + } + + Label { + id: labelFrameCount + text: "Frame Count" + antialiasing: false + } + + Label { + id: labelTime + text: "Time" + antialiasing: false + } + + Label { + id: labelTimePerFrame + text: "Time/Frame" + antialiasing: false + } + + Label { + id: labelFps + text: "FPS" + antialiasing: false + } + } }