diff options
| author | Michael Weghorn <m.weghorn@posteo.de> | 2023-07-25 11:52:32 +0200 |
|---|---|---|
| committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-07-25 14:48:26 +0200 |
| commit | f3a4b6e1d71ed40d84ef65c6626fb7eb77a13545 (patch) | |
| tree | ff58ad9852ba565497f2fe4c937834c9c762d593 | |
| parent | e320460f9793608ef79aab402b3a03dc28ba7dd5 (diff) | |
tdf#155414 kf a11y: Honor KDE Plasma setting to reduce animation
When using the kf5/kf6 VCL plugin on KDE Plasma, use the animation speed
setting to determine whether animations should be disabled, in line with
what is documented in MDN docs for Firefox using for the
"prefers-reduced-motion" CSS media feature [1] and how
kde-gtk-config maps that to the "gtk-enable-animations" setting [2].
The setting can be set as described in [2]:
> In Plasma/KDE: System Settings > Workspace Behavior -> General Behavior >
> "Animation speed" is set all the way to right to "Instant".
On top of
commit 9d68c794d67259a38de1465090f6f1e7fb588d62
Author: Patrick Luby <plubius@neooffice.org>
Date: Fri Jul 21 19:55:02 2023 -0400
tdf#155414 include system "reduce animation" preferences
, this basically implements the KF5/KDE Plasma equivalent of what that change does
for macOS.
Other than Gtk, Qt does not seem to have a general way to specify
that animations should be reduced/disabled, so evaluate
that based on the desktop environment instead, and implement
for KDE Plasma for the kf5/kf6 VCL plugin only for now, which is
probably the most common use case.
Logically, this would better fit in the qt5/qt6 VCL plugin
than the kf5/kf6 one, but do it in the KF-specific code to avoid
a dependency on KF5/KF6 libraries in qt5/qt6. (And other than
qt5/qt6, kf5/kf6 are auto-selected in Qt-based desktop environments,
so it shouldn't make much of a difference in practice.)
Another alternative - should the need aries - might be to move this
from the VCL plugin to the desktop backend (`shell/source/backends/kf5be/`
for the case of KDE Plasma 5.) and introduce a new property for that.
[1] https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
[2] https://docs.gtk.org/gtk4/property.Settings.gtk-enable-animations.html
[3] https://invent.kde.org/plasma/kde-gtk-config/-/blob/881ae01ad361a03396f7f327365f225ef87688e8/kded/gtkconfig.cpp#L205
Change-Id: I35cd6c2568a3716491581e51dfaeaf32cad454aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154888
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
| -rw-r--r-- | vcl/inc/qt5/QtFrame.hxx | 1 | ||||
| -rw-r--r-- | vcl/inc/qt5/QtInstance.hxx | 2 | ||||
| -rw-r--r-- | vcl/qt5/QtFrame.cxx | 2 | ||||
| -rw-r--r-- | vcl/unx/kf5/KFSalInstance.cxx | 23 | ||||
| -rw-r--r-- | vcl/unx/kf5/KFSalInstance.hxx | 2 |
5 files changed, 30 insertions, 0 deletions
diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index 1fd010d7c8ae..90195f55a543 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -214,6 +214,7 @@ public: virtual void SetScreenNumber(unsigned int) override; virtual void SetApplicationID(const OUString&) override; virtual void ResolveWindowHandle(SystemEnvData& rData) const override; + virtual bool GetUseReducedAnimation() const override; inline bool CallCallback(SalEvent nEvent, const void* pEvent) const; diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx index a0a2f6fa60f7..2073c8ac05d8 100644 --- a/vcl/inc/qt5/QtInstance.hxx +++ b/vcl/inc/qt5/QtInstance.hxx @@ -174,6 +174,8 @@ public: virtual css::uno::Reference<css::uno::XInterface> ImplCreateDropTarget(const SystemEnvData*) override; + // whether to reduce animations; KFSalInstance overrides this to read Plasma settings + virtual bool GetUseReducedAnimation() { return false; } void UpdateStyle(bool bFontsChanged); void* CreateGStreamerSink(const SystemChildWindow*) override; diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 08d206261b88..0bd436266714 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -1349,6 +1349,8 @@ void QtFrame::ResolveWindowHandle(SystemEnvData& rData) const rData.SetWindowHandle(static_cast<QWidget*>(rData.pWidget)->winId()); } +bool QtFrame::GetUseReducedAnimation() const { return GetQtInstance()->GetUseReducedAnimation(); } + // Drag'n'drop foo void QtFrame::registerDragSource(QtDragSource* pDragSource) diff --git a/vcl/unx/kf5/KFSalInstance.cxx b/vcl/unx/kf5/KFSalInstance.cxx index bed513167957..cc280e9d99a1 100644 --- a/vcl/unx/kf5/KFSalInstance.cxx +++ b/vcl/unx/kf5/KFSalInstance.cxx @@ -21,6 +21,8 @@ #include <utility> +#include <KConfigCore/KConfigGroup> +#include <KConfigCore/KSharedConfig> #include <QtWidgets/QApplication> #include <sal/log.hxx> @@ -40,6 +42,27 @@ KFSalInstance::KFSalInstance(std::unique_ptr<QApplication>& pQApp) pSVData->maAppData.mxToolkitName = constructToolkitID(sToolkit); } +bool KFSalInstance::GetUseReducedAnimation() +{ + // since Qt doesn not have a standard way to disable animations for the toolkit + // use the animation speed setting when on KDE Plasma, in accordance with how kde-gtk-config + // sets the Gtk setting based on that: + // https://invent.kde.org/plasma/kde-gtk-config/-/blob/881ae01ad361a03396f7f327365f225ef87688e8/kded/configvalueprovider.cpp#L239 + // (ideally, this should probably be done in the desktop backend rather than directly + // in the VCL plugin) + const OUString sDesktop = Application::GetDesktopEnvironment(); + if (sDesktop == "PLASMA5" || sDesktop == "PLASMA6") + { + KSharedConfigPtr pSharedConfig = KSharedConfig::openConfig(); + KConfigGroup aGeneralConfig = pSharedConfig->group(QStringLiteral("KDE")); + const qreal fAnimationSpeedModifier + = qMax(0.0, aGeneralConfig.readEntry("AnimationDurationFactor", 1.0)); + return qFuzzyIsNull(fAnimationSpeedModifier); + } + + return QtInstance::GetUseReducedAnimation(); +} + bool KFSalInstance::hasNativeFileSelection() const { const OUString sDesktop = Application::GetDesktopEnvironment(); diff --git a/vcl/unx/kf5/KFSalInstance.hxx b/vcl/unx/kf5/KFSalInstance.hxx index b4c12e895e48..86795a1ba94a 100644 --- a/vcl/unx/kf5/KFSalInstance.hxx +++ b/vcl/unx/kf5/KFSalInstance.hxx @@ -28,6 +28,8 @@ class KFSalInstance final : public QtInstance createPicker(css::uno::Reference<css::uno::XComponentContext> const& context, QFileDialog::FileMode) override; + virtual bool GetUseReducedAnimation() override; + public: explicit KFSalInstance(std::unique_ptr<QApplication>& pQApp); }; |
