TunerScreen: first work with qmlscene
This commit is contained in:
parent
1ed6b9eed5
commit
a8a1d089d4
3 changed files with 87 additions and 0 deletions
32
qml/CircleMeter.qml
Normal file
32
qml/CircleMeter.qml
Normal file
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
35
qml/Scene.qml
Normal file
35
qml/Scene.qml
Normal file
|
@ -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
|
||||
}
|
||||
}
|
20
qml/TunerScreen.qml
Normal file
20
qml/TunerScreen.qml
Normal file
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue