From 0e8691878c4664320e3367b4217de7a55913af82 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 4 Mar 2017 15:29:56 +0200 Subject: [PATCH] fix #194,the user can enable a solid background --this is especial useful for plasma themes with big transparency. Latte can not support blur and background contrast kwin effects for panel backgrounds that are drawn inside its qml side. --- app/dockcorona.cpp | 4 +- containment/contents/config/main.xml | 3 + containment/contents/ui/PanelBox.qml | 73 ++++++++++++++----- containment/contents/ui/main.qml | 3 +- .../configuration/AppearanceConfig.qml | 36 +++++++-- 5 files changed, 94 insertions(+), 25 deletions(-) diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 11ec4ea2e..2eb2645f8 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -245,7 +245,7 @@ QRegion DockCorona::availableScreenRegion(int id) const case Latte::Dock::Center: case Latte::Dock::Justify: - realGeometry = QRect(view->geometry().center().x() - realWidth / 2 , view->y(), + realGeometry = QRect(qMax(view->geometry().x(), view->geometry().center().x() - realWidth / 2) , view->y(), realWidth , realThickness); break; @@ -295,9 +295,11 @@ QRegion DockCorona::availableScreenRegion(int id) const } /*qDebug() << "::::: FREE AREAS :::::"; + for (int i = 0; i < available.rectCount(); ++i) { qDebug() << available.rects().at(i); } + qDebug() << "::::: END OF FREE AREAS :::::";*/ return available; diff --git a/containment/contents/config/main.xml b/containment/contents/config/main.xml index af33613b1..e0bc924a0 100644 --- a/containment/contents/config/main.xml +++ b/containment/contents/config/main.xml @@ -34,6 +34,9 @@ 58 + + false + false diff --git a/containment/contents/ui/PanelBox.qml b/containment/contents/ui/PanelBox.qml index 7cc3a7629..917c1d798 100644 --- a/containment/contents/ui/PanelBox.qml +++ b/containment/contents/ui/PanelBox.qml @@ -57,7 +57,7 @@ Item{ if ((root.panelAlignment === Latte.Dock.Justify) && root.isVertical && !root.editMode) { return root.maxLength; } else { - return mainLayout.height + spacing; + return mainLayout.height + spacing; } } } @@ -99,8 +99,10 @@ Item{ PlasmaCore.FrameSvgItem{ id: shadowsSvgItem - width: root.isVertical ? panelSize + marginsWidth : Math.min(parent.width + marginsWidth, root.width - marginsWidth) - height: root.isVertical ? Math.min(parent.height + marginsHeight, root.height - marginsHeight) : panelSize + marginsHeight + width: root.isVertical ? panelSize + marginsWidth - (solidBackground.leftIncreaser + solidBackground.rightIncreaser) : + Math.min(parent.width + marginsWidth, root.width - marginsWidth) + height: root.isVertical ? Math.min(parent.height + marginsHeight, root.height - marginsHeight) : + panelSize + marginsHeight - (solidBackground.topIncreaser + solidBackground.bottomIncreaser) imagePath: root.drawShadowsExternal ? "" : "widgets/panel-background" prefix: root.drawShadowsExternal ? "" : "shadow" @@ -114,12 +116,12 @@ Item{ if (root.drawShadowsExternal) { return 0; } else { - if (root.panelAlignment === Latte.Dock.Left) - return margins.right; - else if (root.panelAlignment === Latte.Dock.Right) - return margins.left; - else - return margins.left+margins.right; + if (root.panelAlignment === Latte.Dock.Left) + return margins.right; + else if (root.panelAlignment === Latte.Dock.Right) + return margins.left; + else + return margins.left+margins.right; } } @@ -128,11 +130,11 @@ Item{ return 0; } else { if (root.panelAlignment === Latte.Dock.Top) - return margins.bottom; + return margins.bottom; else if (root.panelAlignment === Latte.Dock.Bottom) - return margins.top; + return margins.top; else - return margins.top + margins.bottom; + return margins.top + margins.bottom; } } @@ -194,13 +196,44 @@ Item{ PlasmaCore.FrameSvgItem{ id: solidBackground - anchors.leftMargin: shadowsSvgItem.margins.left - anchors.rightMargin: shadowsSvgItem.margins.right - anchors.topMargin: shadowsSvgItem.margins.top - anchors.bottomMargin: shadowsSvgItem.margins.bottom + anchors.leftMargin: shadowsSvgItem.margins.left - leftIncreaser + anchors.rightMargin: shadowsSvgItem.margins.right - rightIncreaser + anchors.topMargin: shadowsSvgItem.margins.top - topIncreaser + anchors.bottomMargin: shadowsSvgItem.margins.bottom - bottomIncreaser anchors.fill:parent - imagePath: "widgets/panel-background" + imagePath: root.solidPanel ? "opaque/dialogs/background" : "widgets/panel-background" + + //! 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: { + if (!(root.solidPanel && root.isVertical && plasmoid.location === PlasmaCore.Types.LeftEdge)) + return 0; + else + return hiddenPanelBackground.margins.right; + } + + property int leftIncreaser: { + if (!(root.solidPanel && root.isVertical && plasmoid.location === PlasmaCore.Types.RightEdge)) + return 0; + else + return hiddenPanelBackground.margins.left; + } + + property int topIncreaser: { + if (!(root.solidPanel && root.isVertical && plasmoid.location === PlasmaCore.Types.BottomEdge)) + return 0; + else + return hiddenPanelBackground.margins.top; + } + + property int bottomIncreaser: { + if (!(root.solidPanel && root.isVertical && plasmoid.location === PlasmaCore.Types.TopEdge)) + return 0; + else + return hiddenPanelBackground.margins.bottom; + } + Binding { target: root @@ -258,7 +291,12 @@ Item{ prefix = ""; } } + } + PlasmaCore.FrameSvgItem{ + id: hiddenPanelBackground + imagePath: "widgets/panel-background" + visible: false } } @@ -484,3 +522,4 @@ Item{ //END states } + diff --git a/containment/contents/ui/main.qml b/containment/contents/ui/main.qml index 93a604202..6aae91ad3 100644 --- a/containment/contents/ui/main.qml +++ b/containment/contents/ui/main.qml @@ -50,7 +50,7 @@ DragDrop.DropArea { property bool confirmedDragEntered: false property bool drawShadowsExternal: visibilityManager.panelIsBiggerFromIconSize && (zoomFactor === 1.0) && (dock.visibility.mode === Latte.Dock.AlwaysVisible) - && (plasmoid.configuration.panelPosition === Latte.Dock.Justify) + && (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && !root.solidPanel property bool editMode: plasmoid.userConfiguring property bool immutable: plasmoid.immutable @@ -61,6 +61,7 @@ DragDrop.DropArea { : (layoutsContainer.hoveredIndex !== -1) //|| wholeArea.containsMouse property bool normalState : false property bool onlyAddingStarup: true //is used for the initialization phase in startup where there arent removals, this variable provides a way to grow icon size + property bool solidPanel: plasmoid.configuration.solidPanel //FIXME: possibly this is going to be the default behavior, this user choice //has been dropped from the Dock Configuration Window //property bool smallAutomaticIconJumps: plasmoid.configuration.smallAutomaticIconJumps diff --git a/shell/contents/configuration/AppearanceConfig.qml b/shell/contents/configuration/AppearanceConfig.qml index e18018c2e..7e0c055cd 100644 --- a/shell/contents/configuration/AppearanceConfig.qml +++ b/shell/contents/configuration/AppearanceConfig.qml @@ -227,14 +227,38 @@ PlasmaComponents.Page { text: i18n("Background") } - PlasmaComponents.CheckBox { - id: showBackground + GridLayout { + width: parent.width + rowSpacing: 1 + columnSpacing: 1 Layout.leftMargin: units.smallSpacing * 2 - text: i18n("Show Panel Background") - checked: plasmoid.configuration.useThemePanel + Layout.rightMargin: units.smallSpacing * 2 + + columns: 2 + + PlasmaComponents.CheckBox { + id: showBackground + Layout.fillWidth: true + text: i18n("Show Panel Background") + checked: plasmoid.configuration.useThemePanel + + onClicked: { + plasmoid.configuration.useThemePanel = checked + } + } + + PlasmaComponents.CheckBox { + id: solidBackground + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter - onClicked: { - plasmoid.configuration.useThemePanel = checked + text: i18n("Solid Background") + checked: plasmoid.configuration.solidPanel + enabled: showBackground.checked + + onClicked: { + plasmoid.configuration.solidPanel = checked + } } }