# HG changeset patch # User sl # Date 1401289727 -7200 # Node ID 64cfde8062c71e581c04dc8425e747d991d21e24 # Parent 52372bbbc0f8ad8637f2a81724bb573d8a266d26 Adding brightness slider and an option to connect display on start-up. Both brightness and connect options are persisted. diff -r 52372bbbc0f8 -r 64cfde8062c7 DisplayTab.qml --- a/DisplayTab.qml Wed May 28 15:23:41 2014 +0200 +++ b/DisplayTab.qml Wed May 28 17:08:47 2014 +0200 @@ -12,14 +12,21 @@ //SystemPalette { id: palette } clip: true // - + Component.onCompleted: { if(checkBoxConnectOnStartUp.checked) display.open()} + // + Settings { + property alias connectOnStratUp: checkBoxConnectOnStartUp.checked; + property alias brightness: sliderBrightness.value; + } // + Column { anchors.fill: parent anchors.margins: 8 spacing: 8 + Button { id: buttonOpenClose text: display.isOpen ? qsTr("Disconnect") : qsTr("Connect") @@ -40,5 +47,26 @@ activeFocusOnPress: false } + CheckBox { + id: checkBoxConnectOnStartUp + text: qsTr("Connect on start-up") + } + } //ColumnLayout + + Slider { + id: sliderBrightness + anchors.margins: 8 + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + // + orientation: Qt.Vertical + minimumValue: display.minBrightness + maximumValue: display.maxBrightness + stepSize:1.0 + tickmarksEnabled: true + onValueChanged: display.brightness = value + } + } //Item diff -r 52372bbbc0f8 -r 64cfde8062c7 MiniDisplay/minidisplay.cpp --- a/MiniDisplay/minidisplay.cpp Wed May 28 15:23:41 2014 +0200 +++ b/MiniDisplay/minidisplay.cpp Wed May 28 17:08:47 2014 +0200 @@ -5,7 +5,7 @@ const int KMaxReadAttempt=100; MiniDisplay::MiniDisplay(QQuickItem *parent): - QQuickItem(parent),iReadAttempt(0) + QQuickItem(parent),iReadAttempt(0),iBrightness(0) { // By default, QQuickItem does not draw anything. If you subclass // QQuickItem to create a visual item, you will need to uncomment the @@ -26,6 +26,7 @@ { if (iDisplay.Open()) { + iDisplay.SetBrightness(iBrightness); emit opened(); emit statusChanged(); } @@ -167,6 +168,9 @@ /** * @brief MiniDisplay::readTimer + * Called when our read timer completes. + * We then attempt to complete our pending display request. + * We typically attempt to read an input report from our HID device. */ void MiniDisplay::readTimer() { @@ -204,3 +208,30 @@ } } + +int MiniDisplay::maxBrightness() const +{ + return iDisplay.MaxBrightness(); +} + +int MiniDisplay::minBrightness() const +{ + return iDisplay.MinBrightness(); +} + +int MiniDisplay::brightness() const +{ + return iBrightness; +} + +void MiniDisplay::setBrightness(int aBrightness) +{ + //Still track the brightness when disconnected + iBrightness=aBrightness; + + if (!iDisplay.IsOpen()) return; + + iDisplay.SetBrightness(aBrightness); +} + + diff -r 52372bbbc0f8 -r 64cfde8062c7 MiniDisplay/minidisplay.h --- a/MiniDisplay/minidisplay.h Wed May 28 15:23:41 2014 +0200 +++ b/MiniDisplay/minidisplay.h Wed May 28 17:08:47 2014 +0200 @@ -14,6 +14,9 @@ Q_PROPERTY(QString vendor READ vendor) Q_PROPERTY(QString product READ product) Q_PROPERTY(QString serialNumber READ serialNumber) + Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) + Q_PROPERTY(int maxBrightness READ maxBrightness NOTIFY opened) + Q_PROPERTY(int minBrightness READ minBrightness NOTIFY opened) public: //Methods @@ -37,6 +40,11 @@ QString vendor(); QString product(); QString serialNumber(); + // + int maxBrightness() const; + int minBrightness() const; + int brightness() const; + void setBrightness(int aBrightness); signals: void opened(); @@ -44,6 +52,7 @@ void closed(); void statusChanged(); void fontChanged(); + void brightnessChanged(); // void powerStatus(bool powerOn); void deviceId(QString deviceId); @@ -61,6 +70,7 @@ GP1212A01A iDisplay; QFont iFont; int iReadAttempt; + int iBrightness; }; #endif // MINIDISPLAY_H