From 9d55a65bf5b8cebdecf8b1242f06850f01f645d3 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 17 May 2017 23:17:47 +0300 Subject: [PATCH] fix #469,support show background on maximized only -- the user can choose this behavior from the Tweaks page, the panel background in shown only when there is maximized window and it is fully transparent otherwise --- containment/package/contents/config/main.xml | 3 + .../package/contents/ui/AppletItem.qml | 17 ++-- containment/package/contents/ui/PanelBox.qml | 14 +++- .../package/contents/ui/WindowsModel.qml | 82 +++++++++++++++++++ containment/package/contents/ui/main.qml | 18 +++- .../contents/configuration/TweaksConfig.qml | 11 +++ 6 files changed, 133 insertions(+), 12 deletions(-) create mode 100644 containment/package/contents/ui/WindowsModel.qml diff --git a/containment/package/contents/config/main.xml b/containment/package/contents/config/main.xml index 5c9ef50e7..d3175389d 100644 --- a/containment/package/contents/config/main.xml +++ b/containment/package/contents/config/main.xml @@ -66,6 +66,9 @@ true + + false + -1 diff --git a/containment/package/contents/ui/AppletItem.qml b/containment/package/contents/ui/AppletItem.qml index 373bb839d..5d6951d2b 100644 --- a/containment/package/contents/ui/AppletItem.qml +++ b/containment/package/contents/ui/AppletItem.qml @@ -827,20 +827,23 @@ Item { anchors.fill: container.appletWrapper active: container.applet - &&((plasmoid.configuration.shadows === 1 /*Locked Applets*/ - && (!container.canBeHovered || (container.lockZoom && (applet.pluginName !== root.plasmoidName))) ) - || (plasmoid.configuration.shadows === 2 /*All Applets*/ - && (applet.pluginName !== root.plasmoidName))) + && (((plasmoid.configuration.shadows === 1 /*Locked Applets*/ + && (!container.canBeHovered || (container.lockZoom && (applet.pluginName !== root.plasmoidName))) ) + || (plasmoid.configuration.shadows === 2 /*All Applets*/ + && (applet.pluginName !== root.plasmoidName))) + || (root.forceTransparentPanel && applet.pluginName !== root.plasmoidName)) /*on forced transparent state*/ sourceComponent: DropShadow{ anchors.fill: parent - color: "#ff080808" + color: forcedShadow ? "#ff040404" : "#ff080808" samples: 2 * radius source: container.fakeIconItem ? wrapperContainer : container.applet radius: shadowSize - verticalOffset: 2 + verticalOffset: forcedShadow ? 1 : 2 - property int shadowSize : Math.ceil(root.iconSize / 12) + property int shadowSize : forcedShadow? 7 : Math.ceil(root.iconSize / 12) + + property bool forcedShadow: root.forceTransparentPanel && applet.pluginName !== root.plasmoidName ? true : false } } diff --git a/containment/package/contents/ui/PanelBox.qml b/containment/package/contents/ui/PanelBox.qml index be2e2e700..c87a8fdeb 100644 --- a/containment/package/contents/ui/PanelBox.qml +++ b/containment/package/contents/ui/PanelBox.qml @@ -224,7 +224,14 @@ Item{ anchors.bottomMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.bottom - bottomIncreaser : 0 anchors.fill:parent - opacity: root.solidPanel ? 1 : plasmoid.configuration.panelTransparency / 100 + opacity: { + if (root.backgroundOnlyOnMaximized && !windowsModel.hasMaximizedWindow) + return 0; + else if (root.solidPanel) + return 1; + else + return plasmoid.configuration.panelTransparency / 100; + } property rect efGeometry: Qt.rect(-1,-1,0,0) @@ -235,6 +242,11 @@ Item{ Component.onCompleted: root.updateEffectsArea.connect(updateEffectsArea); + Behavior on opacity { + enabled: root.backgroundOnlyOnMaximized + NumberAnimation { duration: 8*root.durationTime*units.shortDuration } + } + Connections{ target: root diff --git a/containment/package/contents/ui/WindowsModel.qml b/containment/package/contents/ui/WindowsModel.qml new file mode 100644 index 000000000..8c1a69194 --- /dev/null +++ b/containment/package/contents/ui/WindowsModel.qml @@ -0,0 +1,82 @@ +/* +* Copyright 2016 Smith AR +* Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +import QtQuick 2.1 + +import org.kde.plasma.plasmoid 2.0 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.taskmanager 0.1 as TaskManager + + +Item{ + id: winModel + + property bool maximizedWindowOnScreen: maximizedWindowModel.count > 0 + + //--- active-window-control start + Component.onCompleted: maximizedWindowModel.doCheck() + TaskManager.VirtualDesktopInfo { id: virtualDesktopInfo } + TaskManager.ActivityInfo { id: activityInfo } + TaskManager.TasksModel { + id: tasksModel + sortMode: TaskManager.TasksModel.SortVirtualDesktop + groupMode: TaskManager.TasksModel.GroupDisabled + + virtualDesktop: virtualDesktopInfo.currentDesktop + activity: activityInfo.currentActivity + + screenGeometry: root.screenGeometry + + filterByVirtualDesktop: true + filterByScreen: true + filterByActivity: true + + onActiveTaskChanged: { + maximizedWindowModel.sourceModel = tasksModel + } + onDataChanged: { maximizedWindowModel.doCheck(); } + onCountChanged: { maximizedWindowModel.doCheck(); } + } + + PlasmaCore.SortFilterModel { + id: maximizedWindowModel + filterRole: 'IsMaximized' + filterRegExp: 'true' + sourceModel: tasksModel + + onDataChanged: { maximizedWindowModel.doCheck(); } + onCountChanged: { maximizedWindowModel.doCheck(); } + function doCheck() { + var screenHasMaximized = false + for (var i = 0; i < maximizedWindowModel.count; i++) { + var task = maximizedWindowModel.get(i) + if (task.IsMaximized && !task.IsMinimized) { + screenHasMaximized = true + break + } + } + if (winModel.maximizedWindowOnScreen != screenHasMaximized) { + winModel.maximizedWindowOnScreen = screenHasMaximized + } + } + } + //--- active-window-control end +} diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 32156e57c..62c7a310a 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -53,19 +53,20 @@ DragDrop.DropArea { property bool addLaunchersMessage: false property bool addLaunchersInTaskManager: plasmoid.configuration.addLaunchersInTaskManager property bool autoDecreaseIconSize: plasmoid.configuration.autoDecreaseIconSize + property bool backgroundOnlyOnMaximized: plasmoid.configuration.backgroundOnlyOnMaximized property bool behaveAsPlasmaPanel: visibilityManager.panelIsBiggerFromIconSize && (zoomFactor === 1.0) && (dock.visibility.mode === Latte.Dock.AlwaysVisible || dock.visibility.mode === Latte.Dock.WindowsGoBelow) && (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && !root.solidPanel - property bool blurEnabled: plasmoid.configuration.blurEnabled + property bool blurEnabled: plasmoid.configuration.blurEnabled && !root.forceTransparentPanel property bool confirmedDragEntered: false property bool dockContainsMouse: dock && dock.visibility ? dock.visibility.containsMouse : false property bool drawShadowsExternal: panelShadowsActive && behaveAsPlasmaPanel - property bool editMode: plasmoid.userConfiguring property bool exposeAltSession: globalSettings ? globalSettings.exposeAltSession : false + property bool forceTransparentPanel: root.backgroundOnlyOnMaximized && !windowsModel.hasMaximizedWindow property bool immutable: plasmoid.immutable property bool indicateAudioStreams: plasmoid.configuration.indicateAudioStreams @@ -119,7 +120,7 @@ DragDrop.DropArea { property int panelEdgeSpacing: iconSize / 3 property int panelTransparency: plasmoid.configuration.panelTransparency - property bool panelShadowsActive: plasmoid.configuration.panelShadows + property bool panelShadowsActive: plasmoid.configuration.panelShadows && !root.forceTransparentPanel property int totalPanelEdgeSpacing: 0 //this is set by PanelBox //FIXME: this is not needed any more probably @@ -203,7 +204,7 @@ DragDrop.DropArea { // TO BE DELETED, if not needed: property int counter:0; ///BEGIN properties provided to Latte Plasmoid - property bool enableShadows: plasmoid.configuration.shadows + property bool enableShadows: plasmoid.configuration.shadows || root.forceTransparentPanel property bool dockIsHidden: dock ? dock.visibility.isHidden : true property bool dotsOnActive: plasmoid.configuration.dotsOnActive property bool highlightWindows: plasmoid.configuration.highlightWindows @@ -1312,6 +1313,15 @@ DragDrop.DropArea { } } + Loader{ + id: windowsModel + + active: plasmoid.configuration.backgroundOnlyOnMaximized + + property bool hasMaximizedWindow: active ? item.maximizedWindowOnScreen : false + sourceComponent: WindowsModel{} + } + EditModeVisual{ id:editModeVisual diff --git a/shell/package/contents/configuration/TweaksConfig.qml b/shell/package/contents/configuration/TweaksConfig.qml index 0d0d6d5bb..62647c545 100644 --- a/shell/package/contents/configuration/TweaksConfig.qml +++ b/shell/package/contents/configuration/TweaksConfig.qml @@ -71,6 +71,17 @@ PlasmaComponents.Page { plasmoid.configuration.shrinkThickMargins = checked } } + + PlasmaComponents.CheckBox { + id: onlyOnMaximizedChk + Layout.leftMargin: units.smallSpacing * 2 + text: i18n("Show background only maximized windows ") + checked: plasmoid.configuration.backgroundOnlyOnMaximized + + onClicked: { + plasmoid.configuration.backgroundOnlyOnMaximized = checked + } + } } //! END: Appearance