on xenial help sign in
Turn off animation when display is off
3c8fd5fMichael Terry
Components/DemoOverlay.qml+18
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17+import Powerd 0.1
17import QtQuick 2.0
18import QtQuick 2.0
18import QtGraphicalEffects 1.0
19import QtGraphicalEffects 1.0
19import Ubuntu.Application 0.1
20import Ubuntu.Application 0.1
@@ -243,4 +244,21 @@ Showable {
243 }
244 }
244 }
245 }
245 }
246 }
247+
248+ // Watch display, so we can turn off animation if it does. No reason to
249+ // chew CPU when user isn't watching.
250+ Connections {
251+ id: powerConnection
252+ target: Powerd
253+
254+ onDisplayPowerStateChange: {
255+ if (status == Powerd.Off && wholeAnimation.running) {
256+ wholeAnimation.paused = true;
257+ //hintAnimation.paused = true;
258+ } else if (status == Powerd.On) {
259+ wholeAnimation.paused = false;
260+ //hintAnimation.paused = false;
261+ }
262+ }
263+ }
246}
264}