From e9af47e1c7b1f81840b49894ec346e53568786e3 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 28 Feb 2021 17:05:43 -0400 Subject: [PATCH] Fix popups not being flickable by keyboard --- src/gui/Base/HFlickableColumnPage.qml | 2 +- src/gui/Base/HShortcut.qml | 3 ++- src/gui/Popups/HFlickableColumnPopup.qml | 1 + src/gui/ShortcutBundles/FlickShortcuts.qml | 7 +++++++ src/gui/ShortcutBundles/TabShortcuts.qml | 3 +++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gui/Base/HFlickableColumnPage.qml b/src/gui/Base/HFlickableColumnPage.qml index d8ca1037..31851eb1 100644 --- a/src/gui/Base/HFlickableColumnPage.qml +++ b/src/gui/Base/HFlickableColumnPage.qml @@ -15,7 +15,7 @@ HPage { property alias flickShortcuts: flickShortcuts property bool enableFlickShortcuts: - SwipeView ? SwipeView.isCurrentItem : true + SwipeView && SwipeView.view ? SwipeView.isCurrentItem : true implicitWidth: theme.controls.box.defaultWidth implicitHeight: contentHeight + implicitHeaderHeight + implicitFooterHeight diff --git a/src/gui/Base/HShortcut.qml b/src/gui/Base/HShortcut.qml index 527d4535..824303fa 100644 --- a/src/gui/Base/HShortcut.qml +++ b/src/gui/Base/HShortcut.qml @@ -6,7 +6,8 @@ import QtQuick 2.12 Shortcut { // TODO: use enabled + a Binding with restoreValue when switch to Qt 5.15 property bool active: true + property bool disableIfAnyPopupOrMenu: true - enabled: ! window.anyPopupOrMenu && active + enabled: (! window.anyPopupOrMenu || ! disableIfAnyPopupOrMenu) && active context: Qt.ApplicationShortcut } diff --git a/src/gui/Popups/HFlickableColumnPopup.qml b/src/gui/Popups/HFlickableColumnPopup.qml index ad27fb39..c5ea3e2c 100644 --- a/src/gui/Popups/HFlickableColumnPopup.qml +++ b/src/gui/Popups/HFlickableColumnPopup.qml @@ -23,6 +23,7 @@ HPopup { popup.maximumPreferredHeight, implicitHeaderHeight + implicitFooterHeight + contentHeight, ) + flickShortcuts.disableIfAnyPopupOrMenu: false Keys.onReturnPressed: popup.keyboardAccept() Keys.onEnterPressed: popup.keyboardAccept() diff --git a/src/gui/ShortcutBundles/FlickShortcuts.qml b/src/gui/ShortcutBundles/FlickShortcuts.qml index 99f01d50..46f62953 100644 --- a/src/gui/ShortcutBundles/FlickShortcuts.qml +++ b/src/gui/ShortcutBundles/FlickShortcuts.qml @@ -9,39 +9,46 @@ HQtObject { property Item flickable: parent property bool active: true + property bool disableIfAnyPopupOrMenu: true HShortcut { active: root.active + disableIfAnyPopupOrMenu: root.disableIfAnyPopupOrMenu sequences: window.settings.Keys.Scrolling.up onActivated: utils.flickPages(flickable, -1 / 10) } HShortcut { active: root.active + disableIfAnyPopupOrMenu: root.disableIfAnyPopupOrMenu sequences: window.settings.Keys.Scrolling.down onActivated: utils.flickPages(flickable, 1 / 10) } HShortcut { active: root.active + disableIfAnyPopupOrMenu: root.disableIfAnyPopupOrMenu sequences: window.settings.Keys.Scrolling.page_up onActivated: utils.flickPages(flickable, -1) } HShortcut { active: root.active + disableIfAnyPopupOrMenu: root.disableIfAnyPopupOrMenu sequences: window.settings.Keys.Scrolling.page_down onActivated: utils.flickPages(flickable, 1) } HShortcut { active: root.active + disableIfAnyPopupOrMenu: root.disableIfAnyPopupOrMenu sequences: window.settings.Keys.Scrolling.top onActivated: utils.flickToTop(flickable) } HShortcut { active: root.active + disableIfAnyPopupOrMenu: root.disableIfAnyPopupOrMenu sequences: window.settings.Keys.Scrolling.bottom onActivated: utils.flickToBottom(flickable) } diff --git a/src/gui/ShortcutBundles/TabShortcuts.qml b/src/gui/ShortcutBundles/TabShortcuts.qml index ad199e27..acc7dbfa 100644 --- a/src/gui/ShortcutBundles/TabShortcuts.qml +++ b/src/gui/ShortcutBundles/TabShortcuts.qml @@ -9,9 +9,11 @@ HQtObject { property Item container: parent property bool active: container.count > 1 + property bool disableIfAnyPopupOrMenu: true HShortcut { active: root.active + disableIfAnyPopupOrMenu: root.disableIfAnyPopupOrMenu sequences: window.settings.Keys.previous_tab onActivated: container.setCurrentIndex( utils.numberWrapAt(container.currentIndex - 1, container.count), @@ -20,6 +22,7 @@ HQtObject { HShortcut { active: root.active + disableIfAnyPopupOrMenu: root.disableIfAnyPopupOrMenu sequences: window.settings.Keys.next_tab onActivated: container.setCurrentIndex( utils.numberWrapAt(container.currentIndex + 1, container.count),