2 * Copyright (C) 2014 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"
29 property alias background: wallpaper.source
34 sourceSize { height: root.height; width: root.width }
35 fillMode: Image.PreserveAspectCrop
39 target: ApplicationManager
41 ApplicationManager.requestFocusApplication(ApplicationManager.get(ApplicationManager.count-1).appId)
45 var appIndex = priv.indexOf(appId);
46 var appDelegate = appRepeater.itemAt(appIndex);
47 if (appDelegate.state === "minimized") {
48 appDelegate.state = "normal"
50 ApplicationManager.focusApplication(appId);
57 readonly property string focusedAppId: ApplicationManager.focusedApplicationId
58 readonly property var focusedAppDelegate: focusedAppId ? appRepeater.itemAt(indexOf(focusedAppId)) : null
60 function indexOf(appId) {
61 for (var i = 0; i < ApplicationManager.count; i++) {
62 if (ApplicationManager.get(i).appId == appId) {
73 ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
75 onMinimize: appRepeater.itemAt(0).state = "minimized"
76 onMaximize: appRepeater.itemAt(0).state = "normal"
81 property: "buttonsVisible"
82 value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.state === "maximized"
87 model: ApplicationManager
91 z: ApplicationManager.count - index
96 readonly property int minWidth: units.gu(10)
97 readonly property int minHeight: units.gu(10)
105 PropertyChanges { target: appDelegate; x: 0; y: 0; width: root.width; height: root.height }
109 PropertyChanges { target: appDelegate; x: -appDelegate.width / 2; scale: units.gu(5) / appDelegate.width; opacity: 0 }
114 PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
118 WindowMoveResizeArea {
120 minWidth: appDelegate.minWidth
121 minHeight: appDelegate.minHeight
122 resizeHandleWidth: units.gu(0.5)
123 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
125 onPressed: ApplicationManager.requestFocusApplication(model.appId)
130 application: ApplicationManager.get(index)
131 active: ApplicationManager.focusedApplicationId === model.appId
133 onClose: ApplicationManager.stopApplication(model.appId)
134 onMaximize: appDelegate.state = (appDelegate.state == "maximized" ? "normal" : "maximized")
135 onMinimize: appDelegate.state = "minimized"