From 68fc3890670cf2a996e5625d9cea33f899931e37 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 20 Feb 2017 01:18:24 +0200 Subject: [PATCH] fix #186,drop shadowedImage and use Latte IconItem --- plasmoid/contents/ui/TaskDelegate.qml | 2 +- plasmoid/contents/ui/TaskIconBuffers.qml | 168 --------- plasmoid/contents/ui/TaskIconItem.qml | 136 +------ plasmoid/contents/ui/ToolTipDelegate.qml | 438 ----------------------- 4 files changed, 13 insertions(+), 731 deletions(-) delete mode 100644 plasmoid/contents/ui/TaskIconBuffers.qml delete mode 100644 plasmoid/contents/ui/ToolTipDelegate.qml diff --git a/plasmoid/contents/ui/TaskDelegate.qml b/plasmoid/contents/ui/TaskDelegate.qml index e0c8ecce4..e589bbff0 100644 --- a/plasmoid/contents/ui/TaskDelegate.qml +++ b/plasmoid/contents/ui/TaskDelegate.qml @@ -1125,7 +1125,7 @@ MouseArea{ PropertyAction { target: mainItemContainer; property: "ListView.delayRemove"; value: true } PropertyAction { target: mainItemContainer; property: "inAnimation"; value: true } PropertyAction { target: icList; property: "delayingRemoval"; value: true } - PropertyAction { target: wrapper; property: "opacity"; value: isWindow ? 0 : 1 } + //PropertyAction { target: wrapper; property: "opacity"; value: isWindow ? 0 : 1 } //animation mainly for launchers removal and startups ParallelAnimation{ id: removalAnimation diff --git a/plasmoid/contents/ui/TaskIconBuffers.qml b/plasmoid/contents/ui/TaskIconBuffers.qml deleted file mode 100644 index 65066f682..000000000 --- a/plasmoid/contents/ui/TaskIconBuffers.qml +++ /dev/null @@ -1,168 +0,0 @@ -/* -* 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.0 -import QtGraphicalEffects 1.0 - -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponents - -import org.kde.kquickcontrolsaddons 2.0 as KQuickControlAddons -import org.kde.latte 0.1 as Latte - -Component { - id: imageBufferingComponent - Item { - id: yourImageWithLoadedIconContainer - anchors.fill: parent - - visible: false - - property QtObject imageTimer - - function updateImage(){ - if(!imageTimer) - imageTimer = tttTimer.createObject(iconImage); - else{ - imageTimer.loop = 1; - imageTimer.restart(); - } - } - - Item{ - id:fixedIcon - - width: root.iconSize + 2*shadowImageNoActive.radius - height: width - - visible:false - - //KQuickControlAddons.QIconItem{ - Latte.IconItem{ - id: iconImage - - width: root.iconSize - height: width - anchors.centerIn: parent - - source: decoration //icon: decoration - //state: KQuickControlAddons.QIconItem.DefaultState - - enabled: true - visible: true - - smooth: true - // onIconChanged: updateBuffers(); - - property int counter: 0 - - function updateBuffers(){ - if((index !== -1) &&(!centralItem.toBeDestroyed) &&(!mainItemContainer.delayingRemove)){ - if(root.initializationStep){ - root.initializationStep = false; - } - - centralItem.firstDrawed = true; - // counter++; - // console.log(counter); - - if(shadowedImage && shadowedImage.source) - shadowedImage.source.destroy(); - - - if(root.enableShadows == true){ - shadowImageNoActive.grabToImage(function(result) { - shadowedImage.source = result.url - result.destroy(); - }, Qt.size(fixedIcon.width,fixedIcon.height) ); - } - else{ - fixedIcon.grabToImage(function(result) { - shadowedImage.source = result.url; - result.destroy(); - }, Qt.size(fixedIcon.width,fixedIcon.height) ); - } - - mainItemContainer.buffersAreReady = true; - if(!root.initializatedBuffers) - root.noInitCreatedBuffers++; - - iconImageBuffer.opacity = 1; - } - } - - Component{ - id:tttTimer - - Timer{ - id:ttt - repeat: true - interval: loop <= 1 ? centralItem.shadowInterval : 2500 - - property int loop: 0; - - onTriggered: { - iconImage.updateBuffers(); - - loop++; - - // console.log(loop+' - '+interval); - if(loop > 2) - ttt.destroy(300); - } - - Component.onCompleted: ttt.start(); - }// end of timer - - }//end of component of timer - - Component.onCompleted: { - yourImageWithLoadedIconContainer.updateImage(); - } - - Component.onDestruction: { - if(yourImageWithLoadedIconContainer.imageTimer) - yourImageWithLoadedIconContainer.imageTimer.destroy(); - } - } - } - - DropShadow { - id:shadowImageNoActive - visible: false - width: fixedIcon.width - height: fixedIcon.height - anchors.centerIn: fixedIcon - - radius: centralItem.shadowSize - samples: 2 * radius - color: "#ff080808" - source: fixedIcon - - verticalOffset: 2 - } - - Component.onDestruction: { - if(yourImageWithLoadedIconContainer.imageTimer) - yourImageWithLoadedIconContainer.imageTimer.destroy(); - } - } -} - diff --git a/plasmoid/contents/ui/TaskIconItem.qml b/plasmoid/contents/ui/TaskIconItem.qml index a762507e2..b246780b2 100644 --- a/plasmoid/contents/ui/TaskIconItem.qml +++ b/plasmoid/contents/ui/TaskIconItem.qml @@ -70,17 +70,6 @@ Item{ color: "transparent" } */ - /*Connections{ - target: root - onZoomFactorChanged: updateImages() - onIconSizeChanged: updateImages() - onEnableShadowsChanged: updateImages() - } - - onIconDecorationChanged: { - updateImages(); - }*/ - onSmartLauncherEnabledChanged: { if (smartLauncherEnabled && !smartLauncherItem) { var smartLauncher = Qt.createQmlObject( @@ -113,41 +102,6 @@ Item{ onTempColorChanged: tempColor.a = 0.35; } - //temporary buffers containing the normal Image icon and the zoomed Image icon - // Image{id:zoomedImage; visible:false} - // Image{id:normalImage; visible:false} - Image{ - id:shadowedImage - anchors.centerIn:iconGraphic - // anchors.horizontalCenter: iconImageBuffer.horizontalCenter - //anchors.verticalCenter: iconImageBuffer.verticalCenter - - width:iconImageBuffer.width+2*shadowSize - height:iconImageBuffer.height+2*shadowSize - - //visible: plasmoid.configuration.showShadows - visible: false - - states: State { - name: "reparented" - ParentChange { target: shadowedImage; parent: root; } - } - - //Corize to use when a window is removed.... - /* Colorize{ - id: removeImageColorizer - source: parent - anchors.fill: parent - - enabled: false - visible: false - - hue: 0 - saturation: 0 - lightness: 0 - }*/ - } - /* Rectangle{ anchors.fill: parent border.width: 1 @@ -340,6 +294,7 @@ Item{ ///Shadow in tasks Loader{ + id: taskWithShadow anchors.fill: iconGraphic active: root.enableShadows @@ -395,55 +350,6 @@ Item{ lightness:0 } - //Something to show until the buffers are updated - - //KQuickControlAddons.QIconItem{ - /* - PlasmaCore.IconItem{ - id: iconImageBackground - - //property real relatedSize: root.iconSize * ( (doubleSize - 7) / doubleSize ); - // width: (visible) ? relatedSize * wrapper.scale : root.iconSize - width: (visible) ? root.iconSize * wrapper.scale : root.iconSize - height: width - anchors.centerIn: parent - - // state: wrapper.containsMouse ? KQuickControlAddons.QIconItem.ActiveState : KQuickControlAddons.QIconItem.DefaultState - // icon: decoration - active: wrapper.containsMouse - enabled: true - source: decoration - usesPlasmaTheme: false - - visible: ((iconImageBuffer.opacity == 1) && (root.enableShadows)) ? false : true - - Component{ - id:hideBackTimer - - Timer{ - id:hideBackgroundTimer - repeat:false - interval: centralItem.shadowInterval - - onTriggered: { - // iconImageBackground.visible = false; - iconImageBuffer.opacity = 1; - hideBackgroundTimer.destroy(); - // iconImageBuffer.visible = false; - } - - Component.onCompleted: hideBackgroundTimer.start(); - } - } - }*/ - - //Loader{ - // id:defaultWithShadow - //sourceComponent: imageBufferingComponent - // sourceComponent: TaskIconBuffers{} - // active: mainItemContainer.isStartup ? false : true - //} - ///////Activate animation///// SequentialAnimation{ id: clickedAnimation @@ -509,9 +415,6 @@ Item{ Component.onDestruction: { centralItem.toBeDestroyed = true; - if(shadowedImage && shadowedImage.source) - shadowedImage.source.destroy(); - if(removingAnimation.removingItem) removingAnimation.removingItem.destroy(); @@ -573,7 +476,6 @@ Item{ } } - onStopped: { //wrapper.mScale = 1; /* if ( root.noTasksInAnimation>0 ) { @@ -758,12 +660,7 @@ Item{ id:removingAnimation function init(){ - var relavantPoint - if(plasmoid.configuration.showShadows) - relavantPoint = root.mapFromItem(shadowedImage,0,0); - else - relavantPoint = root.mapFromItem(iconImageBuffer,0,0); - + var relavantPoint = root.mapFromItem(iconImageBuffer,0,0); var removingItem = removeTaskComponent.createObject(root); removingItem.x = relavantPoint.x; @@ -773,9 +670,7 @@ Item{ } function removeTask(){ - if(centralItem.firstDrawed && !centralItem.toBeDestroyed - && mainItemContainer.buffersAreReady && plasmoid.configuration.showShadows - && windowSystem.compositingActive){ + if(!centralItem.toBeDestroyed && plasmoid.configuration.showShadows && windowSystem.compositingActive){ removingAnimation.init(); } } @@ -791,16 +686,20 @@ Item{ id: removeTaskComponent Item{ id: removeTask - width: plasmoid.configuration.showShadows ? shadowedImage.width : iconImageBuffer.width - height: plasmoid.configuration.showShadows ? shadowedImage.height : iconImageBuffer.height + width: iconImageBuffer.width + height: iconImageBuffer.height //parent: panel visible: false - Image { + Latte.IconItem{ id: tempRemoveIcon - source: plasmoid.configuration.showShadows ? shadowedImage.source : iconImageBuffer.source - anchors.fill: parent + anchors.centerIn: parent + + width: iconImageBuffer.width + height: width + + source: decoration } Colorize{ @@ -982,15 +881,4 @@ Item{ } ] - - ////////////////////////// - - /* function updateImages(){ - if(root){ - if(defaultWithShadow.item){ - defaultWithShadow.item.updateImage(); - } - } - }*/ - }// Icon Item diff --git a/plasmoid/contents/ui/ToolTipDelegate.qml b/plasmoid/contents/ui/ToolTipDelegate.qml deleted file mode 100644 index eda15176b..000000000 --- a/plasmoid/contents/ui/ToolTipDelegate.qml +++ /dev/null @@ -1,438 +0,0 @@ -/* -* 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.0 -import QtQuick.Layouts 1.1 -import QtGraphicalEffects 1.0 - -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons - -//Column { -MouseArea{ - id: tooltipContentItem - hoverEnabled: true - - property Item toolTip - property var parentIndex - property var titles - property var windows - property string mainText - property string subText - property variant icon - property url launcherUrl - property bool group: windows ? (windows.length > 1) : false - - readonly property int thumbnailWidth: units.gridUnit * 15 - readonly property int thumbnailHeight: units.gridUnit * 10 - - property int preferredTextWidth: theme.mSize(theme.defaultFont).width * 30 - property int _s: units.largeSpacing / 2 - - Layout.minimumWidth: Math.max(thumbnailWidth, windowRow.width, appLabelRow.width) + _s - Layout.minimumHeight: childrenRect.height - Layout.maximumWidth: Layout.minimumWidth - Layout.maximumHeight: Layout.minimumHeight - - onContainsMouseChanged: { - checkMouseInside(); - } - - function checkMouseInside(){ - var isInside = containsMouse || windowRow.containsMouse(); - if (isInside){ - toolTipDelegate.currentItem = parentIndex; - } - else{ - root.disableRestoreZoom = false; - toolTipDelegate.currentItem = -1; - checkListHovered.restart(); - } - } - - states: State { - when: mpris2Source.hasPlayer - - PropertyChanges { - target: thumbnailSourceItem - opacity: 0 // cannot set visible to false or else WindowThumbnail won't provide thumbnail - } - PropertyChanges { - target: playerControlsOpacityMask - visible: true - source: thumbnailSourceItem - maskSource: playerControlsShadowMask - } - PropertyChanges { - target: playerControlsRow - visible: mpris2Source.hasPlayer - } - } - - PlasmaCore.DataSource { - id: mpris2Source - readonly property string current: { - var desktopFileName = launcherUrl.toString().split('/').pop().replace(".desktop", "") - - for (var i = 0, length = sources.length; i < length; ++i) { - var source = sources[i]; - var sourceData = data[source]; - - if (sourceData && sourceData.DesktopEntry === desktopFileName) { - return source - } - } - - return "" - } - - readonly property bool hasPlayer: !!current - - readonly property bool playing: hasPlayer && data[current].PlaybackStatus === "Playing" - readonly property bool canControl: hasPlayer && data[current].CanControl - readonly property bool canGoBack: hasPlayer && data[current].CanGoPrevious - readonly property bool canGoNext: hasPlayer && data[current].CanGoNext - readonly property bool canRaise: hasPlayer && data[current].CanRaise - - readonly property var currentMetadata: hasPlayer ? data[current].Metadata : ({}) - - readonly property string track: { - var xesamTitle = currentMetadata["xesam:title"] - if (xesamTitle) { - return xesamTitle - } - // if no track title is given, print out the file name - var xesamUrl = currentMetadata["xesam:url"] ? currentMetadata["xesam:url"].toString() : "" - if (!xesamUrl) { - return "" - } - var lastSlashPos = xesamUrl.lastIndexOf('/') - if (lastSlashPos < 0) { - return "" - } - var lastUrlPart = xesamUrl.substring(lastSlashPos + 1) - return decodeURIComponent(lastUrlPart) - } - readonly property string artist: currentMetadata["xesam:artist"] || "" - readonly property string albumArt: currentMetadata["mpris:artUrl"] || "" - - function goPrevious() { - startOperation("Previous") - } - - function goNext() { - startOperation("Next") - } - - function playPause() { - startOperation("PlayPause") - } - - function raise() { - startOperation("Raise") - } - - function startOperation(op) { - var service = mpris2Source.serviceForSource(current) - var operation = service.operationDescription(op) - return service.startOperationCall(operation) - } - - engine: "mpris2" - connectedSources: sources - } - - Column{ - spacing: _s - - Item { - id: thumbnailContainer - width: Math.max(tooltipContentItem.width, windowRow.width) - height: albumArtImage.available ? albumArtImage.height : - raisePlayerArea.visible ? raisePlayerArea.height : - windowRow.height - - Item { - id: thumbnailSourceItem - anchors.fill: parent - - PlasmaExtras.ScrollArea { - id: scrollArea - anchors.horizontalCenter: parent.horizontalCenter - width: Math.max(windowRow.width, thumbnailWidth) - height: parent.height - - visible: !albumArtImage.available - - verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff - horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff - - Component.onCompleted: { - flickableItem.interactive = Qt.binding(function() { - return contentItem.width > viewport.width; - }); - } - - Row { - id: windowRow - width: childrenRect.width - height: childrenRect.height - spacing: units.largeSpacing - - Repeater { - model: (root.showPreviews && !albumArtImage.available) - || !windowSystem.compositingActive ? windows : null - - Column{ - PlasmaCore.WindowThumbnail { - id: windowThumbnail - - width: thumbnailWidth - height: thumbnailHeight - - winId: modelData - - ToolTipWindowMouseArea { - anchors.fill: parent - modelIndex: tasksModel.makeModelIndex(parentIndex, group ? index : -1) - winId: modelData - thumbnailItem: parent - } - } - - PlasmaComponents.Label{ - text: titles && titles[index] ? titles[index] : "" - wrapMode: Text.Wrap - font.italic: true - elide: Text.ElideRight - opacity: 0.7 - textFormat: Text.PlainText - verticalAlignment: Text.AlignVCenter - - width: thumbnailWidth - } - } - - } - - function containsMouse(){ - for(var i=0; i