Adding brightness slider and an option to connect display on start-up.
Both brightness and connect options are persisted.
1.1 --- a/DisplayTab.qml Wed May 28 15:23:41 2014 +0200
1.2 +++ b/DisplayTab.qml Wed May 28 17:08:47 2014 +0200
1.3 @@ -12,14 +12,21 @@
1.4 //SystemPalette { id: palette }
1.5 clip: true
1.6 //
1.7 -
1.8 + Component.onCompleted: { if(checkBoxConnectOnStartUp.checked) display.open()}
1.9 + //
1.10 + Settings {
1.11 + property alias connectOnStratUp: checkBoxConnectOnStartUp.checked;
1.12 + property alias brightness: sliderBrightness.value;
1.13 + }
1.14
1.15 //
1.16 +
1.17 Column {
1.18 anchors.fill: parent
1.19 anchors.margins: 8
1.20 spacing: 8
1.21
1.22 +
1.23 Button {
1.24 id: buttonOpenClose
1.25 text: display.isOpen ? qsTr("Disconnect") : qsTr("Connect")
1.26 @@ -40,5 +47,26 @@
1.27 activeFocusOnPress: false
1.28 }
1.29
1.30 + CheckBox {
1.31 + id: checkBoxConnectOnStartUp
1.32 + text: qsTr("Connect on start-up")
1.33 + }
1.34 +
1.35 } //ColumnLayout
1.36 +
1.37 + Slider {
1.38 + id: sliderBrightness
1.39 + anchors.margins: 8
1.40 + anchors.right: parent.right
1.41 + anchors.top: parent.top
1.42 + anchors.bottom: parent.bottom
1.43 + //
1.44 + orientation: Qt.Vertical
1.45 + minimumValue: display.minBrightness
1.46 + maximumValue: display.maxBrightness
1.47 + stepSize:1.0
1.48 + tickmarksEnabled: true
1.49 + onValueChanged: display.brightness = value
1.50 + }
1.51 +
1.52 } //Item
2.1 --- a/MiniDisplay/minidisplay.cpp Wed May 28 15:23:41 2014 +0200
2.2 +++ b/MiniDisplay/minidisplay.cpp Wed May 28 17:08:47 2014 +0200
2.3 @@ -5,7 +5,7 @@
2.4 const int KMaxReadAttempt=100;
2.5
2.6 MiniDisplay::MiniDisplay(QQuickItem *parent):
2.7 - QQuickItem(parent),iReadAttempt(0)
2.8 + QQuickItem(parent),iReadAttempt(0),iBrightness(0)
2.9 {
2.10 // By default, QQuickItem does not draw anything. If you subclass
2.11 // QQuickItem to create a visual item, you will need to uncomment the
2.12 @@ -26,6 +26,7 @@
2.13 {
2.14 if (iDisplay.Open())
2.15 {
2.16 + iDisplay.SetBrightness(iBrightness);
2.17 emit opened();
2.18 emit statusChanged();
2.19 }
2.20 @@ -167,6 +168,9 @@
2.21
2.22 /**
2.23 * @brief MiniDisplay::readTimer
2.24 + * Called when our read timer completes.
2.25 + * We then attempt to complete our pending display request.
2.26 + * We typically attempt to read an input report from our HID device.
2.27 */
2.28 void MiniDisplay::readTimer()
2.29 {
2.30 @@ -204,3 +208,30 @@
2.31 }
2.32 }
2.33
2.34 +
2.35 +int MiniDisplay::maxBrightness() const
2.36 +{
2.37 + return iDisplay.MaxBrightness();
2.38 +}
2.39 +
2.40 +int MiniDisplay::minBrightness() const
2.41 +{
2.42 + return iDisplay.MinBrightness();
2.43 +}
2.44 +
2.45 +int MiniDisplay::brightness() const
2.46 +{
2.47 + return iBrightness;
2.48 +}
2.49 +
2.50 +void MiniDisplay::setBrightness(int aBrightness)
2.51 +{
2.52 + //Still track the brightness when disconnected
2.53 + iBrightness=aBrightness;
2.54 +
2.55 + if (!iDisplay.IsOpen()) return;
2.56 +
2.57 + iDisplay.SetBrightness(aBrightness);
2.58 +}
2.59 +
2.60 +
3.1 --- a/MiniDisplay/minidisplay.h Wed May 28 15:23:41 2014 +0200
3.2 +++ b/MiniDisplay/minidisplay.h Wed May 28 17:08:47 2014 +0200
3.3 @@ -14,6 +14,9 @@
3.4 Q_PROPERTY(QString vendor READ vendor)
3.5 Q_PROPERTY(QString product READ product)
3.6 Q_PROPERTY(QString serialNumber READ serialNumber)
3.7 + Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
3.8 + Q_PROPERTY(int maxBrightness READ maxBrightness NOTIFY opened)
3.9 + Q_PROPERTY(int minBrightness READ minBrightness NOTIFY opened)
3.10
3.11 public:
3.12 //Methods
3.13 @@ -37,6 +40,11 @@
3.14 QString vendor();
3.15 QString product();
3.16 QString serialNumber();
3.17 + //
3.18 + int maxBrightness() const;
3.19 + int minBrightness() const;
3.20 + int brightness() const;
3.21 + void setBrightness(int aBrightness);
3.22
3.23 signals:
3.24 void opened();
3.25 @@ -44,6 +52,7 @@
3.26 void closed();
3.27 void statusChanged();
3.28 void fontChanged();
3.29 + void brightnessChanged();
3.30 //
3.31 void powerStatus(bool powerOn);
3.32 void deviceId(QString deviceId);
3.33 @@ -61,6 +70,7 @@
3.34 GP1212A01A iDisplay;
3.35 QFont iFont;
3.36 int iReadAttempt;
3.37 + int iBrightness;
3.38 };
3.39
3.40 #endif // MINIDISPLAY_H