AnchorButtons.qml 4.15 KB
Newer Older
1 2 3 4 5 6 7 8
import Qt 4.6
import Bauhaus 1.0


QWidget {
    id: anchorButtons
    fixedHeight: 32

9 10 11
    function isBorderAnchored() {
        return anchorBackend.leftAnchored || anchorBackend.topAnchored || anchorBackend.rightAnchored || anchorBackend.bottomAnchored;
    }
12

13 14 15
    function fill() {
        anchorBackend.fill();
    }
16

17 18
    function breakLayout() {
        anchorBackend.resetLayout()
19 20 21 22 23
    }

    QPushButton {

        checkable: true
24
        fixedWidth: 31
25
		width: fixedWidth
26
        fixedHeight: 28
27
		height: fixedHeight
28 29 30
        styleSheetFile: "anchortop.css";

        checked: anchorBackend.topAnchored;
31
        onReleased: {
32 33 34 35 36 37 38 39 40 41 42 43
            if (checked) {
                anchorBackend.verticalCentered = false;
                anchorBackend.topAnchored = true;
            } else {
                anchorBackend.topAnchored = false;
            }
        }

    }

    QPushButton {

44
        x: 31
45
        checkable: true
46
        fixedWidth: 30
47
		width: fixedWidth
48
        fixedHeight: 28
49
		height: fixedHeight
50 51 52 53

        styleSheetFile: "anchorbottom.css";

        checked: anchorBackend.bottomAnchored;
54
        onReleased: {
55 56 57 58 59 60 61 62 63 64 65
            if (checked) {
                anchorBackend.verticalCentered = false;
                anchorBackend.bottomAnchored = true;
            } else {
                anchorBackend.bottomAnchored = false;
            }
        }

    }
    QPushButton {

66
        x: 61
67
        checkable: true
68
        fixedWidth: 30
69
		width: fixedWidth
70
        fixedHeight: 28
71
		height: fixedHeight
72 73 74 75

        styleSheetFile: "anchorleft.css";

        checked: anchorBackend.leftAnchored;
76
        onReleased: {
77 78 79 80 81 82 83 84 85 86 87
            if (checked) {
                    anchorBackend.horizontalCentered = false;
                    anchorBackend.leftAnchored = true;
                } else {
                    anchorBackend.leftAnchored = false;
                }
        }
    }

    QPushButton {

88
        x: 91
89
        checkable: true
90
        fixedWidth: 30
91
		width: fixedWidth
92
        fixedHeight: 28
93
		height: fixedHeight
94 95 96 97

        styleSheetFile: "anchorright.css";

        checked: anchorBackend.rightAnchored;
98
        onReleased: {
99 100 101 102 103 104 105 106 107 108
            if (checked) {
                    anchorBackend.horizontalCentered = false;
                    anchorBackend.rightAnchored = true;
                } else {
                    anchorBackend.rightAnchored = false;
                }
        }
    }

    QPushButton {
109
        x: 121
110
        checkable: true
111
        fixedWidth: 19
112
		width: fixedWidth
113
        fixedHeight: 28
114
		height: fixedHeight
115 116 117 118 119 120 121

        styleSheetFile: "anchorspacer.css";


    }

    QPushButton {
122 123 124
        x: 140
        fixedWidth: 30
        fixedHeight: 28
125
		height: fixedHeight
126 127 128 129 130 131 132

        styleSheetFile: "anchorfill.css";

        onReleased: fill();
    }

    QPushButton {
133
        x: 170
134
        checkable: true
135
        fixedWidth: 19
136
		width: fixedWidth
137
        fixedHeight: 28
138
		height: fixedHeight
139 140 141 142 143 144

        styleSheetFile: "anchorspacer.css";

    }

    QPushButton {
145
        x: 189
146
        checkable: true
147
        fixedWidth: 30
148
		width: fixedWidth
149
        fixedHeight: 28
150
		height: fixedHeight
151

152
		styleSheetFile: "anchorvertical.css";
153

154
        checked: anchorBackend.verticalCentered;
155
        onReleased: {
156 157 158
            if (checked) {
                    anchorBackend.leftAnchored = false;
                    anchorBackend.rightAnchored = false;
159 160
					anchorBackend.topAnchored = false;
                    anchorBackend.bottomAnchored = false;
161
                    anchorBackend.verticalCentered = true;
162
            } else {
163
                    anchorBackend.verticalCentered = false;
164 165 166 167 168
            }
        }
    }

    QPushButton {
169
        x: 219
170
        checkable: true
171
        fixedWidth: 31
172
		width: fixedWidth
173
        fixedHeight: 28
174
		height: fixedHeight
175 176
        
		styleSheetFile: "anchorhorizontal.css";
177

178
        checked: anchorBackend.horizontalCentered;
179
        onReleased: {
180
            if (checked) {
181 182
                    anchorBackend.leftAnchored = false;
                    anchorBackend.rightAnchored = false;
183
                    anchorBackend.horizontalCentered = true;
184
            } else {
185
                    anchorBackend.horizontalCentered = false;
186 187 188 189 190
            }
        }
    }
}