2 * Copyright (C) 2014-2015 Canonical, Ltd.
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.
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.
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/>.
16 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
20 import Ubuntu.Components 1.1
21 import Unity.Application 0.1
22 import "../Components/PanelState"
30 property alias background: wallpaper.source
32 property var windowStateStorage: WindowStateStorage
37 sourceSize { height: root.height; width: root.width }
38 fillMode: Image.PreserveAspectCrop
42 target: ApplicationManager
44 ApplicationManager.requestFocusApplication(ApplicationManager.get(ApplicationManager.count-1).appId)
48 var appIndex = priv.indexOf(appId);
49 var appDelegate = appRepeater.itemAt(appIndex);
50 if (appDelegate.state === "minimized") {
51 appDelegate.state = "normal"
53 ApplicationManager.focusApplication(appId);
60 readonly property string focusedAppId: ApplicationManager.focusedApplicationId
61 readonly property var focusedAppDelegate: focusedAppId ? appRepeater.itemAt(indexOf(focusedAppId)) : null
63 function indexOf(appId) {
64 for (var i = 0; i < ApplicationManager.count; i++) {
65 if (ApplicationManager.get(i).appId == appId) {
76 ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
78 onMinimize: appRepeater.itemAt(0).state = "minimized"
79 onMaximize: appRepeater.itemAt(0).state = "normal"
84 property: "buttonsVisible"
85 value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.state === "maximized"
90 model: ApplicationManager
94 z: ApplicationManager.count - index
99 readonly property int minWidth: units.gu(10)
100 readonly property int minHeight: units.gu(10)
108 PropertyChanges { target: appDelegate; x: 0; y: 0; width: root.width; height: root.height }
112 PropertyChanges { target: appDelegate; x: -appDelegate.width / 2; scale: units.gu(5) / appDelegate.width; opacity: 0 }
117 PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
121 WindowMoveResizeArea {
122 windowStateStorage: root.windowStateStorage
124 minWidth: appDelegate.minWidth
125 minHeight: appDelegate.minHeight
126 resizeHandleWidth: units.gu(0.5)
127 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
129 onPressed: decoratedWindow.focus = true;
134 objectName: "decoratedWindow_" + appId
136 application: ApplicationManager.get(index)
137 active: ApplicationManager.focusedApplicationId === model.appId
141 ApplicationManager.requestFocusApplication(model.appId);
145 onClose: ApplicationManager.stopApplication(model.appId)
146 onMaximize: appDelegate.state = (appDelegate.state == "maximized" ? "normal" : "maximized")
147 onMinimize: appDelegate.state = "minimized"