Commit 2201ebd1 authored by Devin Lin's avatar Devin Lin 🎨
Browse files

Remove QtFeedback dependency

parent 3353cfc4
Pipeline #169864 passed with stage
in 1 minute and 19 seconds
......@@ -46,7 +46,6 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED
Qml
Quick
QuickCompiler
Feedback
)
if (QUICK_COMPILER)
......
......@@ -6,7 +6,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
set(mobileshellplugin_SRCS
mobileshellplugin.cpp
haptics.cpp
mobileshellsettings.cpp
quicksetting.cpp
quicksettingsmodel.cpp
......@@ -38,7 +37,6 @@ target_link_libraries(mobileshellplugin
Qt::Qml
Qt::Gui
Qt::Quick
Qt::Feedback
KF5::ConfigWidgets # for KStandardAction
KF5::KIOGui
KF5::Plasma
......
/*
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "haptics.h"
#include <QFeedbackHapticsEffect>
#include "mobileshellsettings.h"
Haptics *Haptics::self()
{
static Haptics *singleton = new Haptics();
return singleton;
}
void Haptics::buttonVibrate()
{
if (MobileShellSettings::self()->vibrationsEnabled()) {
QFeedbackHapticsEffect rumble;
rumble.setIntensity(0.5);
rumble.setDuration(100);
rumble.start();
}
}
......@@ -19,7 +19,6 @@
#include "taskswitcher/displaysmodel.h"
#include "haptics.h"
#include "mobileshellsettings.h"
#include "quicksetting.h"
#include "quicksettingsmodel.h"
......@@ -39,10 +38,6 @@ void MobileShellPlugin::registerTypes(const char *uri)
return ShellUtil::instance();
});
qmlRegisterSingletonType<Haptics>(uri, 1, 0, "Haptics", [](QQmlEngine *, QJSEngine *) -> QObject * {
return Haptics::self();
});
qmlRegisterSingletonType<MobileShellSettings>(uri, 1, 0, "MobileShellSettings", [](QQmlEngine *, QJSEngine *) -> QObject * {
return MobileShellSettings::self();
});
......@@ -82,6 +77,7 @@ void MobileShellPlugin::registerTypes(const char *uri)
// /components
qmlRegisterType(resolvePath("components/BaseItem.qml"), uri, 1, 0, "BaseItem");
qmlRegisterSingletonType(resolvePath("components/Haptics.qml"), uri, 1, 0, "Haptics");
qmlRegisterType(resolvePath("components/StartupFeedback.qml"), uri, 1, 0, "StartupFeedback");
qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator");
......
/*
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.15
import QtFeedback 5.0
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
pragma Singleton
QtObject {
id: root
function buttonVibrate() {
if (MobileShell.MobileShellSettings.vibrationsEnabled) {
if (hapticsEffect.status == Loader.Ready) {
hapticsEffect.item.intensity = 0.5;
hapticsEffect.item.duration = 100;
hapticsEffect.item.start();
}
}
}
Component.onCompleted: {
hapticsEffect.setSource("HapticsEffectWrapper.qml");
}
property var hapticsEffect: Loader {}
}
......@@ -3,16 +3,12 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
import QtQuick 2.15
import QtFeedback 5.0
#include <QObject>
class Haptics : public QObject
{
Q_OBJECT
public:
static Haptics *self();
/**
* Private component that wraps a QtFeedback HapticsEffect, so that we can optionally load
* this component.
*/
Q_INVOKABLE void buttonVibrate();
};
HapticsEffect {}
......@@ -21,6 +21,8 @@
<file>qml/actiondrawer/PortraitContentContainer.qml</file>
<file>qml/components/BaseItem.qml</file>
<file>qml/components/Haptics.qml</file>
<file>qml/components/HapticsEffectWrapper.qml</file>
<file>qml/components/MarqueeLabel.qml</file>
<file>qml/components/StartupFeedback.qml</file>
<file>qml/components/util.js</file>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment