marcin 2014-07-15 13:59:51 +02:00
parent 95cec0e2fd
commit c65a878d8c
3 changed files with 78 additions and 43 deletions

View File

@ -36,7 +36,7 @@ Item {
color: { color: {
if(item.fillLevel < 3) return "#FF6C3C" if(item.fillLevel < 3) return "#FF6C3C"
if(item.fillLevel < repeater.count - 1) return "#FFE00A" if(item.fillLevel < 13) return "#FFE00A"
return "#36B25C" return "#36B25C"
} }
@ -59,8 +59,8 @@ Item {
function positionBar() { function positionBar() {
var xDiff = 999999 var xDiff = 999999
var index = -1 var index = -1
for(var i = 0; i < repeater.count; ++i) { for(var i = 0; i < 14; ++i) {
var tmp = Math.abs(repeater.modelItems[i].x + row.x - mouseX) var tmp = Math.abs(row.positions[i].currentX + row.x - mouseX)
if(tmp < xDiff) { if(tmp < xDiff) {
xDiff = tmp xDiff = tmp
index = i index = i
@ -68,7 +68,7 @@ Item {
} }
if(index !== -1) { if(index !== -1) {
fillRect.width = Qt.binding(function(){ return repeater.modelItems[index].x + row.x; }) fillRect.width = Qt.binding(function(){ return row.positions[index].currentX + row.x })
item.fillLevel = index item.fillLevel = index
} }
} }
@ -84,51 +84,42 @@ Item {
anchors.rightMargin: 8 anchors.rightMargin: 8
anchors.top: bar.bottom anchors.top: bar.bottom
anchors.topMargin: -1 anchors.topMargin: -1
spacing: ((bar.width - 8) / 2) / 10 property var positions: new Array()
Repeater { Row {
id: repeater id: row2
model: 14 spacing: ((bar.width - 8) / 2) / 4
property var modelItems: new Array()
delegate: Item { Repeater {
id: delegate model: 4
width: 1
height: 48
property bool mainTick: index === 0 || index === 3 || index === repeater.count - 1
Component.onCompleted: repeater.modelItems[index] = delegate
Image { delegate: TickDelegate {
anchors.horizontalCenter: parent.horizontalCenter id: delegateItem2
anchors.top: parent.top currentX: x + row2.x
visible: parent.mainTick currentIndex: index
source: "../images/privacyTick.png" mainTick: currentIndex === 0 || currentIndex === 3 || currentIndex === 13
Component.onCompleted: {
Text { row.positions[currentIndex] = delegateItem2
anchors.right: parent.right
anchors.rightMargin: 12
anchors.bottom: parent.bottom
anchors.bottomMargin: 2
font.family: "Arial"
font.bold: true
font.pixelSize: 12
color: "#4A4949"
text: {
if(index === 0) return qsTr("LOW")
if(index === 3) return qsTr("MEDIUM")
if(index === repeater.count - 1) return qsTr("HIGH")
return ""
}
} }
} }
}
}
Rectangle { Row {
anchors.top: parent.top id: row1
anchors.topMargin: 14 spacing: ((bar.width - 8) / 2) / 10
width: 1
color: "#DBDBDB" Repeater {
height: index === 8 ? 16 : 8 model: 10
visible: !parent.mainTick
delegate: TickDelegate {
id: delegateItem1
currentX: x + row1.x
currentIndex: index + 4
mainTick: currentIndex === 0 || currentIndex === 3 || currentIndex === 13
Component.onCompleted: {
row.positions[currentIndex] = delegateItem1
}
} }
} }
} }

View File

@ -0,0 +1,43 @@
import QtQuick 2.0
Item {
id: delegateItem
width: 1
height: 48
property bool mainTick: false
property int currentIndex
property int currentX
Image {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
visible: parent.mainTick
source: "../images/privacyTick.png"
Text {
anchors.right: parent.right
anchors.rightMargin: 12
anchors.bottom: parent.bottom
anchors.bottomMargin: 2
font.family: "Arial"
font.bold: true
font.pixelSize: 12
color: "#4A4949"
text: {
if(currentIndex === 0) return qsTr("LOW")
if(currentIndex === 3) return qsTr("MEDIUM")
if(currentIndex === 13) return qsTr("HIGH")
return ""
}
}
}
Rectangle {
anchors.top: parent.top
anchors.topMargin: 14
width: 1
color: "#DBDBDB"
height: currentIndex === 8 ? 16 : 8
visible: !parent.mainTick
}
}

View File

@ -70,5 +70,6 @@
<file>images/nextMonth.png</file> <file>images/nextMonth.png</file>
<file>images/prevMonth.png</file> <file>images/prevMonth.png</file>
<file>components/TitleBar.qml</file> <file>components/TitleBar.qml</file>
<file>components/TickDelegate.qml</file>
</qresource> </qresource>
</RCC> </RCC>