homescreens/halcyon: Don't have hovered state

This commit is contained in:
Devin Lin 2022-07-12 21:02:04 -04:00
parent 88417b3e0a
commit 92d9295995
3 changed files with 65 additions and 23 deletions

View file

@ -123,16 +123,63 @@ Item {
property bool inDrag: false property bool inDrag: false
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: (mouse.button === Qt.RightButton) ? openContextMenu() : launch();
onReleased: { onReleased: {
delegate.Drag.drop(); delegate.Drag.drop();
inDrag = false; inDrag = false;
} }
onPressAndHold: { inDrag = true; openContextMenu() } onPressAndHold: { inDrag = true; openContextMenu() }
drag.target: inDrag ? delegate : undefined 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 { HoverHandler {
id: hoverHandler id: hoverHandler
acceptedDevices: PointerDevice.Mouse acceptedDevices: PointerDevice.Mouse
@ -142,7 +189,7 @@ Item {
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: height / 2 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 { RowLayout {

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 { MouseArea {
id: delegate id: delegate
width: GridView.view.cellWidth width: GridView.view.cellWidth
height: GridView.view.cellHeight height: GridView.view.cellHeight
@ -40,8 +40,8 @@ MobileShell.ExtendedAbstractButton {
} }
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressAndHold: openContextMenu() onPressAndHold: openContextMenu()
onRightClickPressed: openContextMenu()
function launchApp() { function launchApp() {
// launch app // launch app
@ -116,7 +116,7 @@ MobileShell.ExtendedAbstractButton {
} }
} }
// launch app handled by press animation // launch app handled by press animation
onClicked: launchAppRequested = true; onClicked: (mouse.button === Qt.RightButton) ? openContextMenu() : launchAppRequested = true
ColumnLayout { ColumnLayout {
anchors { anchors {
@ -153,7 +153,7 @@ MobileShell.ExtendedAbstractButton {
// darken effect when hovered/pressed // darken effect when hovered/pressed
layer { layer {
enabled: delegate.pressed || delegate.mouseHovered enabled: delegate.pressed
effect: ColorOverlay { effect: ColorOverlay {
color: Qt.rgba(0, 0, 0, 0.3) color: Qt.rgba(0, 0, 0, 0.3)
} }

View file

@ -64,25 +64,20 @@ Item {
} }
} }
ColumnLayout {
id: column
height: swipeView.height
width: swipeView.width
property real horizontalMargin: Math.max(Kirigami.Units.largeSpacing, root.width * 0.1 / 2)
QQC2.ScrollView { QQC2.ScrollView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
width: swipeView.width
height: swipeView.height
GridAppList { GridAppList {
id: gridAppList id: gridAppList
property real horizontalMargin: Math.max(Kirigami.Units.largeSpacing, swipeView.width * 0.1 / 2)
interactive: root.interactive interactive: root.interactive
leftMargin: column.horizontalMargin leftMargin: horizontalMargin
rightMargin: column.horizontalMargin rightMargin: horizontalMargin
effectiveContentWidth: swipeView.width - leftMargin - rightMargin effectiveContentWidth: swipeView.width - leftMargin - rightMargin
} }
} }
} }
}
} }