on xenial help sign in
dragging between stages working now
fd4d1c9Michael Zanetti
qml/Stages/DesktopStage.qml+153−26
@@ -172,21 +172,23 @@ AbstractStage {
172 property string sideStageAppId: ""
172 property string sideStageAppId: ""
173
173
174 function updateMainAndSideStageIndexes() {
174 function updateMainAndSideStageIndexes() {
175+ print("updating stage indexes, sideStage shown:", sideStage.shown)
175 var choseMainStage = false;
176 var choseMainStage = false;
176 var choseSideStage = false;
177 var choseSideStage = false;
177
178
178 if (!root.topLevelSurfaceList)
179 if (!root.topLevelSurfaceList)
179 return;
180 return;
180
181
181− for (var i = 0; i < topLevelSurfaceRepeater.count && (!choseMainStage || !choseSideStage); ++i) {
182+ for (var i = 0; i < appRepeater.count && (!choseMainStage || !choseSideStage); ++i) {
182− var appDelegate = topLevelSurfaceRepeater.itemAt(i);
183+ var appDelegate = appRepeater.itemAt(i);
184+ print("have app on stage", appDelegate.applicationId, appDelegate.stage)
183− if (sideStage.shown && spreadDelegate.stage == ApplicationInfoInterface.SideStage
185+ if (sideStage.shown && appDelegate.stage == ApplicationInfoInterface.SideStage
184 && !choseSideStage) {
186 && !choseSideStage) {
185 priv.sideStageDelegate = appDelegate
187 priv.sideStageDelegate = appDelegate
186 priv.sideStageItemId = root.topLevelSurfaceList.idAt(i);
188 priv.sideStageItemId = root.topLevelSurfaceList.idAt(i);
187 priv.sideStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
189 priv.sideStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
188 choseSideStage = true;
190 choseSideStage = true;
189− } else if (!choseMainStage && spreadDelegate.stage == ApplicationInfoInterface.MainStage) {
191+ } else if (!choseMainStage && appDelegate.stage == ApplicationInfoInterface.MainStage) {
190 priv.mainStageDelegate = appDelegate;
192 priv.mainStageDelegate = appDelegate;
191 priv.mainStageItemId = root.topLevelSurfaceList.idAt(i);
193 priv.mainStageItemId = root.topLevelSurfaceList.idAt(i);
192 priv.mainStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
194 priv.mainStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
@@ -203,6 +205,8 @@ AbstractStage {
203 priv.sideStageItemId = 0;
205 priv.sideStageItemId = 0;
204 priv.sideStageAppId = "";
206 priv.sideStageAppId = "";
205 }
207 }
208+
209+ print("*** updated! MainStage:", priv.mainStageAppId, "SideStage:", priv.sideStageAppId)
206 }
210 }
207 }
211 }
208
212
@@ -297,6 +301,7 @@ AbstractStage {
297 },
301 },
298 State {
302 State {
299 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
303 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
304+ PropertyChanges { target: triGestureArea; enabled: true }
300 },
305 },
301 State {
306 State {
302 name: "windowed"; when: root.mode === "windowed"
307 name: "windowed"; when: root.mode === "windowed"
@@ -304,6 +309,7 @@ AbstractStage {
304 ]
309 ]
305 onStateChanged: print("spread going to state:", state)
310 onStateChanged: print("spread going to state:", state)
306
311
312+
307 FocusScope {
313 FocusScope {
308 id: appContainer
314 id: appContainer
309 objectName: "appContainer"
315 objectName: "appContainer"
@@ -318,6 +324,65 @@ AbstractStage {
318 fillMode: Image.PreserveAspectCrop
324 fillMode: Image.PreserveAspectCrop
319 }
325 }
320
326
327+ Connections {
328+ target: root.topLevelSurfaceList
329+ onListChanged: priv.updateMainAndSideStageIndexes()
330+ }
331+
332+
333+ DropArea {
334+ objectName: "MainStageDropArea"
335+ anchors {
336+ left: parent.left
337+ top: parent.top
338+ bottom: parent.bottom
339+ }
340+ width: appContainer.width - sideStage.width
341+ enabled: sideStage.enabled
342+
343+ onDropped: {
344+ print("dropped on main stage drop area")
345+ drop.source.appDelegate.saveStage(ApplicationInfoInterface.MainStage);
346+ drop.source.appDelegate.focus = true;
347+ }
348+ keys: "SideStage"
349+ }
350+
351+ SideStage {
352+ id: sideStage
353+ shown: false
354+ height: appContainer.height
355+ x: appContainer.width - width
356+
357+ DropArea {
358+ id: sideStageDropArea
359+ objectName: "SideStageDropArea"
360+ anchors.fill: parent
361+
362+ property bool dropAllowed: true
363+
364+ onEntered: {
365+ dropAllowed = drag.keys != "Disabled";
366+ }
367+ onExited: {
368+ dropAllowed = true;
369+ }
370+ onDropped: {
371+ if (drop.keys == "MainStage") {
372+ drop.source.appDelegate.saveStage(ApplicationInfoInterface.SideStage);
373+ drop.source.appDelegate.focus = true;
374+ }
375+ }
376+ drag {
377+ onSourceChanged: {
378+ if (!sideStageDropArea.drag.source) {
379+ dropAllowed = true;
380+ }
381+ }
382+ }
383+ }
384+ }
385+
321 TopLevelSurfaceRepeater {
386 TopLevelSurfaceRepeater {
322 id: appRepeater
387 id: appRepeater
323 model: topLevelSurfaceList
388 model: topLevelSurfaceList
@@ -404,6 +469,10 @@ AbstractStage {
404 property bool visuallyMinimized: false
469 property bool visuallyMinimized: false
405
470
406 property int stage: ApplicationInfoInterface.MainStage
471 property int stage: ApplicationInfoInterface.MainStage
472+ function saveStage(stage) {
473+ appDelegate.stage = stage;
474+ WindowStateStorage.saveStage(application.appId, newStage);
475+ }
407
476
408 readonly property var surface: model.surface
477 readonly property var surface: model.surface
409 readonly property alias resizeArea: resizeArea
478 readonly property alias resizeArea: resizeArea
@@ -723,19 +792,13 @@ AbstractStage {
723 requestedWidth: appContainer.width;
792 requestedWidth: appContainer.width;
724 requestedHeight: appContainer.height;
793 requestedHeight: appContainer.height;
725 }
794 }
726− PropertyChanges {
727− target: decoratedWindow
795+ PropertyChanges { target: decoratedWindow; hasDecoration: false }
728− hasDecoration: false
729− }
730 },
796 },
731 State {
797 State {
732 name: "normal";
798 name: "normal";
733 when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
799 when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
734− PropertyChanges {
735− target: appDelegate;
736− visuallyMinimized: false;
800+ PropertyChanges { target: appDelegate; visuallyMinimized: false; visuallyMaximized: false; }
737− visuallyMaximized: false;
801+ PropertyChanges { target: touchControls; enabled: true }
738− }
739 },
802 },
740 State {
803 State {
741 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
804 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
@@ -842,8 +905,12 @@ AbstractStage {
842 to: "staged"
905 to: "staged"
843 UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
906 UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
844 UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
907 UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
908+ },
909+ Transition {
910+ to: "stagedWithSideStage"
911+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
912+ UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
845 }
913 }
846−
847 ]
914 ]
848
915
849// Binding {
916// Binding {
@@ -966,6 +1033,7 @@ AbstractStage {
966 id: touchControls
1033 id: touchControls
967 anchors.fill: appDelegate
1034 anchors.fill: appDelegate
968 target: appDelegate
1035 target: appDelegate
1036+ enabled: false
969 }
1037 }
970
1038
971 WindowedFullscreenPolicy {
1039 WindowedFullscreenPolicy {
@@ -1112,16 +1180,75 @@ AbstractStage {
1112 }
1180 }
1113 }
1181 }
1114
1182
1115−// DesktopSpread {
1183+ TabletSideStageTouchGesture {
1116−// id: spread
1184+ id: triGestureArea
1117−// objectName: "spread"
1118−// anchors.fill: appContainer
1185+ anchors.fill: parent
1119−// workspace: appContainer
1186+ enabled: false
1120−// focus: state == "altTab"
1187+ property Item appDelegate
1121−// altTabPressed: root.altTabPressed
1188+
1122−
1189+ dragComponent: dragComponent
1123−// onPlayFocusAnimation: {
1190+ dragComponentProperties: { "appDelegate": appDelegate }
1124−// appRepeater.itemAt(index).playFocusAnimation();
1191+
1192+ onPressed: {
1193+ print("********* triGestureArea pressed!")
1194+ function matchDelegate(obj) { return String(obj.objectName).indexOf("appDelegate") >= 0; }
1195+
1196+ var delegateAtCenter = Functions.itemAt(appContainer, x, y, matchDelegate);
1197+ print("dragging delegate", delegateAtCenter)
1198+ if (!delegateAtCenter) return;
1199+
1200+ appDelegate = delegateAtCenter;
1201+ }
1202+
1203+ onClicked: {
1204+ if (sideStage.shown) {
1205+ sideStage.hide();
1206+ } else {
1207+ sideStage.show();
1208+ }
1209+ }
1210+
1211+ onDragStarted: {
1212+ // If we're dragging to the sidestage.
1213+ if (!sideStage.shown) {
1214+ sideStage.show();
1215+ }
1216+ }
1217+
1218+ Component {
1219+ id: dragComponent
1220+ SurfaceContainer {
1221+ property Item appDelegate
1222+
1223+ surface: appDelegate ? appDelegate.surface : null
1224+
1225+ consumesInput: false
1226+ interactive: false
1227+// resizeSurface: false
1228+ focus: false
1229+ requestedWidth: appDelegate.requestedWidth
1230+ requestedHeight: appDelegate.requestedHeight
1231+
1232+ width: units.gu(40)
1233+ height: units.gu(40)
1234+
1235+ Drag.hotSpot.x: width/2
1236+ Drag.hotSpot.y: height/2
1237+ // only accept opposite stage.
1238+ Drag.keys: {
1239+ if (!surface) return "Disabled";
1240+ if (appDelegate.isDash) return "Disabled";
1241+
1242+ if (appDelegate.stage === ApplicationInfo.MainStage) {
1243+ if (appDelegate.application.supportedOrientations
1244+ & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
1245+ return "MainStage";
1246+ }
1247+ return "Disabled";
1248+ }
1249+ return "SideStage";
1250+ }
1251+ }
1125−// }
1252+ }
1126−// }
1253+ }
1127}
1254}
tests/mocks/Unity/Application/ApplicationManager.cpp+1
@@ -413,6 +413,7 @@ void ApplicationManager::buildListOfAvailableApplications()
413 application->setAppId("notes-app");
413 application->setAppId("notes-app");
414 application->setName("Notepad");
414 application->setName("Notepad");
415 application->setIconId("notepad");
415 application->setIconId("notepad");
416+ application->setStage(ApplicationInfoInterface::SideStage);
416 m_availableApplications.append(application);
417 m_availableApplications.append(application);
417
418
418 application = new ApplicationInfo(this);
419 application = new ApplicationInfo(this);