mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
homescreens/halcyon: Use TapHandler and HoverHandler for list delegate
This commit is contained in:
parent
824a9f33ed
commit
d3a0aa4852
1 changed files with 22 additions and 16 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.4
|
import QtQuick 2.15
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtQuick.Controls 2.3 as Controls
|
import QtQuick.Controls 2.3 as Controls
|
||||||
import QtGraphicalEffects 1.6
|
import QtGraphicalEffects 1.6
|
||||||
|
|
@ -17,7 +17,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
|
||||||
|
|
||||||
MouseArea {
|
Item {
|
||||||
id: delegate
|
id: delegate
|
||||||
|
|
||||||
property alias iconItem: icon
|
property alias iconItem: icon
|
||||||
|
|
@ -49,23 +49,29 @@ MouseArea {
|
||||||
dialogLoader.item.open();
|
dialogLoader.item.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
hoverEnabled: true
|
function launchApp() {
|
||||||
onPressAndHold: openContextMenu()
|
if (application.running) {
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
delegate.launch(0, 0, "", applicationName, applicationStorageId);
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
if (mouse.button === Qt.RightButton) {
|
|
||||||
openContextMenu();
|
|
||||||
} else {
|
} else {
|
||||||
// launch app
|
delegate.launch(delegate.x + (PlasmaCore.Units.smallSpacing * 2), delegate.y + (PlasmaCore.Units.smallSpacing * 2), icon.source, applicationName, applicationStorageId);
|
||||||
if (application.running) {
|
|
||||||
delegate.launch(0, 0, "", applicationName, applicationStorageId);
|
|
||||||
} else {
|
|
||||||
delegate.launch(delegate.x + (PlasmaCore.Units.smallSpacing * 2), delegate.y + (PlasmaCore.Units.smallSpacing * 2), icon.source, applicationName, applicationStorageId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TapHandler {
|
||||||
|
id: tapHandler
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
|
||||||
|
onLongPressed: delegate.openContextMenu()
|
||||||
|
onTapped: (eventPoint.event.button === Qt.RightButton) ? delegate.openContextMenu() : delegate.launchApp();
|
||||||
|
|
||||||
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||||
|
}
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
id: hoverHandler
|
||||||
|
acceptedPointerTypes: PointerDevice.GenericPointer | PointerDevice.Cursor | PointerDevice.Pen
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: dialogLoader
|
id: dialogLoader
|
||||||
active: false
|
active: false
|
||||||
|
|
@ -88,7 +94,7 @@ MouseArea {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: height / 2
|
radius: height / 2
|
||||||
color: delegate.pressed ? Qt.rgba(255, 255, 255, 0.2) : (delegate.containsMouse ? Qt.rgba(255, 255, 255, 0.1) : "transparent")
|
color: tapHandler.pressed ? Qt.rgba(255, 255, 255, 0.2) : (hoverHandler.hovered ? Qt.rgba(255, 255, 255, 0.1) : "transparent")
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue