mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-11 13:18:13 +03:00
fix #270,enable blur for panel background
--the user can habe blur and background contrast effects in all cases for the panel and can also choose the behavior from Tweaks page
This commit is contained in:
parent
66411e83db
commit
a4ee035c93
@ -164,7 +164,10 @@ void DockView::init()
|
||||
updateFormFactor();
|
||||
syncGeometry();
|
||||
});
|
||||
connect(&m_theme, &Plasma::Theme::themeChanged, this, &DockView::themeChanged);
|
||||
connect(this, &DockView::drawEffectsChanged, this, &DockView::updateEffects);
|
||||
connect(this, &DockView::effectsAreaChanged, this, &DockView::updateEffects);
|
||||
|
||||
connect(&m_theme, &Plasma::Theme::themeChanged, this, &DockView::updateEffects);
|
||||
connect(this, SIGNAL(normalThicknessChanged()), corona(), SIGNAL(availableScreenRectChanged()));
|
||||
connect(this, SIGNAL(shadowChanged()), corona(), SIGNAL(availableScreenRectChanged()));
|
||||
rootContext()->setContextProperty(QStringLiteral("dock"), this);
|
||||
@ -733,10 +736,26 @@ void DockView::setDrawShadows(bool draw)
|
||||
emit enabledBordersChanged();
|
||||
}
|
||||
|
||||
themeChanged();
|
||||
updateEffects();
|
||||
emit drawShadowsChanged();
|
||||
}
|
||||
|
||||
bool DockView::drawEffects() const
|
||||
{
|
||||
return m_drawShadows;
|
||||
}
|
||||
|
||||
void DockView::setDrawEffects(bool draw)
|
||||
{
|
||||
if (m_drawEffects == draw) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_drawEffects = draw;
|
||||
|
||||
emit drawEffectsChanged();
|
||||
}
|
||||
|
||||
bool DockView::onPrimary() const
|
||||
{
|
||||
return m_onPrimary;
|
||||
@ -834,6 +853,9 @@ void DockView::setMaskArea(QRect area)
|
||||
//! rounded corners to be shown correctly
|
||||
if (!m_background) {
|
||||
m_background = new Plasma::FrameSvg(this);
|
||||
}
|
||||
|
||||
if (m_background->imagePath() != "opaque/dialogs/background") {
|
||||
m_background->setImagePath(QStringLiteral("opaque/dialogs/background"));
|
||||
}
|
||||
|
||||
@ -848,6 +870,22 @@ void DockView::setMaskArea(QRect area)
|
||||
emit maskAreaChanged();
|
||||
}
|
||||
|
||||
|
||||
QRect DockView::effectsArea() const
|
||||
{
|
||||
return m_effectsArea;
|
||||
}
|
||||
|
||||
void DockView::setEffectsArea(QRect area)
|
||||
{
|
||||
if (m_effectsArea == area) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_effectsArea = area;
|
||||
emit effectsAreaChanged();
|
||||
}
|
||||
|
||||
QRect DockView::absGeometry() const
|
||||
{
|
||||
return m_absGeometry;
|
||||
@ -882,18 +920,45 @@ void DockView::setShadow(int shadow)
|
||||
emit shadowChanged();
|
||||
}
|
||||
|
||||
|
||||
void DockView::themeChanged()
|
||||
void DockView::updateEffects()
|
||||
{
|
||||
if (!m_drawShadows) {
|
||||
KWindowEffects::enableBlurBehind(winId(), false);
|
||||
KWindowEffects::enableBackgroundContrast(winId(), false);
|
||||
} else {
|
||||
if (m_drawEffects && !m_effectsArea.isNull() && !m_effectsArea.isEmpty()) {
|
||||
//! this is used when compositing is disabled and provides
|
||||
//! the correct way for the mask to be painted in order for
|
||||
//! rounded corners to be shown correctly
|
||||
if (!m_background) {
|
||||
m_background = new Plasma::FrameSvg(this);
|
||||
}
|
||||
|
||||
if (m_background->imagePath() != "widgets/panel-background") {
|
||||
m_background->setImagePath(QStringLiteral("widgets/panel-background"));
|
||||
}
|
||||
|
||||
m_background->setEnabledBorders(enabledBorders());
|
||||
m_background->resizeFrame(m_effectsArea.size());
|
||||
QRegion fixedMask = m_background->mask();
|
||||
fixedMask.translate(m_effectsArea.x(), m_effectsArea.y());
|
||||
|
||||
KWindowEffects::enableBlurBehind(winId(), true, fixedMask);
|
||||
KWindowEffects::enableBackgroundContrast(winId(), m_theme.backgroundContrastEnabled(),
|
||||
m_theme.backgroundContrast(),
|
||||
m_theme.backgroundIntensity(),
|
||||
m_theme.backgroundSaturation(),
|
||||
fixedMask);
|
||||
} else {
|
||||
KWindowEffects::enableBlurBehind(winId(), false);
|
||||
KWindowEffects::enableBackgroundContrast(winId(), false);
|
||||
}
|
||||
} else if (m_drawShadows && m_drawEffects) {
|
||||
KWindowEffects::enableBlurBehind(winId(), true);
|
||||
KWindowEffects::enableBackgroundContrast(winId(), m_theme.backgroundContrastEnabled(),
|
||||
m_theme.backgroundContrast(),
|
||||
m_theme.backgroundIntensity(),
|
||||
m_theme.backgroundSaturation());
|
||||
} else {
|
||||
KWindowEffects::enableBlurBehind(winId(), false);
|
||||
KWindowEffects::enableBackgroundContrast(winId(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ namespace Latte {
|
||||
class DockView : public PlasmaQuick::ContainmentView {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool drawShadows READ drawShadows WRITE setDrawShadows NOTIFY drawShadowsChanged)
|
||||
Q_PROPERTY(bool drawEffects READ drawEffects WRITE setDrawEffects NOTIFY drawEffectsChanged)
|
||||
Q_PROPERTY(bool onPrimary READ onPrimary WRITE setOnPrimary NOTIFY onPrimaryChanged)
|
||||
|
||||
Q_PROPERTY(int alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||
@ -64,11 +65,13 @@ class DockView : public PlasmaQuick::ContainmentView {
|
||||
|
||||
Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders NOTIFY enabledBordersChanged)
|
||||
|
||||
Q_PROPERTY(QRect maskArea READ maskArea WRITE setMaskArea NOTIFY maskAreaChanged)
|
||||
|
||||
Q_PROPERTY(VisibilityManager *visibility READ visibility NOTIFY visibilityChanged)
|
||||
Q_PROPERTY(QQmlListProperty<QScreen> screens READ screens)
|
||||
|
||||
Q_PROPERTY(QRect effectsArea READ effectsArea WRITE setEffectsArea NOTIFY effectsAreaChanged)
|
||||
Q_PROPERTY(QRect localGeometry READ localGeometry WRITE setLocalGeometry NOTIFY localGeometryChanged)
|
||||
Q_PROPERTY(QRect maskArea READ maskArea WRITE setMaskArea NOTIFY maskAreaChanged)
|
||||
Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
|
||||
|
||||
Q_PROPERTY(Latte::Dock::SessionType session READ session WRITE setSession NOTIFY sessionChanged)
|
||||
@ -94,6 +97,9 @@ public:
|
||||
bool drawShadows() const;
|
||||
void setDrawShadows(bool draw);
|
||||
|
||||
bool drawEffects() const;
|
||||
void setDrawEffects(bool draw);
|
||||
|
||||
float maxLength() const;
|
||||
void setMaxLength(float length);
|
||||
|
||||
@ -112,8 +118,10 @@ public:
|
||||
QRect maskArea() const;
|
||||
void setMaskArea(QRect area);
|
||||
|
||||
QRect absGeometry() const;
|
||||
QRect effectsArea() const;
|
||||
void setEffectsArea(QRect area);
|
||||
|
||||
QRect absGeometry() const;
|
||||
QRect screenGeometry() const;
|
||||
|
||||
Plasma::FrameSvg::EnabledBorders enabledBorders() const;
|
||||
@ -166,6 +174,8 @@ signals:
|
||||
void dockLocationChanged();
|
||||
void docksCountChanged();
|
||||
void drawShadowsChanged();
|
||||
void drawEffectsChanged();
|
||||
void effectsAreaChanged();
|
||||
void enabledBordersChanged();
|
||||
void widthChanged();
|
||||
void heightChanged();
|
||||
@ -188,7 +198,7 @@ private slots:
|
||||
void menuAboutToHide();
|
||||
void statusChanged(Plasma::Types::ItemStatus);
|
||||
void screenChanged(QScreen *screen);
|
||||
void themeChanged();
|
||||
void updateEffects();
|
||||
|
||||
void restoreConfig();
|
||||
void saveConfig();
|
||||
@ -206,6 +216,7 @@ private:
|
||||
|
||||
bool m_forceDrawCenteredBorders{false};
|
||||
bool m_drawShadows{false};
|
||||
bool m_drawEffects{false};
|
||||
bool m_onPrimary{true};
|
||||
int m_maxThickness{24};
|
||||
int m_normalThickness{24};
|
||||
@ -215,6 +226,7 @@ private:
|
||||
Dock::Alignment m_alignment{Dock::Center};
|
||||
Dock::SessionType m_session{Dock::DefaultSession};
|
||||
|
||||
QRect m_effectsArea;
|
||||
QRect m_localGeometry;
|
||||
QRect m_absGeometry;
|
||||
QRect m_maskArea;
|
||||
|
@ -48,6 +48,9 @@
|
||||
<entry name="solidPanel" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="blurEnabled" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="automaticIconSize" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
|
@ -44,6 +44,8 @@ Image{
|
||||
property bool farEdge: (plasmoid.location===PlasmaCore.Types.BottomEdge) || (plasmoid.location===PlasmaCore.Types.RightEdge)
|
||||
property bool editAnimationEnded: false
|
||||
|
||||
property rect efGeometry
|
||||
|
||||
layer.enabled: true
|
||||
layer.effect: DropShadow {
|
||||
radius: root.editShadow
|
||||
@ -88,18 +90,40 @@ Image{
|
||||
}
|
||||
}
|
||||
|
||||
onXChanged: updateEffectsArea();
|
||||
onYChanged: updateEffectsArea();
|
||||
|
||||
onWidthChanged: {
|
||||
if (root.isHorizontal) {
|
||||
initializeEditPosition();
|
||||
}
|
||||
|
||||
updateEffectsArea();
|
||||
}
|
||||
|
||||
onHeightChanged: {
|
||||
if (root.isVertical) {
|
||||
initializeEditPosition();
|
||||
}
|
||||
|
||||
updateEffectsArea();
|
||||
}
|
||||
|
||||
function updateEffectsArea(){
|
||||
if (!dock || state !== "edit" || !editAnimationEnded)
|
||||
return;
|
||||
|
||||
var rootGeometry = mapToItem(root, 0, 0);
|
||||
|
||||
efGeometry.x = rootGeometry.x;
|
||||
efGeometry.y = rootGeometry.y;
|
||||
efGeometry.width = width;
|
||||
efGeometry.height = height;
|
||||
|
||||
dock.effectsArea = efGeometry;
|
||||
}
|
||||
|
||||
|
||||
function initializeNormalPosition() {
|
||||
if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
|
||||
y = rootThickness;
|
||||
@ -228,6 +252,7 @@ Image{
|
||||
ScriptAction{
|
||||
script:{
|
||||
editVisual.editAnimationEnded = true;
|
||||
updateEffectsArea();
|
||||
visibilityManager.updateMaskArea();
|
||||
}
|
||||
}
|
||||
|
@ -221,8 +221,39 @@ Item{
|
||||
anchors.bottomMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.bottom - bottomIncreaser : 0
|
||||
anchors.fill:parent
|
||||
|
||||
property rect efGeometry: Qt.rect(-1,-1,0,0)
|
||||
|
||||
imagePath: root.solidPanel ? "opaque/dialogs/background" : "widgets/panel-background"
|
||||
|
||||
onWidthChanged: updateEffectsArea();
|
||||
onHeightChanged: updateEffectsArea();
|
||||
|
||||
Component.onCompleted: root.updateEffectsArea.connect(updateEffectsArea);
|
||||
|
||||
Connections{
|
||||
target: root
|
||||
|
||||
onEditModeChanged: {
|
||||
if (!root.editMode){
|
||||
solidBackground.updateEffectsArea();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateEffectsArea(){
|
||||
if (!dock || root.editMode)
|
||||
return;
|
||||
|
||||
var rootGeometry = mapToItem(root, 0, 0);
|
||||
|
||||
efGeometry.x = rootGeometry.x;
|
||||
efGeometry.y = rootGeometry.y;
|
||||
efGeometry.width = width;
|
||||
efGeometry.height = height;
|
||||
|
||||
dock.effectsArea = efGeometry;
|
||||
}
|
||||
|
||||
//! the increases used when the user forces a solid background and the background
|
||||
//! must be increased in order to look ok in the corners
|
||||
property int rightIncreaser: {
|
||||
|
@ -82,6 +82,13 @@ Item{
|
||||
value: root.drawShadowsExternal
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock
|
||||
property: "drawEffects"
|
||||
when: dock
|
||||
value: root.blurEnabled && !root.solidPanel
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock
|
||||
property:"shadow"
|
||||
|
@ -38,6 +38,7 @@ DragDrop.DropArea {
|
||||
|
||||
//// BEGIN SIGNALS
|
||||
signal clearZoomSignal();
|
||||
signal updateEffectsArea();
|
||||
signal updateIndexes();
|
||||
////
|
||||
|
||||
@ -47,6 +48,7 @@ DragDrop.DropArea {
|
||||
property bool globalDirectRender: false //it is used to check both the applet and the containment for direct render
|
||||
|
||||
property bool automaticSize: plasmoid.configuration.automaticIconSize
|
||||
property bool blurEnabled: plasmoid.configuration.blurEnabled
|
||||
property bool confirmedDragEntered: false
|
||||
property bool drawShadowsExternal: visibilityManager.panelIsBiggerFromIconSize && (zoomFactor === 1.0)
|
||||
&& (dock.visibility.mode === Latte.Dock.AlwaysVisible)
|
||||
@ -1345,6 +1347,9 @@ DragDrop.DropArea {
|
||||
}
|
||||
}
|
||||
|
||||
onXChanged: root.updateEffectsArea();
|
||||
onYChanged: root.updateEffectsArea();
|
||||
|
||||
Grid{
|
||||
id:startLayout
|
||||
|
||||
|
@ -48,6 +48,17 @@ PlasmaComponents.Page {
|
||||
text: i18n("Appearance")
|
||||
}
|
||||
|
||||
PlasmaComponents.CheckBox {
|
||||
id: blurPanel
|
||||
Layout.leftMargin: units.smallSpacing * 2
|
||||
text: i18n("Blur for panel background")
|
||||
checked: plasmoid.configuration.blurEnabled
|
||||
|
||||
onClicked: {
|
||||
plasmoid.configuration.blurEnabled = checked
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.CheckBox {
|
||||
id: shrinkThickness
|
||||
Layout.leftMargin: units.smallSpacing * 2
|
||||
|
Loading…
Reference in New Issue
Block a user