sl@2: import QtQuick 2.2 sl@2: import QtQuick.Controls 1.2 sl@2: import MiniDisplay 1.0 sl@4: import QtQuick.Layouts 1.1 sl@4: import Qt.labs.settings 1.0 sl@4: sl@2: sl@8: sl@2: Item { sl@14: //width: 100 sl@14: //height: 62 sl@2: //SystemPalette { id: palette } sl@2: clip: true sl@4: // sl@11: Component.onCompleted: { sl@11: display.closing.connect(onDisplayClosing); sl@11: display.opened.connect(onDisplayOpened); sl@13: appWindow.closing.connect(onWindowClosing); sl@11: if(checkBoxConnectOnStartUp.checked) display.open() sl@11: } sl@11: sl@11: //We need to disconnect our signals to avoid receiving stray events sl@11: Component.onDestruction: { sl@13: disconnectDisplaySignals() sl@11: } sl@10: // sl@10: Settings { sl@10: property alias connectOnStratUp: checkBoxConnectOnStartUp.checked; sl@11: property alias clearWhenDisconnecting: checkBoxClearWhenDisconnecting.checked; sl@11: property alias clearWhenConnecting: checkBoxClearWhenConnecting.checked; sl@10: property alias brightness: sliderBrightness.value; sl@10: } sl@2: sl@13: function disconnectDisplaySignals() sl@13: { sl@13: display.closed.disconnect(onDisplayClosing); sl@13: display.opened.disconnect(onDisplayOpened); sl@13: } sl@13: sl@13: //Clear both front and back buffers sl@13: function clearBuffers() sl@13: { sl@13: display.clear(); sl@13: display.swapBuffers(); sl@13: display.clear(); sl@13: display.swapBuffers(); sl@13: } sl@13: sl@13: function onWindowClosing() sl@13: { sl@13: //Clear both our frames sl@13: onDisplayClosing(); sl@13: disconnectDisplaySignals(); sl@13: } sl@13: sl@11: function onDisplayClosing() sl@11: { sl@13: if (checkBoxClearWhenDisconnecting != null && checkBoxClearWhenDisconnecting.checked) sl@11: { sl@13: clearBuffers(); sl@11: } sl@11: } sl@11: sl@11: function onDisplayOpened() sl@11: { sl@11: if (checkBoxClearWhenConnecting.checked) sl@11: { sl@13: clearBuffers(); sl@11: } sl@11: } sl@11: sl@4: // sl@10: sl@8: Column { sl@4: anchors.fill: parent sl@4: anchors.margins: 8 sl@4: spacing: 8 sl@4: sl@10: sl@4: Button { sl@4: id: buttonOpenClose sl@4: text: display.isOpen ? qsTr("Disconnect") : qsTr("Connect") sl@4: onClicked: display.isOpen ? display.close() : display.open() sl@4: } sl@4: sl@4: Button { sl@4: text: qsTr("Clear") sl@4: onClicked: {display.clear(); display.swapBuffers();} sl@4: enabled: display.isOpen sl@4: activeFocusOnPress: false sl@4: } sl@4: sl@4: Button { sl@4: text: qsTr("Fill") sl@4: onClicked: {display.fill(); display.swapBuffers();} sl@4: enabled: display.isOpen sl@4: activeFocusOnPress: false sl@4: } sl@4: sl@10: CheckBox { sl@10: id: checkBoxConnectOnStartUp sl@10: text: qsTr("Connect on start-up") sl@10: } sl@10: sl@11: CheckBox { sl@11: id: checkBoxClearWhenDisconnecting sl@11: text: qsTr("Clear when disconnecting") sl@11: } sl@11: sl@11: CheckBox { sl@11: id: checkBoxClearWhenConnecting sl@11: text: qsTr("Clear when connecting") sl@11: } sl@11: sl@11: sl@4: } //ColumnLayout sl@10: sl@10: Slider { sl@10: id: sliderBrightness sl@10: anchors.margins: 8 sl@10: anchors.right: parent.right sl@10: anchors.top: parent.top sl@17: height:parent.height/2 sl@10: // sl@10: orientation: Qt.Vertical sl@10: minimumValue: display.minBrightness sl@10: maximumValue: display.maxBrightness sl@10: stepSize:1.0 sl@10: tickmarksEnabled: true sl@10: onValueChanged: display.brightness = value sl@10: } sl@10: sl@4: } //Item