Adding status bar to display vendor and product strings.
authorsl
Wed, 28 May 2014 11:42:49 +0200
changeset 89543e1703afb
parent 7 b3cce7791326
child 9 52372bbbc0f8
Adding status bar to display vendor and product strings.
DisplayStatusBar.qml
DisplayTab.qml
Manager.pro
MiniDisplay/minidisplay.cpp
MiniDisplay/minidisplay.h
main.qml
qml.qrc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/DisplayStatusBar.qml	Wed May 28 11:42:49 2014 +0200
     1.3 @@ -0,0 +1,60 @@
     1.4 +import QtQuick 2.0
     1.5 +import QtQuick.Controls 1.2
     1.6 +import QtQuick.Layouts 1.1
     1.7 +
     1.8 +
     1.9 +
    1.10 +StatusBar {
    1.11 +
    1.12 +    Component.onCompleted: {
    1.13 +        display.closed.connect(updateDisplayStatus);
    1.14 +        display.opened.connect(updateDisplayStatus);
    1.15 +        display.openError.connect(updateDisplayStatusError);
    1.16 +    }
    1.17 +
    1.18 +    function updateDisplayStatusError()
    1.19 +    {
    1.20 +        updateDisplayStatus();
    1.21 +        labelDisplayStatus.text=qsTr("Connection error");
    1.22 +    }
    1.23 +
    1.24 +    function updateDisplayStatus()
    1.25 +    {
    1.26 +        if (display.isOpen)
    1.27 +        {
    1.28 +            labelDisplayStatus.text=qsTr("Connected");
    1.29 +        }
    1.30 +        else
    1.31 +        {
    1.32 +            labelDisplayStatus.text=qsTr("Disconnected");
    1.33 +        }
    1.34 +
    1.35 +        labelDisplayVendor.text=display.vendor;
    1.36 +        labelDisplayProduct.text=display.product;
    1.37 +        labelDisplaySerialNumber.text=display.serialNumber;
    1.38 +    }
    1.39 +
    1.40 +
    1.41 +    RowLayout {
    1.42 +        Label {
    1.43 +            id: labelDisplayStatus
    1.44 +            text: qsTr("Disconnected")
    1.45 +        }
    1.46 +
    1.47 +        Label {
    1.48 +            id: labelDisplayVendor
    1.49 +            text: qsTr("")
    1.50 +        }
    1.51 +
    1.52 +        Label {
    1.53 +            id: labelDisplayProduct
    1.54 +            text: qsTr("")
    1.55 +        }
    1.56 +
    1.57 +        Label {
    1.58 +            id: labelDisplaySerialNumber
    1.59 +            visible: false //We don't want to display that. GP1212A01A does not even provide a proper string.
    1.60 +            text: qsTr("")
    1.61 +        }
    1.62 +    }
    1.63 +}
     2.1 --- a/DisplayTab.qml	Wed May 28 10:20:32 2014 +0200
     2.2 +++ b/DisplayTab.qml	Wed May 28 11:42:49 2014 +0200
     2.3 @@ -5,6 +5,7 @@
     2.4  import Qt.labs.settings 1.0
     2.5  
     2.6  
     2.7 +
     2.8  Item {
     2.9      width: 100
    2.10      height: 62
    2.11 @@ -14,16 +15,11 @@
    2.12  
    2.13  
    2.14      //
    2.15 -    ColumnLayout {
    2.16 +    Column {
    2.17          anchors.fill: parent
    2.18          anchors.margins: 8
    2.19          spacing: 8
    2.20  
    2.21 -        Text {
    2.22 -            id: textDisplayStatus
    2.23 -            text: qsTr("Disconnect")
    2.24 -        }
    2.25 -
    2.26          Button {
    2.27              id: buttonOpenClose
    2.28              text: display.isOpen ? qsTr("Disconnect") : qsTr("Connect")
     3.1 --- a/Manager.pro	Wed May 28 10:20:32 2014 +0200
     3.2 +++ b/Manager.pro	Wed May 28 11:42:49 2014 +0200
     3.3 @@ -22,4 +22,5 @@
     3.4      FontsTab.qml \
     3.5      main.qml \
     3.6      TestsTab.qml \
     3.7 -    DisplayTab.qml
     3.8 +    DisplayTab.qml \
     3.9 +    DisplayStatusBar.qml
     4.1 --- a/MiniDisplay/minidisplay.cpp	Wed May 28 10:20:32 2014 +0200
     4.2 +++ b/MiniDisplay/minidisplay.cpp	Wed May 28 11:42:49 2014 +0200
     4.3 @@ -108,8 +108,29 @@
     4.4              }
     4.5          }
     4.6  
     4.7 -    iDisplay.Clear();
     4.8 -    iDisplay.BitBlit(bits,w,h,0,0);
     4.9 -    iDisplay.SwapBuffers();
    4.10 +    if (iDisplay.IsOpen())
    4.11 +    {
    4.12 +        iDisplay.Clear();
    4.13 +        iDisplay.BitBlit(bits,w,h,0,0);
    4.14 +        iDisplay.SwapBuffers();
    4.15 +    }
    4.16      //
    4.17  }
    4.18 +
    4.19 +
    4.20 +QString MiniDisplay::vendor()
    4.21 +{
    4.22 +    return QString::fromWCharArray(iDisplay.Vendor());
    4.23 +}
    4.24 +
    4.25 +QString MiniDisplay::product()
    4.26 +{
    4.27 +    return QString::fromWCharArray(iDisplay.Product());
    4.28 +}
    4.29 +
    4.30 +QString MiniDisplay::serialNumber()
    4.31 +{
    4.32 +    return QString::fromWCharArray(iDisplay.SerialNumber());
    4.33 +}
    4.34 +
    4.35 +
     5.1 --- a/MiniDisplay/minidisplay.h	Wed May 28 10:20:32 2014 +0200
     5.2 +++ b/MiniDisplay/minidisplay.h	Wed May 28 11:42:49 2014 +0200
     5.3 @@ -11,7 +11,9 @@
     5.4      //
     5.5      Q_PROPERTY(bool isOpen READ isOpen NOTIFY statusChanged)
     5.6      Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
     5.7 -
     5.8 +    Q_PROPERTY(QString vendor READ vendor)
     5.9 +    Q_PROPERTY(QString product READ product)
    5.10 +    Q_PROPERTY(QString serialNumber READ serialNumber)
    5.11  
    5.12  public:
    5.13      //Methods
    5.14 @@ -27,6 +29,10 @@
    5.15      bool isOpen();
    5.16      QFont font() const {return iFont;}
    5.17      void setFont(const QFont& aFont);
    5.18 +    //
    5.19 +    QString vendor();
    5.20 +    QString product();
    5.21 +    QString serialNumber();
    5.22  
    5.23  signals:
    5.24      void opened();
     6.1 --- a/main.qml	Wed May 28 10:20:32 2014 +0200
     6.2 +++ b/main.qml	Wed May 28 11:42:49 2014 +0200
     6.3 @@ -6,7 +6,7 @@
     6.4  import QtQuick.Window 2.1
     6.5  import Qt.labs.settings 1.0
     6.6  import MiniDisplay 1.0
     6.7 -
     6.8 +import QtQuick.Layouts 1.1
     6.9  
    6.10  
    6.11  ApplicationWindow {
    6.12 @@ -18,6 +18,9 @@
    6.13      SystemPalette { id: palette }
    6.14      //Component.onCompleted: progressBar.visible=tabViewMain.getTab(tabViewMain.currentIndex).status !== Loader.Ready
    6.15  
    6.16 +    statusBar: DisplayStatusBar {}
    6.17 +
    6.18 +
    6.19      Settings {
    6.20          property alias x: appWindow.x
    6.21          property alias y: appWindow.y
    6.22 @@ -43,11 +46,29 @@
    6.23          progressBar.visible = tabViewMain.getTab(tabViewMain.currentIndex).status !== Loader.Ready;
    6.24      }
    6.25  
    6.26 +    /*
    6.27 +    function updateDisplayStatus()
    6.28 +    {
    6.29 +        if (display.isOpen)
    6.30 +        {
    6.31 +            labelDisplayStatus.text=qsTr("Connected");
    6.32 +        }
    6.33 +        else
    6.34 +        {
    6.35 +            labelDisplayStatus.text=qsTr("Disconnected");
    6.36 +        }
    6.37 +
    6.38 +        labelDisplayVendor.text=display.vendor;
    6.39 +        labelDisplayProduct.text=display.product;
    6.40 +        labelDisplaySerialNumber.text=display.serialNumber;
    6.41 +    }*/
    6.42 +
    6.43 +
    6.44      MiniDisplay {
    6.45          id: display
    6.46 -        onOpened:{ textDisplayStatus.text=qsTr("Connected");}
    6.47 -        onClosed:textDisplayStatus.text=qsTr("Disconnected")
    6.48 -        onOpenError:{ textDisplayStatus.text=qsTr("Connection error");}
    6.49 +        //onOpened:updateDisplayStatus()
    6.50 +        //onClosed:updateDisplayStatus()
    6.51 +        //onOpenError:{ updateDisplayStatus(); labelDisplayStatus.text=qsTr("Connection error");}
    6.52      }
    6.53  
    6.54  
     7.1 --- a/qml.qrc	Wed May 28 10:20:32 2014 +0200
     7.2 +++ b/qml.qrc	Wed May 28 11:42:49 2014 +0200
     7.3 @@ -4,5 +4,6 @@
     7.4          <file>FontsTab.qml</file>
     7.5          <file>TestsTab.qml</file>
     7.6          <file>DisplayTab.qml</file>
     7.7 +        <file>DisplayStatusBar.qml</file>
     7.8      </qresource>
     7.9  </RCC>