From a8a1d089d499819430118571c17c932f5ed4550b Mon Sep 17 00:00:00 2001 From: Louis-Joseph Fournier Date: Sun, 27 Dec 2015 12:01:07 +0100 Subject: [PATCH] TunerScreen: first work with qmlscene --- qml/CircleMeter.qml | 32 ++++++++++++++++++++++++++++++++ qml/Scene.qml | 35 +++++++++++++++++++++++++++++++++++ qml/TunerScreen.qml | 20 ++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 qml/CircleMeter.qml create mode 100644 qml/Scene.qml create mode 100644 qml/TunerScreen.qml diff --git a/qml/CircleMeter.qml b/qml/CircleMeter.qml new file mode 100644 index 0000000..8d26ce0 --- /dev/null +++ b/qml/CircleMeter.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 + +/** + * Meter in half circle + */ + +Item { + /// current level + property double level: 0 + /// minimum level + property double min: -1 + /// maximum level + property double max: 1 + /// theme object + property QtObject theme + + Canvas { + id: canvas + anchors.fill: parent + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.strokeStyle = theme.primaryColor + ctx.lineWidth = 1 + ctx.beginPath() + ctx.moveTo(0,height - 1) + ctx.bezierCurveTo(0, 0, width * 0.5 * (1 - Math.cos(Math.PI/4)), height * Math.sin(Math.PI/4), width / 2, 0) + //ctx.closePath() + ctx.stroke() + console.log("canvas done") + } + } +} diff --git a/qml/Scene.qml b/qml/Scene.qml new file mode 100644 index 0000000..b591a54 --- /dev/null +++ b/qml/Scene.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +/** + * display tuner screen with qmlscene + * to work on qml files + */ + +Item { + width: 600 + height: 400 + + Item { + id: theme + property color primaryColor: "#000000" + property color secondaryColor: "#444444" + property int paddingSmall: 4 + property int paddingLarge: 20 + property int fontSizeSmall: 10 + property int fontSizeMedium: 16 + property int fontSizeLarge: 25 + } + + Item { + id: tuner + property int note: 2 + property int octave: 4 + property double freq: 440 + property double deviation: 0.1 + } + + TunerScreen { + tuner: tuner + theme: theme + } +} diff --git a/qml/TunerScreen.qml b/qml/TunerScreen.qml new file mode 100644 index 0000000..c4a3645 --- /dev/null +++ b/qml/TunerScreen.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +/** + * Main tuner screen + * + */ + +Item { + /// tuner object + property QtObject tuner + /// theme corresponding to Silica Theme object + property QtObject theme + + anchors.fill: parent + + CircleMeter { + theme: parent.theme + anchors.fill: parent + } +}