diff --git a/containments/desktop/package/contents/ui/AppletAppearance.qml b/containments/desktop/package/contents/ui/AppletAppearance.qml --- a/containments/desktop/package/contents/ui/AppletAppearance.qml +++ b/containments/desktop/package/contents/ui/AppletAppearance.qml @@ -36,7 +36,8 @@ property int handleHeight: (height < minimumHandleHeight) ? minimumHandleHeight : height property string category - property bool showAppletHandle: false + property bool showAppletHandle: temporaryShowAppletHandle || toolBox.open + property bool temporaryShowAppletHandle: false property real controlsOpacity: (plasmoid.immutable || !showAppletHandle) ? 0 : 1 property string backgroundHints: "NoBackground" property bool hasBackground: false @@ -216,7 +217,7 @@ onPressAndHold: { if (!plasmoid.immutable && plasmoid.configuration.pressToMove) { if (!dragMouseArea.dragging && !root.isDrag(pressX, pressY, mouse.x, mouse.y)) { - showAppletHandle = true; + temporaryShowAppletHandle = true; dragMouseArea.dragging = true; @@ -245,10 +246,10 @@ onTriggered: { if (mouseListener.containsMouse || (appletHandle.item && (appletHandle.item.containsMouse || appletHandle.item.pressed))) { if (!plasmoid.configuration.pressToMove) { - showAppletHandle = true; + temporaryShowAppletHandle = true; } } else if (!dragMouseArea.dragging) { - showAppletHandle = false; + temporaryShowAppletHandle = false; } } } @@ -282,7 +283,7 @@ onImmutableChanged: { // print(" TB dragMouseArea.visible: " + plasmoid.immutable) dragMouseArea.visible = !plasmoid.immutable; - showAppletHandle = false; + temporaryShowAppletHandle = false; } onAppletRemoved: { // print("Applet removed Applet-" + applet.id) diff --git a/containments/desktop/package/contents/ui/main.qml b/containments/desktop/package/contents/ui/main.qml --- a/containments/desktop/package/contents/ui/main.qml +++ b/containments/desktop/package/contents/ui/main.qml @@ -397,6 +397,9 @@ onPressed: { root.forceActiveFocus() mouse.accepted = false // Bug 351277 + if (toolBox && toolBox.open) { + toolBox.open = false; + } } } diff --git a/toolboxes/desktoptoolbox/contents/ui/ToolBoxButton.qml b/toolboxes/desktoptoolbox/contents/ui/ToolBoxButton.qml --- a/toolboxes/desktoptoolbox/contents/ui/ToolBoxButton.qml +++ b/toolboxes/desktoptoolbox/contents/ui/ToolBoxButton.qml @@ -259,9 +259,8 @@ } } onClicked: { - toolBoxLoader.active = true // the dialog auto-closes on losing focus - toolBoxLoader.item.visible = !main.dialogWasVisible + main.open = !main.dialogWasVisible plasmoid.focus = true; } onReleased: { diff --git a/toolboxes/desktoptoolbox/contents/ui/ToolBoxItem.qml b/toolboxes/desktoptoolbox/contents/ui/ToolBoxItem.qml --- a/toolboxes/desktoptoolbox/contents/ui/ToolBoxItem.qml +++ b/toolboxes/desktoptoolbox/contents/ui/ToolBoxItem.qml @@ -39,7 +39,7 @@ // because of the dialog closing right on the key *press* event Keys.onReleased: { if (event.key === Qt.Key_Escape) { - toolBoxLoader.item.visible = false + main.open = false event.accepted = true } } @@ -53,7 +53,7 @@ model[currentIndex].trigger() } } - toolBoxLoader.item.visible = false + main.open = false event.accepted = true } } @@ -118,7 +118,7 @@ onExited: menu.currentIndex = -1 onClicked: { - toolBoxLoader.item.visible = false + main.open = false if (modelData.operation) { performOperation(modelData.operation) } else { diff --git a/toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml b/toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml --- a/toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml +++ b/toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml @@ -20,6 +20,7 @@ */ import QtQuick 2.2 +import QtQuick.Window 2.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons @@ -39,6 +40,28 @@ onAvailableScreenRegionChanged: placeToolBoxTimer.restart(); } + //FIXME: this timer shouldn't exist, but unfortunately when the focus passes + //from the desktop to the dialog or vice versa, the event is not atomic + //and ends up with neither of those having focus, hiding the dialog when + //it shouldn't + Timer { + id: hideDialogTimer + interval: 0 + //NOTE: it's checking activeFocusItem instead of active as active doesn't correctly signal its change + property bool desktopOrDialogFocus: main.Window.activeFocusItem != null || (toolBoxLoader.item && toolBoxLoader.item.activeFocusItem != null) + onDesktopOrDialogFocusChanged: { + if (!desktopOrDialogFocus) { + hideDialogTimer.restart(); + } + + } + onTriggered: { + if (!desktopOrDialogFocus) { + open = false; + } + } + } + signal minimumWidthChanged signal minimumHeightChanged signal maximumWidthChanged @@ -50,6 +73,15 @@ property int iconWidth: units.iconSizes.smallMedium property int iconHeight: iconWidth property bool dialogWasVisible: false + property bool open: false + onOpenChanged: { + if (open) { + toolBoxLoader.active = true; + toolBoxLoader.item.visible = true; + } else { + toolBoxLoader.item.visible = false; + } + } onWidthChanged: placeToolBoxTimer.restart(); onHeightChanged: placeToolBoxTimer.restart(); @@ -101,7 +133,7 @@ flags: Qt.WindowStaysOnTopHint location: PlasmaCore.Types.Floating visualParent: toolBoxButton - hideOnWindowDeactivate: true + // hideOnWindowDeactivate: true mainItem: ToolBoxItem { id: dialog