| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 | */ |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | #include <kcoreaddons_export.h> |
| 10 | |
| 11 | #include <QObject> |
| 12 | #include <memory> |
| 13 | |
| 14 | class KSystemClockSkewNotifierPrivate; |
| 15 | |
| 16 | /*! |
| 17 | * \class KSystemClockSkewNotifier |
| 18 | * \inmodule KCoreAddons |
| 19 | * |
| 20 | * \brief The KSystemClockSkewNotifier class provides a way for monitoring system clock changes. |
| 21 | * |
| 22 | * The KSystemClockSkewNotifier class makes it possible to detect discontinuous changes to |
| 23 | * the system clock. Such changes are usually initiated by the user adjusting values |
| 24 | * in the Date and Time KCM or calls made to functions like settimeofday(). |
| 25 | * |
| 26 | * \since 6.15 |
| 27 | */ |
| 28 | class KCOREADDONS_EXPORT KSystemClockSkewNotifier : public QObject |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) |
| 32 | |
| 33 | public: |
| 34 | explicit KSystemClockSkewNotifier(QObject *parent = nullptr); |
| 35 | ~KSystemClockSkewNotifier() override; |
| 36 | |
| 37 | /*! |
| 38 | * Returns \c true if the notifier is active; otherwise returns \c false. |
| 39 | */ |
| 40 | bool isActive() const; |
| 41 | |
| 42 | /*! |
| 43 | * Sets the active status of the clock skew notifier to \a active. |
| 44 | * |
| 45 | * The skewed() signal won't be emitted while the notifier is inactive. |
| 46 | * |
| 47 | * The notifier is inactive by default. |
| 48 | * |
| 49 | * \sa activeChanged() |
| 50 | */ |
| 51 | void setActive(bool active); |
| 52 | |
| 53 | Q_SIGNALS: |
| 54 | /*! |
| 55 | * This signal is emitted whenever the active property is changed. |
| 56 | */ |
| 57 | void activeChanged(); |
| 58 | |
| 59 | /*! |
| 60 | * This signal is emitted whenever the system clock is changed. |
| 61 | */ |
| 62 | void skewed(); |
| 63 | |
| 64 | private: |
| 65 | std::unique_ptr<KSystemClockSkewNotifierPrivate> d; |
| 66 | }; |
| 67 | |