# HG changeset patch # User sl # Date 1401270169 -7200 # Node ID 9543e1703afbf9ae1798a088a530759887333bcd # Parent b3cce7791326a7e1464962d59f7080e1e7d0cd85 Adding status bar to display vendor and product strings. diff -r b3cce7791326 -r 9543e1703afb DisplayStatusBar.qml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DisplayStatusBar.qml Wed May 28 11:42:49 2014 +0200 @@ -0,0 +1,60 @@ +import QtQuick 2.0 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.1 + + + +StatusBar { + + Component.onCompleted: { + display.closed.connect(updateDisplayStatus); + display.opened.connect(updateDisplayStatus); + display.openError.connect(updateDisplayStatusError); + } + + function updateDisplayStatusError() + { + updateDisplayStatus(); + labelDisplayStatus.text=qsTr("Connection error"); + } + + function updateDisplayStatus() + { + if (display.isOpen) + { + labelDisplayStatus.text=qsTr("Connected"); + } + else + { + labelDisplayStatus.text=qsTr("Disconnected"); + } + + labelDisplayVendor.text=display.vendor; + labelDisplayProduct.text=display.product; + labelDisplaySerialNumber.text=display.serialNumber; + } + + + RowLayout { + Label { + id: labelDisplayStatus + text: qsTr("Disconnected") + } + + Label { + id: labelDisplayVendor + text: qsTr("") + } + + Label { + id: labelDisplayProduct + text: qsTr("") + } + + Label { + id: labelDisplaySerialNumber + visible: false //We don't want to display that. GP1212A01A does not even provide a proper string. + text: qsTr("") + } + } +} diff -r b3cce7791326 -r 9543e1703afb DisplayTab.qml --- a/DisplayTab.qml Wed May 28 10:20:32 2014 +0200 +++ b/DisplayTab.qml Wed May 28 11:42:49 2014 +0200 @@ -5,6 +5,7 @@ import Qt.labs.settings 1.0 + Item { width: 100 height: 62 @@ -14,16 +15,11 @@ // - ColumnLayout { + Column { anchors.fill: parent anchors.margins: 8 spacing: 8 - Text { - id: textDisplayStatus - text: qsTr("Disconnect") - } - Button { id: buttonOpenClose text: display.isOpen ? qsTr("Disconnect") : qsTr("Connect") diff -r b3cce7791326 -r 9543e1703afb Manager.pro --- a/Manager.pro Wed May 28 10:20:32 2014 +0200 +++ b/Manager.pro Wed May 28 11:42:49 2014 +0200 @@ -22,4 +22,5 @@ FontsTab.qml \ main.qml \ TestsTab.qml \ - DisplayTab.qml + DisplayTab.qml \ + DisplayStatusBar.qml diff -r b3cce7791326 -r 9543e1703afb MiniDisplay/minidisplay.cpp --- a/MiniDisplay/minidisplay.cpp Wed May 28 10:20:32 2014 +0200 +++ b/MiniDisplay/minidisplay.cpp Wed May 28 11:42:49 2014 +0200 @@ -108,8 +108,29 @@ } } - iDisplay.Clear(); - iDisplay.BitBlit(bits,w,h,0,0); - iDisplay.SwapBuffers(); + if (iDisplay.IsOpen()) + { + iDisplay.Clear(); + iDisplay.BitBlit(bits,w,h,0,0); + iDisplay.SwapBuffers(); + } // } + + +QString MiniDisplay::vendor() +{ + return QString::fromWCharArray(iDisplay.Vendor()); +} + +QString MiniDisplay::product() +{ + return QString::fromWCharArray(iDisplay.Product()); +} + +QString MiniDisplay::serialNumber() +{ + return QString::fromWCharArray(iDisplay.SerialNumber()); +} + + diff -r b3cce7791326 -r 9543e1703afb MiniDisplay/minidisplay.h --- a/MiniDisplay/minidisplay.h Wed May 28 10:20:32 2014 +0200 +++ b/MiniDisplay/minidisplay.h Wed May 28 11:42:49 2014 +0200 @@ -11,7 +11,9 @@ // Q_PROPERTY(bool isOpen READ isOpen NOTIFY statusChanged) Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) - + Q_PROPERTY(QString vendor READ vendor) + Q_PROPERTY(QString product READ product) + Q_PROPERTY(QString serialNumber READ serialNumber) public: //Methods @@ -27,6 +29,10 @@ bool isOpen(); QFont font() const {return iFont;} void setFont(const QFont& aFont); + // + QString vendor(); + QString product(); + QString serialNumber(); signals: void opened(); diff -r b3cce7791326 -r 9543e1703afb main.qml --- a/main.qml Wed May 28 10:20:32 2014 +0200 +++ b/main.qml Wed May 28 11:42:49 2014 +0200 @@ -6,7 +6,7 @@ import QtQuick.Window 2.1 import Qt.labs.settings 1.0 import MiniDisplay 1.0 - +import QtQuick.Layouts 1.1 ApplicationWindow { @@ -18,6 +18,9 @@ SystemPalette { id: palette } //Component.onCompleted: progressBar.visible=tabViewMain.getTab(tabViewMain.currentIndex).status !== Loader.Ready + statusBar: DisplayStatusBar {} + + Settings { property alias x: appWindow.x property alias y: appWindow.y @@ -43,11 +46,29 @@ progressBar.visible = tabViewMain.getTab(tabViewMain.currentIndex).status !== Loader.Ready; } + /* + function updateDisplayStatus() + { + if (display.isOpen) + { + labelDisplayStatus.text=qsTr("Connected"); + } + else + { + labelDisplayStatus.text=qsTr("Disconnected"); + } + + labelDisplayVendor.text=display.vendor; + labelDisplayProduct.text=display.product; + labelDisplaySerialNumber.text=display.serialNumber; + }*/ + + MiniDisplay { id: display - onOpened:{ textDisplayStatus.text=qsTr("Connected");} - onClosed:textDisplayStatus.text=qsTr("Disconnected") - onOpenError:{ textDisplayStatus.text=qsTr("Connection error");} + //onOpened:updateDisplayStatus() + //onClosed:updateDisplayStatus() + //onOpenError:{ updateDisplayStatus(); labelDisplayStatus.text=qsTr("Connection error");} } diff -r b3cce7791326 -r 9543e1703afb qml.qrc --- a/qml.qrc Wed May 28 10:20:32 2014 +0200 +++ b/qml.qrc Wed May 28 11:42:49 2014 +0200 @@ -4,5 +4,6 @@ FontsTab.qml TestsTab.qml DisplayTab.qml + DisplayStatusBar.qml