| 1 | /* |
|---|---|
| 2 | * SPDX-FileCopyrightText: 2024 Nathan Misner <nathan@infochunk.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #include "smoothscrollwatcher.h" |
| 8 | |
| 9 | #ifdef KIRIGAMI_ENABLE_DBUS |
| 10 | #include <QDBusConnection> |
| 11 | #endif |
| 12 | |
| 13 | #include "kirigamiplatform_logging.h" |
| 14 | |
| 15 | namespace Kirigami |
| 16 | { |
| 17 | namespace Platform |
| 18 | { |
| 19 | Q_GLOBAL_STATIC(SmoothScrollWatcher, smoothScrollWatcherSelf) |
| 20 | |
| 21 | SmoothScrollWatcher::SmoothScrollWatcher(QObject *parent) |
| 22 | : QObject(parent) |
| 23 | { |
| 24 | #ifdef KIRIGAMI_ENABLE_DBUS |
| 25 | QDBusConnection::sessionBus().connect(QStringLiteral(""), |
| 26 | QStringLiteral("/SmoothScroll"), |
| 27 | QStringLiteral("org.kde.SmoothScroll"), |
| 28 | QStringLiteral("notifyChange"), |
| 29 | receiver: this, |
| 30 | SLOT(setEnabled(bool))); |
| 31 | #endif |
| 32 | m_enabled = true; |
| 33 | } |
| 34 | |
| 35 | SmoothScrollWatcher::~SmoothScrollWatcher() = default; |
| 36 | |
| 37 | bool SmoothScrollWatcher::enabled() const |
| 38 | { |
| 39 | return m_enabled; |
| 40 | } |
| 41 | |
| 42 | SmoothScrollWatcher *SmoothScrollWatcher::self() |
| 43 | { |
| 44 | return smoothScrollWatcherSelf(); |
| 45 | } |
| 46 | |
| 47 | void SmoothScrollWatcher::setEnabled(bool value) |
| 48 | { |
| 49 | m_enabled = value; |
| 50 | Q_EMIT enabledChanged(value); |
| 51 | } |
| 52 | |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | #include "moc_smoothscrollwatcher.cpp" |
| 57 |
