Commit c8b4aba2 authored by Arek Stopczynski's avatar Arek Stopczynski

added qml components

parent b519b21e
import Qt 4.7
Rectangle {
width: 180
height: 60
color: "black"
property string desc
x: 0
y: 0
Text {
color: "white"
text: parent.desc
font.pointSize: 20
anchors.centerIn: parent
font.bold: true
}
MouseArea
{
anchors.fill: parent
onClicked:
{
if (parent.desc == "quit")
Qt.quit();
if (parent.desc == "start")
{
page.state = "show";
page.event("STARTED;"+ user.text + ";"+description.text);
}
}
}
}
//import QtQuick 1.1
import QtQuick 1.0
Rectangle {
width: 10
height: width
radius: width/3
property int value: 0
smooth: true
property string name: ""
color: {
if (value < 81)
return "black"
if (value < 221)
return "red"
if (value < 314)
return "orange"
if (value < 407)
return "yellow"
if (value >= 407)
return "green"
return "blue"
}
}
import Qt 4.7
Item
{
x: 100
y: 100
property string desc
property string text : textInput.text
property int fakeWidth: 260
property int fakeHeight: 80
Rectangle
{
id: input
width: parent.fakeWidth
height: parent.fakeHeight
color: "lightGray"
border.color: "black"
Rectangle{
width: 40
height: width
color: parent.color
border.width: 1
border.color: "black"
anchors.left: parent.right
anchors.verticalCenter: parent.verticalCenter
Text
{
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
text: "X"
color: "black"
}
MouseArea
{
anchors.fill: parent
onClicked:
{
textInput.text = ""
}
}
}
TextInput
{
id: textInput
color: "black"
font.bold: true
font.pointSize: 20
cursorVisible: false
smooth: true
anchors.fill: parent
anchors.leftMargin: 10
anchors.topMargin: 30
}
}
Rectangle
{
width: 140
height: 40
color: "gray"
border.color: "black"
Text
{
text: {return String(parent.parent.desc); }
anchors.centerIn: parent
}
anchors.bottom: parent.top
anchors.bottomMargin: -5
anchors.left: parent.left
anchors.leftMargin: 5
}
}
Reusable qml components.
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
//import QtQuick 1.1
import QtQuick 1.0
Rectangle {
id: scalpmap
property int scalling: 2
width: 800 / scalling
height: 480 / scalling
function cqValue(name,value)
{
//console.log(name + " "+value)
for (var i=0; i<children.length; ++i)
{
if (children[i].name == name)
children[i].value = value
//console.log(children[i].name)
}
}
Image {
id: scalpimage
source: "qrc:/scalpmap.png"
anchors.fill: parent
}
Electrode{name: "P7"; x: 291/scalling- 5; y: 316/scalling}
Electrode{name: "FC6"; x: 540/scalling- 5; y: 202/scalling}
Electrode{name: "T7"; x: 240/scalling- 5; y: 246/scalling}
Electrode{name: "P8"; x: 534/scalling- 5; y: 316/scalling}
Electrode{name: "O2"; x: 450/scalling- 5; y: 343/scalling}
Electrode{name: "O1"; x: 373/scalling- 5; y: 343/scalling}
Electrode{name: "FC5"; x: 291/scalling- 5; y: 202/scalling}
Electrode{name: "F3"; x: 348/scalling- 5; y: 171/scalling}
Electrode{name: "F4"; x: 484/scalling- 5; y: 171/scalling}
Electrode{name: "T8"; x: 590/scalling- 5; y: 246/scalling}
Electrode{name: "F7"; x: 269/scalling- 5; y: 154/scalling}
Electrode{name: "F8"; x: 562/scalling- 5; y: 154/scalling}
Electrode{name: "AF4"; x: 464/scalling- 5; y: 137/scalling}
Electrode{name: "AF3"; x: 366/scalling- 5; y: 137/scalling}
}
import Qt 4.7
Rectangle {
// anchors.fill: parent
id: setupScreen
x: 0
y: 0
width: parent.width
height: parent.height
color: "white"
property int counter: 0
property int direction: 1
function cqValue(name,value)
{
scalpmap.cqValue(name,value);
setupScreen.counter = (setupScreen.counter + direction)
if (setupScreen.counter == 100)
direction = -1
if (setupScreen.counter == 0)
direction = 1
}
Rectangle
{
color: parent.color
border.color: "darkGrey"
border.width: 4
anchors.centerIn: parent
width: parent.width - 10
height: parent.height - 10
}
Scalpmap{id:scalpmap; anchors.right: parent.right; anchors.bottom: parent.bottom; anchors.margins: 10}
Text {
x: 20;
y: 20;
color: "black"
text: page.title
font.family: "Helvetica"
font.pointSize: 27
font.bold: true
}
Text {
id: time
text: " "
property int move : 0
Component.onCompleted: set()
function set()
{
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
var timeString="" ;
if (minutes < 10)
{
minutes = "0" + minutes
}
if (hours < 10)
{
hours = "0" + hours
}
if (seconds < 10)
{
seconds = "0" + seconds
}
timeString+=hours + ":" + minutes + ":" + seconds;
time.text = timeString;
time.move = seconds;
}
Timer
{
id: timeTimer
interval: 1000
repeat: true
running: true
onTriggered: {time.set(); }
}
x: 20
y: page.height - 40
color: "grey"
font.family: "Helvetica"
font.pointSize: 27
font.bold: true
Rectangle
{
color: "grey"
anchors.top: parent.bottom
anchors.topMargin: 0
width: parent.width
height: 10
Behavior on width {
NumberAnimation {easing.type: Easing.InOutBounce}
}
Rectangle
{
color: "black"
height: parent.height
width: 10
x: time.move/ 60.0 * parent.width - width
opacity: time.move/ 60.0
Behavior on x
{
NumberAnimation {easing.type: Easing.InOutBounce}
}
}
}
}
MyTextInput {id: user; desc: "user"; x: 20; y: 100}
MyTextInput {id: description; desc: "description"; x: 20; y: 230}
Button {id: quit; desc: "quit"; y: 80; x: page.width-quit.width}
Button {id: start; desc: "start"; y: 330; x: 0}
Rectangle
{
id: displayLitSwitch
color: {if (turnedOn) return "black"; return "white" }
property int turnedOn: 1
border.width: 1
border.color: "black"
anchors.verticalCenter: user.verticalCenter
x: page.width/2
width: 40
height: width
Text
{
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.top
text: "keep display on"
}
MouseArea
{
anchors.fill: parent
onClicked:
{
parent.turnedOn = !parent.turnedOn;
page.sendSignal("displaylit");
}
}
}
Rectangle
{
id: rotationSwitch
color: {if (turnedOn) return "black"; return "white" }
property int turnedOn: 1
border.width: 1
border.color: "black"
anchors.verticalCenter: description.verticalCenter
x: page.width/2
width: 40
height: width
Text
{
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.top
text: "real rotation test"
}
MouseArea
{
anchors.fill: parent
onClicked:
{
parent.turnedOn = !parent.turnedOn;
page.emp = !parent.turnedOn;
}
}
}
Rectangle
{
id: aliveIndicator
width: 15* (setupScreen.counter+1)/100.0
height: start.height
color: "black"
anchors.bottom: start.bottom
anchors.left: start.right
}
Behavior on opacity {
NumberAnimation { duration: 300; easing.type: Easing.InOutBounce }
}
Behavior on x {
NumberAnimation { duration: 200; easing.type: Easing.InOutBounce }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment