Implemented closing popups when parent is not in visible area

This commit is contained in:
Eism 2021-07-19 18:07:27 +02:00
parent 016bbbe2d9
commit 5ae5e206a0
5 changed files with 14 additions and 8 deletions

View file

@ -48,8 +48,6 @@ FlatButton {
StyledMenuLoader {
id: menuLoader
menuAnchorItem: ui.rootItem
onHandleAction: {
root.handleAction(actionCode, actionIndex)
}

View file

@ -60,7 +60,6 @@ StyledPopupView {
signal addElementsRequested(var mimeDataList)
navigation.name: "MoreElementsPopup"
navigation.direction: NavigationPanel.Both

View file

@ -53,6 +53,8 @@ GridView {
property bool enableAnimations: true
property bool isInVisibleArea: true
property NavigationPanel navigationPanel: null
property int navigationRow: 0
property int navigationCol: 1
@ -173,6 +175,8 @@ GridView {
anchors.fill: parent
visible: paletteView.isInVisibleArea
navigation.panel: paletteView.navigationPanel
//! NOTE Just Up/Down navigation now
navigation.row: paletteView.ncells + paletteView.navigationRow
@ -390,7 +394,6 @@ GridView {
moreButton.forceActiveFocus();
} else {
currentIndex = 0;
currentItem.forceActiveFocus();
}
}
@ -399,7 +402,6 @@ GridView {
moreButton.forceActiveFocus();
} else {
currentIndex = count - 1;
currentItem.forceActiveFocus();
}
}
@ -408,7 +410,6 @@ GridView {
const matchedIndexList = paletteModel.match(modelIndex, Qt.ToolTipRole, str);
if (matchedIndexList.length) {
currentIndex = matchedIndexList[0].row;
currentItem.forceActiveFocus();
return true;
}
return false;

View file

@ -58,7 +58,6 @@ ListView {
Accessible.name: qsTrc("palette", "Palettes Tree, contains %n palette(s)", "", count)
NavigationPanel {
id: keynavTree
name: "PalettesTree"
@ -450,6 +449,8 @@ ListView {
hovered: control.hovered
text: model.display
isInVisibleArea: control.y >= paletteTree.contentY && control.y < (paletteTree.contentY + paletteTree.height)
navigationPanel: keynavTree
navigationRow: control.navigationRow
@ -523,6 +524,11 @@ ListView {
paletteController: paletteTree.paletteController
selectionModel: paletteSelectionModel
isInVisibleArea: {
var mainPaletteBottom = control.y + mainPalette.height
return mainPaletteBottom >= paletteTree.contentY && mainPaletteBottom < (paletteTree.contentY + paletteTree.height)
}
showMoreButton: !filter.length
onMoreButtonClicked: control.togglePopup(btn);

View file

@ -37,6 +37,8 @@ Item {
property bool custom: false
property bool unresolved: false
property bool isInVisibleArea: true
property PaletteProvider paletteProvider
property var modelIndex: null
@ -128,7 +130,7 @@ Item {
z: 1000
visible: root.expanded || root.hovered || isMenuOpened || navigation.active
visible: (root.expanded || root.hovered || isMenuOpened || navigation.active) && root.isInVisibleArea
navigation.panel: root.navigationPanel
navigation.row: root.navigationRow