Fix need to press Esc twice to exit popups/menus
This commit is contained in:
parent
e33c202376
commit
554f5d6013
|
@ -16,7 +16,7 @@ HPage {
|
|||
contentHeight: column.childrenRect.height
|
||||
|
||||
FlickShortcuts {
|
||||
enabled: ! mainUI.debugConsole.visible
|
||||
active: ! mainUI.debugConsole.visible
|
||||
flickable: flickable
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import CppUtils 0.1
|
||||
|
||||
Menu {
|
||||
id: menu
|
||||
|
@ -31,7 +32,15 @@ Menu {
|
|||
previouslyFocused = window.activeFocusItem
|
||||
focusOnClosed = Qt.binding(() => previouslyFocused)
|
||||
}
|
||||
onClosed: if (focusOnClosed) focusOnClosed.forceActiveFocus()
|
||||
onOpened: {
|
||||
window.visibleMenus[uuid] = this
|
||||
window.visibleMenusChanged()
|
||||
}
|
||||
onClosed: {
|
||||
if (focusOnClosed) focusOnClosed.forceActiveFocus()
|
||||
delete window.visibleMenus[uuid]
|
||||
window.visibleMenusChanged()
|
||||
}
|
||||
|
||||
|
||||
property var previouslyFocused: null
|
||||
|
@ -40,4 +49,6 @@ Menu {
|
|||
// should set this to null. It will be reset to previouslyFocus when
|
||||
// the Menu is closed and opened again.
|
||||
property Item focusOnClosed: previouslyFocused
|
||||
|
||||
readonly property string uuid: CppUtils.uuid()
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import CppUtils 0.1
|
||||
|
||||
Popup {
|
||||
id: popup
|
||||
|
@ -30,7 +31,15 @@ Popup {
|
|||
}
|
||||
|
||||
onAboutToShow: previouslyFocused = window.activeFocusItem
|
||||
onClosed: if (focusOnClosed) focusOnClosed.forceActiveFocus()
|
||||
onOpened: {
|
||||
window.visiblePopups[uuid] = this
|
||||
window.visibleMenusChanged()
|
||||
}
|
||||
onClosed: {
|
||||
if (focusOnClosed) focusOnClosed.forceActiveFocus()
|
||||
delete window.visiblePopups[uuid]
|
||||
window.visibleMenusChanged()
|
||||
}
|
||||
|
||||
|
||||
property var previouslyFocused: null
|
||||
|
@ -41,4 +50,6 @@ Popup {
|
|||
|
||||
readonly property int maximumPreferredHeight:
|
||||
window.height - topMargin - bottomMargin - topInset - bottomInset
|
||||
|
||||
readonly property string uuid: CppUtils.uuid()
|
||||
}
|
||||
|
|
|
@ -3,5 +3,10 @@
|
|||
import QtQuick 2.12
|
||||
|
||||
Shortcut {
|
||||
enabled: ! window.anyPopupOrMenu && active
|
||||
context: Qt.ApplicationShortcut
|
||||
|
||||
|
||||
// TODO: use enabled + a Binding with restoreValue when switch to Qt 5.15
|
||||
property bool active: true
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ HDrawer {
|
|||
}
|
||||
|
||||
FlickShortcuts {
|
||||
enabled: debugConsole.visible
|
||||
active: debugConsole.visible
|
||||
flickable: commandsView
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ HDrawer {
|
|||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: mainUI.accountsPresent
|
||||
active: mainUI.accountsPresent
|
||||
sequences: window.settings.keys.toggleFocusMainPane
|
||||
onActivated: toggleFocus()
|
||||
}
|
||||
|
|
|
@ -38,20 +38,20 @@ Rectangle {
|
|||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: eventList.currentItem
|
||||
active: eventList.currentItem
|
||||
sequences: window.settings.keys.toggleSelectMessage
|
||||
onActivated: eventList.toggleCheck(eventList.currentIndex)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: eventList.currentItem
|
||||
active: eventList.currentItem
|
||||
sequences: window.settings.keys.selectMessagesUntilHere
|
||||
onActivated:
|
||||
eventList.checkFromLastToHere(eventList.currentIndex)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: eventList.currentItem
|
||||
active: eventList.currentItem
|
||||
sequences: window.settings.keys.debugFocusedMessage
|
||||
onActivated:
|
||||
eventList.currentItem.eventContent.debugConsoleLoader.toggle()
|
||||
|
@ -70,7 +70,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
FlickShortcuts {
|
||||
enabled: ! mainUI.debugConsole.visible
|
||||
active: ! mainUI.debugConsole.visible
|
||||
flickable: eventList
|
||||
}
|
||||
|
||||
|
|
|
@ -8,41 +8,41 @@ HQtObject {
|
|||
|
||||
|
||||
property Item flickable: parent
|
||||
property bool enabled: true
|
||||
property bool active: true
|
||||
|
||||
|
||||
HShortcut {
|
||||
enabled: root.enabled
|
||||
active: root.active
|
||||
sequences: window.settings.keys.scrollUp
|
||||
onActivated: utils.flickPages(flickable, -1 / 10)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: root.enabled
|
||||
active: root.active
|
||||
sequences: window.settings.keys.scrollDown
|
||||
onActivated: utils.flickPages(flickable, 1 / 10)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: root.enabled
|
||||
active: root.active
|
||||
sequences: window.settings.keys.scrollPageUp
|
||||
onActivated: utils.flickPages(flickable, -1)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: root.enabled
|
||||
active: root.active
|
||||
sequences: window.settings.keys.scrollPageDown
|
||||
onActivated: utils.flickPages(flickable, 1)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: root.enabled
|
||||
active: root.active
|
||||
sequences: window.settings.keys.scrollToTop
|
||||
onActivated: utils.flickToTop(flickable)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: root.enabled
|
||||
active: root.active
|
||||
sequences: window.settings.keys.scrollToBottom
|
||||
onActivated: utils.flickToBottom(flickable)
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ HQtObject {
|
|||
|
||||
|
||||
property Item container: parent
|
||||
property bool enabled: true
|
||||
property bool active: true
|
||||
|
||||
|
||||
HShortcut {
|
||||
enabled: root.enabled
|
||||
active: root.active
|
||||
sequences: window.settings.keys.previousTab
|
||||
onActivated: container.setCurrentIndex(
|
||||
utils.numberWrapAt(container.currentIndex - 1, container.count),
|
||||
|
@ -20,7 +20,7 @@ HQtObject {
|
|||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: root.enabled
|
||||
active: root.active
|
||||
sequences: window.settings.keys.nextTab
|
||||
onActivated: container.setCurrentIndex(
|
||||
utils.numberWrapAt(container.currentIndex + 1, container.count),
|
||||
|
|
|
@ -45,6 +45,12 @@ ApplicationWindow {
|
|||
|
||||
property var hideErrorTypes: new Set()
|
||||
|
||||
readonly property var visibleMenus: ({})
|
||||
readonly property var visiblePopups: ({})
|
||||
readonly property bool anyPopupOrMenu:
|
||||
Object.keys(window.visibleMenus).length > 0 ||
|
||||
Object.keys(window.visiblePopups).length > 0
|
||||
|
||||
|
||||
function saveState(obj) {
|
||||
if (! obj.saveName || ! obj.saveProperties ||
|
||||
|
|
Loading…
Reference in New Issue
Block a user