From cfa4cbbd3a5c3f4a16bd4fcf2d42a72b9825292b Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Thu, 8 Feb 2024 17:10:55 +0000 Subject: [PATCH] homescreens/folio: Add setting to toggle wallpaper blur, and disable by default The wallpaper blur causes extreme lag on the PinePhone, best to disable it for now by default, and hide it behind a setting. :C https://invent.kde.org/plasma/plasma-mobile/-/issues/306 PS: is there a string freeze ongoing? this introduces 2 new strings --- .../homescreens/folio/foliosettings.cpp | 17 ++++++ .../homescreens/folio/foliosettings.h | 6 ++ .../folio/package/contents/ui/main.qml | 56 +++++++++++-------- .../contents/ui/settings/SettingsWindow.qml | 19 ++++++- 4 files changed, 74 insertions(+), 24 deletions(-) diff --git a/containments/homescreens/folio/foliosettings.cpp b/containments/homescreens/folio/foliosettings.cpp index f82271fb..e94408f9 100644 --- a/containments/homescreens/folio/foliosettings.cpp +++ b/containments/homescreens/folio/foliosettings.cpp @@ -120,6 +120,20 @@ void FolioSettings::setPageTransitionEffect(PageTransitionEffect pageTransitionE } } +bool FolioSettings::showWallpaperBlur() const +{ + return m_showWallpaperBlur; +} + +void FolioSettings::setShowWallpaperBlur(bool showWallpaperBlur) +{ + if (m_showWallpaperBlur != showWallpaperBlur) { + m_showWallpaperBlur = showWallpaperBlur; + Q_EMIT showWallpaperBlurChanged(); + save(); + } +} + void FolioSettings::setApplet(Plasma::Applet *applet) { m_applet = applet; @@ -138,6 +152,7 @@ void FolioSettings::save() m_applet->config().writeEntry("delegateIconSize", m_delegateIconSize); m_applet->config().writeEntry("showFavouritesBarBackground", m_showFavouritesBarBackground); m_applet->config().writeEntry("pageTransitionEffect", (int)m_pageTransitionEffect); + m_applet->config().writeEntry("showWallpaperBlur", m_showWallpaperBlur); Q_EMIT m_applet->configNeedsSaving(); } @@ -155,12 +170,14 @@ void FolioSettings::load() m_delegateIconSize = m_applet->config().readEntry("delegateIconSize", 48); m_showFavouritesBarBackground = m_applet->config().readEntry("showFavoritesBarBackground", true); m_pageTransitionEffect = static_cast(m_applet->config().readEntry("pageTransitionEffect", (int)SlideTransition)); + m_showWallpaperBlur = m_applet->config().readEntry("showWallpaperBlur", false); Q_EMIT homeScreenRowsChanged(); Q_EMIT homeScreenColumnsChanged(); Q_EMIT showPagesAppLabels(); Q_EMIT showFavouritesAppLabelsChanged(); Q_EMIT delegateIconSizeChanged(); + Q_EMIT showWallpaperBlurChanged(); } bool FolioSettings::saveLayoutToFile(QString path) diff --git a/containments/homescreens/folio/foliosettings.h b/containments/homescreens/folio/foliosettings.h index 0e45fac2..1d8d7554 100644 --- a/containments/homescreens/folio/foliosettings.h +++ b/containments/homescreens/folio/foliosettings.h @@ -18,6 +18,7 @@ class FolioSettings : public QObject Q_PROPERTY(bool showFavouritesBarBackground READ showFavouritesBarBackground WRITE setShowFavouritesBarBackground NOTIFY showFavouritesBarBackgroundChanged) Q_PROPERTY( FolioSettings::PageTransitionEffect pageTransitionEffect READ pageTransitionEffect WRITE setPageTransitionEffect NOTIFY pageTransitionEffectChanged) + Q_PROPERTY(bool showWallpaperBlur READ showWallpaperBlur WRITE setShowWallpaperBlur NOTIFY showWallpaperBlurChanged) public: FolioSettings(QObject *parent = nullptr); @@ -58,6 +59,9 @@ public: PageTransitionEffect pageTransitionEffect() const; void setPageTransitionEffect(PageTransitionEffect pageTransitionEffect); + bool showWallpaperBlur() const; + void setShowWallpaperBlur(bool showWallpaperBlur); + Q_INVOKABLE void load(); Q_INVOKABLE bool saveLayoutToFile(QString path); @@ -73,6 +77,7 @@ Q_SIGNALS: void delegateIconSizeChanged(); void showFavouritesBarBackgroundChanged(); void pageTransitionEffectChanged(); + void showWallpaperBlurChanged(); private: void save(); @@ -84,6 +89,7 @@ private: qreal m_delegateIconSize{48}; bool m_showFavouritesBarBackground{false}; PageTransitionEffect m_pageTransitionEffect{SlideTransition}; + bool m_showWallpaperBlur{false}; Plasma::Applet *m_applet{nullptr}; }; diff --git a/containments/homescreens/folio/package/contents/ui/main.qml b/containments/homescreens/folio/package/contents/ui/main.qml index 9d0b2923..b9e68b7b 100644 --- a/containments/homescreens/folio/package/contents/ui/main.qml +++ b/containments/homescreens/folio/package/contents/ui/main.qml @@ -29,31 +29,41 @@ ContainmentItem { forceActiveFocus(); } - // wallpaper - MultiEffect { - blurEnabled: true - blur: 0.0 - autoPaddingEnabled: false - source: Plasmoid.wallpaperGraphicsObject + Loader { + id: wallpaperBlurLoader + active: Folio.FolioSettings.showWallpaperBlur anchors.fill: parent - } - // wallpaper blur - MultiEffect { - blurEnabled: true - blur: 1.0 - blurMax: 50 - autoPaddingEnabled: false - source: Plasmoid.wallpaperGraphicsObject - anchors.fill: parent - opacity: Math.min(1, - Math.max( - 1 - homeScreen.contentOpacity, - Folio.HomeScreenState.appDrawerOpenProgress * 2, // blur faster during swipe - Folio.HomeScreenState.searchWidgetOpenProgress * 1.5, // blur faster during swipe - Folio.HomeScreenState.folderOpenProgress - ) - ) + sourceComponent: Item { + // HACK: wallpaper (to enforce same dimensions that blur uses) + MultiEffect { + blurEnabled: true + blur: 0.0 + blurMax: 0.0 + autoPaddingEnabled: false + source: Plasmoid.wallpaperGraphicsObject + anchors.fill: parent + } + + // wallpaper blur + MultiEffect { + blurEnabled: true + blur: 1.0 + blurMax: 50 + autoPaddingEnabled: false + source: Plasmoid.wallpaperGraphicsObject + anchors.fill: parent + visible: opacity > 0 + opacity: Math.min(1, + Math.max( + 1 - homeScreen.contentOpacity, + Folio.HomeScreenState.appDrawerOpenProgress * 2, // blur faster during swipe + Folio.HomeScreenState.searchWidgetOpenProgress * 1.5, // blur faster during swipe + Folio.HomeScreenState.folderOpenProgress + ) + ) + } + } } function homeAction() { diff --git a/containments/homescreens/folio/package/contents/ui/settings/SettingsWindow.qml b/containments/homescreens/folio/package/contents/ui/settings/SettingsWindow.qml index 41c98418..bb63d5a8 100644 --- a/containments/homescreens/folio/package/contents/ui/settings/SettingsWindow.qml +++ b/containments/homescreens/folio/package/contents/ui/settings/SettingsWindow.qml @@ -236,6 +236,23 @@ Window { } } + FormCard.FormHeader { + title: i18nc("@title:group settings group", "Wallpaper") + } + + FormCard.FormCard { + FormCard.FormSwitchDelegate { + id: showWallpaperBlur + text: i18nc("@option:check", "Show wallpaper blur effect") + checked: Folio.FolioSettings.showWallpaperBlur + onCheckedChanged: { + if (checked != Folio.FolioSettings.showWallpaperBlur) { + Folio.FolioSettings.showWallpaperBlur = checked; + } + } + } + } + FormCard.FormHeader { title: i18n("General") } @@ -244,7 +261,7 @@ Window { Layout.bottomMargin: Kirigami.Units.gridUnit FormCard.FormButtonDelegate { id: containmentSettings - text: i18n('Switch Homescreen') + text: i18nc("@action:button", "Switch between homescreens and more wallpaper options") icon.name: 'settings-configure' onClicked: root.requestConfigureMenu() }