Possibility to add offset to sunrise/sunset values
This commit is contained in:
parent
ff1e24d14f
commit
c235310e53
4 changed files with 140 additions and 78 deletions
|
@ -3,17 +3,17 @@ import "schedulerscripts.js" as Scripts
|
|||
|
||||
Rectangle{
|
||||
id: pointRect
|
||||
//property variant xposition
|
||||
property string actionTypeColor: "blue" //TODO default value
|
||||
property int actionType: 1 //TODO default value
|
||||
property double actionTypeOpacity: 1
|
||||
property string actionTypeImage: "/home/stefan/Projects/tellstick/trunk/telldus-gui/TelldusCenter/images/devices.png"
|
||||
property string actionTypeImage: imageActionOn
|
||||
property string isPoint: "true"
|
||||
property variant isLoaded
|
||||
property int xvalue
|
||||
//property variant hangOnToBar
|
||||
property int fuzzyBefore: 100
|
||||
property int fuzzyAfter: 55
|
||||
property int fuzzyBefore: 0
|
||||
property int fuzzyAfter: 0
|
||||
property int offset: -100
|
||||
property alias triggerstate: trigger.state
|
||||
|
||||
Component.onCompleted: {
|
||||
//TODO useless really, still gets Cannot anchor to a null item-warning...
|
||||
|
@ -22,14 +22,6 @@ Rectangle{
|
|||
dynamicBar.hangOnToPoint = pointRect
|
||||
//pointRect.hangOnToBar = dynamicBar
|
||||
}
|
||||
//x: xposition
|
||||
|
||||
/*
|
||||
states: State {
|
||||
name: "myState"; when: xposition != undefined
|
||||
PropertyChanges { target: pointRect; x: myListView.width - xposition }
|
||||
}
|
||||
*/
|
||||
|
||||
//use item instead of rectangle (no border then though) to make it invisible (opacity: 0)
|
||||
width: 30
|
||||
|
@ -103,14 +95,16 @@ Rectangle{
|
|||
PropertyChanges { target: triggerImage; source: imageTriggerSunrise; opacity: 1 }
|
||||
PropertyChanges { target: triggerTime; opacity: 0 }
|
||||
PropertyChanges { target: pointRectMouseArea; drag.target: undefined }
|
||||
PropertyChanges { target: pointRect; x: getSunRiseTime.call(pointRect.parent.width, pointRect.width) }
|
||||
PropertyChanges { target: pointRect; x: getSunRiseTime.call(pointRect.parent.width, pointRect.width) + minutesToTimelineUnits(pointRect.offset) } //TODO se nedan
|
||||
PropertyChanges { target: dialog; offsetPanelOpacity: 1 }
|
||||
},
|
||||
State {
|
||||
name: "sunset"
|
||||
PropertyChanges { target: triggerImage; source: imageTriggerSunset; opacity: 1 }
|
||||
PropertyChanges { target: triggerTime; opacity: 0 }
|
||||
PropertyChanges { target: pointRectMouseArea; drag.target: undefined }
|
||||
PropertyChanges { target: pointRect; x: getSunSetTime.call(pointRect.parent.width, pointRect.width) }
|
||||
PropertyChanges { target: pointRect; x: getSunSetTime.call(pointRect.parent.width, pointRect.width) + minutesToTimelineUnits(pointRect.offset) } //TODO räkna om till tidsunits
|
||||
PropertyChanges { target: dialog; offsetPanelOpacity: 1 }
|
||||
},
|
||||
State {
|
||||
name: "absolute"
|
||||
|
@ -118,6 +112,7 @@ Rectangle{
|
|||
PropertyChanges { target: triggerTime; opacity: 1 }
|
||||
PropertyChanges { target: pointRectMouseArea; drag.target: parent }
|
||||
PropertyChanges { target: pointRect; x: xvalue }
|
||||
PropertyChanges { target: dialog; offsetPanelOpacity: 0 }
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -142,7 +137,7 @@ Rectangle{
|
|||
states: [
|
||||
State {
|
||||
name: "on"
|
||||
PropertyChanges { target: pointRect; actionTypeColor: "blue"; actionTypeOpacity: 1 } //TODO: images!!
|
||||
PropertyChanges { target: pointRect; actionTypeColor: "blue"; actionTypeOpacity: 1 }
|
||||
PropertyChanges { target: pointRect; actionTypeImage: imageActionOn }
|
||||
},
|
||||
State{
|
||||
|
@ -163,10 +158,10 @@ Rectangle{
|
|||
]
|
||||
|
||||
Rectangle{
|
||||
width: fuzzyAfter + fuzzyBefore
|
||||
width: minutesToTimelineUnits(fuzzyAfter + fuzzyBefore)
|
||||
height: constBarHeight
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: parent.width/2 - fuzzyBefore
|
||||
x: parent.width/2 - minutesToTimelineUnits(fuzzyBefore)
|
||||
opacity: 0.2
|
||||
z: 140
|
||||
|
||||
|
@ -194,7 +189,7 @@ Rectangle{
|
|||
anchors.left: pointRect.horizontalCenter
|
||||
color: pointRect.actionTypeColor
|
||||
opacity: pointRect.actionTypeOpacity
|
||||
width: Scripts.getNextAndPrevBarWidth(actionBar, pointRect, pointRect.parent.children); //getBarWidth(actionBar, hangOnToPoint, hangOnToPoint.parent.children)
|
||||
width: Scripts.getNextAndPrevBarWidth(actionBar, pointRect, pointRect.parent.children);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,21 +215,6 @@ Rectangle{
|
|||
}
|
||||
|
||||
pointRect.state = activeStates[index];
|
||||
|
||||
/*
|
||||
if(pointRect.state == "on"){
|
||||
pointRect.state = "off"
|
||||
}
|
||||
else if(pointRect.state == "off"){
|
||||
pointRect.state = "dim"
|
||||
}
|
||||
else if(pointRect.state == "dim"){
|
||||
pointRect.state = "bell"
|
||||
}
|
||||
else if(pointRect.state == "bell"){
|
||||
pointRect.state = "on"
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
function setType(name){
|
||||
|
@ -250,7 +230,7 @@ Rectangle{
|
|||
trigger.state = "absolute";
|
||||
}
|
||||
else if(trigger.state == "absolute"){
|
||||
pointRect.xvalue = pointRect.x; //TODO right place to set it?
|
||||
pointRect.xvalue = pointRect.x;
|
||||
trigger.state = "sunrise";
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +247,6 @@ Rectangle{
|
|||
}
|
||||
}
|
||||
|
||||
var test = ""
|
||||
//TODO Binding loop here when moving transperent point over other point
|
||||
//...or just changing state to transparent
|
||||
//something with point depending on point depending on point?
|
||||
|
@ -292,8 +271,6 @@ Rectangle{
|
|||
partOfHour = Math.floor(partOfHour);
|
||||
partOfHour = Scripts.pad(partOfHour, 2);
|
||||
hours = Scripts.pad(hours, 2);
|
||||
//print("Hours: " + hours);
|
||||
//print("Minutes? " + partOfHour);
|
||||
return hours + ":" + partOfHour;
|
||||
}
|
||||
|
||||
|
@ -350,6 +327,12 @@ Rectangle{
|
|||
var pointList = pointRect.parent.children;
|
||||
pointRect.destroy();
|
||||
dialog.hide();
|
||||
//Scripts.recalculateWidth(x, pointList);
|
||||
}
|
||||
|
||||
function minutesToTimelineUnits(minutes){
|
||||
if(pointRect.parent == null){
|
||||
return 0;
|
||||
}
|
||||
return pointRect.parent.width/24 * (minutes/60);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
Rectangle {
|
||||
id: container
|
||||
property ActionPoint actionPoint
|
||||
property alias offsetPanelOpacity: offsetPanel.opacity
|
||||
|
||||
focus: true
|
||||
Keys.onPressed: {
|
||||
|
@ -31,21 +32,13 @@
|
|||
container.actionPoint = dynamicPoint
|
||||
}
|
||||
|
||||
/*
|
||||
states: State{
|
||||
name: "visible"; when: actionPoint.fuzzyAfter != undefined
|
||||
PropertyChanges{
|
||||
target: container; fuzzyAfter: actionPoint.fuzzyAfter
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
function show(actionPoint) {
|
||||
container.opacity = 0;
|
||||
container.opacity = 0; //needed for fuzz/offset unbinding
|
||||
container.border.color = "black"
|
||||
container.border.width = 2
|
||||
inputFuzzyBeforeText.text = actionPoint.fuzzyBefore
|
||||
inputFuzzyAfterText.text = actionPoint.fuzzyAfter
|
||||
inputOffsetText.text = actionPoint.offset
|
||||
container.actionPoint = actionPoint
|
||||
|
||||
var rootCoordinates = actionPoint.mapToItem(null, actionPoint.x, actionPoint.y);
|
||||
|
@ -250,7 +243,6 @@
|
|||
validator: IntValidator{bottom: 0; top: 10080;} //0 to a week...
|
||||
selectByMouse: true
|
||||
color: "#151515"; selectionColor: "mediumseagreen"
|
||||
//text: actionPoint.fuzzyAfter
|
||||
}
|
||||
|
||||
Binding {
|
||||
|
@ -326,6 +318,85 @@
|
|||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id: offsetPanel
|
||||
height: 50
|
||||
width: 80
|
||||
|
||||
opacity: 0
|
||||
|
||||
anchors.left: removePoint.right
|
||||
anchors.leftMargin: 10
|
||||
anchors.top: fuzzyPanel.bottom
|
||||
anchors.topMargin: 10
|
||||
|
||||
Text{
|
||||
id: textOffset
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 5
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 5
|
||||
text: "Offset:"
|
||||
}
|
||||
|
||||
Text{
|
||||
id: textOffsetUnit
|
||||
anchors.left: inputOffset.right
|
||||
anchors.leftMargin: 5
|
||||
anchors.verticalCenter: textOffset.verticalCenter
|
||||
text: "minutes"
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id: inputOffset
|
||||
property alias offsetText: inputOffsetText.text
|
||||
anchors.left: textOffset.right
|
||||
anchors.leftMargin: 5
|
||||
anchors.verticalCenter: textOffset.verticalCenter
|
||||
width: 35
|
||||
height: textOffset.height
|
||||
border.width: 1
|
||||
|
||||
TextInput{
|
||||
id: inputOffsetText
|
||||
anchors.fill: parent
|
||||
maximumLength: 4
|
||||
validator: IntValidator{bottom: getMinimumOffset(actionPoint.triggerstate); top: getMaximumOffset(actionPoint.triggerstate);} // +/- 12 hours
|
||||
selectByMouse: true
|
||||
color: "#151515"; selectionColor: "mediumseagreen"
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: actionPoint
|
||||
property: "offset"
|
||||
value: inputOffsetText.text
|
||||
when: container.opacity == 1
|
||||
}
|
||||
}
|
||||
|
||||
Image{
|
||||
anchors.left: textOffsetUnit.right
|
||||
anchors.leftMargin: 5
|
||||
anchors.verticalCenter: textOffsetUnit.verticalCenter
|
||||
|
||||
source: imageInfo
|
||||
width: 15
|
||||
height: 15
|
||||
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: {
|
||||
infobox.opacity = 1
|
||||
infobox.infoboxtext = "Enter a positive or negative value for how many minutes before or after sunset/sunrise this action will be executed."
|
||||
}
|
||||
onExited: {
|
||||
infobox.opacity = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle { //TODO create common button-class (but how to differentiate action?)
|
||||
id: closeButton
|
||||
height: 20
|
||||
|
@ -444,4 +515,39 @@
|
|||
print("KEY: " + event.key + " Från: " + origin);
|
||||
}
|
||||
|
||||
function getMinimumOffset(state){
|
||||
//TODO this will not work if a value is set to the highest limit, then not reentering scheduler until the sunrise/set has changed so much that the device will be hidden anyway... Not common though
|
||||
var minutes = 0;
|
||||
var time;
|
||||
if(state == "sunrise"){
|
||||
time = main.sunData[0].split(':');
|
||||
}
|
||||
else if(state == "sunset"){
|
||||
time = main.sunData[1].split(':');
|
||||
}
|
||||
else{
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
return -1 * (parseInt(time[0], 10) * 60 + parseInt(time[1], 10));
|
||||
}
|
||||
|
||||
function getMaximumOffset(state){
|
||||
print("state: " + state);
|
||||
var minutes = 0;
|
||||
var time;
|
||||
if(state == "sunrise"){
|
||||
time = main.sunData[0].split(':');
|
||||
}
|
||||
else if(state == "sunset"){
|
||||
time = main.sunData[1].split(':');
|
||||
}
|
||||
else{
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
return 24 * 60 - (parseInt(time[0], 10) * 60 + parseInt(time[1], 10));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ com.telldus.schedulersimplegui = function() {
|
|||
}
|
||||
|
||||
function addDevice() {
|
||||
deviceList.push({name:'Stallet'});
|
||||
deviceList.push({name:'Stallet istallet'});
|
||||
}
|
||||
|
||||
function getSun(riseset, rowWidth, pointWidth){
|
||||
|
|
|
@ -19,7 +19,6 @@ function getBarWidth(currentBar, currentPointRect, pointList){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (nextX - currentPointRect.x);
|
||||
}
|
||||
|
||||
|
@ -50,8 +49,6 @@ function isMidnightDark(){
|
|||
var sunset = main.sunData[1].split(':');
|
||||
|
||||
if(sunset[0] < sunrise[0] || (sunset[0] == sunrise[0] && sunset[1] < sunrise[1])){
|
||||
print("Rise: " + sunrise);
|
||||
print("Set: " + sunset);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -68,29 +65,5 @@ function pad(number, length) {
|
|||
}
|
||||
|
||||
function getNextAndPrevBarWidth(currentBar, currentPointRect, pointList){
|
||||
//TODO error whn < 30 (width)
|
||||
//recalculateWidth(currentPointRect.x, pointList);
|
||||
return getBarWidth(currentBar, currentPointRect, pointList);
|
||||
}
|
||||
|
||||
/*
|
||||
function recalculateWidth(currentx, pointList){
|
||||
var prevPoint = null;
|
||||
for(var i=0;i<pointList.length;i++){
|
||||
if(pointList[i].isPoint != undefined && pointList[i].isPoint == "true"){
|
||||
if(pointList[i].x < currentx && (prevPoint == null || pointList[i].x > prevPoint.x)){
|
||||
prevPoint = pointList[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(prevPoint == null || prevPoint.hangOnToBar == undefined){
|
||||
return;
|
||||
}
|
||||
|
||||
var temp = getBarWidth(prevPoint.hangOnToBar, prevPoint, pointList);
|
||||
print(temp);
|
||||
|
||||
//prevPoint.hangOnToBar.width = temp;
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue