File indexing completed on 2024-12-01 06:49:40
0001 /* 0002 SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QBindable> 0010 0011 #ifdef Q_OS_UNIX 0012 #include <QObject> 0013 0014 #include <KConfigWatcher> 0015 #endif 0016 0017 #ifdef Q_OS_WIN 0018 #include <QAbstractNativeEventFilter> 0019 #endif 0020 0021 class AnimationSpeedProvider 0022 { 0023 public: 0024 explicit AnimationSpeedProvider(); 0025 virtual ~AnimationSpeedProvider(); 0026 Q_DISABLE_COPY_MOVE(AnimationSpeedProvider) 0027 0028 QBindable<double> animationSpeedModifier() const; 0029 0030 protected: 0031 QProperty<double> m_animationSpeedModifier{1.0}; 0032 }; 0033 0034 #ifdef Q_OS_UNIX 0035 class KConfigAnimationSpeedProvider : public QObject, public AnimationSpeedProvider 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 explicit KConfigAnimationSpeedProvider(QObject *parent = nullptr); 0041 ~KConfigAnimationSpeedProvider() override; 0042 Q_DISABLE_COPY_MOVE(KConfigAnimationSpeedProvider) 0043 0044 private: 0045 KConfigWatcher::Ptr m_animationSpeedWatcher; 0046 }; 0047 #endif 0048 0049 #ifdef Q_OS_WIN 0050 class WindowsAnimationSpeedProvider : public QAbstractNativeEventFilter, public AnimationSpeedProvider 0051 { 0052 public: 0053 explicit WindowsAnimationSpeedProvider(); 0054 ~WindowsAnimationSpeedProvider() override; 0055 Q_DISABLE_COPY_MOVE(WindowsAnimationSpeedProvider) 0056 0057 private: 0058 void update(); 0059 bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override; 0060 }; 0061 #endif