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
This commit is contained in:
Devin Lin 2024-02-08 17:10:55 +00:00
parent 17f0674cc2
commit cfa4cbbd3a
4 changed files with 74 additions and 24 deletions

View file

@ -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) void FolioSettings::setApplet(Plasma::Applet *applet)
{ {
m_applet = applet; m_applet = applet;
@ -138,6 +152,7 @@ void FolioSettings::save()
m_applet->config().writeEntry("delegateIconSize", m_delegateIconSize); m_applet->config().writeEntry("delegateIconSize", m_delegateIconSize);
m_applet->config().writeEntry("showFavouritesBarBackground", m_showFavouritesBarBackground); m_applet->config().writeEntry("showFavouritesBarBackground", m_showFavouritesBarBackground);
m_applet->config().writeEntry("pageTransitionEffect", (int)m_pageTransitionEffect); m_applet->config().writeEntry("pageTransitionEffect", (int)m_pageTransitionEffect);
m_applet->config().writeEntry("showWallpaperBlur", m_showWallpaperBlur);
Q_EMIT m_applet->configNeedsSaving(); Q_EMIT m_applet->configNeedsSaving();
} }
@ -155,12 +170,14 @@ void FolioSettings::load()
m_delegateIconSize = m_applet->config().readEntry("delegateIconSize", 48); m_delegateIconSize = m_applet->config().readEntry("delegateIconSize", 48);
m_showFavouritesBarBackground = m_applet->config().readEntry("showFavoritesBarBackground", true); m_showFavouritesBarBackground = m_applet->config().readEntry("showFavoritesBarBackground", true);
m_pageTransitionEffect = static_cast<PageTransitionEffect>(m_applet->config().readEntry("pageTransitionEffect", (int)SlideTransition)); m_pageTransitionEffect = static_cast<PageTransitionEffect>(m_applet->config().readEntry("pageTransitionEffect", (int)SlideTransition));
m_showWallpaperBlur = m_applet->config().readEntry("showWallpaperBlur", false);
Q_EMIT homeScreenRowsChanged(); Q_EMIT homeScreenRowsChanged();
Q_EMIT homeScreenColumnsChanged(); Q_EMIT homeScreenColumnsChanged();
Q_EMIT showPagesAppLabels(); Q_EMIT showPagesAppLabels();
Q_EMIT showFavouritesAppLabelsChanged(); Q_EMIT showFavouritesAppLabelsChanged();
Q_EMIT delegateIconSizeChanged(); Q_EMIT delegateIconSizeChanged();
Q_EMIT showWallpaperBlurChanged();
} }
bool FolioSettings::saveLayoutToFile(QString path) bool FolioSettings::saveLayoutToFile(QString path)

View file

@ -18,6 +18,7 @@ class FolioSettings : public QObject
Q_PROPERTY(bool showFavouritesBarBackground READ showFavouritesBarBackground WRITE setShowFavouritesBarBackground NOTIFY showFavouritesBarBackgroundChanged) Q_PROPERTY(bool showFavouritesBarBackground READ showFavouritesBarBackground WRITE setShowFavouritesBarBackground NOTIFY showFavouritesBarBackgroundChanged)
Q_PROPERTY( Q_PROPERTY(
FolioSettings::PageTransitionEffect pageTransitionEffect READ pageTransitionEffect WRITE setPageTransitionEffect NOTIFY pageTransitionEffectChanged) FolioSettings::PageTransitionEffect pageTransitionEffect READ pageTransitionEffect WRITE setPageTransitionEffect NOTIFY pageTransitionEffectChanged)
Q_PROPERTY(bool showWallpaperBlur READ showWallpaperBlur WRITE setShowWallpaperBlur NOTIFY showWallpaperBlurChanged)
public: public:
FolioSettings(QObject *parent = nullptr); FolioSettings(QObject *parent = nullptr);
@ -58,6 +59,9 @@ public:
PageTransitionEffect pageTransitionEffect() const; PageTransitionEffect pageTransitionEffect() const;
void setPageTransitionEffect(PageTransitionEffect pageTransitionEffect); void setPageTransitionEffect(PageTransitionEffect pageTransitionEffect);
bool showWallpaperBlur() const;
void setShowWallpaperBlur(bool showWallpaperBlur);
Q_INVOKABLE void load(); Q_INVOKABLE void load();
Q_INVOKABLE bool saveLayoutToFile(QString path); Q_INVOKABLE bool saveLayoutToFile(QString path);
@ -73,6 +77,7 @@ Q_SIGNALS:
void delegateIconSizeChanged(); void delegateIconSizeChanged();
void showFavouritesBarBackgroundChanged(); void showFavouritesBarBackgroundChanged();
void pageTransitionEffectChanged(); void pageTransitionEffectChanged();
void showWallpaperBlurChanged();
private: private:
void save(); void save();
@ -84,6 +89,7 @@ private:
qreal m_delegateIconSize{48}; qreal m_delegateIconSize{48};
bool m_showFavouritesBarBackground{false}; bool m_showFavouritesBarBackground{false};
PageTransitionEffect m_pageTransitionEffect{SlideTransition}; PageTransitionEffect m_pageTransitionEffect{SlideTransition};
bool m_showWallpaperBlur{false};
Plasma::Applet *m_applet{nullptr}; Plasma::Applet *m_applet{nullptr};
}; };

View file

@ -29,10 +29,17 @@ ContainmentItem {
forceActiveFocus(); forceActiveFocus();
} }
// wallpaper Loader {
id: wallpaperBlurLoader
active: Folio.FolioSettings.showWallpaperBlur
anchors.fill: parent
sourceComponent: Item {
// HACK: wallpaper (to enforce same dimensions that blur uses)
MultiEffect { MultiEffect {
blurEnabled: true blurEnabled: true
blur: 0.0 blur: 0.0
blurMax: 0.0
autoPaddingEnabled: false autoPaddingEnabled: false
source: Plasmoid.wallpaperGraphicsObject source: Plasmoid.wallpaperGraphicsObject
anchors.fill: parent anchors.fill: parent
@ -46,6 +53,7 @@ ContainmentItem {
autoPaddingEnabled: false autoPaddingEnabled: false
source: Plasmoid.wallpaperGraphicsObject source: Plasmoid.wallpaperGraphicsObject
anchors.fill: parent anchors.fill: parent
visible: opacity > 0
opacity: Math.min(1, opacity: Math.min(1,
Math.max( Math.max(
1 - homeScreen.contentOpacity, 1 - homeScreen.contentOpacity,
@ -55,6 +63,8 @@ ContainmentItem {
) )
) )
} }
}
}
function homeAction() { function homeAction() {
const isInWindow = (!WindowPlugin.WindowUtil.isShowingDesktop && WindowPlugin.WindowMaximizedTracker.showingWindow); const isInWindow = (!WindowPlugin.WindowUtil.isShowingDesktop && WindowPlugin.WindowMaximizedTracker.showingWindow);

View file

@ -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 { FormCard.FormHeader {
title: i18n("General") title: i18n("General")
} }
@ -244,7 +261,7 @@ Window {
Layout.bottomMargin: Kirigami.Units.gridUnit Layout.bottomMargin: Kirigami.Units.gridUnit
FormCard.FormButtonDelegate { FormCard.FormButtonDelegate {
id: containmentSettings id: containmentSettings
text: i18n('Switch Homescreen') text: i18nc("@action:button", "Switch between homescreens and more wallpaper options")
icon.name: 'settings-configure' icon.name: 'settings-configure'
onClicked: root.requestConfigureMenu() onClicked: root.requestConfigureMenu()
} }