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,7 +64,7 @@ Item {
Connections { Connections {
target: actionDrawer target: actionDrawer
onOpenedChanged: { function onOpenedChanged() {
if (!actionDrawer.opened) { if (!actionDrawer.opened) {
resetSwipeView(); resetSwipeView();
} }

View file

@ -17,7 +17,6 @@ import org.kde.phone.homescreen.halcyon 1.0 as Halcyon
GridView { GridView {
id: root id: root
layer.enabled: true // cache
required property var searchWidget required property var searchWidget
signal openConfigureRequested() 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 import org.kde.kirigami 2.19 as Kirigami
MobileShell.ExtendedAbstractButton { Item {
id: delegate id: delegate
width: GridView.view.cellWidth width: GridView.view.cellWidth
height: GridView.view.cellHeight height: GridView.view.cellHeight
@ -39,11 +39,6 @@ MobileShell.ExtendedAbstractButton {
dialogLoader.item.open(); dialogLoader.item.open();
} }
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onPressAndHold: openContextMenu()
onRightClickPressed: openContextMenu()
function launchApp() { function launchApp() {
// launch app // launch app
if (application.running) { 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 { Loader {
id: dialogLoader id: dialogLoader
active: false active: false
@ -89,7 +110,7 @@ MobileShell.ExtendedAbstractButton {
duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1 duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1
to: MobileShell.MobileShellSettings.animationsEnabled ? 0.8 : 1 to: MobileShell.MobileShellSettings.animationsEnabled ? 0.8 : 1
onFinished: { onFinished: {
if (!delegate.pressed) { if (!tapHandler.pressed) {
growAnim.restart(); 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 { ColumnLayout {
anchors { anchors {
fill: parent fill: parent
@ -154,7 +164,7 @@ MobileShell.ExtendedAbstractButton {
// darken effect when hovered/pressed // darken effect when hovered/pressed
layer { layer {
enabled: delegate.pressed || delegate.hovered enabled: tapHandler.pressed || hoverHandler.hovered
effect: ColorOverlay { effect: ColorOverlay {
color: Qt.rgba(0, 0, 0, 0.3) 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 { GridView {
id: gridView id: gridView
layer.enabled: true // caching
readonly property int reservedSpaceForLabel: metrics.height readonly property int reservedSpaceForLabel: metrics.height
required property real effectiveContentWidth required property real effectiveContentWidth