mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-27 14:33:08 +00:00
hapticsplugin: Only initialize dbus interface if used
Only create dbus interface when needed to avoid wasting resources.
This commit is contained in:
parent
3fd81679ed
commit
c4b49cf086
2 changed files with 6 additions and 3 deletions
|
|
@ -6,11 +6,14 @@
|
||||||
VibrationManager::VibrationManager(QObject *parent)
|
VibrationManager::VibrationManager(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{
|
{
|
||||||
const auto objectPath = QStringLiteral("/com/lomiri/hfd");
|
|
||||||
m_interface = new com::lomiri::hfd::Vibrator("com.lomiri.hfd", objectPath, QDBusConnection::systemBus(), this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VibrationManager::vibrate(int durationMs)
|
void VibrationManager::vibrate(int durationMs)
|
||||||
{
|
{
|
||||||
|
// Only create interface when needed.
|
||||||
|
if (!m_interface) {
|
||||||
|
const auto objectPath = QStringLiteral("/com/lomiri/hfd");
|
||||||
|
m_interface = new com::lomiri::hfd::Vibrator("com.lomiri.hfd", objectPath, QDBusConnection::systemBus(), this);
|
||||||
|
}
|
||||||
m_interface->vibrate(durationMs);
|
m_interface->vibrate(durationMs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,5 @@ public:
|
||||||
Q_INVOKABLE void vibrate(int durationMs);
|
Q_INVOKABLE void vibrate(int durationMs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
com::lomiri::hfd::Vibrator *m_interface;
|
com::lomiri::hfd::Vibrator *m_interface{nullptr};
|
||||||
};
|
};
|
||||||
Loading…
Reference in a new issue