added hovering effect of button

This commit is contained in:
ronoaer
2023-10-19 11:22:52 +08:00
parent 366e27a321
commit 6ec773079c
3 changed files with 48 additions and 11 deletions
@@ -31,7 +31,7 @@ Drawer2Type {
height: parent.height height: parent.height
contentHeight: parent.height * 0.9 contentHeight: parent.height * 0.9
onClosed: { onDrawerClosed: {
configExtension = ".vpn" configExtension = ".vpn"
configCaption = qsTr("Save AmneziaVPN config") configCaption = qsTr("Save AmneziaVPN config")
configFileName = "amnezia_config" configFileName = "amnezia_config"
+23 -9
View File
@@ -22,6 +22,11 @@ Item {
} }
signal drawerClosed signal drawerClosed
signal collapsedEntered
signal collapsedExited
signal collapsedEnter
signal collapsedPressChanged
visible: false visible: false
@@ -41,6 +46,7 @@ Item {
property int collapsedHeight: 0 property int collapsedHeight: 0
property bool fullMouseAreaVisible: true property bool fullMouseAreaVisible: true
property MouseArea drawerDragArea: dragArea
state: "closed" state: "closed"
@@ -165,6 +171,18 @@ Item {
root.state = "expanded" root.state = "expanded"
} }
} }
onExited: {
collapsedExited()
}
onEntered: {
collapsedEnter()
}
onPressedChanged: {
collapsedPressChanged()
}
} }
} }
@@ -306,7 +324,6 @@ Item {
} }
function open() { function open() {
//if (root.visible && !root.closed()) {
if (root.opened()) { if (root.opened()) {
return return
} }
@@ -341,6 +358,11 @@ Item {
root.state = "collapsed" root.state = "collapsed"
} }
function expand() {
draw2Background.color = "#90000000"
root.state = "expanded"
}
function visibledMouseArea(visbile) { function visibledMouseArea(visbile) {
fullMouseArea.visible = visbile fullMouseArea.visible = visbile
@@ -374,14 +396,6 @@ Item {
close() close()
} }
if (root.expanded()) {
if (needCloseButton) {
PageController.drawerClose()
}
collapse()
}
} }
} }
} }
+24 -1
View File
@@ -122,7 +122,7 @@ PageType {
ColumnLayout { ColumnLayout {
id: content id: collapsedButtonContent
parent: buttonContent.contentParent parent: buttonContent.contentParent
@@ -178,6 +178,12 @@ PageType {
PropertyAnimation { duration: 200 } PropertyAnimation { duration: 200 }
} }
} }
onClicked: {
if (buttonContent.collapsed()) {
buttonContent.expand()
}
}
} }
} }
@@ -424,5 +430,22 @@ PageType {
} }
} }
} }
onCollapsedEnter: {
collapsedButtonChevron.backgroundColor = collapsedButtonChevron.hoveredColor
collapsedButtonHeader.opacity = 0.8
}
onCollapsedExited: {
collapsedButtonChevron.backgroundColor = collapsedButtonChevron.defaultColor
collapsedButtonHeader.opacity = 1
}
onCollapsedPressChanged: {
collapsedButtonChevron.backgroundColor = buttonContent.drawerDragArea.pressed ?
collapsedButtonChevron.pressedColor : buttonContent.drawerDragArea.entered ?
collapsedButtonChevron.hoveredColor : collapsedButtonChevron.defaultColor
collapsedButtonHeader.opacity = 0.7
}
} }
} }