author | sl |
Tue, 03 Jun 2014 18:35:43 +0200 | |
changeset 31 | e68f1542d9d3 |
parent 17 | aa257fdcd093 |
permissions | -rw-r--r-- |
sl@2 | 1 |
import QtQuick 2.2 |
sl@2 | 2 |
import QtQuick.Controls 1.2 |
sl@2 | 3 |
import MiniDisplay 1.0 |
sl@4 | 4 |
import QtQuick.Layouts 1.1 |
sl@4 | 5 |
import Qt.labs.settings 1.0 |
sl@4 | 6 |
|
sl@2 | 7 |
|
sl@8 | 8 |
|
sl@2 | 9 |
Item { |
sl@14 | 10 |
//width: 100 |
sl@14 | 11 |
//height: 62 |
sl@2 | 12 |
//SystemPalette { id: palette } |
sl@2 | 13 |
clip: true |
sl@4 | 14 |
// |
sl@11 | 15 |
Component.onCompleted: { |
sl@11 | 16 |
display.closing.connect(onDisplayClosing); |
sl@11 | 17 |
display.opened.connect(onDisplayOpened); |
sl@13 | 18 |
appWindow.closing.connect(onWindowClosing); |
sl@11 | 19 |
if(checkBoxConnectOnStartUp.checked) display.open() |
sl@11 | 20 |
} |
sl@11 | 21 |
|
sl@11 | 22 |
//We need to disconnect our signals to avoid receiving stray events |
sl@11 | 23 |
Component.onDestruction: { |
sl@13 | 24 |
disconnectDisplaySignals() |
sl@11 | 25 |
} |
sl@10 | 26 |
// |
sl@10 | 27 |
Settings { |
sl@10 | 28 |
property alias connectOnStratUp: checkBoxConnectOnStartUp.checked; |
sl@11 | 29 |
property alias clearWhenDisconnecting: checkBoxClearWhenDisconnecting.checked; |
sl@11 | 30 |
property alias clearWhenConnecting: checkBoxClearWhenConnecting.checked; |
sl@10 | 31 |
property alias brightness: sliderBrightness.value; |
sl@10 | 32 |
} |
sl@2 | 33 |
|
sl@13 | 34 |
function disconnectDisplaySignals() |
sl@13 | 35 |
{ |
sl@13 | 36 |
display.closed.disconnect(onDisplayClosing); |
sl@13 | 37 |
display.opened.disconnect(onDisplayOpened); |
sl@13 | 38 |
} |
sl@13 | 39 |
|
sl@13 | 40 |
//Clear both front and back buffers |
sl@13 | 41 |
function clearBuffers() |
sl@13 | 42 |
{ |
sl@13 | 43 |
display.clear(); |
sl@13 | 44 |
display.swapBuffers(); |
sl@13 | 45 |
display.clear(); |
sl@13 | 46 |
display.swapBuffers(); |
sl@13 | 47 |
} |
sl@13 | 48 |
|
sl@13 | 49 |
function onWindowClosing() |
sl@13 | 50 |
{ |
sl@13 | 51 |
//Clear both our frames |
sl@13 | 52 |
onDisplayClosing(); |
sl@13 | 53 |
disconnectDisplaySignals(); |
sl@13 | 54 |
} |
sl@13 | 55 |
|
sl@11 | 56 |
function onDisplayClosing() |
sl@11 | 57 |
{ |
sl@13 | 58 |
if (checkBoxClearWhenDisconnecting != null && checkBoxClearWhenDisconnecting.checked) |
sl@11 | 59 |
{ |
sl@13 | 60 |
clearBuffers(); |
sl@11 | 61 |
} |
sl@11 | 62 |
} |
sl@11 | 63 |
|
sl@11 | 64 |
function onDisplayOpened() |
sl@11 | 65 |
{ |
sl@11 | 66 |
if (checkBoxClearWhenConnecting.checked) |
sl@11 | 67 |
{ |
sl@13 | 68 |
clearBuffers(); |
sl@11 | 69 |
} |
sl@11 | 70 |
} |
sl@11 | 71 |
|
sl@4 | 72 |
// |
sl@10 | 73 |
|
sl@8 | 74 |
Column { |
sl@4 | 75 |
anchors.fill: parent |
sl@4 | 76 |
anchors.margins: 8 |
sl@4 | 77 |
spacing: 8 |
sl@4 | 78 |
|
sl@10 | 79 |
|
sl@4 | 80 |
Button { |
sl@4 | 81 |
id: buttonOpenClose |
sl@4 | 82 |
text: display.isOpen ? qsTr("Disconnect") : qsTr("Connect") |
sl@4 | 83 |
onClicked: display.isOpen ? display.close() : display.open() |
sl@4 | 84 |
} |
sl@4 | 85 |
|
sl@4 | 86 |
Button { |
sl@4 | 87 |
text: qsTr("Clear") |
sl@4 | 88 |
onClicked: {display.clear(); display.swapBuffers();} |
sl@4 | 89 |
enabled: display.isOpen |
sl@4 | 90 |
activeFocusOnPress: false |
sl@4 | 91 |
} |
sl@4 | 92 |
|
sl@4 | 93 |
Button { |
sl@4 | 94 |
text: qsTr("Fill") |
sl@4 | 95 |
onClicked: {display.fill(); display.swapBuffers();} |
sl@4 | 96 |
enabled: display.isOpen |
sl@4 | 97 |
activeFocusOnPress: false |
sl@4 | 98 |
} |
sl@4 | 99 |
|
sl@10 | 100 |
CheckBox { |
sl@10 | 101 |
id: checkBoxConnectOnStartUp |
sl@10 | 102 |
text: qsTr("Connect on start-up") |
sl@10 | 103 |
} |
sl@10 | 104 |
|
sl@11 | 105 |
CheckBox { |
sl@11 | 106 |
id: checkBoxClearWhenDisconnecting |
sl@11 | 107 |
text: qsTr("Clear when disconnecting") |
sl@11 | 108 |
} |
sl@11 | 109 |
|
sl@11 | 110 |
CheckBox { |
sl@11 | 111 |
id: checkBoxClearWhenConnecting |
sl@11 | 112 |
text: qsTr("Clear when connecting") |
sl@11 | 113 |
} |
sl@11 | 114 |
|
sl@11 | 115 |
|
sl@4 | 116 |
} //ColumnLayout |
sl@10 | 117 |
|
sl@10 | 118 |
Slider { |
sl@10 | 119 |
id: sliderBrightness |
sl@10 | 120 |
anchors.margins: 8 |
sl@10 | 121 |
anchors.right: parent.right |
sl@10 | 122 |
anchors.top: parent.top |
sl@17 | 123 |
height:parent.height/2 |
sl@10 | 124 |
// |
sl@10 | 125 |
orientation: Qt.Vertical |
sl@10 | 126 |
minimumValue: display.minBrightness |
sl@10 | 127 |
maximumValue: display.maxBrightness |
sl@10 | 128 |
stepSize:1.0 |
sl@10 | 129 |
tickmarksEnabled: true |
sl@10 | 130 |
onValueChanged: display.brightness = value |
sl@10 | 131 |
} |
sl@10 | 132 |
|
sl@4 | 133 |
} //Item |