From 92d92959953990bb537f87941f06bb41b7bf51e6 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Tue, 12 Jul 2022 21:02:04 -0400 Subject: [PATCH] homescreens/halcyon: Don't have hovered state --- .../contents/ui/FavoritesAppDelegate.qml | 53 +++++++++++++++++-- .../package/contents/ui/GridAppDelegate.qml | 8 +-- .../package/contents/ui/HomeScreen.qml | 27 ++++------ 3 files changed, 65 insertions(+), 23 deletions(-) diff --git a/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml b/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml index 263dee4b..82b523af 100644 --- a/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml +++ b/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml @@ -123,16 +123,63 @@ Item { property bool inDrag: false + cursorShape: Qt.PointingHandCursor acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: (mouse.button === Qt.RightButton) ? openContextMenu() : launch(); onReleased: { delegate.Drag.drop(); inDrag = false; } onPressAndHold: { inDrag = true; openContextMenu() } - drag.target: inDrag ? delegate : undefined + // grow/shrink animation + property real zoomScale: 1 + transform: Scale { + origin.x: mouseArea.width / 2; + origin.y: mouseArea.height / 2; + xScale: mouseArea.zoomScale + yScale: mouseArea.zoomScale + } + + property bool launchAppRequested: false + + NumberAnimation on zoomScale { + id: shrinkAnim + running: false + duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1 + to: MobileShell.MobileShellSettings.animationsEnabled ? 0.95 : 1 + onFinished: { + if (!mouseArea.pressed) { + growAnim.restart(); + } + } + } + + NumberAnimation on zoomScale { + id: growAnim + running: false + duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1 + to: 1 + onFinished: { + if (mouseArea.launchAppRequested) { + delegate.launch(); + mouseArea.launchAppRequested = false; + } + } + } + + onPressedChanged: { + if (pressed) { + growAnim.stop(); + shrinkAnim.restart(); + } else if (!pressed && !shrinkAnim.running) { + growAnim.restart(); + } + } + + // launch app handled by press animation + onClicked: (mouse.button === Qt.RightButton) ? openContextMenu() : launchAppRequested = true; + HoverHandler { id: hoverHandler acceptedDevices: PointerDevice.Mouse @@ -142,7 +189,7 @@ Item { Rectangle { anchors.fill: parent radius: height / 2 - color: mouseArea.pressed ? Qt.rgba(255, 255, 255, 0.2) : (hoverHandler.hovered ? Qt.rgba(255, 255, 255, 0.1) : "transparent") + color: mouseArea.pressed ? Qt.rgba(255, 255, 255, 0.2) : "transparent" } RowLayout { diff --git a/containments/homescreens/halcyon/package/contents/ui/GridAppDelegate.qml b/containments/homescreens/halcyon/package/contents/ui/GridAppDelegate.qml index b58ef9c4..e1afa722 100644 --- a/containments/homescreens/halcyon/package/contents/ui/GridAppDelegate.qml +++ b/containments/homescreens/halcyon/package/contents/ui/GridAppDelegate.qml @@ -20,7 +20,7 @@ import org.kde.phone.homescreen.halcyon 1.0 as Halcyon import org.kde.kirigami 2.19 as Kirigami -MobileShell.ExtendedAbstractButton { +MouseArea { id: delegate width: GridView.view.cellWidth height: GridView.view.cellHeight @@ -40,8 +40,8 @@ MobileShell.ExtendedAbstractButton { } cursorShape: Qt.PointingHandCursor + acceptedButtons: Qt.LeftButton | Qt.RightButton onPressAndHold: openContextMenu() - onRightClickPressed: openContextMenu() function launchApp() { // launch app @@ -116,7 +116,7 @@ MobileShell.ExtendedAbstractButton { } } // launch app handled by press animation - onClicked: launchAppRequested = true; + onClicked: (mouse.button === Qt.RightButton) ? openContextMenu() : launchAppRequested = true ColumnLayout { anchors { @@ -153,7 +153,7 @@ MobileShell.ExtendedAbstractButton { // darken effect when hovered/pressed layer { - enabled: delegate.pressed || delegate.mouseHovered + enabled: delegate.pressed effect: ColorOverlay { color: Qt.rgba(0, 0, 0, 0.3) } diff --git a/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml b/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml index 53e177a4..9a49ac7d 100644 --- a/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml +++ b/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml @@ -64,24 +64,19 @@ Item { } } - ColumnLayout { - id: column - height: swipeView.height + QQC2.ScrollView { + Layout.fillWidth: true + Layout.fillHeight: true width: swipeView.width + height: swipeView.height - property real horizontalMargin: Math.max(Kirigami.Units.largeSpacing, root.width * 0.1 / 2) - - QQC2.ScrollView { - Layout.fillWidth: true - Layout.fillHeight: true - - GridAppList { - id: gridAppList - interactive: root.interactive - leftMargin: column.horizontalMargin - rightMargin: column.horizontalMargin - effectiveContentWidth: swipeView.width - leftMargin - rightMargin - } + GridAppList { + id: gridAppList + property real horizontalMargin: Math.max(Kirigami.Units.largeSpacing, swipeView.width * 0.1 / 2) + interactive: root.interactive + leftMargin: horizontalMargin + rightMargin: horizontalMargin + effectiveContentWidth: swipeView.width - leftMargin - rightMargin } } }