Desktop version with player fully working

Double-click on upper part of tuner screen to launch player
This commit is contained in:
Louis-Joseph Fournier 2016-01-13 11:08:01 +01:00
parent 6850095533
commit 48afd68d06
8 changed files with 68 additions and 21 deletions

View file

@ -16,12 +16,15 @@
*/
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import LJTuner 1.0
import LJUtils 1.0
import "."
Item {
id: root
width: 600
height: 500
@ -50,11 +53,45 @@ Item {
anchors.fill: parent
theme: theme
tuner: tuner
onToggleRun: tuner.running ^= true
}
MouseArea {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: parent.height / 8
onDoubleClicked: {
var win = player.createObject(player, {theme: theme, tuner: tuner})
win.show()
}
}
}
MouseArea {
anchors.fill: parent
onClicked: tuner.running = (tuner.running ^ true)
// player
Component {
id: player
ApplicationWindow {
id: player_app
width: 600
height: 500
property QtObject tuner
property QtObject theme
Image {
source: "../images/bg_portrait.png"
anchors.fill: parent
}
PlayerScreen {
tuner: player_app.tuner
theme: player_app.theme
anchors.fill: parent
onTogglePlay: tuner.playing ^= true
}
}
}
}

View file

@ -29,19 +29,15 @@ Item {
/// theme corresponding to Silica Theme object
property QtObject theme
/// called wher user clicked for play/pause
signal togglePlay()
anchors.fill: parent
property int h_margin: (height - toise.height * 2 - image_play.height) / 5
// landscape / portrait
property bool is_portrait: height > width
// maximum absolute deviation to display green led
property double deviation_ok: 0.05
property color led_green: "green"
property color led_red: "red"
property bool dev_is_ok: Math.abs(tuner.deviation) <= deviation_ok
// frequency and temperament
Column {
id: freq_temp
@ -115,8 +111,8 @@ Item {
//octave: tuner.octave
onReleased: {
octave = tuner.octave = index / 12
note = tuner.note = index % 12
octave = tuner.octave = index / 12
toise_octave.index = tuner.octave - 1
toise_octave.updateFlickable()
}
@ -162,6 +158,15 @@ Item {
}
}
/// play/pause area
MouseArea {
anchors.top: parent.top
anchors.bottom: note_info.top
anchors.left: parent.left
anchors.right: parent.right
onClicked: togglePlay()
}
/// update toise indexes if tuner note and octave changed from exterior
function update() {
toise.note = tuner.note

View file

@ -45,8 +45,6 @@ ApplicationWindow {
id: page
allowedOrientations: Orientation.All
signal togglePause()
SilicaFlickable {
anchors.fill: parent
@ -61,14 +59,10 @@ ApplicationWindow {
}
TunerScreen {
id: screen
anchors.fill: parent
theme: Theme
tuner: app.tuner
MouseArea {
anchors.fill: parent
onClicked: togglePause()
}
}
}
@ -83,7 +77,7 @@ ApplicationWindow {
Component.onCompleted: {
app.tuner = tunerObject
togglePause.connect(app.togglePause)
screen.toggleRun.connect(app.toggleRun)
}
}
}
@ -97,7 +91,7 @@ ApplicationWindow {
}
}
function togglePause() {
function toggleRun() {
app.userRunning = app.userRunning ? false : true
}
}

View file

@ -63,8 +63,8 @@ ToiseFlickable {
max: notes_en.length * 9 - 1 // si 8
onOctaveChanged: {
if (!flik_enable) return
index = note + notes_en.length * octave
updateFlickable()
}
onNoteChanged: console.log(note)
}

View file

@ -48,5 +48,7 @@ Image {
PlayerScreen {
tuner: tuner
theme: theme
onTogglePlay: tuner.playing ^= true
}
}

View file

@ -29,6 +29,8 @@ Item {
/// theme corresponding to Silica Theme object
property QtObject theme
signal toggleRun()
anchors.fill: parent
property int h_margin: (height - meter.height - toise.height) / 3
@ -183,4 +185,9 @@ Item {
height: width
source: theme.icon_pause ? theme.icon_pause : "image://theme/icon-m-pause?" + theme.secondaryColor
}
MouseArea {
anchors.fill: parent
onClicked: toggleRun()
}
}

View file

@ -3,6 +3,7 @@
<file>Desktop.qml</file>
<file>SimpleDisplay.qml</file>
<file>DesktopTheme.qml</file>
<file>PlayerScreen.qml</file>
<file>TunerScreen.qml</file>
<file>CircleMeter.qml</file>
<file>ScaleToise.qml</file>

View file

@ -2,6 +2,7 @@
<qresource prefix="/qml/">
<file>Sailfish.qml</file>
<file>SimpleDisplay.qml</file>
<file>PlayerScreen.qml</file>
<file>TunerScreen.qml</file>
<file>CircleMeter.qml</file>
<file>ScaleToise.qml</file>