Added absolute time setting, and changed to positioning based on time values instead of width, a few things left to solve
This commit is contained in:
parent
e2f749a012
commit
472e5be28f
4 changed files with 170 additions and 10 deletions
|
@ -10,10 +10,12 @@ Rectangle{
|
||||||
property string actionTypeImage: imageActionOn
|
property string actionTypeImage: imageActionOn
|
||||||
property string isPoint: "true"
|
property string isPoint: "true"
|
||||||
property variant isLoaded
|
property variant isLoaded
|
||||||
property int xvalue
|
//property int xvalue
|
||||||
property int fuzzyBefore: 0
|
property int fuzzyBefore: 0
|
||||||
property int fuzzyAfter: 0
|
property int fuzzyAfter: 0
|
||||||
property int offset: -100
|
property int offset: -100
|
||||||
|
property int absoluteHour: parseInt(dialog.absoluteHour, 10)
|
||||||
|
property int absoluteMinute: parseInt(dialog.absoluteMinute, 10)
|
||||||
property alias triggerstate: trigger.state
|
property alias triggerstate: trigger.state
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -51,23 +53,49 @@ Rectangle{
|
||||||
id: pointRectMouseArea
|
id: pointRectMouseArea
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
|
||||||
|
onPressed:{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
//pointRect.focus = true
|
//pointRect.focus = true
|
||||||
if (mouse.button == Qt.RightButton){
|
if (mouse.button == Qt.RightButton){
|
||||||
pointRect.toggleType()
|
pointRect.toggleType()
|
||||||
|
dialog.show(pointRect)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
dialog.show(pointRect) //TODO om inte redan i visandes läge....
|
dialog.show(pointRect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//onPositionChange... maybe emit signal to change in row...
|
onPositionChanged: {
|
||||||
|
var rootCoordinates = pointRect.mapToItem(pointRect.parent, mouse.x, mouse.y);
|
||||||
|
var hourMinute = getTimeFromPosition(rootCoordinates.x)
|
||||||
|
pointRect.absoluteHour = hourMinute[0]
|
||||||
|
pointRect.absoluteMinute = hourMinute[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
onReleased: {
|
||||||
|
dialog.show(pointRect)
|
||||||
|
//var rootCoordinates = pointRect.mapToItem(pointRect.parent, mouse.x, mouse.y);
|
||||||
|
//var hourMinute = getTimeFromPosition(rootCoordinates.x)
|
||||||
|
dialog.absoluteHour = Scripts.pad(pointRect.absoluteHour, 2) //Scripts.pad(hourMinute[0], 2)
|
||||||
|
dialog.absoluteMinute = Scripts.pad(pointRect.absoluteMinute, 2) //Scripts.pad(hourMinute[1], 2)
|
||||||
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
drag.target: pointRect
|
drag.target: pointRect
|
||||||
drag.axis: Drag.XAxis
|
drag.axis: Drag.XAxis
|
||||||
drag.minimumX: -15 //TODO make relative
|
drag.minimumX: -15 //TODO make relative
|
||||||
drag.maximumX: 685 //TODO make relative!!
|
drag.maximumX: 685 //TODO make relative!!
|
||||||
|
drag.filterChildren: true //TODO testing this
|
||||||
//TODO make it impossible to overlap (on release)
|
//TODO make it impossible to overlap (on release)
|
||||||
|
|
||||||
|
states: State{
|
||||||
|
id: "hidden"; when: pointRectMouseArea.drag.active
|
||||||
|
PropertyChanges { target: pointRect; opacity: 0.5; }
|
||||||
|
//PropertyChanges { target: triggerTime; opacity: 0; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column{
|
Column{
|
||||||
|
@ -106,16 +134,18 @@ Rectangle{
|
||||||
PropertyChanges { target: pointRect; x: getSunSetTime.call(pointRect.parent.width, pointRect.width) + minutesToTimelineUnits(pointRect.offset) } //TODO räkna om till tidsunits
|
PropertyChanges { target: pointRect; x: getSunSetTime.call(pointRect.parent.width, pointRect.width) + minutesToTimelineUnits(pointRect.offset) } //TODO räkna om till tidsunits
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "absolute"
|
name: "absolute"; when: !pointRectMouseArea.drag.active
|
||||||
PropertyChanges { target: triggerImage; opacity: 0; }
|
PropertyChanges { target: triggerImage; opacity: 0; }
|
||||||
PropertyChanges { target: triggerTime; opacity: 1 }
|
PropertyChanges { target: triggerTime; opacity: 1 }
|
||||||
PropertyChanges { target: pointRectMouseArea; drag.target: parent }
|
PropertyChanges { target: pointRectMouseArea; drag.target: parent }
|
||||||
PropertyChanges { target: pointRect; x: xvalue }
|
//PropertyChanges { target: pointRect; x: xvalue }
|
||||||
|
PropertyChanges { target: pointRect; x: getAbsoluteXValue() }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id: triggerTime
|
id: triggerTime
|
||||||
|
opacity: 1
|
||||||
width: 20; height: 20
|
width: 20; height: 20
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
Text{
|
Text{
|
||||||
|
@ -125,6 +155,7 @@ Rectangle{
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: triggerImage
|
id: triggerImage
|
||||||
|
opacity: 0
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
width: 20; height: 20
|
width: 20; height: 20
|
||||||
source: imageTriggerAbsolute
|
source: imageTriggerAbsolute
|
||||||
|
@ -194,6 +225,14 @@ Rectangle{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAbsoluteXValue(){
|
||||||
|
if(pointRect.parent == null){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
var hourSize = pointRect.parent.width / 24;
|
||||||
|
return pointRect.absoluteHour * hourSize + hourSize * (pointRect.absoluteMinute/60) - pointRect.width/2;
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
@ -225,9 +264,10 @@ Rectangle{
|
||||||
}
|
}
|
||||||
else if(trigger.state == "sunset"){
|
else if(trigger.state == "sunset"){
|
||||||
trigger.state = "absolute";
|
trigger.state = "absolute";
|
||||||
|
pointRect.x = getAbsoluteXValue();
|
||||||
}
|
}
|
||||||
else if(trigger.state == "absolute"){
|
else if(trigger.state == "absolute"){
|
||||||
pointRect.xvalue = pointRect.x;
|
//pointRect.xvalue = pointRect.x;
|
||||||
trigger.state = "sunrise";
|
trigger.state = "sunrise";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,14 +301,24 @@ Rectangle{
|
||||||
if(pointRect.parent == null){
|
if(pointRect.parent == null){
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
var timeOfDay = pointRect.x + (pointRect.width/2);
|
|
||||||
|
var hours = Scripts.pad(pointRect.absoluteHour, 2);
|
||||||
|
var minutes = Scripts.pad(pointRect.absoluteMinute, 2);
|
||||||
|
return hours + ":" + minutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTimeFromPosition(mouseX){
|
||||||
|
if(pointRect.parent == null){
|
||||||
|
return [0,0];
|
||||||
|
}
|
||||||
|
var timeOfDay = mouseX; // + (pointRect.width/2);
|
||||||
var hourSize = pointRect.parent.width / 24;
|
var hourSize = pointRect.parent.width / 24;
|
||||||
var hours = Math.floor(timeOfDay / hourSize);
|
var hours = Math.floor(timeOfDay / hourSize);
|
||||||
var partOfHour = ((timeOfDay - (hourSize * hours))/hourSize) * 60
|
var partOfHour = ((timeOfDay - (hourSize * hours))/hourSize) * 60
|
||||||
partOfHour = Math.floor(partOfHour);
|
partOfHour = Math.floor(partOfHour);
|
||||||
partOfHour = Scripts.pad(partOfHour, 2);
|
partOfHour = Scripts.pad(partOfHour, 2);
|
||||||
hours = Scripts.pad(hours, 2);
|
hours = Scripts.pad(hours, 2);
|
||||||
return hours + ":" + partOfHour;
|
return [hours, partOfHour];
|
||||||
}
|
}
|
||||||
|
|
||||||
function addState(state){
|
function addState(state){
|
||||||
|
|
|
@ -8,7 +8,6 @@ Rectangle {
|
||||||
property color buttonColor: "lightgrey"
|
property color buttonColor: "lightgrey"
|
||||||
property alias text: buttonText.text
|
property alias text: buttonText.text
|
||||||
signal clicked()
|
signal clicked()
|
||||||
//property alias event: buttonMouseArea.onClicked
|
|
||||||
|
|
||||||
Text{
|
Text{
|
||||||
id: buttonText
|
id: buttonText
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import Qt 4.7
|
import Qt 4.7
|
||||||
|
import "schedulerscripts.js" as Scripts
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: container
|
id: container
|
||||||
property ActionPoint actionPoint
|
property ActionPoint actionPoint
|
||||||
|
property alias absoluteHour: inputAbsoluteHourText.text
|
||||||
|
property alias absoluteMinute: inputAbsoluteMinuteText.text
|
||||||
|
|
||||||
focus: true
|
focus: true
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
|
@ -39,6 +42,8 @@
|
||||||
inputFuzzyAfterText.text = actionPoint.fuzzyAfter
|
inputFuzzyAfterText.text = actionPoint.fuzzyAfter
|
||||||
inputOffsetText.text = actionPoint.offset
|
inputOffsetText.text = actionPoint.offset
|
||||||
inputDimText.text = actionPoint.dimvalue
|
inputDimText.text = actionPoint.dimvalue
|
||||||
|
inputAbsoluteHourText.text = Scripts.pad(actionPoint.absoluteHour, 2)
|
||||||
|
inputAbsoluteMinuteText.text = Scripts.pad(actionPoint.absoluteMinute, 2)
|
||||||
container.actionPoint = actionPoint
|
container.actionPoint = actionPoint
|
||||||
|
|
||||||
var rootCoordinates = actionPoint.mapToItem(null, actionPoint.x, actionPoint.y);
|
var rootCoordinates = actionPoint.mapToItem(null, actionPoint.x, actionPoint.y);
|
||||||
|
@ -345,6 +350,108 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: absolutePanel
|
||||||
|
height: 50
|
||||||
|
width: 80
|
||||||
|
|
||||||
|
opacity: actionPoint.triggerstate == "absolute"
|
||||||
|
|
||||||
|
anchors.left: removePoint.right
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.top: fuzzyPanel.bottom
|
||||||
|
anchors.topMargin: 10
|
||||||
|
//property alias absoluteHourText: inputAbsoluteHourText.text
|
||||||
|
//property alias absoluteMinuteText: inputAbsoluteMinuteText.text
|
||||||
|
|
||||||
|
Row{
|
||||||
|
Text{
|
||||||
|
/*id: textAbsolute
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 5
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 5
|
||||||
|
*/
|
||||||
|
text: "Time:"
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: inputAbsoluteHour
|
||||||
|
//property alias absoluteHour: inputAbsoluteHourText.text
|
||||||
|
/*anchors.left: textOffset.right
|
||||||
|
anchors.leftMargin: 5
|
||||||
|
anchors.verticalCenter: textOffset.verticalCenter
|
||||||
|
*/
|
||||||
|
width: 35
|
||||||
|
height: inputAbsoluteHourText.height
|
||||||
|
border.width: 1
|
||||||
|
|
||||||
|
TextInput{
|
||||||
|
id: inputAbsoluteHourText
|
||||||
|
anchors.fill: parent
|
||||||
|
maximumLength: 4
|
||||||
|
validator: IntValidator{bottom: 0; top: 23;}
|
||||||
|
selectByMouse: true
|
||||||
|
color: "#151515"; selectionColor: "mediumseagreen"
|
||||||
|
Keys.onTabPressed: {
|
||||||
|
event.accepted = true;
|
||||||
|
inputAbsoluteMinuteText.focus = true;
|
||||||
|
}
|
||||||
|
text: "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
Binding {
|
||||||
|
target: actionPoint
|
||||||
|
property: "absoluteHour"
|
||||||
|
value: inputAbsoluteHourText.text
|
||||||
|
when: container.opacity == 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text{
|
||||||
|
/*id: textOffsetUnit
|
||||||
|
anchors.left: inputOffset.right
|
||||||
|
anchors.leftMargin: 5
|
||||||
|
anchors.verticalCenter: textOffset.verticalCenter
|
||||||
|
*/
|
||||||
|
text: ":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: inputAbsoluteMinute
|
||||||
|
property alias absoluteMinute: inputAbsoluteMinuteText.text
|
||||||
|
/*anchors.left: textOffset.right
|
||||||
|
anchors.leftMargin: 5
|
||||||
|
anchors.verticalCenter: textOffset.verticalCenter
|
||||||
|
*/
|
||||||
|
width: 35
|
||||||
|
height: inputAbsoluteMinuteText.height
|
||||||
|
border.width: 1
|
||||||
|
|
||||||
|
TextInput{
|
||||||
|
id: inputAbsoluteMinuteText
|
||||||
|
anchors.fill: parent
|
||||||
|
maximumLength: 4
|
||||||
|
validator: IntValidator{bottom: 0; top: 59;}
|
||||||
|
selectByMouse: true
|
||||||
|
color: "#151515"; selectionColor: "mediumseagreen"
|
||||||
|
Keys.onTabPressed: {
|
||||||
|
event.accepted = true;
|
||||||
|
inputAbsoluteHourText.focus = true;
|
||||||
|
}
|
||||||
|
text: "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
Binding {
|
||||||
|
target: actionPoint
|
||||||
|
property: "absoluteMinute"
|
||||||
|
value: inputAbsoluteMinuteText.text
|
||||||
|
when: container.opacity == 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id: dimPanel
|
id: dimPanel
|
||||||
height: 50
|
height: 50
|
||||||
|
|
|
@ -41,7 +41,11 @@ import "schedulerscripts.js" as Scripts
|
||||||
|
|
||||||
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 - dynamicPoint.width/2 //xposition
|
//dynamicPoint.x = mouseX - dynamicPoint.width/2 //xposition
|
||||||
|
var hourMinute = dynamicPoint.getTimeFromPosition(mouse.x)
|
||||||
|
dynamicPoint.absoluteHour = hourMinute[0]
|
||||||
|
dynamicPoint.absoluteMinute = hourMinute[1]
|
||||||
|
dynamicPoint.x = dynamicPoint.getAbsoluteXValue();
|
||||||
dynamicPoint.border.color = "blue"
|
dynamicPoint.border.color = "blue"
|
||||||
|
|
||||||
//TODO different states depending on the device
|
//TODO different states depending on the device
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue