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