on xenial help sign in
Restore focus to where it was when our ShellDialogs get unloaded
a87fdb3Albert Astals Cid
qml/Components/Dialogs.qml+18
@@ -149,6 +149,24 @@ MouseArea {
149 objectName: "dialogLoader"
149 objectName: "dialogLoader"
150 anchors.fill: parent
150 anchors.fill: parent
151 active: false
151 active: false
152+ onActiveChanged: {
153+ if (!active) {
154+ previousSourceComponent = undefined;
155+ if (previousFocusedComponent) {
156+ previousFocusedComponent.forceActiveFocus(Qt.OtherFocusReason);
157+ previousFocusedComponent = undefined;
158+ }
159+ }
160+ }
161+ onSourceComponentChanged: {
162+ if (previousSourceComponent !== sourceComponent) {
163+ previousSourceComponent = sourceComponent;
164+ previousFocusedComponent = window.activeFocusItem;
165+ }
166+ }
167+
168+ property var previousSourceComponent: undefined
169+ property var previousFocusedComponent: undefined
152 }
170 }
153
171
154 Component {
172 Component {
tests/qmltests/tst_OrientedShell.qml+25
@@ -1596,5 +1596,30 @@ Rectangle {
1596
1596
1597 tryCompare(dialogLoader, "item", null);
1597 tryCompare(dialogLoader, "item", null);
1598 }
1598 }
1599+
1600+ function test_focusOnShutdownDialogClose() {
1601+ loadShell("manta");
1602+ usageModeSelector.selectWindowed();
1603+
1604+ var surfaceId = topLevelSurfaceList.nextId;
1605+ var app = ApplicationManager.startApplication("twitter-webapp");
1606+ waitUntilAppWindowIsFullyLoaded(surfaceId);
1607+
1608+ var primaryAppWindow = findAppWindowForSurfaceId(surfaceId);
1609+ var surface = app.surfaceList.get(0);
1610+ var surfaceItem = findSurfaceItem(primaryAppWindow, surface);
1611+
1612+ compare(window.activeFocusItem, surfaceItem);
1613+
1614+ testCase.showPowerDialog();
1615+
1616+ var dialogLoader = findChild(orientedShell, "dialogLoader");
1617+ tryCompareFunction(function() { return dialogLoader.item !== null }, true);
1618+
1619+ keyClick(Qt.Key_Escape);
1620+
1621+ tryCompare(dialogLoader, "item", null);
1622+ compare(window.activeFocusItem, surfaceItem);
1623+ }
1599 }
1624 }
1600}
1625}