homescreens/halcyon: Turn off layer, and use handlers for grid delegates

This commit is contained in:
Devin Lin 2022-06-28 12:31:18 -04:00
parent d3a0aa4852
commit ba597e1de2
4 changed files with 31 additions and 23 deletions

View file

@ -64,8 +64,8 @@ Item {
Connections {
target: actionDrawer
onOpenedChanged: {
if(!actionDrawer.opened) {
function onOpenedChanged() {
if (!actionDrawer.opened) {
resetSwipeView();
}
}

View file

@ -17,7 +17,6 @@ import org.kde.phone.homescreen.halcyon 1.0 as Halcyon
GridView {
id: root
layer.enabled: true // cache
required property var searchWidget
signal openConfigureRequested()

View file

@ -20,7 +20,7 @@ import org.kde.phone.homescreen.halcyon 1.0 as Halcyon
import org.kde.kirigami 2.19 as Kirigami
MobileShell.ExtendedAbstractButton {
Item {
id: delegate
width: GridView.view.cellWidth
height: GridView.view.cellHeight
@ -39,11 +39,6 @@ MobileShell.ExtendedAbstractButton {
dialogLoader.item.open();
}
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onPressAndHold: openContextMenu()
onRightClickPressed: openContextMenu()
function launchApp() {
// launch app
if (application.running) {
@ -53,6 +48,32 @@ MobileShell.ExtendedAbstractButton {
}
}
TapHandler {
id: tapHandler
acceptedButtons: Qt.LeftButton | Qt.RightButton
// launch app handled by press animation
onTapped: (eventPoint.event.button === Qt.RightButton) ? delegate.openContextMenu() : delegate.launchAppRequested = true;
onLongPressed: delegate.openContextMenu()
onPressedChanged: {
if (pressed) {
growAnim.stop();
shrinkAnim.restart();
} else if (!pressed && !shrinkAnim.running) {
growAnim.restart();
}
}
gesturePolicy: TapHandler.ReleaseWithinBounds
}
HoverHandler {
id: hoverHandler
cursorShape: Qt.PointingHandCursor
acceptedPointerTypes: PointerDevice.GenericPointer | PointerDevice.Cursor | PointerDevice.Pen
}
Loader {
id: dialogLoader
active: false
@ -89,7 +110,7 @@ MobileShell.ExtendedAbstractButton {
duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1
to: MobileShell.MobileShellSettings.animationsEnabled ? 0.8 : 1
onFinished: {
if (!delegate.pressed) {
if (!tapHandler.pressed) {
growAnim.restart();
}
}
@ -108,17 +129,6 @@ MobileShell.ExtendedAbstractButton {
}
}
onPressedChanged: {
if (pressed) {
growAnim.stop();
shrinkAnim.restart();
} else if (!pressed && !shrinkAnim.running) {
growAnim.restart();
}
}
// launch app handled by press animation
onClicked: launchAppRequested = true;
ColumnLayout {
anchors {
fill: parent
@ -154,7 +164,7 @@ MobileShell.ExtendedAbstractButton {
// darken effect when hovered/pressed
layer {
enabled: delegate.pressed || delegate.hovered
enabled: tapHandler.pressed || hoverHandler.hovered
effect: ColorOverlay {
color: Qt.rgba(0, 0, 0, 0.3)
}

View file

@ -19,7 +19,6 @@ import org.kde.phone.homescreen.halcyon 1.0 as Halcyon
GridView {
id: gridView
layer.enabled: true // caching
readonly property int reservedSpaceForLabel: metrics.height
required property real effectiveContentWidth