added escape key handler (#461)
Added escape key handler for drawer2type
This commit is contained in:
parent
6dbdb85aaf
commit
b05ad2392b
7 changed files with 90 additions and 8 deletions
|
@ -25,6 +25,8 @@ Item {
|
|||
property real expandedHeight
|
||||
property real collapsedHeight: 0
|
||||
|
||||
property int depthIndex: 0
|
||||
|
||||
signal entered
|
||||
signal exited
|
||||
signal pressed(bool pressed, bool entered)
|
||||
|
@ -36,6 +38,24 @@ Item {
|
|||
signal closed
|
||||
signal opened
|
||||
|
||||
Connections {
|
||||
target: PageController
|
||||
|
||||
function onCloseTopDrawer() {
|
||||
if (depthIndex === PageController.getDrawerDepth()) {
|
||||
if (isCollapsed) {
|
||||
return
|
||||
}
|
||||
|
||||
aboutToHide()
|
||||
|
||||
drawerContent.state = root.drawerCollapsed
|
||||
depthIndex = 0
|
||||
closed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root
|
||||
|
||||
|
@ -47,6 +67,8 @@ Item {
|
|||
aboutToHide()
|
||||
|
||||
drawerContent.state = root.drawerCollapsed
|
||||
depthIndex = 0
|
||||
PageController.setDrawerDepth(PageController.getDrawerDepth() - 1)
|
||||
closed()
|
||||
}
|
||||
|
||||
|
@ -58,6 +80,8 @@ Item {
|
|||
aboutToShow()
|
||||
|
||||
drawerContent.state = root.drawerExpanded
|
||||
depthIndex = PageController.getDrawerDepth() + 1
|
||||
PageController.setDrawerDepth(depthIndex)
|
||||
opened()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ import "../Config"
|
|||
PageType {
|
||||
id: root
|
||||
|
||||
Component.onCompleted: PageController.enableTabBar(false)
|
||||
Component.onDestruction: PageController.enableTabBar(true)
|
||||
Component.onCompleted: PageController.disableControls(true)
|
||||
Component.onDestruction: PageController.disableControls(false)
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: proxyServersModel
|
||||
|
|
|
@ -14,8 +14,8 @@ import "../Config"
|
|||
PageType {
|
||||
id: root
|
||||
|
||||
Component.onCompleted: PageController.enableTabBar(false)
|
||||
Component.onDestruction: PageController.enableTabBar(true)
|
||||
Component.onCompleted: PageController.disableControls(true)
|
||||
Component.onDestruction: PageController.disableControls(false)
|
||||
|
||||
property bool isTimerRunning: true
|
||||
property string progressBarText: qsTr("Usually it takes no more than 5 minutes")
|
||||
|
|
|
@ -13,6 +13,8 @@ import "../Components"
|
|||
PageType {
|
||||
id: root
|
||||
|
||||
property bool isControlsDisabled: false
|
||||
|
||||
Connections {
|
||||
target: PageController
|
||||
|
||||
|
@ -45,6 +47,18 @@ PageType {
|
|||
stackView.pop()
|
||||
}
|
||||
}
|
||||
|
||||
function onDisableControls(disabled) {
|
||||
isControlsDisabled = disabled
|
||||
}
|
||||
|
||||
function onEscapePressed() {
|
||||
if (isControlsDisabled || busyIndicator.visible) {
|
||||
return
|
||||
}
|
||||
|
||||
PageController.closePage()
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
|
@ -38,8 +38,8 @@ PageType {
|
|||
tabBar.enabled = !visible
|
||||
}
|
||||
|
||||
function onEnableTabBar(enabled) {
|
||||
tabBar.enabled = enabled
|
||||
function onDisableControls(disabled) {
|
||||
tabBar.enabled = !disabled
|
||||
}
|
||||
|
||||
function onClosePage() {
|
||||
|
@ -70,6 +70,21 @@ PageType {
|
|||
tabBarStackView.pop()
|
||||
}
|
||||
}
|
||||
|
||||
function onEscapePressed() {
|
||||
if (!tabBar.enabled || busyIndicator.visible) {
|
||||
return
|
||||
}
|
||||
|
||||
var pageName = tabBarStackView.currentItem.objectName
|
||||
if ((pageName === PageController.getPagePath(PageEnum.PageShare)) ||
|
||||
(pageName === PageController.getPagePath(PageEnum.PageSettings))) {
|
||||
PageController.goToPageHome()
|
||||
tabBar.previousIndex = 0
|
||||
} else {
|
||||
PageController.closePage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue