2016-01-03 19:32:36 +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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2015-12-27 14:01:07 +03:00
|
|
|
|
import QtQuick 2.0
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Main tuner screen
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Item {
|
2016-01-02 17:20:19 +03:00
|
|
|
|
id: main
|
2015-12-27 14:01:07 +03:00
|
|
|
|
/// tuner object
|
|
|
|
|
property QtObject tuner
|
|
|
|
|
/// theme corresponding to Silica Theme object
|
|
|
|
|
property QtObject theme
|
|
|
|
|
|
2016-01-13 13:08:01 +03:00
|
|
|
|
signal toggleRun()
|
|
|
|
|
|
2015-12-27 14:01:07 +03:00
|
|
|
|
anchors.fill: parent
|
2016-01-01 20:43:42 +03:00
|
|
|
|
property int h_margin: (height - meter.height - toise.height) / 3
|
2015-12-27 14:01:07 +03:00
|
|
|
|
|
2016-01-02 18:07:12 +03:00
|
|
|
|
// landscape / portrait
|
|
|
|
|
property bool is_portrait: height > width
|
|
|
|
|
|
2016-01-02 18:36:55 +03:00
|
|
|
|
// maximum absolute deviation to display green led
|
2016-01-03 15:36:29 +03:00
|
|
|
|
property double deviation_ok: 0.05
|
2016-01-02 18:36:55 +03:00
|
|
|
|
property color led_green: "green"
|
|
|
|
|
property color led_red: "red"
|
|
|
|
|
|
|
|
|
|
property bool dev_is_ok: Math.abs(tuner.deviation) <= deviation_ok
|
|
|
|
|
|
|
|
|
|
Led {
|
|
|
|
|
anchors.top: meter.top
|
|
|
|
|
anchors.left: meter.left
|
|
|
|
|
anchors.topMargin: meter.width / 24
|
|
|
|
|
anchors.leftMargin: anchors.topMargin
|
|
|
|
|
width: meter.width / 12
|
|
|
|
|
height: width
|
|
|
|
|
led_color: dev_is_ok ? led_green : led_red
|
2016-01-03 16:50:55 +03:00
|
|
|
|
on: tuner.found && (dev_is_ok || tuner.deviation < 0)
|
2016-01-02 18:36:55 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Led {
|
|
|
|
|
anchors.top: meter.top
|
|
|
|
|
anchors.right: meter.right
|
|
|
|
|
anchors.topMargin: meter.width / 24
|
|
|
|
|
anchors.rightMargin: anchors.topMargin
|
|
|
|
|
width: meter.width / 12
|
|
|
|
|
height: width
|
|
|
|
|
led_color: dev_is_ok ? led_green : led_red
|
2016-01-03 16:50:55 +03:00
|
|
|
|
on: tuner.found && (dev_is_ok || tuner.deviation > 0)
|
2016-01-02 18:36:55 +03:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-27 14:01:07 +03:00
|
|
|
|
CircleMeter {
|
2016-01-01 18:39:43 +03:00
|
|
|
|
id: meter
|
2015-12-27 14:01:07 +03:00
|
|
|
|
theme: parent.theme
|
2016-01-01 20:43:42 +03:00
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: h_margin
|
2016-01-01 21:20:29 +03:00
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2016-01-01 20:43:42 +03:00
|
|
|
|
|
2016-01-01 21:20:29 +03:00
|
|
|
|
width: Math.min(parent.width, parent.height * 1.5)
|
2016-01-01 18:39:43 +03:00
|
|
|
|
height: width / 2
|
2016-01-01 21:20:29 +03:00
|
|
|
|
|
2016-01-02 12:19:37 +03:00
|
|
|
|
level: tuner.found ? tuner.deviation * 100 : -50
|
2016-01-01 18:39:43 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-02 17:20:19 +03:00
|
|
|
|
Item {
|
2016-01-02 18:07:12 +03:00
|
|
|
|
id: note_info
|
|
|
|
|
|
2016-01-01 20:43:42 +03:00
|
|
|
|
anchors.top: meter.bottom
|
2016-01-05 23:50:51 +03:00
|
|
|
|
anchors.left: meter.left
|
|
|
|
|
anchors.right: meter.right
|
2016-01-02 17:20:19 +03:00
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
2016-01-02 18:07:12 +03:00
|
|
|
|
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) / 2
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-02 17:20:19 +03:00
|
|
|
|
ScaleToise {
|
|
|
|
|
id: toise
|
|
|
|
|
theme: main.theme
|
|
|
|
|
|
2016-01-13 01:09:13 +03:00
|
|
|
|
flik_enable: false
|
|
|
|
|
|
2016-01-02 18:07:12 +03:00
|
|
|
|
anchors.top: main.is_portrait ? title_note.bottom : parent.top
|
|
|
|
|
anchors.topMargin: parent.margin_h
|
2016-01-01 21:20:29 +03:00
|
|
|
|
|
2016-01-05 23:50:51 +03:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: is_portrait ? 0 : parent.width / 20
|
|
|
|
|
|
|
|
|
|
width: is_portrait ? meter.width : meter.width * 2 / 3
|
2016-01-02 18:07:12 +03:00
|
|
|
|
height: parent.toise_h
|
|
|
|
|
|
|
|
|
|
note: tuner.note
|
|
|
|
|
octave: tuner.octave
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
Toise {
|
2016-01-05 23:50:51 +03:00
|
|
|
|
anchors.top: main.is_portrait ? title_octave.bottom : parent.top
|
2016-01-02 18:07:12 +03:00
|
|
|
|
anchors.topMargin: parent.margin_h
|
|
|
|
|
|
2016-01-05 23:50:51 +03:00
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: is_portrait ? (parent.width - width) / 2 : parent.width / 20
|
2016-01-02 18:07:12 +03:00
|
|
|
|
theme: main.theme
|
|
|
|
|
|
2016-01-12 18:16:25 +03:00
|
|
|
|
marks: [1, 2, 3, 4, 5, 6, 7, 8]
|
2016-01-05 23:50:51 +03:00
|
|
|
|
nb_marks_displayed: is_portrait ? 4 : 3
|
2016-01-02 18:07:12 +03:00
|
|
|
|
|
2016-01-05 23:50:51 +03:00
|
|
|
|
width: is_portrait ? meter.width / 2 : parent.width / 6
|
2016-01-02 18:07:12 +03:00
|
|
|
|
height: parent.toise_h
|
2016-01-01 21:20:29 +03:00
|
|
|
|
|
2016-01-13 00:16:41 +03:00
|
|
|
|
index: tuner.octave - 1
|
2016-01-02 17:20:19 +03:00
|
|
|
|
}
|
2015-12-27 14:01:07 +03:00
|
|
|
|
}
|
2016-01-06 00:02:44 +03:00
|
|
|
|
|
|
|
|
|
// frequency and temperament
|
|
|
|
|
Column {
|
2016-01-06 00:55:08 +03:00
|
|
|
|
id: freq_temp
|
2016-01-06 00:02:44 +03:00
|
|
|
|
x: is_portrait ? theme.paddingLarge : meter.x + meter.width / 6
|
|
|
|
|
y: is_portrait ? theme.paddingLarge : meter.y + meter.height - theme.fontSizeSmall * 4 - theme.paddingLarge
|
|
|
|
|
width: parent.width * 0.4
|
|
|
|
|
height: width / 2
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
text: tuner.la + " hz"
|
|
|
|
|
font.pixelSize: theme.fontSizeSmall
|
2016-01-06 00:55:08 +03:00
|
|
|
|
color: theme.secondaryColor
|
2016-01-06 00:02:44 +03:00
|
|
|
|
}
|
|
|
|
|
Text {
|
|
|
|
|
text: tuner.temperament_list[tuner.temperament_idx]
|
|
|
|
|
font.pixelSize: theme.fontSizeSmall
|
2016-01-06 00:55:08 +03:00
|
|
|
|
color: theme.secondaryColor
|
2016-01-06 00:02:44 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-06 00:55:08 +03:00
|
|
|
|
|
|
|
|
|
// icon for pause status
|
|
|
|
|
Image {
|
|
|
|
|
visible: !tuner.running
|
|
|
|
|
|
|
|
|
|
x: is_portrait ? parent.width - freq_temp.x - width : parent.width - freq_temp.x - width * 2
|
|
|
|
|
y: freq_temp.y
|
|
|
|
|
width: theme.iconSizeMedium
|
|
|
|
|
height: width
|
|
|
|
|
source: theme.icon_pause ? theme.icon_pause : "image://theme/icon-m-pause?" + theme.secondaryColor
|
|
|
|
|
}
|
2016-01-13 13:08:01 +03:00
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked: toggleRun()
|
|
|
|
|
}
|
2015-12-27 14:01:07 +03:00
|
|
|
|
}
|