~saviq/unity8/build-arm64

« back to all changes in this revision

Viewing changes to qml/Stages/TabletStage.qml

  • Committer: Michał Sawicz
  • Date: 2016-07-15 09:51:02 UTC
  • mfrom: (2400.1.142 unity8)
  • Revision ID: michal.sawicz@canonical.com-20160715095102-hf5ac4iqnfn1itpw
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
            orientations |= Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation;
102
102
            if (priv.sideStageItemId && !spreadView.surfaceDragging) {
103
103
                // If we have a sidestage app, support Portrait orientation
104
 
                // so that it will switch the sidestage app to mainstage on rotate
 
104
                // so that it will switch the sidestage app to mainstage on rotate to portrait
105
105
                orientations |= Qt.PortraitOrientation|Qt.InvertedPortraitOrientation;
106
106
            }
107
107
            return orientations;
624
624
                enabled: priv.sideStageEnabled
625
625
 
626
626
                onDropped: {
627
 
                    drop.source.spreadDelegate.stage = ApplicationInfoInterface.MainStage;
 
627
                    drop.source.spreadDelegate.saveStage(ApplicationInfoInterface.MainStage);
628
628
                    drop.source.spreadDelegate.focus = true;
629
629
                }
630
630
                keys: "SideStage"
679
679
                    }
680
680
                    onDropped: {
681
681
                        if (drop.keys == "MainStage") {
682
 
                            drop.source.spreadDelegate.stage = ApplicationInfoInterface.SideStage;
 
682
                            drop.source.spreadDelegate.saveStage(ApplicationInfoInterface.SideStage);
683
683
                            drop.source.spreadDelegate.focus = true;
684
684
                        }
685
685
                    }
752
752
 
753
753
                    readonly property bool wantsMainStage: stage == ApplicationInfoInterface.MainStage
754
754
 
755
 
                    readonly property bool isDash: model.application.appId == "unity8-dash"
 
755
                    readonly property bool isDash: application.appId == "unity8-dash"
756
756
 
757
757
                    onFocusChanged: {
758
758
                        if (focus && !spreadRepeater.startingUp) {
768
768
                        onFocusRequested: spreadTile.focus = true;
769
769
                    }
770
770
                    Connections {
771
 
                        target: model.application
 
771
                        target: spreadTile.application
772
772
                        onFocusRequested: {
773
773
                            if (!model.surface) {
774
774
                                // when an app has no surfaces, we assume there's only one entry representing it:
810
810
                        }
811
811
                    }
812
812
 
 
813
                    function saveStage(newStage) {
 
814
                        stage = newStage;
 
815
                        WindowStateStorage.saveStage(application.appId, newStage);
 
816
                    }
 
817
 
813
818
                    // FIXME: A regular binding doesn't update any more after closing an app.
814
819
                    // Using a Binding for now.
815
820
                    Binding {
843
848
                        refreshStage();
844
849
                        _constructing = false;
845
850
                    }
846
 
                    Component.onDestruction: {
847
 
                        WindowStateStorage.saveStage(model.application.appId, stage);
848
 
                    }
849
851
 
850
852
                    function refreshStage() {
851
853
                        var newStage = ApplicationInfoInterface.MainStage;
852
 
                        if (priv.sideStageEnabled) {
853
 
                            if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
854
 
                                newStage = WindowStateStorage.getStage(application.appId);
 
854
                        if (priv.sideStageEnabled) { // we're in lanscape rotation.
 
855
                            if (!isDash && application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
 
856
                                var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
 
857
                                if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
 
858
                                    // if it supports lanscape, it defaults to mainstage.
 
859
                                    defaultStage = ApplicationInfoInterface.MainStage;
 
860
                                }
 
861
                                newStage = WindowStateStorage.getStage(application.appId, defaultStage);
855
862
                            }
856
863
                        }
857
864
 
1035
1042
        id: triGestureArea
1036
1043
        anchors.fill: parent
1037
1044
        enabled: priv.sideStageEnabled && !spreadView.active
1038
 
        property var dragObject: null
1039
1045
 
1040
1046
        property Item spreadDelegate
1041
1047
 
1073
1079
 
1074
1080
                surface: spreadDelegate ? spreadDelegate.surface : null
1075
1081
 
 
1082
                consumesInput: false
1076
1083
                interactive: false
1077
1084
                resizeSurface: false
1078
1085
                focus: false
1085
1092
                // only accept opposite stage.
1086
1093
                Drag.keys: {
1087
1094
                    if (!surface) return "Disabled";
 
1095
                    if (spreadDelegate.isDash) return "Disabled";
1088
1096
 
1089
1097
                    if (spreadDelegate.stage === ApplicationInfo.MainStage) {
1090
1098
                        if (spreadDelegate.application.supportedOrientations
1105
1113
        enabled: spreadDragArea.dragging
1106
1114
    }
1107
1115
 
1108
 
    DirectionalDragArea {
 
1116
    SwipeArea {
1109
1117
        id: spreadDragArea
1110
1118
        objectName: "spreadDragArea"
1111
1119
        x: parent.width - root.dragAreaWidth
1116
1124
 
1117
1125
        property var gesturePoints: new Array()
1118
1126
 
1119
 
        onTouchXChanged: {
 
1127
        onTouchPositionChanged: {
1120
1128
            if (!dragging) {
1121
1129
                spreadView.phase = 0;
1122
1130
                spreadView.contentX = -spreadView.shift;
1123
1131
            }
1124
1132
 
1125
1133
            if (dragging) {
1126
 
                var dragX = -touchX + spreadDragArea.width - spreadView.shift;
 
1134
                var dragX = -touchPosition.x + spreadDragArea.width - spreadView.shift;
1127
1135
                var maxDrag = spreadView.width * spreadView.positionMarker4 - spreadView.shift;
1128
1136
                spreadView.contentX = Math.min(dragX, maxDrag);
1129
1137
            }
1130
 
            gesturePoints.push(touchX);
 
1138
            gesturePoints.push(touchPosition.x);
1131
1139
        }
1132
1140
 
1133
1141
        onDraggingChanged: {