~dandrader/unity8/multiInstanceApp

« back to all changes in this revision

Viewing changes to qml/Stage/DecoratedWindow.qml

Merge mterry's prereq

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import Ubuntu.Components 1.3
19
19
import Unity.Application 0.1
20
20
import "Spread/MathUtils.js" as MathUtils
 
21
import Unity.ApplicationMenu 0.1
 
22
import Unity.Indicators 0.1 as Indicators
 
23
import "../Components/PanelState"
21
24
 
22
25
FocusScope {
23
26
    id: root
147
150
        opacity: root.shadowOpacity
148
151
    }
149
152
 
150
 
    WindowDecoration {
151
 
        id: decoration
152
 
        closeButtonVisible: root.application.appId !== "unity8-dash"
153
 
        objectName: "appWindowDecoration"
154
 
        anchors { left: parent.left; top: parent.top; right: parent.right }
155
 
        height: units.gu(3)
156
 
        width: root.width
157
 
        title: applicationWindow.title
158
 
        opacity: root.hasDecoration ? Math.min(1, root.showDecoration) : 0
159
 
 
160
 
        Behavior on opacity { UbuntuNumberAnimation { } }
161
 
 
162
 
        onCloseClicked: root.closeClicked();
163
 
        onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
164
 
        onMaximizeHorizontallyClicked: { root.decorationPressed(); root.maximizeHorizontallyClicked(); }
165
 
        onMaximizeVerticallyClicked: { root.decorationPressed(); root.maximizeVerticallyClicked(); }
166
 
        onMinimizeClicked: root.minimizeClicked();
167
 
        onPressed: root.decorationPressed();
168
 
 
169
 
        onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
170
 
        onPositionChanged: moveHandler.handlePositionChanged(mouse)
171
 
        onReleased: {
172
 
            root.decorationReleased();
173
 
            moveHandler.handleReleased();
174
 
        }
175
 
    }
176
 
 
177
 
    MoveHandler {
178
 
        id: moveHandler
179
 
        objectName: "moveHandler"
180
 
        target: root.parent
181
 
        buttonsWidth: decoration.buttonsWidth
182
 
    }
183
 
 
184
153
    ApplicationWindow {
185
154
        id: applicationWindow
186
155
        objectName: "appWindow"
187
 
        anchors.left: parent.left
188
156
        anchors.top: parent.top
189
157
        anchors.topMargin: root.decorationHeight * Math.min(1, root.showDecoration)
 
158
        anchors.left: parent.left
190
159
        width: implicitWidth
191
160
        height: implicitHeight
192
161
        requestedHeight: !counterRotate ? root.requestedHeight - d.requestedDecorationHeight : root.requestedWidth
228
197
    }
229
198
 
230
199
    MouseArea {
 
200
        anchors { left: parent.left; top: parent.top; right: parent.right }
 
201
        height: units.gu(3)
 
202
 
 
203
        opacity: root.hasDecoration ? Math.min(1, root.showDecoration) : 0
 
204
 
 
205
        Behavior on opacity { UbuntuNumberAnimation { } }
 
206
 
 
207
        drag.target: Item {}
 
208
        drag.filterChildren: true
 
209
        drag.threshold: 0
 
210
 
 
211
        onPressed: root.decorationPressed();
 
212
        onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
 
213
        onPositionChanged: moveHandler.handlePositionChanged(mouse)
 
214
        onReleased: {
 
215
            root.decorationReleased();
 
216
            moveHandler.handleReleased();
 
217
        }
 
218
 
 
219
        WindowDecoration {
 
220
            id: decoration
 
221
            closeButtonVisible: root.application.appId !== "unity8-dash"
 
222
            objectName: "appWindowDecoration"
 
223
            anchors.fill: parent
 
224
            title: applicationWindow.title
 
225
 
 
226
            onCloseClicked: root.closeClicked();
 
227
            onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
 
228
            onMaximizeHorizontallyClicked: { root.decorationPressed(); root.maximizeHorizontallyClicked(); }
 
229
            onMaximizeVerticallyClicked: { root.decorationPressed(); root.maximizeVerticallyClicked(); }
 
230
            onMinimizeClicked: root.minimizeClicked();
 
231
 
 
232
            enableMenus: {
 
233
                return active &&
 
234
                         surface &&
 
235
                          (PanelState.focusedPersistentSurfaceId === surface.persistentId && !PanelState.decorationsVisible)
 
236
            }
 
237
            menu: sharedAppModel.model
 
238
 
 
239
            Indicators.SharedUnityMenuModel {
 
240
                id: sharedAppModel
 
241
                property var menus: surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : []
 
242
                property var menuService: menus.length > 0 ? menus[0] : undefined
 
243
 
 
244
                busName: menuService ? menuService.service : ""
 
245
                menuObjectPath: menuService && menuService.menuPath ? menuService.menuPath : ""
 
246
                actions: menuService && menuService.actionPath ? { "unity": menuService.actionPath } : {}
 
247
            }
 
248
 
 
249
            Connections {
 
250
                target: ApplicationMenuRegistry
 
251
                onSurfaceMenuRegistered: {
 
252
                    if (surface && surfaceId === surface.persistentId) {
 
253
                        sharedAppModel.menus = Qt.binding(function() { return surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : [] });
 
254
                    }
 
255
                }
 
256
                onSurfaceMenuUnregistered: {
 
257
                    if (surface && surfaceId === surface.persistentId) {
 
258
                        sharedAppModel.menus = Qt.binding(function() { return surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : [] });
 
259
                    }
 
260
                }
 
261
            }
 
262
        }
 
263
    }
 
264
 
 
265
    MouseArea {
231
266
        anchors.fill: applicationWindow
232
267
        acceptedButtons: Qt.LeftButton
233
268
        property bool dragging: false
257
292
        }
258
293
    }
259
294
 
 
295
    MoveHandler {
 
296
        id: moveHandler
 
297
        objectName: "moveHandler"
 
298
        target: root.parent
 
299
        buttonsWidth: decoration.buttonsWidth
 
300
    }
 
301
 
260
302
    Rectangle {
261
303
        anchors.fill: parent
262
304
        color: "black"