Trying to get rid of our QML timer.
We now connect to our window after animation signal from C++.
It looks like it works much better now. Less UI lags smother animation.
2 import QtQuick.Controls 1.2
4 import QtQuick.Layouts 1.1
5 import Qt.labs.settings 1.0
12 //SystemPalette { id: palette }
15 Component.onCompleted: {
16 display.closing.connect(onDisplayClosing);
17 display.opened.connect(onDisplayOpened);
18 appWindow.closing.connect(onWindowClosing);
19 if(checkBoxConnectOnStartUp.checked) display.open()
22 //We need to disconnect our signals to avoid receiving stray events
23 Component.onDestruction: {
24 disconnectDisplaySignals()
28 property alias connectOnStratUp: checkBoxConnectOnStartUp.checked;
29 property alias clearWhenDisconnecting: checkBoxClearWhenDisconnecting.checked;
30 property alias clearWhenConnecting: checkBoxClearWhenConnecting.checked;
31 property alias brightness: sliderBrightness.value;
34 function disconnectDisplaySignals()
36 display.closed.disconnect(onDisplayClosing);
37 display.opened.disconnect(onDisplayOpened);
40 //Clear both front and back buffers
41 function clearBuffers()
44 display.swapBuffers();
46 display.swapBuffers();
49 function onWindowClosing()
51 //Clear both our frames
53 disconnectDisplaySignals();
56 function onDisplayClosing()
58 if (checkBoxClearWhenDisconnecting != null && checkBoxClearWhenDisconnecting.checked)
64 function onDisplayOpened()
66 if (checkBoxClearWhenConnecting.checked)
82 text: display.isOpen ? qsTr("Disconnect") : qsTr("Connect")
83 onClicked: display.isOpen ? display.close() : display.open()
88 onClicked: {display.clear(); display.swapBuffers();}
89 enabled: display.isOpen
90 activeFocusOnPress: false
95 onClicked: {display.fill(); display.swapBuffers();}
96 enabled: display.isOpen
97 activeFocusOnPress: false
101 id: checkBoxConnectOnStartUp
102 text: qsTr("Connect on start-up")
106 id: checkBoxClearWhenDisconnecting
107 text: qsTr("Clear when disconnecting")
111 id: checkBoxClearWhenConnecting
112 text: qsTr("Clear when connecting")
121 anchors.right: parent.right
122 anchors.top: parent.top
123 height:parent.height/2
125 orientation: Qt.Vertical
126 minimumValue: display.minBrightness
127 maximumValue: display.maxBrightness
129 tickmarksEnabled: true
130 onValueChanged: display.brightness = value