moment/src/gui/Base/HPopup.qml
miruka 9bd739a0db Fix focus and simplify popup-opener menu items
Introduce a HmenuItemPopupSpawner component that takes care of reacting
to onTriggered signals and calling the utils.makePopup() function.

The combination of this new component used in HMenu to open a HPopup
now correctly takes and restore focus to the right element when closed.
2019-12-20 10:30:50 -04:00

39 lines
978 B
QML

// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Controls 2.12
Popup {
id: popup
anchors.centerIn: Overlay.overlay
modal: true
focus: true
padding: 0
margins: theme.spacing
enter: Transition {
HNumberAnimation { property: "scale"; from: 0; to: 1; overshoot: 4 }
}
exit: Transition {
HNumberAnimation { property: "scale"; to: 0 }
}
background: Rectangle {
color: theme.controls.popup.background
}
onAboutToShow: previouslyFocused = window.activeFocusItem
onClosed: if (focusOnClosed) focusOnClosed.forceActiveFocus()
property var previouslyFocused: null
property Item focusOnClosed: previouslyFocused
readonly property int maximumPreferredWidth:
window.width - leftMargin - rightMargin - leftInset - rightInset
readonly property int maximumPreferredHeight:
window.height - topMargin - bottomMargin - topInset - bottomInset
}