@@ -42,6 +42,8 @@ Rectangle {
42 property bool beingResized: false
42 property bool beingResized: false
43 property bool keepDashRunning: true
43 property bool keepDashRunning: true
44 property bool suspended: false
44 property bool suspended: false
45+ property alias background: wallpaper.source
46+ property alias altTabPressed: spread.altTabPressed
46 // functions to be called from outside
48 // functions to be called from outside
47 function updateFocusedAppOrientation() { /* TODO */ }
49 function updateFocusedAppOrientation() { /* TODO */ }
@@ -54,14 +56,11 @@ Rectangle {
54 property int mainAppWindowOrientationAngle: 0
56 property int mainAppWindowOrientationAngle: 0
55 readonly property bool orientationChangesEnabled: false
57 readonly property bool orientationChangesEnabled: false
57− property alias background: wallpaper.source
58− property bool altTabPressed: false
60 Connections {
59 Connections {
61 target: ApplicationManager
60 target: ApplicationManager
62 onApplicationAdded: {
61 onApplicationAdded: {
63− if (root.state == "altTab") {
62+ if (spread.state == "altTab") {
64− root.state = "";
63+ spread.state = "";
67 ApplicationManager.requestFocusApplication(appId)
66 ApplicationManager.requestFocusApplication(appId)
@@ -115,62 +114,6 @@ Rectangle {
115 anchors.fill: parent
114 anchors.fill: parent
116 focus: true
115 focus: true
119− switch (event.key) {
121− case Qt.Key_Backtab:
122− selectPrevious(event.isAutoRepeat)
123− event.accepted = true;
127− selectNext(event.isAutoRepeat)
128− event.accepted = true;
131− spreadRepeater.highlightedIndex = -1
132− // Falling through intentionally
137− event.accepted = true;
141− function selectNext(isAutoRepeat) {
142− print("should select next", isAutoRepeat)
143− if (isAutoRepeat && spreadRepeater.highlightedIndex >= ApplicationManager.count -1) {
144− return; // AutoRepeat is not allowed to wrap around
147− spreadRepeater.highlightedIndex = (spreadRepeater.highlightedIndex + 1) % ApplicationManager.count;
148− var newContentX = ((spreadFlickable.contentWidth) / (ApplicationManager.count + 1)) * Math.max(0, Math.min(ApplicationManager.count - 5, spreadRepeater.highlightedIndex - 3));
149− if (spreadFlickable.contentX < newContentX || spreadRepeater.highlightedIndex == 0) {
150− spreadFlickable.snapTo(newContentX)
154− function selectPrevious(isAutoRepeat) {
155− if (isAutoRepeat && spreadRepeater.highlightedIndex == 0) {
156− return; // AutoRepeat is not allowed to wrap around
159− var newIndex = spreadRepeater.highlightedIndex - 1 >= 0 ? spreadRepeater.highlightedIndex - 1 : ApplicationManager.count - 1;
160− spreadRepeater.highlightedIndex = newIndex;
161− var newContentX = ((spreadFlickable.contentWidth) / (ApplicationManager.count + 1)) * Math.max(0, Math.min(ApplicationManager.count - 5, spreadRepeater.highlightedIndex - 1));
162− if (spreadFlickable.contentX > newContentX || newIndex == ApplicationManager.count -1) {
163− spreadFlickable.snapTo(newContentX)
167− function focusSelected() {
168− if (spreadRepeater.highlightedIndex != -1) {
169− var application = ApplicationManager.get(spreadRepeater.highlightedIndex);
170− ApplicationManager.focusApplication(application.appId);
174 CrossFadeImage {
117 CrossFadeImage {
175 id: wallpaper
118 id: wallpaper
176 anchors.fill: parent
119 anchors.fill: parent
@@ -196,7 +139,7 @@ Rectangle {
196 property bool maximized: false
139 property bool maximized: false
197 property bool minimized: false
140 property bool minimized: false
199− focus: priv.focusedAppId === model.appId && root.state !== "altTab"
142+ focus: priv.focusedAppId === model.appId && spread.state !== "altTab"
201 Binding {
144 Binding {
202 target: ApplicationManager.get(index)
145 target: ApplicationManager.get(index)
@@ -248,7 +191,7 @@ Rectangle {
248 target: appDelegate
191 target: appDelegate
249 property: "z"
192 property: "z"
250 value: ApplicationManager.count + 1
193 value: ApplicationManager.count + 1
251− when: index == spreadRepeater.highlightedIndex && blurLayer.ready
194+ when: index == spread.highlightedIndex && blurLayer.ready
254 WindowMoveResizeArea {
197 WindowMoveResizeArea {
@@ -295,424 +238,10 @@ Rectangle {
295 visible: false
238 visible: false
298− Item {
241+ DesktopSpread {
299− id: spreadContainer
242+ id: spread
301− onVisibleChanged: print("container visible changed", visible)
305− model: ApplicationManager
307− property int highlightedIndex: -1
308− property int closingIndex: -1
310− function indexOf(delegateItem) {
311− for (var i = 0; i < spreadRepeater.count; i++) {
312− if (spreadRepeater.itemAt(i) === delegateItem) {
321− objectName: "spreadDelegate"
323− height: units.gu(20)
325− property real angle: 0
326− property real itemScale: 1
327− property int itemScaleOriginX: 0
328− property int itemScaleOriginY: 0
332− enabled: spreadRepeater.closingIndex >= 0
333− UbuntuNumberAnimation {
334− onRunningChanged: if (!running) spreadRepeater.closingIndex = -1
338− DesktopSpreadDelegate {
339− id: clippedSpreadDelegate
340− objectName: "clippedSpreadDelegate"
341− anchors.left: parent.left
342− anchors.top: parent.top
343− application: ApplicationManager.get(index)
344− width: spreadMaths.spreadHeight
345− height: spreadMaths.spreadHeight
349− origin.x: itemScaleOriginX
350− origin.y: itemScaleOriginY
355− origin { x: 0; y: (clippedSpreadDelegate.height - (clippedSpreadDelegate.height * itemScale / 2)) }
356− axis { x: 0; y: 1; z: 0 }
357− angle: spreadDelegate.angle
362− id: spreadSelectArea
363− anchors.fill: parent
364− anchors.margins: -units.gu(2)
374− flickable: spreadFlickable
376− totalItems: Math.max(6, ApplicationManager.count)
377− sceneHeight: root.height
378− itemHeight: spreadDelegate.height
383− name: "altTab"; when: root.state == "altTab" && spreadContainer.visible
385− target: spreadDelegate
386− x: spreadMaths.animatedX
387− y: spreadMaths.animatedY + (spreadDelegate.height - clippedSpreadDelegate.height) - units.gu(2)
388− width: spreadMaths.spreadHeight
389− height: spreadMaths.sceneHeight
390− angle: spreadMaths.animatedAngle
391− itemScale: spreadMaths.scale
392− itemScaleOriginY: clippedSpreadDelegate.height / 2;
394− visible: spreadMaths.itemVisible
397− target: clippedSpreadDelegate
398− highlightShown: index == spreadRepeater.highlightedIndex
399− state: "transformed"
400− shadowOpacity: spreadMaths.shadowOpacity
401− anchors.topMargin: units.gu(2)
406− opacity: spreadMaths.tileInfoOpacity
409− target: spreadSelectArea
418− PropertyAction { target: spreadDelegate; properties: "y,height,width,angle,z,itemScale,itemScaleOriginY,visible" }
419− PropertyAction { target: clippedSpreadDelegate; properties: "anchors.topMargin" }
421− target: spreadDelegate; properties: "x"
423− duration: rightEdgePushArea.containsMouse ? UbuntuAnimation.FastDuration :0
424− easing: UbuntuAnimation.StandardEasing
431− objectName: "tileInfo"
432− anchors { left: parent.left; top: clippedSpreadDelegate.bottom; topMargin: units.gu(5) }
434− height: titleInfoColumn.height
438− onContainsMouseChanged: {
439− if (containsMouse) {
440− spreadRepeater.highlightedIndex = index
450− anchors { left: parent.left; top: parent.top; right: parent.right }
451− spacing: units.gu(1)
454− Layout.preferredHeight: Math.min(units.gu(6), root.height * .05)
455− Layout.preferredWidth: height * 8 / 7.6
457− anchors.fill: parent
462− Layout.fillWidth: true
463− Layout.preferredHeight: units.gu(6)
465− wrapMode: Text.WordWrap
473− anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset + units.gu(2) }
474− source: "graphics/window-close.svg"
475− readonly property var mousePos: hoverMouseArea.mapToItem(spreadDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
476− visible: index == spreadRepeater.highlightedIndex
477− && mousePos.y < (clippedSpreadDelegate.height / 3)
478− && mousePos.y > -units.gu(4)
479− && mousePos.x > -units.gu(4)
480− && mousePos.x < (clippedSpreadDelegate.width * 2 / 3)
481− height: units.gu(1.5)
483− sourceSize.width: width
484− sourceSize.height: height
488− objectName: "closeMouseArea"
489− anchors.fill: closeImage
490− anchors.margins: -units.gu(2)
492− spreadRepeater.closingIndex = index;
493− ApplicationManager.stopApplication(model.appId)
504− anchors.fill: appContainer
505− propagateComposedEvents: true
509− property int scrollAreaWidth: root.width / 3
510− property bool progressiveScrollingEnabled: false
513− mouse.accepted = false
515− // Find the hovered item and mark it active
516− var mapped = mapToItem(spreadContainer, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
517− var itemUnder = spreadContainer.childAt(mapped.x, mapped.y)
519− mapped = mapToItem(itemUnder, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
520− var delegateChild = itemUnder.childAt(mapped.x, mapped.y)
521− if (delegateChild && (delegateChild.objectName === "clippedSpreadDelegate" || delegateChild.objectName === "tileInfo")) {
522− spreadRepeater.highlightedIndex = spreadRepeater.indexOf(itemUnder)
526− if (spreadFlickable.contentWidth > spreadFlickable.minContentWidth) {
527− var margins = spreadFlickable.width * 0.05;
529− if (!progressiveScrollingEnabled && mouseX < spreadFlickable.width - scrollAreaWidth) {
530− progressiveScrollingEnabled = true
533− // do we need to scroll?
534− if (mouseX < scrollAreaWidth) {
535− var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
536− var contentX = (1 - progress) * (spreadFlickable.contentWidth - spreadFlickable.width)
537− spreadFlickable.contentX = Math.max(0, Math.min(spreadFlickable.contentX, contentX))
539− if (mouseX > spreadFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
540− var progress = Math.min(1, (mouseX - (spreadFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
541− var contentX = progress * (spreadFlickable.contentWidth - spreadFlickable.width)
542− spreadFlickable.contentX = Math.min(spreadFlickable.contentWidth - spreadFlickable.width, Math.max(spreadFlickable.contentX, contentX))
546− onPressed: mouse.accepted = false
551− objectName: "spreadFlickable"
552 anchors.fill: parent
243 anchors.fill: parent
553− property int minContentWidth: 6 * Math.min(height / 4, width / 5)
554− contentWidth: Math.max(6, ApplicationManager.count) * Math.min(height / 4, width / 5)
557− function snapTo(contentX) {
558− snapAnimation.stop();
559− snapAnimation.to = contentX
560− snapAnimation.start();
563− UbuntuNumberAnimation {
565− target: spreadFlickable
566− property: "contentX"
571− id: workspaceSelector
576− topMargin: units.gu(3.5)
578− height: root.height * 0.25
582− anchors.fill: parent
583− spacing: units.gu(1)
584− Item { Layout.fillWidth: true }
586− model: 1 // TODO: will be a workspacemodel in the future
588− Layout.fillHeight: true
589− Layout.preferredWidth: ((height - units.gu(6)) * root.width / root.height)
591− source: root.background
595− verticalCenter: parent.verticalCenter
597− height: parent.height * 0.75
600− anchors.fill: parent
602− property var source: ShaderEffectSource {
603− id: shaderEffectSource
604− sourceItem: appContainer
244+ workspace: appContainer
608− varying highp vec2 qt_TexCoord0;
609− uniform sampler2D source;
612− highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
613− gl_FragColor = sourceColor;
618− // TODO: This is the bar for the currently selected workspace
619− // Enable this once the workspace stuff is implemented
621−// anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
622−// height: units.dp(2)
623−// color: UbuntuColors.orange
624−// visible: index == 0 // TODO: should be active workspace index
629− // TODO: This is the "new workspace" button. Enable this once workspaces are implemented
631−// Layout.fillHeight: true
632−// Layout.preferredWidth: ((height - units.gu(6)) * root.width / root.height)
636−// right: parent.right
637−// verticalCenter: parent.verticalCenter
639−// height: parent.height * 0.75
640−// color: "#22ffffff"
643−// anchors.centerIn: parent
644−// font.pixelSize: parent.height / 2
649− Item { Layout.fillWidth: true }
654− id: currentSelectedLabel
655− anchors { bottom: parent.bottom; bottomMargin: root.height * 0.625; horizontalCenter: parent.horizontalCenter }
656− text: spreadRepeater.highlightedIndex >= 0 ? ApplicationManager.get(spreadRepeater.highlightedIndex).name : ""
663− name: "altTab"; when: root.altTabPressed
245+ focus: root.altTabPressed
664− PropertyChanges { target: blurLayer; saturation: 0.8; blurRadius: 60; visible: true }
665− PropertyChanges { target: workspaceSelector; visible: true }
666− PropertyChanges { target: spreadContainer; visible: true }
667− PropertyChanges { target: spreadFlickable; enabled: spreadFlickable.contentWidth > spreadFlickable.minContentWidth }
668− PropertyChanges { target: currentSelectedLabel; visible: true }
669− PropertyChanges { target: spreadBackground; visible: true }
670− PropertyChanges { target: hoverMouseArea; enabled: true }
677− SequentialAnimation {
678− PropertyAction { target: hoverMouseArea; property: "progressiveScrollingEnabled"; value: false }
679− PropertyAction { target: spreadRepeater; property: "highlightedIndex"; value: Math.min(ApplicationManager.count - 1, 1) }
680− PauseAnimation { duration: 50 }
681− PropertyAction { target: workspaceSelector; property: "visible" }
682− PropertyAction { target: spreadContainer; property: "visible" }
684− UbuntuNumberAnimation { target: blurLayer; properties: "saturation,blurRadius" }
685− PropertyAction { target: spreadFlickable; property: "visible" }
686− PropertyAction { targets: [currentSelectedLabel,spreadBackground]; property: "visible" }
687− PropertyAction { target: spreadFlickable; property: "contentX"; value: 0 }
694− PropertyAnimation { property: "opacity" }
695− ScriptAction { script: { appContainer.focusSelected() } }
696− PropertyAction { target: spreadRepeater; property: "highlightedIndex"; value: -1 }
702− id: rightEdgePushArea
706− bottom: parent.bottom
708− // TODO: Make this a push to edge thing like the launcher when we can,
709− // for now, yes, we want 1 pixel, regardless of the scaling
712− onContainsMouseChanged: {
713− if (containsMouse) {
714− root.state = "altTab";