diff --git a/qml/NoteNames.qml b/qml/NoteNames.qml
new file mode 100644
index 0000000..8a49cc0
--- /dev/null
+++ b/qml/NoteNames.qml
@@ -0,0 +1,43 @@
+/* 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
+import "."
+
+pragma Singleton
+
+/**
+ * NoteNames
+ *
+ * Singleton to provide facilities to note names
+ */
+
+QtObject {
+ property int notes_style: Config.notes_style
+
+ property variant notes_fr: [
+ "do", "do#", "ré", "mib", "mi", "fa", "fa#", "sol", "sol#", "la", "sib", "si"]
+ property variant notes_en: [
+ "C", "C#", "D", "Eb", "E", "F", "F#", "G", "G#", "A", "Bb", "B"]
+
+ property variant notesTab: [notes_en, notes_fr]
+
+ property int nb: notes_fr.length
+ property variant notes: notesTab[notes_style]
+
+ function noteName(note) { return notes[note]; }
+}
diff --git a/qml/PlayerScreen.qml b/qml/PlayerScreen.qml
index f6cbd10..daa026d 100644
--- a/qml/PlayerScreen.qml
+++ b/qml/PlayerScreen.qml
@@ -16,6 +16,7 @@
*/
import QtQuick 2.0
+import "."
/**
* Main tuner screen
@@ -113,8 +114,8 @@ Item {
//octave: tuner.octave
onReleased: {
- note = index % 12
- octave = index / 12
+ note = index % NoteNames.nb
+ octave = index / NoteNames.nb
toise_octave.index = octave
// set octave and note atomically
tuner.setNoteOctave(note, octave)
@@ -178,7 +179,7 @@ Item {
toise.note = tuner.note
toise.octave = tuner.octave
toise_octave.index = tuner.octave
- toise.index = tuner.note + 12 * tuner.octave
+ toise.index = tuner.note + NoteNames.nb * tuner.octave
toise.updateFlickable()
toise_octave.updateFlickable()
toise.flik_enable = true
diff --git a/qml/ScaleToise.qml b/qml/ScaleToise.qml
index 4f37c20..76f7343 100644
--- a/qml/ScaleToise.qml
+++ b/qml/ScaleToise.qml
@@ -31,22 +31,14 @@ ToiseFlickable {
property int note: 1
// octave
property int octave: 4
- // en or fr
- property int notes_style: Config.notes_style
-
- property variant notes_fr: [
- "do", "do#", "ré", "mib", "mi", "fa", "fa#", "sol", "sol#", "la", "sib", "si"]
- property variant notes_en: [
- "C", "C#", "D", "Eb", "E", "F", "F#", "G", "G#", "A", "Bb", "B"]
- property variant notes: [notes_en, notes_fr]
// case colors
property color colorAltered: "#40888888"
property color colorNatural: "transparent"
// Toise parameters
- index: note + notes_en.length * octave
- marks: notes[notes_style]
+ index: note + NoteNames.nb * octave
+ marks: NoteNames.notes
nb_marks_displayed: width > 100 ? Math.min(nb_marks, width / theme.fontSizeLarge * 0.8) : 1
mark_color: function(note) {
@@ -59,12 +51,12 @@ ToiseFlickable {
}
// ToiseFlikcable parameters
- min: notes_en.length * 0 // ut 0
- max: notes_en.length * 9 - 1 // si 8
+ min: NoteNames.nb * 0 // ut 0
+ max: NoteNames.nb * 9 - 1 // si 8
onOctaveChanged: {
if (!flik_enable) return
- index = note + notes_en.length * octave
+ index = note + NoteNames.nb * octave
updateFlickable()
}
}
diff --git a/qml/TunerScreen.qml b/qml/TunerScreen.qml
index cc5e9e9..d10b591 100644
--- a/qml/TunerScreen.qml
+++ b/qml/TunerScreen.qml
@@ -16,6 +16,7 @@
*/
import QtQuick 2.0
+import "."
/**
* Main tuner screen
@@ -49,7 +50,7 @@ Item {
anchors.left: meter.left
anchors.topMargin: meter.width / 24
anchors.leftMargin: anchors.topMargin
- width: meter.width / 12
+ width: meter.width / NoteNames.nb
height: width
led_color: dev_is_ok ? led_green : led_red
on: tuner.found && (dev_is_ok || tuner.deviation < 0)
@@ -60,7 +61,7 @@ Item {
anchors.right: meter.right
anchors.topMargin: meter.width / 24
anchors.rightMargin: anchors.topMargin
- width: meter.width / 12
+ width: meter.width / NoteNames.nb
height: width
led_color: dev_is_ok ? led_green : led_red
on: tuner.found && (dev_is_ok || tuner.deviation > 0)
diff --git a/qml/desktop.qrc b/qml/desktop.qrc
index 51aa83a..7d941a0 100644
--- a/qml/desktop.qrc
+++ b/qml/desktop.qrc
@@ -11,6 +11,7 @@
ToiseFlickable.qml
Led.qml
Config.qml
+NoteNames.qml
qmldir
diff --git a/qml/qmldir b/qml/qmldir
index 126440d..9c9baff 100644
--- a/qml/qmldir
+++ b/qml/qmldir
@@ -1 +1,2 @@
singleton Config Config.qml
+singleton NoteNames NoteNames.qml
diff --git a/qml/sailfish.qrc b/qml/sailfish.qrc
index da7d06b..9e4c120 100644
--- a/qml/sailfish.qrc
+++ b/qml/sailfish.qrc
@@ -11,6 +11,7 @@
Led.qml
ConfigurePageSailfish.qml
Config.qml
+NoteNames.qml
qmldir