~ubuntu-branches/ubuntu/wily/kscreen/wily

« back to all changes in this revision

Viewing changes to kcm/qml/Output.qml

  • Committer: Package Import Robot
  • Author(s): Howard Chan
  • Date: 2013-03-11 21:24:40 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130311212440-85jrf9k7tl8csj0f
Tags: 0.0.71+git20130311-0ubuntu1
* New upstream snapshot. 
* Make build-depends libkscreen (>= 0.0.71+git20130311 so it can build

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    signal clicked(string self);
28
28
    signal primaryTriggered(string self);
29
29
    signal moved(string self);
 
30
    signal enabledToggled(string self);
 
31
    signal mousePressed();
 
32
    signal mouseReleased();
30
33
 
31
34
    property Item outputView;
32
35
    property bool isDragged: monitorMouseArea.drag.active;
33
36
    property bool isDragEnabled: false;
 
37
    property bool hasMoved: false;
34
38
 
35
39
    width: monitorMouseArea.width;
36
40
    height: monitorMouseArea.height;
49
53
    function updateRootProperties() {
50
54
        var transformedX, transformedY, transformedWidth, transformedHeight;
51
55
 
52
 
        if ((output.rotation == Output.Left) || (output.rotation == Output.Right)) {
 
56
        if (output.isHorizontal()) {
 
57
            transformedWidth = monitorMouseArea.width;
 
58
            transformedHeight = monitorMouseArea.height;
 
59
        } else {
53
60
            transformedWidth = monitorMouseArea.height;
54
61
            transformedHeight = monitorMouseArea.width;
55
 
        } else {
56
 
            transformedWidth = monitorMouseArea.width;
57
 
            transformedHeight = monitorMouseArea.height;
58
62
        }
59
63
 
60
64
        transformedX = root.x + (root.width / 2) - (transformedWidth / 2);
80
84
            centerIn: parent;
81
85
        }
82
86
 
83
 
        scale: (output.enabled) ? 1.0 : 0.6;
 
87
        opacity: (output.enabled) ? 1.0 : 0.3;
84
88
        width: root.currentOutputWidth * root.displayScale;
85
89
        height: root.currentOutputHeight * root.displayScale;
86
90
        transformOrigin: Item.Center;
96
100
            }
97
101
        }
98
102
 
 
103
        hoverEnabled: true;
99
104
        preventStealing: true;
100
105
        drag {
101
106
            target: root.isDragEnabled ? root : null;
120
125
        onClicked: root.clicked(root.output.name);
121
126
        onPositionChanged: {
122
127
 
 
128
            if ((mouse.buttons == 0) || !root.output.enabled) {
 
129
                return;
 
130
            }
 
131
 
123
132
            root.moved(root.output.name);
124
133
 
 
134
            if (root.isDragged) {
 
135
                root.hasMoved = true;
 
136
            }
 
137
 
 
138
 
125
139
            if (x < 0) {
126
140
                x = 0;
127
141
            } else if (x > outputView.maxContentWidth - width) {
135
149
 
136
150
        /* When button is pressed, emit clicked() signal
137
151
         * which is cought by QMLOutputView */
138
 
        onPressed: root.clicked(root.output.name);
 
152
        onPressed: {
 
153
            root.clicked(root.output.name);
 
154
            tip.visible = true;
 
155
            root.mousePressed();
 
156
        }
 
157
        onReleased: {
 
158
            tip.visible = false;
 
159
            root.mouseReleased();
 
160
        }
139
161
 
140
162
        onRotationChanged: updateRootProperties();
141
163
 
154
176
            easing.type: "OutCubic";
155
177
        }
156
178
 
157
 
        Behavior on scale {
 
179
        Behavior on opacity {
158
180
            PropertyAnimation {
159
 
                property: "scale";
160
 
                easing.type: "OutElastic";
161
 
                duration: 350;
 
181
                property: "opacity";
 
182
                easing.type: "OutCubic";
 
183
                duration: 250;
162
184
            }
163
185
        }
164
186
 
193
215
            property bool enabled: output.enabled;
194
216
            property bool connected: output.connected;
195
217
            property bool primary: output.primary;
196
 
            property int currentModeId: output.currentMode;
197
218
            property int rotationDirection;
198
219
 
199
220
            radius: 4;
200
221
            color: palette.window;
201
222
            width: parent.width;
202
223
            height: parent.height;
 
224
            smooth: true;
 
225
 
203
226
            border {
204
227
                color: palette.shadow;
205
228
                width: 1;
217
240
                rotationDirection: parent.rotationDirection;
218
241
 
219
242
                onPrimaryTriggered: root.primaryTriggered(root.output.name);
 
243
                onEnabledToggled: root.enabledToggled(root.output.name);
220
244
            }
221
245
 
222
246
            Rectangle {
231
255
 
232
256
                height: 10;
233
257
                color: palette.shadow;
 
258
                smooth: true;
234
259
            }
235
260
        }
236
261
    }