Folio: Add Haptic Feedback

This merge request adds haptic feedback to the folio home screen when:
- Pressing and holding on an app icon
- Pressing and holding on an widget
- Pressing and holding for opening the settings component
This commit is contained in:
Micah Stanley 2025-05-01 09:04:38 +00:00 committed by Devin Lin
parent be730d36db
commit 8e3e05ddea
6 changed files with 41 additions and 2 deletions

View file

@ -78,6 +78,10 @@ MobileShell.GridView {
id: velocityCalculator id: velocityCalculator
} }
MobileShell.HapticsEffect {
id: haptics
}
model: folio.ApplicationListSearchModel model: folio.ApplicationListSearchModel
delegate: AppDelegate { delegate: AppDelegate {
@ -96,6 +100,7 @@ MobileShell.GridView {
const mappedCoords = root.homeScreen.prepareStartDelegateDrag(model.delegate, appDelegate.delegateItem, true); const mappedCoords = root.homeScreen.prepareStartDelegateDrag(model.delegate, appDelegate.delegateItem, true);
folio.HomeScreenState.closeAppDrawer(); folio.HomeScreenState.closeAppDrawer();
haptics.buttonVibrate();
// we need to adjust because app drawer delegates have a different size than regular homescreen delegates // we need to adjust because app drawer delegates have a different size than regular homescreen delegates
const centerX = mappedCoords.x + root.cellWidth / 2; const centerX = mappedCoords.x + root.cellWidth / 2;

View file

@ -22,7 +22,14 @@ MouseArea {
signal delegateDragRequested(var item) signal delegateDragRequested(var item)
onPressAndHold: folio.HomeScreenState.openSettingsView() onPressAndHold: {
folio.HomeScreenState.openSettingsView();
haptics.buttonVibrate();
}
MobileShell.HapticsEffect {
id: haptics
}
Repeater { Repeater {
id: repeater id: repeater
@ -121,6 +128,7 @@ MouseArea {
); );
contextMenu.open(); contextMenu.open();
haptics.buttonVibrate();
} }
onPressAndHoldReleased: { onPressAndHoldReleased: {
@ -196,6 +204,7 @@ MouseArea {
); );
contextMenu.open(); contextMenu.open();
haptics.buttonVibrate();
} }
onPressAndHoldReleased: { onPressAndHoldReleased: {

View file

@ -26,6 +26,10 @@ Folio.DelegateTouchArea {
property Folio.FolioApplicationFolder folder: folio.HomeScreenState.currentFolder property Folio.FolioApplicationFolder folder: folio.HomeScreenState.currentFolder
MobileShell.HapticsEffect {
id: haptics
}
onClicked: close(); onClicked: close();
function close() { function close() {
@ -260,6 +264,7 @@ Folio.DelegateTouchArea {
); );
contextMenu.open(); contextMenu.open();
haptics.buttonVibrate();
} }
onPressAndHoldReleased: { onPressAndHoldReleased: {

View file

@ -24,6 +24,10 @@ Item {
property var pageModel property var pageModel
property var homeScreen property var homeScreen
MobileShell.HapticsEffect {
id: haptics
}
// background when in settings view (for rearranging pages) // background when in settings view (for rearranging pages)
Rectangle { Rectangle {
id: settingsViewBackground id: settingsViewBackground
@ -189,6 +193,7 @@ Item {
); );
contextMenu.open(); contextMenu.open();
haptics.buttonVibrate();
} }
onPressAndHoldReleased: { onPressAndHoldReleased: {
// cancel the event if the delegate is not dragged // cancel the event if the delegate is not dragged
@ -272,6 +277,7 @@ Item {
); );
contextMenu.open(); contextMenu.open();
haptics.buttonVibrate();
} }
onPressAndHoldReleased: { onPressAndHoldReleased: {
@ -349,6 +355,7 @@ Item {
); );
widgetConfig.startOpen(); widgetConfig.startOpen();
haptics.buttonVibrate();
} }
onPressReleased: { onPressReleased: {

View file

@ -6,6 +6,7 @@ import QtQuick.Window
import QtQuick.Layouts import QtQuick.Layouts
import org.kde.plasma.components 3.0 as PC3 import org.kde.plasma.components 3.0 as PC3
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.kirigami 2.10 as Kirigami import org.kde.kirigami 2.10 as Kirigami
import org.kde.private.mobile.homescreen.folio 1.0 as Folio import org.kde.private.mobile.homescreen.folio 1.0 as Folio
@ -18,7 +19,14 @@ MouseArea {
readonly property real verticalMargin: Math.round((folio.HomeScreenState.pageHeight - folio.HomeScreenState.pageContentHeight) / 2) readonly property real verticalMargin: Math.round((folio.HomeScreenState.pageHeight - folio.HomeScreenState.pageContentHeight) / 2)
readonly property real horizontalMargin: Math.round((folio.HomeScreenState.pageWidth - folio.HomeScreenState.pageContentWidth) / 2) readonly property real horizontalMargin: Math.round((folio.HomeScreenState.pageWidth - folio.HomeScreenState.pageContentWidth) / 2)
onPressAndHold: folio.HomeScreenState.openSettingsView() MobileShell.HapticsEffect {
id: haptics
}
onPressAndHold: {
folio.HomeScreenState.openSettingsView()
haptics.buttonVibrate();
}
Repeater { Repeater {
model: folio.PageListModel model: folio.PageListModel

View file

@ -30,6 +30,10 @@ MouseArea {
Kirigami.Theme.inherit: false Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
MobileShell.HapticsEffect {
id: haptics
}
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: Qt.rgba(0, 0, 0, 0.7) color: Qt.rgba(0, 0, 0, 0.7)
@ -119,6 +123,7 @@ MouseArea {
onPressAndHold: { onPressAndHold: {
root.requestClose(); root.requestClose();
folio.HomeScreenState.closeSettingsView(); folio.HomeScreenState.closeSettingsView();
haptics.buttonVibrate();
let mappedCoords = root.homeScreen.prepareStartDelegateDrag(null, delegate, true); let mappedCoords = root.homeScreen.prepareStartDelegateDrag(null, delegate, true);
const widthOffset = folio.HomeScreenState.pageCellWidth / 2; const widthOffset = folio.HomeScreenState.pageCellWidth / 2;