effects/overview: Allow blurring desktop background

This puts more emphasis on windows and less on desktop background.
This commit is contained in:
Vlad Zahorodnii 2021-10-20 09:43:10 +03:00
parent baf05ec4a5
commit c7c63ba269
5 changed files with 47 additions and 6 deletions

View file

@ -37,26 +37,33 @@
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="KShortcutsEditor" name="shortcutsEditor" native="true">
<item row="2" column="0" colspan="2">
<widget class="KShortcutsEditor" name="shortcutsEditor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="actionTypes">
<enum>KShortcutsEditor::GlobalAction</enum>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_BlurBackground">
<property name="text">
<string>Blur background:</string>
</property>
</widget>
</item>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="kcfg_BlurBackground"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KShortcutsEditor</class>
<extends>QWidget</extends>
<header location="global">KShortcutsEditor</header>
<header>kshortcutseditor.h</header>
<container>1</container>
</customwidget>
</customwidgets>

View file

@ -14,6 +14,10 @@
<default>1</default>
</entry>
<entry name="BlurBackground" type="Bool">
<default>true</default>
</entry>
<entry name="BorderActivate" type="IntList" />
<entry name="TouchBorderActivate" type="IntList" />
</group>

View file

@ -106,6 +106,7 @@ void OverviewEffect::reconfigure(ReconfigureFlags)
OverviewConfig::self()->read();
setLayout(ExpoLayout::LayoutMode(OverviewConfig::layoutMode()));
setAnimationDuration(animationTime(200));
setBlurBackground(OverviewConfig::blurBackground());
for (const ElectricBorder &border : qAsConst(m_borderActivate)) {
effects->unreserveElectricBorder(border, this);
@ -157,6 +158,19 @@ void OverviewEffect::setLayout(ExpoLayout::LayoutMode layout)
}
}
bool OverviewEffect::blurBackground() const
{
return m_blurBackground;
}
void OverviewEffect::setBlurBackground(bool blur)
{
if (m_blurBackground != blur) {
m_blurBackground = blur;
Q_EMIT blurBackgroundChanged();
}
}
void OverviewEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData &data)
{
Q_UNUSED(mask)

View file

@ -40,6 +40,7 @@ class OverviewEffect : public Effect
Q_OBJECT
Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged)
Q_PROPERTY(ExpoLayout::LayoutMode layout READ layout NOTIFY layoutChanged)
Q_PROPERTY(bool blurBackground READ blurBackground NOTIFY blurBackgroundChanged)
public:
OverviewEffect();
@ -51,6 +52,9 @@ public:
int animationDuration() const;
void setAnimationDuration(int duration);
bool blurBackground() const;
void setBlurBackground(bool blur);
void paintScreen(int mask, const QRegion &region, ScreenPaintData &data) override;
void postPaintScreen() override;
bool isActive() const override;
@ -66,6 +70,7 @@ public:
Q_SIGNALS:
void animationDurationChanged();
void layoutChanged();
void blurBackgroundChanged();
public Q_SLOTS:
void activate();
@ -88,6 +93,7 @@ private:
QList<QKeySequence> m_toggleShortcut;
QList<ElectricBorder> m_borderActivate;
QList<ElectricBorder> m_touchBorderActivate;
bool m_blurBackground = false;
bool m_activated = false;
int m_animationDuration = 200;
ExpoLayout::LayoutMode m_layout = ExpoLayout::LayoutNatural;

View file

@ -5,6 +5,7 @@
*/
import QtQuick 2.12
import QtGraphicalEffects 1.12
import org.kde.kwin 3.0 as KWinComponents
import org.kde.kwin.private.overview 1.0
import org.kde.plasma.components 3.0 as PC3
@ -42,6 +43,15 @@ FocusScope {
y: model.client.y - targetScreen.geometry.y
width: model.client.width
height: model.client.height
layer.enabled: effect.blurBackground
layer.effect: FastBlur {
radius: container.organized ? 64 : 0
Behavior on radius {
NumberAnimation { duration: effect.animationDuration; easing.type: Easing.OutCubic }
}
}
}
}