RectangleColorGroupBox.qml 5.6 KB
Newer Older
1
import Qt 4.7
2 3 4
import Bauhaus 1.0

GroupBox {
5 6
    id: rectangleColorGroupBox

7
    caption: qsTr("Colors")
8

9 10 11 12 13 14 15

    property bool selectionFlag: selectionChanged

    property bool isSetup;

    property bool hasBorder

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    property variant colorAlpha: colorGroupBox.alpha
    property bool hasGradient: backendValues.gradient.isInModel

    onHasGradientChanged: {
        print("onGradientInModelChanged")
        if (backendValues.gradient.isInModel) {
            print("inmodel")
            colorGroupBox.setGradientButtonChecked = true;
        } else {
            print("else")
            if (colorGroupBox.alpha == 0)
                colorGroupBox.setNoneButtonChecked = true;
            else
                colorGroupBox.setSolidButtonChecked = true;
        }
    }

    onColorAlphaChanged: {
          if (backendValues.gradient.isInModel)
              return
        if (colorGroupBox.alpha == 0)
            colorGroupBox.setNoneButtonChecked = true;
        else
            colorGroupBox.setSolidButtonChecked = true;
    }
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

    onSelectionFlagChanged: {
        isSetup = true;
        gradientLine.active = false;
        colorGroupBox.setSolidButtonChecked = true;
        if (backendValues.gradient.isInModel) {
            colorGroupBox.setGradientButtonChecked = true;
            gradientLine.active = true;
            gradientLine.setupGradient();
        }
        if (colorGroupBox.alpha == 0) {
            colorGroupBox.setNoneButtonChecked = true;
            //borderColorBox.collapseBox = true
        }

        if (backendValues.border_color.isInModel || backendValues.border_width.isInModel) {
            borderColorBox.setSolidButtonChecked = true;
            hasBorder = true;
        } else {
            borderColorBox.setNoneButtonChecked = true;
            hasBorder = false
            //borderColorBox.collapseBox = true
        }

        isSetup = false
    }

    layout: VerticalLayout {

        QWidget {
71
            visible: colorGroupBox.gradientButtonChecked
72 73 74 75
            layout: HorizontalLayout {
                spacing: 2
                Label {
                    text: qsTr("Stops")
76
                    toolTip: qsTr("Gradient stops")
77 78 79 80 81 82 83 84 85
                }

                GradientLine {
                    id: gradientLine;
                    activeColor: colorGroupBox.color
                    itemNode: anchorBackend.itemNode
                }
            }
        }
86 87

        ColorGroupBox {
88
            id: colorGroupBox
89
            caption: qsTr("Rectangle")
90
            finished: finishedNotify
91
            backendColor: backendValues.color
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
            //gradientEditing: true;
            gradientColor: gradientLine.activeColor;
            showButtons: true;
            showGradientButton: true;

            onGradientButtonCheckedChanged: {
                if (isSetup)
                    return;
                if (gradientButtonChecked) {
                    gradientLine.active = true
                    gradientLine.setupGradient();
                    backendValues.color.resetValue();
                } else {
                    gradientLine.active = false
                    if (backendValues.gradient.isInModel)
                        gradientLine.deleteGradient();

                }
            }

            onNoneButtonCheckedChanged: {
                if (isSetup)
                    return;
                if (noneButtonChecked) {
                    backendValues.color.value = "transparent";
                    collapseBox = false
                } else {
                    alpha = 255;
                }
            }

            onSolidButtonCheckedChanged: {
                if (isSetup)
                    return;
                if (solidButtonChecked) {
                    backendValues.color.resetValue();
                }
            }
        }
131 132

        ColorGroupBox {
133
            id: borderColorBox
134
            caption: qsTr("Border")
135
            finished: finishedNotify
136
            showButtons: true;
137 138

            backendColor: backendValues.border_color
139

140
            property bool backendColorValue: backendValues.border_color.isInModel
141 142 143
            enabled: isBaseState || hasBorder

            onBackendColorValueChanged: {
144 145 146 147
                if (backendValues.border_color.isInModel) {
                    borderColorBox.setSolidButtonChecked = true;
                    hasBorder = true;
                } else {
148
                    borderColorBox.setNoneButtonChecked = true;
149 150
                    hasBorder = false;
                }
151
            }
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182

            onNoneButtonCheckedChanged: {
                if (isSetup)
                    return;
                if (noneButtonChecked) {
                    transaction.start();
                    backendValues.border_color.resetValue();
                    backendValues.border_width.resetValue();
                    transaction.end();
                    hasBorder = false
                    collapseBox = false
                } else {
                    transaction.start();
                    backendValues.border_color.value = "blue"
                    backendValues.border_color.value = "#000000";
                    transaction.end();
                    hasBorder = true
                }
            }

            onSolidButtonCheckedChanged: {
                if (isSetup)
                    return;
                if (solidButtonChecked) {
                    transaction.start();
                    backendValues.border_color.value = "blue"
                    backendValues.border_color.value = "#000000";
                    transaction.end();
                    hasBorder = true
                }
            }
183 184
        }

185 186 187
    }

}