Unity 8
DecoratedWindow.qml
1 /*
2  * Copyright (C) 2014-2015 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17  */
18 
19 import QtQuick 2.4
20 import Ubuntu.Components 1.3
21 import Unity.Application 0.1
22 
23 FocusScope {
24  id: root
25 
26  property alias window: applicationWindow
27  property alias application: applicationWindow.application
28  property alias active: decoration.active
29 
30  property bool decorationShown: true
31  property bool highlightShown: false
32  property real shadowOpacity: 1
33 
34  signal close()
35  signal maximize()
36  signal minimize()
37  signal decorationPressed()
38 
39  BorderImage {
40  anchors {
41  fill: root
42  margins: -units.gu(2)
43  }
44  source: "graphics/dropshadow2gu.sci"
45  opacity: root.shadowOpacity * .3
46  }
47 
48  Rectangle {
49  id: selectionHighlight
50  anchors.fill: parent
51  anchors.margins: -units.gu(1)
52  color: "white"
53  opacity: highlightShown ? 0.15 : 0
54  }
55 
56  Rectangle {
57  anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
58  height: units.dp(2)
59  color: UbuntuColors.orange
60  visible: root.highlightShown
61  }
62 
63  WindowDecoration {
64  id: decoration
65  target: root.parent
66  objectName: application ? "appWindowDecoration_" + application.appId : "appWindowDecoration_null"
67  anchors { left: parent.left; top: parent.top; right: parent.right }
68  height: units.gu(3)
69  title: window.title !== "" ? window.title : model.name
70  onClose: root.close();
71  onMaximize: root.maximize();
72  onMinimize: root.minimize();
73  onPressed: root.decorationPressed();
74  visible: decorationShown
75  }
76 
77  ApplicationWindow {
78  id: applicationWindow
79  objectName: application ? "appWindow_" + application.appId : "appWindow_null"
80  anchors.top: parent.top
81  anchors.topMargin: decoration.height
82  anchors.left: parent.left
83  width: root.width
84  height: root.height - decoration.height
85  interactive: true
86  focus: true
87  }
88 }