From 8e3e05ddeabdc920f5af9e4c16827fb5d26b740b Mon Sep 17 00:00:00 2001 From: Micah Stanley Date: Thu, 1 May 2025 09:04:38 +0000 Subject: [PATCH] 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 --- .../folio/package/contents/ui/AppDrawerGrid.qml | 5 +++++ .../folio/package/contents/ui/FavouritesBar.qml | 11 ++++++++++- .../folio/package/contents/ui/FolderView.qml | 5 +++++ .../folio/package/contents/ui/HomeScreenPage.qml | 7 +++++++ .../folio/package/contents/ui/HomeScreenPages.qml | 10 +++++++++- .../package/contents/ui/settings/AppletListViewer.qml | 5 +++++ 6 files changed, 41 insertions(+), 2 deletions(-) diff --git a/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml b/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml index a406a4f9..d526222b 100644 --- a/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml +++ b/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml @@ -78,6 +78,10 @@ MobileShell.GridView { id: velocityCalculator } + MobileShell.HapticsEffect { + id: haptics + } + model: folio.ApplicationListSearchModel delegate: AppDelegate { @@ -96,6 +100,7 @@ MobileShell.GridView { const mappedCoords = root.homeScreen.prepareStartDelegateDrag(model.delegate, appDelegate.delegateItem, true); folio.HomeScreenState.closeAppDrawer(); + haptics.buttonVibrate(); // we need to adjust because app drawer delegates have a different size than regular homescreen delegates const centerX = mappedCoords.x + root.cellWidth / 2; diff --git a/containments/homescreens/folio/package/contents/ui/FavouritesBar.qml b/containments/homescreens/folio/package/contents/ui/FavouritesBar.qml index f002a3ea..46a231f9 100644 --- a/containments/homescreens/folio/package/contents/ui/FavouritesBar.qml +++ b/containments/homescreens/folio/package/contents/ui/FavouritesBar.qml @@ -22,7 +22,14 @@ MouseArea { signal delegateDragRequested(var item) - onPressAndHold: folio.HomeScreenState.openSettingsView() + onPressAndHold: { + folio.HomeScreenState.openSettingsView(); + haptics.buttonVibrate(); + } + + MobileShell.HapticsEffect { + id: haptics + } Repeater { id: repeater @@ -121,6 +128,7 @@ MouseArea { ); contextMenu.open(); + haptics.buttonVibrate(); } onPressAndHoldReleased: { @@ -196,6 +204,7 @@ MouseArea { ); contextMenu.open(); + haptics.buttonVibrate(); } onPressAndHoldReleased: { diff --git a/containments/homescreens/folio/package/contents/ui/FolderView.qml b/containments/homescreens/folio/package/contents/ui/FolderView.qml index 54ffdf31..58b2012f 100644 --- a/containments/homescreens/folio/package/contents/ui/FolderView.qml +++ b/containments/homescreens/folio/package/contents/ui/FolderView.qml @@ -26,6 +26,10 @@ Folio.DelegateTouchArea { property Folio.FolioApplicationFolder folder: folio.HomeScreenState.currentFolder + MobileShell.HapticsEffect { + id: haptics + } + onClicked: close(); function close() { @@ -260,6 +264,7 @@ Folio.DelegateTouchArea { ); contextMenu.open(); + haptics.buttonVibrate(); } onPressAndHoldReleased: { diff --git a/containments/homescreens/folio/package/contents/ui/HomeScreenPage.qml b/containments/homescreens/folio/package/contents/ui/HomeScreenPage.qml index 6aa6e9bb..9eb8218a 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeScreenPage.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeScreenPage.qml @@ -24,6 +24,10 @@ Item { property var pageModel property var homeScreen + MobileShell.HapticsEffect { + id: haptics + } + // background when in settings view (for rearranging pages) Rectangle { id: settingsViewBackground @@ -189,6 +193,7 @@ Item { ); contextMenu.open(); + haptics.buttonVibrate(); } onPressAndHoldReleased: { // cancel the event if the delegate is not dragged @@ -272,6 +277,7 @@ Item { ); contextMenu.open(); + haptics.buttonVibrate(); } onPressAndHoldReleased: { @@ -349,6 +355,7 @@ Item { ); widgetConfig.startOpen(); + haptics.buttonVibrate(); } onPressReleased: { diff --git a/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml b/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml index 17ba858f..7a8715c5 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml @@ -6,6 +6,7 @@ import QtQuick.Window import QtQuick.Layouts 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.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 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 { model: folio.PageListModel diff --git a/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml b/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml index 518d25bf..e6e3a307 100644 --- a/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml +++ b/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml @@ -30,6 +30,10 @@ MouseArea { Kirigami.Theme.inherit: false Kirigami.Theme.colorSet: Kirigami.Theme.Complementary + MobileShell.HapticsEffect { + id: haptics + } + Rectangle { anchors.fill: parent color: Qt.rgba(0, 0, 0, 0.7) @@ -119,6 +123,7 @@ MouseArea { onPressAndHold: { root.requestClose(); folio.HomeScreenState.closeSettingsView(); + haptics.buttonVibrate(); let mappedCoords = root.homeScreen.prepareStartDelegateDrag(null, delegate, true); const widthOffset = folio.HomeScreenState.pageCellWidth / 2;