State of added point will depend on already added points state
This commit is contained in:
parent
eb463ca09f
commit
6ca06ca24d
4 changed files with 178 additions and 47 deletions
|
@ -7,6 +7,7 @@ Rectangle{
|
||||||
property string actionTypeColor: "blue" //TODO default value
|
property string actionTypeColor: "blue" //TODO default value
|
||||||
property int actionType: 1 //TODO default value
|
property int actionType: 1 //TODO default value
|
||||||
property double actionTypeOpacity: 1
|
property double actionTypeOpacity: 1
|
||||||
|
property string actionTypeImage: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices.png"
|
||||||
property string isPoint: "true"
|
property string isPoint: "true"
|
||||||
property variant isLoaded
|
property variant isLoaded
|
||||||
property int xvalue
|
property int xvalue
|
||||||
|
@ -80,7 +81,7 @@ Rectangle{
|
||||||
//opacity: 1
|
//opacity: 1
|
||||||
id: actionImage
|
id: actionImage
|
||||||
width: 20; height: 20
|
width: 20; height: 20
|
||||||
source: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices.png"
|
source: pointRect.actionTypeImage
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
|
@ -140,29 +141,29 @@ Rectangle{
|
||||||
State {
|
State {
|
||||||
name: "on"
|
name: "on"
|
||||||
PropertyChanges { target: pointRect; actionTypeColor: "blue"; actionTypeOpacity: 1 } //TODO: images!!
|
PropertyChanges { target: pointRect; actionTypeColor: "blue"; actionTypeOpacity: 1 } //TODO: images!!
|
||||||
PropertyChanges { target: actionImage; source: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices.png" }
|
PropertyChanges { target: pointRect; actionTypeImage: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices.png" }
|
||||||
},
|
},
|
||||||
State{
|
State{
|
||||||
name: "off"
|
name: "off"
|
||||||
PropertyChanges { target: pointRect; actionTypeColor: "gainsboro"; actionTypeOpacity: 0 }
|
PropertyChanges { target: pointRect; actionTypeColor: "gainsboro"; actionTypeOpacity: 0 }
|
||||||
PropertyChanges { target: actionImage; source: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices-bw.png" }
|
PropertyChanges { target: pointRect; actionTypeImage: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices-bw.png" }
|
||||||
|
//PropertyChanges { target: actionImage; source: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices-bw.png" }
|
||||||
},
|
},
|
||||||
State{
|
State{
|
||||||
name: "dim"
|
name: "dim"
|
||||||
PropertyChanges { target: pointRect; actionTypeColor: "green"; actionTypeOpacity: 1 }
|
PropertyChanges { target: pointRect; actionTypeColor: "green"; actionTypeOpacity: 1 }
|
||||||
PropertyChanges { target: actionImage; source: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/TelldusCenter_128.png" }
|
PropertyChanges { target: pointRect; actionTypeImage: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/TelldusCenter_128.png" }
|
||||||
//something opacity = dim for example
|
//something opacity = dim for example
|
||||||
},
|
},
|
||||||
State{
|
State{
|
||||||
name: "bell"
|
name: "bell"
|
||||||
PropertyChanges { target: pointRect; actionTypeColor: getLastPointColor() }
|
PropertyChanges { target: pointRect; actionTypeColor: getLastPointColor() }
|
||||||
PropertyChanges { target: actionImage; source: "icon.png" }
|
PropertyChanges { target: pointRect; actionTypeImage: "icon.png" }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
function toggleType(){ //TODO other kind of selection method
|
function toggleType(){ //TODO other kind of selection method
|
||||||
var index = 0;
|
var index = 0;
|
||||||
|
|
||||||
var activeStates = Scripts.getActiveStates();
|
var activeStates = Scripts.getActiveStates();
|
||||||
if(activeStates == undefined || activeStates.length == 0){
|
if(activeStates == undefined || activeStates.length == 0){
|
||||||
return;
|
return;
|
||||||
|
@ -197,6 +198,11 @@ Rectangle{
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setType(name){
|
||||||
|
print("setting state to " + name);
|
||||||
|
pointRect.state = name;
|
||||||
|
}
|
||||||
|
|
||||||
function toggleTrigger(){ //TODO other kind of selection method
|
function toggleTrigger(){ //TODO other kind of selection method
|
||||||
if(trigger.state == "sunrise"){
|
if(trigger.state == "sunrise"){
|
||||||
trigger.state = "sunset";
|
trigger.state = "sunset";
|
||||||
|
@ -252,4 +258,44 @@ Rectangle{
|
||||||
function addState(state){
|
function addState(state){
|
||||||
Scripts.addState(state);
|
Scripts.addState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setFirstState(firstState){
|
||||||
|
|
||||||
|
var activeStates = Scripts.getActiveStates();
|
||||||
|
|
||||||
|
if(activeStates == null || activeStates.length == 0){
|
||||||
|
//nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//state may already be set:
|
||||||
|
if(firstState != undefined && firstState != ""){
|
||||||
|
pointRect.state = firstState;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check that device has the "off" state:
|
||||||
|
var exists = false;
|
||||||
|
for(var i=1;i<activeStates.length;i++){
|
||||||
|
if(activeStates[i] == "off"){
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!exists){
|
||||||
|
//no "off", just set state to the first added state
|
||||||
|
pointRect.state = activeStates[0];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var previousState = Scripts.getPreviousState(pointRect, pointRect.parent.children);
|
||||||
|
if(previousState == "" || previousState == "off"){
|
||||||
|
//nothing on/dimmed at the moment, use first added state
|
||||||
|
pointRect.state = activeStates[0];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointRect.state = "off"; //previous point should be "on" or "dim"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,16 @@
|
||||||
property ActionPoint actionPoint
|
property ActionPoint actionPoint
|
||||||
|
|
||||||
function show(actionPoint) {
|
function show(actionPoint) {
|
||||||
dialogText.text = "Nice dialog with possibility to set type of action, exact time, fuzziness, offset etc"
|
|
||||||
container.opacity = 1;
|
container.opacity = 1;
|
||||||
container.border.color = "black"
|
container.border.color = "black"
|
||||||
container.border.width = 2
|
container.border.width = 2
|
||||||
container.actionPoint = actionPoint
|
container.actionPoint = actionPoint
|
||||||
|
|
||||||
|
var rootCoordinates = actionPoint.mapToItem(null, actionPoint.x, actionPoint.y);
|
||||||
|
//container.x = rootCoordinates.x + actionPoint.parent.width/2 - container.width/2;
|
||||||
|
container.y = rootCoordinates.y + actionPoint.height + 10;
|
||||||
|
container.width = actionPoint.parent.width;
|
||||||
|
container.x = (actionPoint.parent.parent.width - container.width)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
|
@ -19,22 +24,18 @@
|
||||||
|
|
||||||
smooth: true
|
smooth: true
|
||||||
radius: 5
|
radius: 5
|
||||||
width: dialogText.width + 120
|
//width: 500 //TODO
|
||||||
height: dialogText.height + 220
|
height: 500 // typelist.height * 2 + 50
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
||||||
Text {
|
|
||||||
id: dialogText
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: circleType //TODO only types this device has...
|
id: circleType //TODO only types this device has...
|
||||||
height: 20
|
height: 20
|
||||||
width: 100
|
width: 100
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.verticalCenterOffset: 0
|
anchors.verticalCenterOffset: 0
|
||||||
|
anchors.left: typeList.right
|
||||||
|
anchors.leftMargin: 50
|
||||||
|
|
||||||
property color buttonColor: "lightgrey"
|
property color buttonColor: "lightgrey"
|
||||||
|
|
||||||
|
@ -126,9 +127,83 @@
|
||||||
color: buttonMouseAreaClose.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
|
color: buttonMouseAreaClose.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
|
||||||
}
|
}
|
||||||
|
|
||||||
Row{
|
ListView{
|
||||||
|
id: typeList
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 20
|
||||||
|
anchors.left: currentType.right
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
width: 100 //TODO relative
|
||||||
|
height: 100 //TODO relative
|
||||||
|
//anchors.fill: parent
|
||||||
|
model: typeSelection
|
||||||
|
delegate: typeSelectionRow
|
||||||
|
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
|
||||||
|
|
||||||
|
//TODO can these paths be turned into some kind of constants? Import from common file or something?
|
||||||
|
ListModel{
|
||||||
|
id: typeSelection
|
||||||
|
ListElement{
|
||||||
|
name: "on"
|
||||||
|
imagesource: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices.png"
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
name: "off"
|
||||||
|
imagesource: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices-bw.png"
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
name: "dim"
|
||||||
|
imagesource: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/TelldusCenter_128.png"
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
name: "bell"
|
||||||
|
imagesource: "icon.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: currentType
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 20
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
border.color: "grey"
|
||||||
|
border.width: 1
|
||||||
|
width: 120
|
||||||
|
height: 120
|
||||||
Image{
|
Image{
|
||||||
|
anchors.fill: parent
|
||||||
|
source: actionPoint.actionTypeImage //TODO, set only when defined...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component{
|
||||||
|
id: typeSelectionRow
|
||||||
|
Row{
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
border.color: "grey"
|
||||||
|
border.width: 2
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
width: 30; height: 30
|
||||||
|
Image{
|
||||||
|
anchors.fill: parent
|
||||||
|
//anchors.left: typeSelectionText.right
|
||||||
|
//anchors.leftMargin: 10
|
||||||
|
//anchors.centerIn: parent
|
||||||
|
source: imagesource
|
||||||
|
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
//pointRect.focus = true
|
||||||
|
container.actionPoint.setType(name)
|
||||||
|
//typeList.highlight = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ import "schedulerscripts.js" as Scripts
|
||||||
id: main
|
id: main
|
||||||
width: 800 //TODO how?
|
width: 800 //TODO how?
|
||||||
height: 600 //TODO how?
|
height: 600 //TODO how?
|
||||||
property variant sunData;
|
property variant sunData
|
||||||
|
property string dimImageSource: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/TelldusCenter_128.png" //TODO use this somehow?
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id: listRow
|
id: listRow
|
||||||
|
@ -17,15 +18,17 @@ import "schedulerscripts.js" as Scripts
|
||||||
width: parent.width; //TODO relative
|
width: parent.width; //TODO relative
|
||||||
height: 50
|
height: 50
|
||||||
//color: "red"
|
//color: "red"
|
||||||
Rectangle { border.color: "red"; width: 100; height:parent.height;
|
Rectangle {
|
||||||
|
border.color: "red"; width: 100; height:parent.height;
|
||||||
Text{
|
Text{
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
//text: "Device " + (index + 1) + "Name: " + name
|
//text: "Device " + (index + 1) + "Name: " + name
|
||||||
|
|
||||||
text: modelData.name + height
|
text: modelData.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle { id: "deviceRow"; border.color: "blue"; width: parent.width-100; height:parent.height;
|
Rectangle { id: "deviceRow"; border.color: "blue"; width: parent.width-100; height:parent.height;
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
@ -37,28 +40,24 @@ import "schedulerscripts.js" as Scripts
|
||||||
//onEntered: parent.border.color = onHoverColor
|
//onEntered: parent.border.color = onHoverColor
|
||||||
//onExited: parent.border.color = borderColor
|
//onExited: parent.border.color = borderColor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
//ny point här
|
|
||||||
|
|
||||||
var component = Qt.createComponent("ActionPoint.qml")
|
var component = Qt.createComponent("ActionPoint.qml")
|
||||||
var dynamicPoint = component.createObject(deviceRow)
|
var dynamicPoint = component.createObject(deviceRow)
|
||||||
//dynamicPoint.x = mouseX (blir inte kvar)
|
|
||||||
//dynamicPoint.
|
|
||||||
dynamicPoint.x = mouseX - dynamicPoint.width/2 //xposition
|
dynamicPoint.x = mouseX - dynamicPoint.width/2 //xposition
|
||||||
//dynamicPoint.width = mouseX-
|
|
||||||
dynamicPoint.border.color = "blue"
|
dynamicPoint.border.color = "blue"
|
||||||
|
|
||||||
|
//TODO different states depending on the device
|
||||||
dynamicPoint.addState("on");
|
dynamicPoint.addState("on");
|
||||||
dynamicPoint.addState("off");
|
dynamicPoint.addState("off");
|
||||||
dynamicPoint.addState("dim");
|
dynamicPoint.addState("dim");
|
||||||
dynamicPoint.addState("bell");
|
dynamicPoint.addState("bell");
|
||||||
|
//dynamicPoint.setFirstState("dim"); //when type is a stored value
|
||||||
|
dynamicPoint.setFirstState();
|
||||||
|
|
||||||
var dynamicBar = actionBar.createObject(deviceRow)
|
var dynamicBar = actionBar.createObject(deviceRow)
|
||||||
dynamicBar.hangOnToPoint = dynamicPoint
|
dynamicBar.hangOnToPoint = dynamicPoint
|
||||||
|
|
||||||
dialog.show(dynamicPoint)
|
dialog.show(dynamicPoint)
|
||||||
//dynamicBar.width = Scripts.getBarWidth(dynamicPoint, deviceRow.children)
|
|
||||||
//dynamicBar.color = "blue" //TODO dependent of point type
|
|
||||||
//dynamicBar.anchors.left = dynamicPoint.right
|
|
||||||
//dynamicBar.width = 100 //TODO dependent of this and next point position
|
|
||||||
|
|
||||||
//deviceRow.add(point)
|
//deviceRow.add(point)
|
||||||
//TODO destroy? (only to remove them if needed)
|
//TODO destroy? (only to remove them if needed)
|
||||||
|
@ -214,7 +213,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: dialog
|
id: dialog
|
||||||
anchors.centerIn: parent
|
//anchors.centerIn: parent
|
||||||
z: 150
|
z: 150
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,11 +286,4 @@ import "schedulerscripts.js" as Scripts
|
||||||
//kan man liksom göra hela linjen (från en vecka tillbaka) men inte visa den? Om det är vettigt... Då hade man tom kunnat zooma en vacker dag
|
//kan man liksom göra hela linjen (från en vecka tillbaka) men inte visa den? Om det är vettigt... Då hade man tom kunnat zooma en vacker dag
|
||||||
//properties, ställa in dem...
|
//properties, ställa in dem...
|
||||||
//fuzziness
|
//fuzziness
|
||||||
/*
|
|
||||||
* Dialog {
|
|
||||||
id: dialog
|
|
||||||
anchors.centerIn: parent
|
|
||||||
z: 100
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,22 @@ function getBarWidth(currentBar, currentPointRect, pointList){
|
||||||
return nextX - (currentPointRect.x + halfPointWidth);
|
return nextX - (currentPointRect.x + halfPointWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pad(number, length) {
|
function getPreviousState(currentPointRect, pointList){
|
||||||
|
|
||||||
var str = '' + number;
|
var prevPoint = null;
|
||||||
while (str.length < length) {
|
for(var i=0;i<pointList.length;i++){
|
||||||
str = '0' + str;
|
if(pointList[i].isPoint != undefined && pointList[i] != currentPointRect){
|
||||||
|
if(pointList[i].x < currentPointRect.x && (prevPoint == null || pointList[i].x > prevPoint.x) && pointList[i].state != "bell"){ //TODO when more than "bell", make dynamic
|
||||||
|
prevPoint = pointList[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
if(prevPoint == null){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return prevPoint.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMidnightDark(){
|
function isMidnightDark(){
|
||||||
|
@ -49,3 +57,13 @@ function isMidnightDark(){
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pad(number, length) {
|
||||||
|
|
||||||
|
var str = '' + number;
|
||||||
|
while (str.length < length) {
|
||||||
|
str = '0' + str;
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue