From c985f7c93e0989d83c2eff7220c0f16899de4d7e Mon Sep 17 00:00:00 2001 From: Louis-Joseph Fournier Date: Fri, 15 Jan 2016 21:11:23 +0100 Subject: [PATCH] Sailfish: cover management --- qml/CircleMeter.qml | 5 +++++ qml/CoverPageSailfish.qml | 16 ++++++++++++---- qml/Sailfish.qml | 22 +++++++++++++++++++++- qml/TunerScreen.qml | 5 +++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/qml/CircleMeter.qml b/qml/CircleMeter.qml index f11e078..de3fe08 100644 --- a/qml/CircleMeter.qml +++ b/qml/CircleMeter.qml @@ -252,4 +252,9 @@ Item { onLevelChanged: { arrow.requestPaint() } + + function redraw() { + ellipse.requestPaint() + arrow.requestPaint() + } } diff --git a/qml/CoverPageSailfish.qml b/qml/CoverPageSailfish.qml index 318a260..d200a34 100644 --- a/qml/CoverPageSailfish.qml +++ b/qml/CoverPageSailfish.qml @@ -29,12 +29,13 @@ CoverBackground { id: cover property QtObject tuner + property bool displayDeviation: true Item { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - anchors.topMargin: parent.height / 12 + anchors.topMargin: parent.height / 6 Label { id: coverLabel @@ -56,11 +57,18 @@ CoverBackground { color: Theme.primaryColor font.pixelSize: 35 } - Led { + + Text { + id: coverDeviation + text: (tuner.deviation > 0 ? "+" : "") + (tuner.deviation * 101).toFixed(2) + "%" + visible: tuner.found && cover.displayDeviation + + anchors.horizontalCenter: parent.horizontalCenter anchors.top: coverNote.bottom anchors.topMargin: Theme.paddingLarge - anchors.horizontalCenter: parent.horizontalCenter - led_color: Math.abs(tuner.deviation) <= 0.05 ? "green" : "red" + + color: Theme.secondaryColor + font.pixelSize: 25 } } } diff --git a/qml/Sailfish.qml b/qml/Sailfish.qml index 54ed984..2a95c60 100644 --- a/qml/Sailfish.qml +++ b/qml/Sailfish.qml @@ -35,6 +35,7 @@ ApplicationWindow { property int dbFontSize: 100 property QtObject tuner + property bool lastPagePlaying: false ObjectSaver { id: saver @@ -84,6 +85,20 @@ ApplicationWindow { } onTunerRunningChanged: app.userRunning = tunerRunning + property bool isVisible: Qt.application.active && status == PageStatus.Active + property int countVisible: 0 + onIsVisibleChanged: { + if (isVisible) { + // don't redraw the first time + if (countVisible > 0) screen.redraw() + countVisible++ + } + } + onStatusChanged: { + if (status == PageStatus.Active) { + app.lastPagePlaying = false + } + } } } @@ -125,7 +140,10 @@ ApplicationWindow { onTunerPlayingChanged: app.userPlaying = tunerPlaying onStatusChanged: { - if (status == PageStatus.Active) screen.update() + if (status == PageStatus.Active) { + app.lastPagePlaying = true + screen.update() + } } } } @@ -133,6 +151,8 @@ ApplicationWindow { cover: Component { CoverPageSailfish { + tuner: app.tuner + displayDeviation: !app.lastPagePlaying } } diff --git a/qml/TunerScreen.qml b/qml/TunerScreen.qml index d10b591..230b87f 100644 --- a/qml/TunerScreen.qml +++ b/qml/TunerScreen.qml @@ -31,6 +31,7 @@ Item { property QtObject theme signal toggleRun() + signal redraw() anchors.fill: parent property int h_margin: (height - meter.height - toise.height) / 3 @@ -191,4 +192,8 @@ Item { anchors.fill: parent onClicked: toggleRun() } + + Component.onCompleted: { + redraw.connect(meter.redraw) + } }