mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
mobileshell: Remove compile time QtFeedback dependency, and make it optional
This commit is contained in:
parent
c6802da477
commit
df65a0e0f2
13 changed files with 53 additions and 28 deletions
|
|
@ -46,7 +46,6 @@ find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED
|
||||||
Core
|
Core
|
||||||
Qml
|
Qml
|
||||||
Quick
|
Quick
|
||||||
Feedback
|
|
||||||
)
|
)
|
||||||
if (QT_MAJOR_VERSION STREQUAL "5")
|
if (QT_MAJOR_VERSION STREQUAL "5")
|
||||||
if (QUICK_COMPILER)
|
if (QUICK_COMPILER)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ Dependencies:
|
||||||
* Plasma Nano
|
* Plasma Nano
|
||||||
* Kirigami
|
* Kirigami
|
||||||
* Kirigami Addons
|
* Kirigami Addons
|
||||||
* Qt Feedback
|
|
||||||
|
|
||||||
To start the phone homescreen in a window, run:
|
To start the phone homescreen in a window, run:
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ target_link_libraries(mobileshellplugin
|
||||||
Qt::Qml
|
Qt::Qml
|
||||||
Qt::Gui
|
Qt::Gui
|
||||||
Qt::Quick
|
Qt::Quick
|
||||||
Qt::Feedback
|
|
||||||
KF5::ConfigWidgets # for KStandardAction
|
KF5::ConfigWidgets # for KStandardAction
|
||||||
KF5::KIOGui
|
KF5::KIOGui
|
||||||
KF5::Plasma
|
KF5::Plasma
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ void MobileShellPlugin::registerTypes(const char *uri)
|
||||||
qmlRegisterType(resolvePath("components/ExtendedAbstractButton.qml"), uri, 1, 0, "ExtendedAbstractButton");
|
qmlRegisterType(resolvePath("components/ExtendedAbstractButton.qml"), uri, 1, 0, "ExtendedAbstractButton");
|
||||||
qmlRegisterType(resolvePath("components/Flickable.qml"), uri, 1, 0, "Flickable");
|
qmlRegisterType(resolvePath("components/Flickable.qml"), uri, 1, 0, "Flickable");
|
||||||
qmlRegisterType(resolvePath("components/GridView.qml"), uri, 1, 0, "GridView");
|
qmlRegisterType(resolvePath("components/GridView.qml"), uri, 1, 0, "GridView");
|
||||||
|
qmlRegisterType(resolvePath("components/HapticsEffectLoader.qml"), uri, 1, 0, "HapticsEffectLoader");
|
||||||
qmlRegisterType(resolvePath("components/ListView.qml"), uri, 1, 0, "ListView");
|
qmlRegisterType(resolvePath("components/ListView.qml"), uri, 1, 0, "ListView");
|
||||||
qmlRegisterType(resolvePath("components/StartupFeedback.qml"), uri, 1, 0, "StartupFeedback");
|
qmlRegisterType(resolvePath("components/StartupFeedback.qml"), uri, 1, 0, "StartupFeedback");
|
||||||
qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator");
|
qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator");
|
||||||
|
|
|
||||||
|
|
@ -55,13 +55,17 @@ QuickSettingsDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileShell.HapticsEffectLoader {
|
||||||
|
id: haptics
|
||||||
|
}
|
||||||
|
|
||||||
contentItem: MouseArea {
|
contentItem: MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
|
||||||
onPressed: MobileShell.ShellUtil.buttonVibrate()
|
onPressed: haptics.buttonVibrate()
|
||||||
onClicked: root.delegateClick()
|
onClicked: root.delegateClick()
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
MobileShell.ShellUtil.buttonVibrate();
|
haptics.buttonVibrate();
|
||||||
root.delegatePressAndHold();
|
root.delegatePressAndHold();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,13 +52,17 @@ QuickSettingsDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileShell.HapticsEffectLoader {
|
||||||
|
id: haptics
|
||||||
|
}
|
||||||
|
|
||||||
contentItem: MouseArea {
|
contentItem: MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
|
||||||
onPressed: MobileShell.ShellUtil.buttonVibrate();
|
onPressed: haptics.buttonVibrate();
|
||||||
onClicked: root.delegateClick()
|
onClicked: root.delegateClick()
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
MobileShell.ShellUtil.buttonVibrate();
|
haptics.buttonVibrate();
|
||||||
root.delegatePressAndHold();
|
root.delegatePressAndHold();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
source: "qrc:/HapticsEffectWrapper.qml"
|
||||||
|
property bool valid: item !== null
|
||||||
|
|
||||||
|
function buttonVibrate() {
|
||||||
|
if (valid && MobileShell.MobileShellSettings.vibrationsEnabled) {
|
||||||
|
item.intensity = MobileShell.MobileShellSettings.vibrationIntensity;
|
||||||
|
item.duration = MobileShell.MobileShellSettings.vibrationDuration;
|
||||||
|
item.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
import QtFeedback 5.0
|
||||||
|
|
||||||
|
HapticsEffect {}
|
||||||
|
|
||||||
|
|
@ -61,12 +61,16 @@ Item {
|
||||||
|
|
||||||
property NavigationPanelButton activeButton
|
property NavigationPanelButton activeButton
|
||||||
|
|
||||||
|
MobileShell.HapticsEffectLoader {
|
||||||
|
id: haptics
|
||||||
|
}
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
startMouseX = oldMouseX = mouse.y;
|
startMouseX = oldMouseX = mouse.y;
|
||||||
startMouseY = oldMouseY = mouse.y;
|
startMouseY = oldMouseY = mouse.y;
|
||||||
activeButton = icons.childAt(mouse.x, mouse.y);
|
activeButton = icons.childAt(mouse.x, mouse.y);
|
||||||
if (activeButton && activeButton.enabled) {
|
if (activeButton && activeButton.enabled) {
|
||||||
MobileShell.ShellUtil.buttonVibrate();
|
haptics.buttonVibrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@
|
||||||
<file>qml/components/ExtendedAbstractButton.qml</file>
|
<file>qml/components/ExtendedAbstractButton.qml</file>
|
||||||
<file>qml/components/Flickable.qml</file>
|
<file>qml/components/Flickable.qml</file>
|
||||||
<file>qml/components/GridView.qml</file>
|
<file>qml/components/GridView.qml</file>
|
||||||
|
<file>qml/components/HapticsEffectLoader.qml</file>
|
||||||
|
<file>qml/components/HapticsEffectWrapper.qml</file>
|
||||||
<file>qml/components/ListView.qml</file>
|
<file>qml/components/ListView.qml</file>
|
||||||
<file>qml/components/MarqueeLabel.qml</file>
|
<file>qml/components/MarqueeLabel.qml</file>
|
||||||
<file>qml/components/StartupFeedback.qml</file>
|
<file>qml/components/StartupFeedback.qml</file>
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ 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);
|
||||||
|
|
||||||
|
|
@ -133,12 +132,3 @@ void ShellUtil::clearLaunchingApp()
|
||||||
m_launchingApp = nullptr;
|
m_launchingApp = nullptr;
|
||||||
Q_EMIT isLaunchingAppChanged();
|
Q_EMIT isLaunchingAppChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellUtil::buttonVibrate()
|
|
||||||
{
|
|
||||||
if (MobileShellSettings::self()->vibrationsEnabled()) {
|
|
||||||
m_hapticsEffect->setDuration(MobileShellSettings::self()->vibrationDuration());
|
|
||||||
m_hapticsEffect->setIntensity(MobileShellSettings::self()->vibrationIntensity());
|
|
||||||
m_hapticsEffect->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QFeedbackHapticsEffect>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
|
|
||||||
|
|
@ -82,11 +81,6 @@ public:
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void clearLaunchingApp();
|
Q_INVOKABLE void clearLaunchingApp();
|
||||||
|
|
||||||
/**
|
|
||||||
* Initiates a vibration event, meant for a button.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void buttonVibrate();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void isSystem24HourFormatChanged();
|
void isSystem24HourFormatChanged();
|
||||||
void isLaunchingAppChanged();
|
void isLaunchingAppChanged();
|
||||||
|
|
@ -99,6 +93,4 @@ private:
|
||||||
|
|
||||||
KIO::ApplicationLauncherJob *m_launchingApp;
|
KIO::ApplicationLauncherJob *m_launchingApp;
|
||||||
QVector<qint64> m_launchingAppPids;
|
QVector<qint64> m_launchingAppPids;
|
||||||
|
|
||||||
std::unique_ptr<QFeedbackHapticsEffect> m_hapticsEffect;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,10 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileShell.HapticsEffectLoader {
|
||||||
|
id: haptics
|
||||||
|
}
|
||||||
|
|
||||||
RectangularGlow {
|
RectangularGlow {
|
||||||
anchors.topMargin: 1
|
anchors.topMargin: 1
|
||||||
anchors.fill: passwordBar
|
anchors.fill: passwordBar
|
||||||
|
|
@ -147,7 +151,7 @@ Rectangle {
|
||||||
|
|
||||||
onPressedChanged: {
|
onPressedChanged: {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
MobileShell.ShellUtil.buttonVibrate();
|
haptics.buttonVibrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +166,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
if (modelData === "R") {
|
if (modelData === "R") {
|
||||||
MobileShell.ShellUtil.buttonVibrate();
|
haptics.buttonVibrate();
|
||||||
passwordBar.clear();
|
passwordBar.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue