diff --git a/krunner/view.cpp b/krunner/view.cpp --- a/krunner/view.cpp +++ b/krunner/view.cpp @@ -175,6 +175,15 @@ void View::slotFocusWindowChanged() { if (!QGuiApplication::focusWindow()) { + // ask the view to hide itself, it may refuse to if there's still a query in the input box (cf. Bug 353026) + if (m_qmlObj->rootObject()) { + // note this doesn't check the return value of focusLost but merely if the call succeeded + if (QMetaObject::invokeMethod(m_qmlObj->rootObject(), "focusLost")) { + return; + } + } + + // fallback for old LNF themes that don't have the function we call setVisible(false); } } diff --git a/lookandfeel/contents/runcommand/RunCommand.qml b/lookandfeel/contents/runcommand/RunCommand.qml --- a/lookandfeel/contents/runcommand/RunCommand.qml +++ b/lookandfeel/contents/runcommand/RunCommand.qml @@ -29,6 +29,13 @@ property string runner property bool showHistory: false + // called by view.cpp when the window loses focus (cf. Bug 353026) + function focusLost() { + if (queryField.text === "") { + runnerWindow.visible = false; + } + } + LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true