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)
{
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<PageTransitionEffect>(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)

View file

@ -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};
};

View file

@ -29,10 +29,17 @@ ContainmentItem {
forceActiveFocus();
}
// wallpaper
Loader {
id: wallpaperBlurLoader
active: Folio.FolioSettings.showWallpaperBlur
anchors.fill: parent
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
@ -46,6 +53,7 @@ ContainmentItem {
autoPaddingEnabled: false
source: Plasmoid.wallpaperGraphicsObject
anchors.fill: parent
visible: opacity > 0
opacity: Math.min(1,
Math.max(
1 - homeScreen.contentOpacity,
@ -55,6 +63,8 @@ ContainmentItem {
)
)
}
}
}
function homeAction() {
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 {
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()
}