From 34bb1a790fcb1ff9672a2e2471cc5810ec9eeaec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 13 Feb 2013 16:04:13 +0100 Subject: [PATCH] Fix layout issues of Desktop Change OSD * no more binding loops - yeah for anchoring * properly update sizes when switching screens * properly handle case layout indicator enabled/disabled * connect to desktop changed and reset desktop model * set a maximum width/height of 0.8 of screen Most interesting change is the moving of visible = true; to the beginning of the block which updates the layout. Without that all the changes are ignored resulting in the incorrect size on screen change. The disadvantage of that is that the OSD is shown before the layout is adjusted. But it's considerable minor given that it should be just one frame. BUG: 312728 BUG: 312727 BUG: 305737 FIXED-IN: 4.10.1 REVIEW: 108945 --- scripts/desktopchangeosd/contents/ui/main.qml | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/desktopchangeosd/contents/ui/main.qml b/scripts/desktopchangeosd/contents/ui/main.qml index 2ea7f2c914..c93896ccbf 100644 --- a/scripts/desktopchangeosd/contents/ui/main.qml +++ b/scripts/desktopchangeosd/contents/ui/main.qml @@ -54,8 +54,8 @@ Item { mainItem: Item { id: dialogItem - width: childrenRect.width - height: childrenRect.height + width: root.showGrid ? view.itemWidth * view.columns : textElement.width + height: root.showGrid ? view.itemHeight * view.rows + textElement.height : textElement.height Plasma.Label { id: textElement anchors.top: root.showGrid ? parent.top : undefined @@ -64,11 +64,19 @@ Item { } Grid { id: view - property int itemWidth: root.screenWidth * 0.1 - property int itemHeight: root.screenHeight * 0.1 - anchors.top: textElement.bottom + columns: 1 + rows: 1 + property int itemWidth: root.screenWidth * Math.min(0.8/columns, 0.1) + property int itemHeight: Math.min(itemWidth * (root.screenHeight / root.screenWidth), root.screenHeight * Math.min(0.8/rows, 0.1)) + anchors { + top: textElement.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } visible: root.showGrid Repeater { + id: repeater model: workspace.desktops Item { width: view.itemWidth @@ -243,10 +251,6 @@ Item { Component.onCompleted: { columns = workspace.desktopGridWidth; rows = workspace.desktopGridHeight; - if (!root.showGrid) { - width = 0; - height = 0; - } } } } @@ -265,6 +269,7 @@ Item { if (root.currentDesktop == workspace.currentDesktop - 1) { return; } + dialog.visible = true; root.previousDesktop = root.currentDesktop; timer.stop(); root.currentDesktop = workspace.currentDesktop - 1; @@ -277,20 +282,15 @@ Item { // non dependable properties might have changed view.columns = workspace.desktopGridWidth; view.rows = workspace.desktopGridHeight; - view.width = workspace.desktopGridWidth * view.itemWidth; - view.height = workspace.desktopGridHeight * view.itemHeight; - } else { - view.width = 0; - view.height = 0; - dialogItem.width = textElement.width; - dialogItem.height = textElement.height; } // position might have changed dialog.x = screen.x + screen.width/2 - dialogItem.width/2; dialog.y = screen.y + screen.height/2 - dialogItem.height/2; // start the hide timer timer.start(); - dialog.visible = true; + } + onNumberDesktopsChanged: { + repeater.model = workspace.desktops; } } Connections {