on xenial help sign in
Sync AS cursor speed properties
commitf8ba2c15e60c452dc733c8fb2f2a128aea4fa502 authorMichael Terry <michael.terry@canonical.com> dateThu 21 Jan 2016, 15:04 (11 years ago) parente2e7e7d
2 files changed+65
plugins/AccountsService/AccountsService.cpp+61 plugins/AccountsService/AccountsService.h+4
plugins/AccountsService/AccountsService.cpp+61
@@ -19,6 +19,7 @@
1919#include "AccountsService.h"
2020#include "AccountsServiceDBusAdaptor.h"
2121
22+#include <QDBusInterface>
2223#include <QFile>
2324#include <QStringList>
2425#include <QDebug>
@@ -35,6 +36,11 @@ AccountsService::AccountsService(QObject* parent, const QString &user)
3536 m_hereEnabled(false),
3637 m_hereLicensePath() // null means not set yet
3738{
39+ m_unityInput = new QDBusInterface(QStringLiteral("com.canonical.Unity.Input"),
40+ QStringLiteral("/com/canonical/Unity/Input"),
41+ QStringLiteral("com.canonical.Unity.Input"),
42+ QDBusConnection::SM_BUSNAME(), this);
43+
3844 connect(m_service, &AccountsServiceDBusAdaptor::propertiesChanged, this, &AccountsService::onPropertiesChanged);
3945 connect(m_service, &AccountsServiceDBusAdaptor::maybeChanged, this, &AccountsService::onMaybeChanged);
4046
@@ -58,6 +64,8 @@ void AccountsService::setUser(const QString &user)
5864 updateEnableLauncherWhileLocked(false);
5965 updateEnableIndicatorsWhileLocked(false);
6066 updateBackgroundFile(false);
67+ updateMouseCursorSpeed();
68+ updateTouchpadCursorSpeed();
6169 updateStatsWelcomeScreen(false);
6270 updatePasswordDisplayHint(false);
6371 updateFailedLogins(false);
@@ -246,6 +254,52 @@ void AccountsService::updateBackgroundFile(bool async)
246254 }
247255}
248256
257+void AccountsService::updateMouseCursorSpeed()
258+{
259+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
260+ QStringLiteral("com.ubuntu.AccountsService.Input"),
261+ QStringLiteral("MouseCursorSpeed"));
262+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
263+
264+ connect(watcher, &QDBusPendingCallWatcher::finished,
265+ this, [this](QDBusPendingCallWatcher* watcher) {
266+
267+ QDBusPendingReply<QVariant> reply = *watcher;
268+ watcher->deleteLater();
269+ if (reply.isError()) {
270+ qWarning() << "Failed to get 'MouseCursorSpeed' property - " << reply.error().message();
271+ return;
272+ }
273+
274+ // Merely proxy this along to USC. We don't care about keeping a copy
275+ // or exporting it internally.
276+ m_unityInput->asyncCall(QStringLiteral("setMouseCursorSpeed"), reply.value());
277+ });
278+}
279+
280+void AccountsService::updateTouchpadCursorSpeed()
281+{
282+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
283+ QStringLiteral("com.ubuntu.AccountsService.Input"),
284+ QStringLiteral("TouchpadCursorSpeed"));
285+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
286+
287+ connect(watcher, &QDBusPendingCallWatcher::finished,
288+ this, [this](QDBusPendingCallWatcher* watcher) {
289+
290+ QDBusPendingReply<QVariant> reply = *watcher;
291+ watcher->deleteLater();
292+ if (reply.isError()) {
293+ qWarning() << "Failed to get 'TouchpadCursorSpeed' property - " << reply.error().message();
294+ return;
295+ }
296+
297+ // Merely proxy this along to USC. We don't care about keeping a copy
298+ // or exporting it internally.
299+ m_unityInput->asyncCall(QStringLiteral("setTouchpadCursorSpeed"), reply.value());
300+ });
301+}
302+
249303void AccountsService::updateStatsWelcomeScreen(bool async)
250304{
251305 QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
@@ -423,6 +477,13 @@ void AccountsService::onPropertiesChanged(const QString &user, const QString &in
423477 if (changed.contains(QStringLiteral("FailedLogins"))) {
424478 updateFailedLogins();
425479 }
480+ } else if (interface == QLatin1String("com.ubuntu.AccountsService.Input")) {
481+ if (changed.contains(QStringLiteral("MouseCursorSpeed"))) {
482+ updateMouseCursorSpeed();
483+ }
484+ if (changed.contains(QStringLiteral("TouchpadCursorSpeed"))) {
485+ updateTouchpadCursorSpeed();
486+ }
426487 } else if (interface == QLatin1String("com.ubuntu.touch.AccountsService.SecurityPrivacy")) {
427488 if (changed.contains(QStringLiteral("StatsWelcomeScreen"))) {
428489 updateStatsWelcomeScreen();
plugins/AccountsService/AccountsService.h+4
@@ -23,6 +23,7 @@
2323#include <QString>
2424
2525class AccountsServiceDBusAdaptor;
26+class QDBusInterface;
2627
2728class AccountsService: public QObject
2829{
@@ -112,6 +113,8 @@ private:
112113 void updateEnableLauncherWhileLocked(bool async = true);
113114 void updateEnableIndicatorsWhileLocked(bool async = true);
114115 void updateBackgroundFile(bool async = true);
116+ void updateMouseCursorSpeed();
117+ void updateTouchpadCursorSpeed();
115118 void updateStatsWelcomeScreen(bool async = true);
116119 void updatePasswordDisplayHint(bool async = true);
117120 void updateFailedLogins(bool async = true);
@@ -119,6 +122,7 @@ private:
119122 void updateHereLicensePath(bool async = true);
120123
121124 AccountsServiceDBusAdaptor *m_service;
125+ QDBusInterface *m_unityInput;
122126 QString m_user;
123127 bool m_demoEdges;
124128 bool m_enableLauncherWhileLocked;