From 0ad2e4ec916e6951181dfdbe98b6e061cad50329 2012-08-28 10:17:47 From: Tero Ahola Date: 2012-08-28 10:17:47 Subject: [PATCH] Improved usability of QML pie tester --- diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml index 22b7a15..999c47d 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml @@ -19,17 +19,66 @@ ****************************************************************************/ import QtQuick 1.0 +import QtCommercial.Chart 1.1 Row { anchors.fill: parent spacing: 5 property variant series + property int sliceIndex: 0 + // buttons for selecting the edited object: series, slice or label Flow { - id: flow + id: editorSelectorFlow spacing: 5 flow: Flow.TopToBottom + Button { + id: seriesButton + text: "series" + unpressedColor: "#79bd8f" + onClicked: { + seriesFlow.visible = true; + slicesFlow.visible = false; + labelsFlow.visible = false; + color = "#00a388"; + sliceButton.color = "#79bd8f"; + labelButton.color = "#79bd8f"; + } + } + Button { + id: sliceButton + text: "slice" + unpressedColor: "#79bd8f" + onClicked: { + seriesFlow.visible = false; + slicesFlow.visible = true; + labelsFlow.visible = false; + color = "#00a388"; + seriesButton.color = "#79bd8f"; + labelButton.color = "#79bd8f"; + } + } + Button { + id: labelButton + text: "label" + unpressedColor: "#79bd8f" + onClicked: { + seriesFlow.visible = false; + slicesFlow.visible = false; + labelsFlow.visible = true; + color = "#00a388"; + seriesButton.color = "#79bd8f"; + sliceButton.color = "#79bd8f"; + } + } + } + // Buttons for editing series + Flow { + id: seriesFlow + spacing: 5 + flow: Flow.TopToBottom + visible: false Button { text: "visible" onClicked: series.visible = !series.visible; @@ -74,69 +123,99 @@ Row { text: "series end angle -" onClicked: series.endAngle -= 1.1; } + } + + // Buttons for editing slices + Flow { + id: slicesFlow + spacing: 5 + flow: Flow.TopToBottom + visible: false + + Button { + text: "append slice" + onClicked: series.append("slice" + (series.count + 1), 3.0); + } Button { text: "remove slice" onClicked: series.remove(series.at(series.count - 1)); } Button { text: "slice color" - onClicked: series.at(0).color = main.nextColor(); + onClicked: series.at(sliceIndex).color = main.nextColor(); } Button { text: "slice border color" - onClicked: series.at(0).borderColor = main.nextColor(); + onClicked: series.at(sliceIndex).borderColor = main.nextColor(); } Button { text: "slice border width +" - onClicked: series.at(0).borderWidth++; + onClicked: series.at(sliceIndex).borderWidth++; } Button { text: "slice border width -" - onClicked: series.at(0).borderWidth--; + onClicked: series.at(sliceIndex).borderWidth--; } Button { - text: "slice label visible" - onClicked: series.at(0).labelVisible = !series.at(0).labelVisible; + text: "slice exploded" + onClicked: series.at(sliceIndex).exploded = !series.at(sliceIndex).exploded; } Button { - text: "slice label position inside" - onClicked: series.at(0).labelPosition = PieSlice.LabelInside; + text: "slice explode dist +" + onClicked: series.at(sliceIndex).explodeDistanceFactor += 0.1; } Button { - text: "slice label position outside" - onClicked: series.at(0).labelPosition = PieSlice.LabelOutside; + text: "slice explode dist -" + onClicked: series.at(sliceIndex).explodeDistanceFactor -= 0.1; } + } + + // Buttons for editing labels + Flow { + id: labelsFlow + spacing: 5 + flow: Flow.TopToBottom + visible: false + Button { - text: "slice label arm len +" - onClicked: series.at(0).labelArmLengthFactor += 0.1; + text: "label visible" + onClicked: series.at(sliceIndex).labelVisible = !series.at(sliceIndex).labelVisible; } Button { - text: "slice label arm len -" - onClicked: series.at(0).labelArmLengthFactor -= 0.1; + text: "LabelInsideNormal" + onClicked: series.at(sliceIndex).labelPosition = PieSlice.LabelInsideNormal; } Button { - text: "slice label color" - onClicked: series.at(0).labelColor = main.nextColor(); + text: "LabelInsideHorizontal" + onClicked: series.at(sliceIndex).labelPosition = PieSlice.LabelInsideHorizontal; } Button { - text: "slice exploded" - onClicked: series.at(0).exploded = !series.at(0).exploded; + text: "LabelInsideTangential" + onClicked: series.at(sliceIndex).labelPosition = PieSlice.LabelInsideTangential; } Button { - text: "slice explode dist +" - onClicked: series.at(0).explodeDistanceFactor += 0.1; + text: "LabelOutside" + onClicked: series.at(sliceIndex).labelPosition = PieSlice.LabelOutside; } Button { - text: "slice explode dist -" - onClicked: series.at(0).explodeDistanceFactor -= 0.1; + text: "label arm len +" + onClicked: series.at(sliceIndex).labelArmLengthFactor += 0.1; + } + Button { + text: "label arm len -" + onClicked: series.at(sliceIndex).labelArmLengthFactor -= 0.1; + } + Button { + text: "slice label color" + onClicked: series.at(sliceIndex).labelColor = main.nextColor(); } - } - FontEditor { - id: fontEditor - fontDescription: "label" - function editedFont() { - return series.at(0).labelFont; + FontEditor { + id: fontEditor + fontDescription: "label" + function editedFont() { + return series.at(sliceIndex).labelFont; + } } } }