e svg for the ruler

This commit is contained in:
Marco Martin 2013-05-08 19:32:23 +02:00
parent 8c07b27cb2
commit 8e14ed33a4
5 changed files with 468 additions and 92 deletions

View File

@ -38,99 +38,34 @@ Rectangle {
//BEGIN Connections
Connections {
target: panel
onOffsetChanged: offsetHandle.value = panel.offset
onMinimumLengthChanged: minimumLengthHandle.value = panel.minimumLength
onMaximumLengthChanged: maximumLengthHandle.value = panel.maximumLength
onOffsetChanged: ruler.offset = panel.offset
onMinimumLengthChanged: ruler.minimumLength = panel.minimumLength
onMaximumLengthChanged: ruler.maximumLength = panel.maximumLength
}
//END Connections
//BEGIN UI components
// Offset
OffsetButton {
id: offsetHandle
}
//Minimum length
Rectangle {
id: minimumLengthHandle
width: 32
height: 32
property int value
onValueChanged: {
if (panel.location == 5 || panel.location == 6) {
y = panel.minimumLength + panel.offset
} else {
x = panel.minimumLength + panel.offset
Ruler {
id: ruler
state: {
switch (panel.location) {
//TopEdge
case 3:
return "TopEdge"
//LeftEdge
case 5:
return "LeftEdge"
//RightEdge
case 6:
return "RightEdge"
//BottomEdge
case 4:
default:
return "BottomEdge"
}
}
MouseArea {
drag {
target: parent
axis: (panel.location == 5 || panel.location == 6) ? Drag.YAxis : Drag.XAxis
}
anchors.fill: parent
onPositionChanged: {
if (panel.location == 5 || panel.location == 6) {
panel.minimumLength = parent.y - panel.offset
} else {
panel.minimumLength = parent.x - panel.offset
}
}
Component.onCompleted: {
if (panel.location == 5 || panel.location == 6) {
parent.y = panel.minimumLength + panel.offset
} else {
parent.x = panel.minimumLength + panel.offset
}
}
}
PlasmaComponents.Label {
text: "Min"
}
}
//Maximum length
Rectangle {
id: maximumLengthHandle
width: 32
height: 32
property int value
onValueChanged: {
if (panel.location == 5 || panel.location == 6) {
y = panel.maximumLength + panel.offset
} else {
x = panel.maximumLength + panel.offset
}
}
MouseArea {
drag {
target: parent
axis: (panel.location == 5 || panel.location == 6) ? Drag.YAxis : Drag.XAxis
}
anchors.fill: parent
onPositionChanged: {
if (panel.location == 5 || panel.location == 6) {
panel.maximumLength = parent.y - panel.offset
} else {
panel.maximumLength = parent.x - panel.offset
}
}
Component.onCompleted: {
if (panel.location == 5 || panel.location == 6) {
parent.y = panel.maximumLength + panel.offset
} else {
parent.x = panel.maximumLength + panel.offset
}
}
}
PlasmaComponents.Label {
text: "Max"
}
}
Row {

View File

@ -0,0 +1,95 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.configuration 2.0
import org.kde.qtextracomponents 2.0 as QtExtras
PlasmaCore.SvgItem {
id: root
svg: containmentControlsSvg
state: parent.state
width: naturalSize.width
height: naturalSize.height
property int value
onValueChanged: {
if (panel.location == 5 || panel.location == 6) {
y = panel.maximumLength + panel.offset
} else {
x = panel.maximumLength + panel.offset
}
}
MouseArea {
drag {
target: parent
axis: (panel.location == 5 || panel.location == 6) ? Drag.YAxis : Drag.XAxis
}
anchors.fill: parent
onPositionChanged: {
if (panel.location == 5 || panel.location == 6) {
panel.maximumLength = parent.y - panel.offset
} else {
panel.maximumLength = parent.x - panel.offset
}
}
Component.onCompleted: {
if (panel.location == 5 || panel.location == 6) {
parent.y = panel.maximumLength + panel.offset
} else {
parent.x = panel.maximumLength + panel.offset
}
}
}
states: [
State {
name: "TopEdge"
PropertyChanges {
target: root
elementId: "north-maxslider"
}
},
State {
name: "BottomEdge"
PropertyChanges {
target: root
elementId: "south-maxslider"
}
},
State {
name: "LeftEdge"
PropertyChanges {
target: root
elementId: "west-maxslider"
}
},
State {
name: "RightEdge"
PropertyChanges {
target: root
elementId: "east-maxslider"
}
}
]
}

View File

@ -0,0 +1,95 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.configuration 2.0
import org.kde.qtextracomponents 2.0 as QtExtras
PlasmaCore.SvgItem {
id: root
svg: containmentControlsSvg
state: parent.state
width: naturalSize.width
height: naturalSize.height
property int value
onValueChanged: {
if (panel.location == 5 || panel.location == 6) {
y = panel.minimumLength + panel.offset
} else {
x = panel.minimumLength + panel.offset
}
}
MouseArea {
drag {
target: parent
axis: (panel.location == 5 || panel.location == 6) ? Drag.YAxis : Drag.XAxis
}
anchors.fill: parent
onPositionChanged: {
if (panel.location == 5 || panel.location == 6) {
panel.minimumLength = parent.y - panel.offset
} else {
panel.minimumLength = parent.x - panel.offset
}
}
Component.onCompleted: {
if (panel.location == 5 || panel.location == 6) {
parent.y = panel.minimumLength + panel.offset
} else {
parent.x = panel.minimumLength + panel.offset
}
}
}
states: [
State {
name: "TopEdge"
PropertyChanges {
target: root
elementId: "north-minslider"
}
},
State {
name: "BottomEdge"
PropertyChanges {
target: root
elementId: "south-minslider"
}
},
State {
name: "LeftEdge"
PropertyChanges {
target: root
elementId: "west-minslider"
}
},
State {
name: "RightEdge"
PropertyChanges {
target: root
elementId: "east-minslider"
}
}
]
}

View File

@ -24,10 +24,12 @@ import org.kde.plasma.configuration 2.0
import org.kde.qtextracomponents 2.0 as QtExtras
Rectangle {
id: offsetHandle
width: 32
height: 32
PlasmaCore.SvgItem {
id: root
svg: containmentControlsSvg
state: parent.state
width: naturalSize.width
height: naturalSize.height
property int value
onValueChanged: {
@ -59,7 +61,35 @@ Rectangle {
}
}
}
PlasmaComponents.Label {
text: "Offset"
}
states: [
State {
name: "TopEdge"
PropertyChanges {
target: root
elementId: "north-offsetslider"
}
},
State {
name: "BottomEdge"
PropertyChanges {
target: root
elementId: "south-offsetslider"
}
},
State {
name: "LeftEdge"
PropertyChanges {
target: root
elementId: "west-offsetslider"
}
},
State {
name: "RightEdge"
PropertyChanges {
target: root
elementId: "east-offsetslider"
}
}
]
}

View File

@ -0,0 +1,221 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.configuration 2.0
import org.kde.qtextracomponents 2.0 as QtExtras
PlasmaCore.FrameSvgItem {
id: root
imagePath: "widgets/containment-controls"
state: "BottomEdge"
implicitWidth: offsetButton.implicitwidth + minimumLengthHandle.implicitwidth
implicitHeight: 32//offsetButton.implicitheight + minimumLengthHandle.implicitheight
PlasmaCore.Svg {
id: containmentControlsSvg
imagePath: "widgets/containment-controls"
}
OffsetHandle {
id: offsetButton
}
MinimumLengthHandle {
id: minimumLengthHandle
}
MaximumLengthHandle {
id: maximumLengthHandle
}
states: [
State {
name: "TopEdge"
PropertyChanges {
target: root
prefix: "north"
}
AnchorChanges {
target: root
anchors {
top: root.parent.top
bottom: undefined
left: root.parent.left
right: root.parent.right
}
}
AnchorChanges {
target: offsetHandle
anchors {
top: undefined
bottom: root.bottom
left: undefined
right: undefined
}
}
AnchorChanges {
target: minimumLengthHandle
anchors {
top: root.top
bottom: undefined
left: undefined
right: undefined
}
}
AnchorChanges {
target: maximumLengthHandle
anchors {
top: undefined
bottom: root.bottom
left: undefined
right: undefined
}
}
},
State {
name: "BottomEdge"
PropertyChanges {
target: root
prefix: "south"
}
AnchorChanges {
target: root
anchors {
top: undefined
bottom: root.parent.bottom
left: root.parent.left
right: root.parent.right
}
}
AnchorChanges {
target: offsetHandle
anchors {
top: root.top
bottom: undefined
left: undefined
right: undefined
}
}
AnchorChanges {
target: minimumLengthHandle
anchors {
top: undefined
bottom: root.bottom
left: undefined
right: undefined
}
}
AnchorChanges {
target: maximumLengthHandle
anchors {
top: root.top
bottom: undefined
left: undefined
right: undefined
}
}
},
State {
name: "LeftEdge"
PropertyChanges {
target: root
prefix: "west"
}
AnchorChanges {
target: root
anchors {
top: root.parent.top
bottom: root.parent.bottom
left: root.parent.left
right: undefined
}
}
AnchorChanges {
target: offsetHandle
anchors {
top: undefined
bottom: undefined
left: undefined
right: root.right
}
}
AnchorChanges {
target: minimumLengthHandle
anchors {
top: undefined
bottom: undefined
left: root.left
right: undefined
}
}
AnchorChanges {
target: maximumLengthHandle
anchors {
top: undefined
bottom: undefined
left: undefined
right: root.right
}
}
},
State {
name: "RightEdge"
PropertyChanges {
target: root
prefix: "east"
}
AnchorChanges {
target: root
anchors {
top: root.parent.top
bottom: root.parent.bottom
left: undefined
right: root.parent.right
}
}
AnchorChanges {
target: offsetHandle
anchors {
top: undefined
bottom: undefined
left: parent.left
right: undefined
}
}
AnchorChanges {
target: minimumLengthHandle
anchors {
top: undefined
bottom: undefined
left: undefined
right: parent.right
}
}
AnchorChanges {
target: maximumLengthHandle
anchors {
top: undefined
bottom: undefined
left: parent.left
right: undefined
}
}
}
]
}