2016-01-11 14:38:05 +03:00
|
|
|
|
/* Copyright 2016 (C) Louis-Joseph Fournier
|
|
|
|
|
* louisjoseph.fournier@gmail.com
|
|
|
|
|
*
|
|
|
|
|
* This file is part of SailTuner.
|
|
|
|
|
*
|
|
|
|
|
* SailTuner is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* SailTuner is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Main tuner screen
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: main
|
|
|
|
|
/// tuner object
|
|
|
|
|
property QtObject tuner
|
|
|
|
|
/// theme corresponding to Silica Theme object
|
|
|
|
|
property QtObject theme
|
|
|
|
|
|
2016-01-13 13:08:01 +03:00
|
|
|
|
/// called wher user clicked for play/pause
|
|
|
|
|
signal togglePlay()
|
|
|
|
|
|
2016-01-11 14:38:05 +03:00
|
|
|
|
anchors.fill: parent
|
|
|
|
|
property int h_margin: (height - toise.height * 2 - image_play.height) / 5
|
|
|
|
|
|
|
|
|
|
// landscape / portrait
|
|
|
|
|
property bool is_portrait: height > width
|
|
|
|
|
|
2016-01-14 18:51:42 +03:00
|
|
|
|
property bool toisepressed: toise.pressed || toise_octave.pressed
|
|
|
|
|
|
2016-01-11 14:38:05 +03:00
|
|
|
|
// frequency and temperament
|
|
|
|
|
Column {
|
|
|
|
|
id: freq_temp
|
|
|
|
|
x: theme.paddingLarge
|
|
|
|
|
y: theme.paddingLarge
|
|
|
|
|
width: parent.width * 0.4
|
|
|
|
|
height: width / 2
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
text: tuner.la + " hz"
|
|
|
|
|
font.pixelSize: theme.fontSizeSmall
|
|
|
|
|
color: theme.secondaryColor
|
|
|
|
|
}
|
|
|
|
|
Text {
|
|
|
|
|
text: tuner.temperament_list[tuner.temperament_idx]
|
|
|
|
|
font.pixelSize: theme.fontSizeSmall
|
|
|
|
|
color: theme.secondaryColor
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// icon for pause status
|
|
|
|
|
Image {
|
|
|
|
|
id: image_play
|
|
|
|
|
anchors.top: parent.top
|
2016-01-14 17:57:58 +03:00
|
|
|
|
anchors.topMargin: h_margin * 1.4
|
2016-01-11 14:38:05 +03:00
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
width: theme.iconSizeLarge
|
|
|
|
|
height: width
|
|
|
|
|
source: tuner.playing ? (theme.icon_play_large ? theme.icon_play_large : "image://theme/icon-l-play?" + theme.secondaryColor) : (theme.icon_pause_large ? theme.icon_pause_large : "image://theme/icon-l-pause?" + theme.secondaryColor)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: note_info
|
|
|
|
|
|
|
|
|
|
anchors.top: image_play.bottom
|
|
|
|
|
anchors.topMargin: h_margin
|
|
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: parent.height - image_play.height - image_play.y - h_margin * 2
|
|
|
|
|
|
|
|
|
|
property int toise_h: Math.max(width / 10, theme.fontSizeLarge * 1.8)
|
|
|
|
|
property double margin_h: parent.is_portrait ? (height - toise_h * 2) / 7 : (height - toise_h) / 6
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: title_note
|
|
|
|
|
visible: main.is_portrait
|
|
|
|
|
text: qsTr("Note")
|
|
|
|
|
|
|
|
|
|
font.pixelSize: theme.fontSizeMedium
|
|
|
|
|
color: theme.highlightColor
|
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: parent.margin_h
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScaleToise {
|
|
|
|
|
id: toise
|
|
|
|
|
theme: main.theme
|
|
|
|
|
|
|
|
|
|
anchors.top: main.is_portrait ? title_note.bottom : parent.top
|
|
|
|
|
anchors.topMargin: parent.margin_h
|
|
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: parent.width * 0.1
|
|
|
|
|
|
|
|
|
|
width: parent.width * 0.8
|
|
|
|
|
height: parent.toise_h
|
|
|
|
|
|
2016-01-13 12:15:35 +03:00
|
|
|
|
//note: tuner.note
|
|
|
|
|
//octave: tuner.octave
|
|
|
|
|
|
|
|
|
|
onReleased: {
|
2016-01-14 17:56:19 +03:00
|
|
|
|
note = index % 12
|
|
|
|
|
octave = index / 12
|
|
|
|
|
toise_octave.index = octave
|
|
|
|
|
// set octave and note atomically
|
2016-01-14 18:35:23 +03:00
|
|
|
|
tuner.setNoteOctave(note, octave)
|
2016-01-13 12:15:35 +03:00
|
|
|
|
toise_octave.updateFlickable()
|
|
|
|
|
}
|
2016-01-11 14:38:05 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: title_octave
|
|
|
|
|
visible: main.is_portrait
|
|
|
|
|
text: qsTr("Octave")
|
|
|
|
|
|
|
|
|
|
font.pixelSize: theme.fontSizeMedium
|
|
|
|
|
color: theme.highlightColor
|
|
|
|
|
|
|
|
|
|
anchors.top: toise.bottom
|
|
|
|
|
anchors.topMargin: parent.margin_h
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// octave toise
|
2016-01-11 19:46:08 +03:00
|
|
|
|
ToiseFlickable {
|
2016-01-13 12:15:35 +03:00
|
|
|
|
id: toise_octave
|
2016-01-11 14:38:05 +03:00
|
|
|
|
anchors.top: main.is_portrait ? title_octave.bottom : toise.bottom
|
|
|
|
|
anchors.topMargin: parent.margin_h
|
|
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: parent.width * 0.2
|
|
|
|
|
|
|
|
|
|
theme: main.theme
|
|
|
|
|
|
2016-01-13 13:16:16 +03:00
|
|
|
|
marks: [0, 1, 2, 3, 4, 5, 6, 7, 8]
|
2016-01-13 01:09:13 +03:00
|
|
|
|
min: 0
|
|
|
|
|
max: marks.length - 1
|
2016-01-11 14:38:05 +03:00
|
|
|
|
//nb_marks_displayed: is_portrait ? 4 : 3
|
|
|
|
|
|
|
|
|
|
width: parent.width * 0.6
|
|
|
|
|
height: parent.toise_h
|
|
|
|
|
|
2016-01-13 12:15:35 +03:00
|
|
|
|
//index: tuner.octave - 1
|
|
|
|
|
onReleased: {
|
2016-01-13 13:16:16 +03:00
|
|
|
|
tuner.octave = index
|
2016-01-13 12:15:35 +03:00
|
|
|
|
toise.octave = tuner.octave
|
2016-01-13 01:09:13 +03:00
|
|
|
|
}
|
2016-01-11 14:38:05 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-13 12:15:35 +03:00
|
|
|
|
|
2016-01-13 13:08:01 +03:00
|
|
|
|
/// play/pause area
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: note_info.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
onClicked: togglePlay()
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-13 12:15:35 +03:00
|
|
|
|
/// update toise indexes if tuner note and octave changed from exterior
|
|
|
|
|
function update() {
|
2016-01-14 19:09:48 +03:00
|
|
|
|
console.log("update")
|
2016-01-13 13:16:16 +03:00
|
|
|
|
toise.flik_enable = false
|
2016-01-13 12:15:35 +03:00
|
|
|
|
toise.note = tuner.note
|
|
|
|
|
toise.octave = tuner.octave
|
2016-01-13 13:16:16 +03:00
|
|
|
|
toise_octave.index = tuner.octave
|
2016-01-14 19:09:48 +03:00
|
|
|
|
toise.index = tuner.note + 12 * tuner.octave
|
|
|
|
|
toise.updateFlickable()
|
|
|
|
|
toise_octave.updateFlickable()
|
2016-01-13 13:16:16 +03:00
|
|
|
|
toise.flik_enable = true
|
2016-01-13 12:15:35 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: update()
|
2016-01-11 14:38:05 +03:00
|
|
|
|
}
|