mobileshell: Use pointer for haptics

This commit is contained in:
Devin Lin 2022-11-11 11:37:23 -05:00
parent 7d3bf39750
commit 7aaa6f4cd2
2 changed files with 7 additions and 5 deletions

View file

@ -19,7 +19,6 @@
#include <QDBusPendingReply> #include <QDBusPendingReply>
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QFeedbackHapticsEffect>
#include <QFile> #include <QFile>
#include <QProcess> #include <QProcess>
@ -29,6 +28,7 @@ ShellUtil::ShellUtil(QObject *parent)
: QObject{parent} : QObject{parent}
, m_localeConfig{KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig)} , m_localeConfig{KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig)}
, m_launchingApp{nullptr} , m_launchingApp{nullptr}
, m_hapticsEffect{std::make_unique<QFeedbackHapticsEffect>()}
{ {
m_localeConfigWatcher = KConfigWatcher::create(m_localeConfig); m_localeConfigWatcher = KConfigWatcher::create(m_localeConfig);
@ -137,9 +137,8 @@ void ShellUtil::clearLaunchingApp()
void ShellUtil::buttonVibrate() void ShellUtil::buttonVibrate()
{ {
if (MobileShellSettings::self()->vibrationsEnabled()) { if (MobileShellSettings::self()->vibrationsEnabled()) {
QFeedbackHapticsEffect rumble; m_hapticsEffect->setDuration(MobileShellSettings::self()->vibrationDuration());
rumble.setDuration(MobileShellSettings::self()->vibrationDuration()); m_hapticsEffect->setIntensity(MobileShellSettings::self()->vibrationIntensity());
rumble.setIntensity(MobileShellSettings::self()->vibrationIntensity()); m_hapticsEffect->start();
rumble.start();
} }
} }

View file

@ -7,6 +7,7 @@
#pragma once #pragma once
#include <QFeedbackHapticsEffect>
#include <QObject> #include <QObject>
#include <QQuickItem> #include <QQuickItem>
@ -98,4 +99,6 @@ private:
KIO::ApplicationLauncherJob *m_launchingApp; KIO::ApplicationLauncherJob *m_launchingApp;
QVector<qint64> m_launchingAppPids; QVector<qint64> m_launchingAppPids;
std::unique_ptr<QFeedbackHapticsEffect> m_hapticsEffect;
}; };