From 1ef4de0da83e2b54c20f163824dbef65bdd68387 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 17 May 2019 21:28:39 +0300 Subject: [PATCH] VASTLY IMPROVE dragging experience --when dragging a new applet over the view the responsiveness is now improved vastly --the new architecture uses two different DragAndDropAreas. One which is the old one and is used when dragged launchers, urls and separators. The second is used only when applets are dragged into the view --the visuals for adding launchers/applets have been improved and a circular visual is preferred now instead --- app/view/view.cpp | 24 ++ app/view/view.h | 6 + .../package/contents/ui/AddWidgetVisual.qml | 25 +- .../package/contents/ui/DragDropArea.qml | 208 ++++++++++++++++ containment/package/contents/ui/PanelBox.qml | 4 +- .../package/contents/ui/applet/AppletItem.qml | 51 +++- .../contents/ui/applet/ItemWrapper.qml | 6 +- containment/package/contents/ui/main.qml | 225 +++++------------- plasmoid/package/contents/ui/main.qml | 15 +- .../package/contents/ui/task/IconItem.qml | 11 +- .../contents/ui/task/VisualAddItem.qml | 32 ++- .../contents/ui/taskslayout/MouseHandler.qml | 8 +- 12 files changed, 420 insertions(+), 195 deletions(-) create mode 100644 containment/package/contents/ui/DragDropArea.qml diff --git a/app/view/view.cpp b/app/view/view.cpp index e7d82d92e..2e32d755c 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -509,6 +509,21 @@ void View::setAlternativesIsShown(bool show) emit alternativesIsShownChanged(); } +bool View::containsDrag() const +{ + return m_containsDrag; +} + +void View::setContainsDrag(bool contains) +{ + if (m_containsDrag == contains) { + return; + } + + m_containsDrag = contains; + emit containsDragChanged(); +} + bool View::containsMouse() const { return m_containsMouse; @@ -1074,6 +1089,15 @@ bool View::event(QEvent *e) engine()->trimComponentCache(); break; + case QEvent::DragEnter: + setContainsDrag(true); + break; + + case QEvent::DragLeave: + case QEvent::Drop: + setContainsDrag(false); + break; + case QEvent::MouseButtonPress: if (auto mouseEvent = dynamic_cast(e)) { emit mousePressed(mouseEvent->pos(), mouseEvent->button()); diff --git a/app/view/view.h b/app/view/view.h index dad3bd37e..5d79f4d71 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -77,6 +77,7 @@ class View : public PlasmaQuick::ContainmentView Q_PROPERTY(bool alternativesIsShown READ alternativesIsShown NOTIFY alternativesIsShownChanged) Q_PROPERTY(bool behaveAsPlasmaPanel READ behaveAsPlasmaPanel WRITE setBehaveAsPlasmaPanel NOTIFY behaveAsPlasmaPanelChanged) Q_PROPERTY(bool byPassWM READ byPassWM WRITE setByPassWM NOTIFY byPassWMChanged) + Q_PROPERTY(bool containsDrag READ containsDrag NOTIFY containsDragChanged) Q_PROPERTY(bool contextMenuIsShown READ contextMenuIsShown NOTIFY contextMenuIsShownChanged) //! Because Latte uses animations, changing to edit mode it may be different than //! when the isUserConfiguring changes value @@ -131,6 +132,7 @@ public: bool behaveAsPlasmaPanel() const; void setBehaveAsPlasmaPanel(bool behavior); + bool containsDrag() const; bool containsMouse() const; bool contextMenuIsShown() const; @@ -236,6 +238,7 @@ signals: void behaveAsPlasmaPanelChanged(); void byPassWMChanged(); void configWindowGeometryChanged(); // is called from config windows + void containsDragChanged(); void contextMenuIsShownChanged(); void dockLocationChanged(); void editThicknessChanged(); @@ -280,12 +283,15 @@ private: void setupWaylandIntegration(); void updateAppletContainsMethod(); + void setContainsDrag(bool contains); + private: Plasma::Containment *containmentById(uint id); bool m_alternativesIsShown{false}; bool m_behaveAsPlasmaPanel{false}; bool m_byPassWM{true}; + bool m_containsDrag{false}; bool m_containsMouse{false}; bool m_inDelete{false}; bool m_inEditMode{false}; diff --git a/containment/package/contents/ui/AddWidgetVisual.qml b/containment/package/contents/ui/AddWidgetVisual.qml index 12c5dbfa3..547fd804b 100644 --- a/containment/package/contents/ui/AddWidgetVisual.qml +++ b/containment/package/contents/ui/AddWidgetVisual.qml @@ -20,21 +20,34 @@ import QtQuick 2.1 +import "../code/ColorizerTools.js" as ColorizerTools + Item{ id: newDroppedLauncherVisual anchors.fill: parent Rectangle{ - anchors.fill: parent + width: Math.min(parent.width, parent.height) + height: width + anchors.centerIn: parent - radius: root.iconSize/10 + radius: Math.max(width,height)/2 - property color tempColor: "#aa222222" - color: tempColor + color: theme.backgroundColor // "#aa222222" border.width: 1 - border.color: "#ff656565" + border.color: outlineColor // "#ff656565" + + property int crossSize: Math.min(0.4*parent.width, 0.4 * parent.height) - property int crossSize: Math.min(parent.width/2, parent.height/2) + readonly property color outlineColorBase: theme.backgroundColor + readonly property real outlineColorBaseBrightness: ColorizerTools.colorBrightness(outlineColorBase) + readonly property color outlineColor: { + if (outlineColorBaseBrightness > 127.5) { + return Qt.darker(outlineColorBase, 1.5); + } else { + return Qt.lighter(outlineColorBase, 2.2); + } + } Rectangle{width: parent.crossSize; height: 4; radius:2; anchors.centerIn: parent; color: theme.highlightColor} Rectangle{width: 4; height: parent.crossSize; radius:2; anchors.centerIn: parent; color: theme.highlightColor} diff --git a/containment/package/contents/ui/DragDropArea.qml b/containment/package/contents/ui/DragDropArea.qml new file mode 100644 index 000000000..d43e466cd --- /dev/null +++ b/containment/package/contents/ui/DragDropArea.qml @@ -0,0 +1,208 @@ +/* +* Copyright 2019 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.7 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.draganddrop 2.0 as DragDrop + +import org.kde.latte 0.2 as Latte + +DragDrop.DropArea { + id: dragArea + + property bool isForeground: false + + readonly property Item dragInfo: Item { + property bool entered: false + property bool isTask: false + property bool isPlasmoid: false + property bool isSeparator: false + property bool isLatteTasks: false + property bool onlyLaunchers: false + } + + Connections{ + target: root.dragInfo + + onEnteredChanged: { + if(!root.dragInfo.entered) { + dragArea.clearInfo(); + } + } + } + + Connections{ + target: latteView + + onContainsDragChanged: { + if(!latteView.containsDrag) { + dragArea.clearInfo(); + } + } + } + + function clearInfo() { + dragArea.dragInfo.entered = false; + dragArea.dragInfo.isTask = false; + dragArea.dragInfo.isPlasmoid = false; + dragArea.dragInfo.isSeparator = false; + dragArea.dragInfo.isLatteTasks = false; + dragArea.dragInfo.onlyLaunchers = false; + + dndSpacer.parent = root; + dndSpacer.opacity = 0; + } + + onDragEnter: { + var isTask = event !== undefined + && event.mimeData !== undefined + && event.mimeData.formats !== undefined + && event.mimeData.formats.indexOf("application/x-orgkdeplasmataskmanager_taskbuttonitem") >= 0; + + var isSeparator = event !== undefined + && event.mimeData !== undefined + && ( latteView.mimeContainsPlasmoid(event.mimeData, "audoban.applet.separator") + || latteView.mimeContainsPlasmoid(event.mimeData, "org.kde.latte.separator") ); + + var isLatteTasks = event !== undefined + && event.mimeData !== undefined + && latteView.mimeContainsPlasmoid(event.mimeData, "org.kde.latte.plasmoid"); + + var isPlasmoid = event !== undefined + && event.mimeData !== undefined + && event.mimeData.formats !== undefined + && !event.mimeData.hasUrls + && event.mimeData.formats.indexOf("text/x-plasmoidservicename") === 0; + + dragInfo.isTask = isTask; + dragInfo.isPlasmoid = isPlasmoid; + dragInfo.isSeparator = isSeparator; + dragInfo.isLatteTasks = isLatteTasks; + dragInfo.onlyLaunchers = latteApplet ? latteApplet.launchersDrop(event) : false; + + dragInfo.entered = true; + slotAnimationsNeedLength(1); + + if (dragInfo.isTask || plasmoid.immutable || dockIsHidden || visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) { + event.ignore(); + return; + } + + if (latteApplet && (dragInfo.onlyLaunchers || dragInfo.isSeparator || !dragInfo.isPlasmoid)) { + if (dragInfo.onlyLaunchers) { + root.addLaunchersMessage = true; + if (root.addLaunchersInTaskManager || root.latteAppletContainer.containsPos(event)) { + dndSpacer.opacity = 0; + dndSpacer.parent = root; + return; + } + } else { + if ((dragInfo.isSeparator || !dragInfo.isPlasmoid) && root.latteAppletContainer.containsPos(event)) { + dndSpacer.opacity = 0; + dndSpacer.parent = root; + return; + } + } + } + + // if (!dragInfo.entered) { + // dragInfo.entered = true; + // slotAnimationsNeedLength(1); +// } + + if (!dragResistaner.running && (!latteApplet || (latteApplet && !dragInfo.isLatteTasks))) { + if (!isForeground) { + dragResistaner.start(); + } + + root.layoutManager().insertAtCoordinates2(dndSpacer, event.x, event.y) + dndSpacer.opacity = 1; + } + } + + onDragMove: { + if (dragInfo.isTask) { + return; + } + + if (latteApplet && (dragInfo.onlyLaunchers || dragInfo.isSeparator || !dragInfo.isPlasmoid)) { + if (dragInfo.onlyLaunchers) { + root.addLaunchersMessage = true; + if (root.addLaunchersInTaskManager || root.latteAppletContainer.containsPos(event)) { + dragInfo.entered = true + dndSpacer.opacity = 0; + dndSpacer.parent = root; + return; + } + } else { + if ((dragInfo.isSeparator || !dragInfo.isPlasmoid) && root.latteAppletContainer.containsPos(event)) { + dragInfo.entered = true + dndSpacer.opacity = 0; + dndSpacer.parent = root; + return; + } + } + } + + if (!dragResistaner.running && (!latteApplet || (latteApplet && !dragInfo.isLatteTasks))) { + if (!isForeground) { + dragResistaner.start(); + } + + root.layoutManager().insertAtCoordinates2(dndSpacer, event.x, event.y) + dndSpacer.opacity = 1; + } + } + + Timer { + id: dragResistaner + interval: 1000 + } + + onDragLeave: { + if (dragInfo.entered) { + slotAnimationsNeedLength(-1); + dragInfo.entered = false; + } + + root.addLaunchersMessage = false; + } + + onDrop: { + if (dragInfo.entered) { + slotAnimationsNeedLength(-1); + dragInfo.entered = false; + } + + if (dragInfo.isTask || dockIsHidden || visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) { + return; + } + + if (latteApplet && dragInfo.onlyLaunchers && (root.addLaunchersInTaskManager || root.latteAppletContainer.containsPos(event))) { + latteApplet.launchersDropped(event.mimeData.urls); + } else if (!latteApplet || (latteApplet && !dragInfo.isLatteTasks)) { + plasmoid.processMimeData(event.mimeData, event.x, event.y); + event.accept(event.proposedAction); + } + + root.addLaunchersMessage = false; + dndSpacer.opacity = 0; + } +} diff --git a/containment/package/contents/ui/PanelBox.qml b/containment/package/contents/ui/PanelBox.qml index dc05b12bb..0e77c1fdf 100644 --- a/containment/package/contents/ui/PanelBox.qml +++ b/containment/package/contents/ui/PanelBox.qml @@ -54,7 +54,7 @@ Item{ if ((root.panelAlignment === Latte.Types.Justify) && root.isHorizontal) { return root.maxLength; } else { - return layoutsContainer.mainLayout.width + spacing; + return layoutsContainerItem.mainLayout.width + spacing; } } } @@ -66,7 +66,7 @@ Item{ if ((root.panelAlignment === Latte.Types.Justify) && root.isVertical) { return root.maxLength; } else { - return layoutsContainer.mainLayout.height + spacing; + return layoutsContainerItem.mainLayout.height + spacing; } } } diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 091cbccad..559c04be4 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -157,17 +157,54 @@ Item { property bool containsMouse: appletMouseArea.containsMouse /*|| appletMouseAreaBottom.containsMouse*/ property bool pressed: viewSignalsConnector.pressed || clickedAnimation.running - /*onComputeHeightChanged: { - if(index==0) - console.log(computeHeight); - }*/ - transitions: Transition { - ParentAnimation { - NumberAnimation { properties: "x,y"; duration: 1000 } + //// BEGIN :: Animate Applet when a new applet is dragged in the view + + //when the applet moves caused by its resize, don't animate. + //this is completely heuristic, but looks way less "jumpy" + property bool movingForResize: false + property int oldX: x + property int oldY: y + + onXChanged: { + if (movingForResize || !root.dragInfo.entered) { + movingForResize = false; + return; + } + translation.x = oldX - x + translation.y = oldY - y + translAnim.running = true + oldX = x + oldY = y + } + + onYChanged: { + if (movingForResize || !root.dragInfo.entered) { + movingForResize = false; + return; } + translation.x = oldX - x + translation.y = oldY - y + translAnim.running = true + oldX = x + oldY = y } + transform: Translate { + id: translation + } + + NumberAnimation { + id: translAnim + duration: units.longDuration + easing.type: Easing.InOutQuad + target: translation + properties: "x,y" + to: 0 + } + + //// END :: Animate Applet when a new applet is dragged in the view + /// BEGIN functions function activateAppletForNeutralAreas(mouse){ //if the event is at the active indicator or spacers area then try to expand the applet, diff --git a/containment/package/contents/ui/applet/ItemWrapper.qml b/containment/package/contents/ui/applet/ItemWrapper.qml index 5b8e7980f..7b369b89c 100644 --- a/containment/package/contents/ui/applet/ItemWrapper.qml +++ b/containment/package/contents/ui/applet/ItemWrapper.qml @@ -214,7 +214,7 @@ Item{ updateLayoutWidth(); } - onAppletMinimumHeightChanged: { + onAppletMinimumHeightChanged: { if(zoomScale === 1) { checkCanBeHovered(); } @@ -287,6 +287,8 @@ Item{ } function updateLayoutHeight(){ + appletItem.movingForResize = true; + if (appletItem.needsFillSpace && root.isVertical) { layoutsContainer.updateSizeForAppletsInFill(); return; @@ -335,6 +337,8 @@ Item{ } function updateLayoutWidth(){ + appletItem.movingForResize = true; + if (appletItem.needsFillSpace && root.isHorizontal) { layoutsContainer.updateSizeForAppletsInFill(); return; diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 18e97bc76..b976f5ae0 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -26,7 +26,6 @@ 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 -import org.kde.draganddrop 2.0 as DragDrop import org.kde.plasma.plasmoid 2.0 import org.kde.latte 0.2 as Latte @@ -38,7 +37,7 @@ import "indicators" as Indicators import "layouts" as Layouts import "../code/LayoutManager.js" as LayoutManager -DragDrop.DropArea { +Item { id: root objectName: "containmentViewLayout" @@ -99,11 +98,17 @@ DragDrop.DropArea { property bool blurEnabled: plasmoid.configuration.blurEnabled && (!forceTransparentPanel || forcePanelForBusyBackground) - property bool confirmedDragEntered: false - property bool dragIsTask: false - property bool dragIsSeparator: false - property bool dragIsLatteTasks: false - property bool dragOnlyLaunchers: false + readonly property Item dragInfo: Item { + property bool entered: backDropArea.dragInfo.entered || foreDropArea.dragInfo.entered + property bool isTask: backDropArea.dragInfo.isTask || foreDropArea.dragInfo.isTask + property bool isPlasmoid: backDropArea.dragInfo.isPlasmoid || foreDropArea.dragInfo.isPlasmoid + property bool isSeparator: backDropArea.dragInfo.isSeparator || foreDropArea.dragInfo.isSeparator + property bool isLatteTasks: backDropArea.dragInfo.isLatteTasks || foreDropArea.dragInfo.isLatteTasks + property bool onlyLaunchers: backDropArea.dragInfo.onlyLaunchers || foreDropArea.dragInfo.onlyLaunchers + + // onIsPlasmoidChanged: console.log("isPlasmoid :: " + backDropArea.dragInfo.isPlasmoid + " _ " + foreDropArea.dragInfo.isPlasmoid ); + // onEnteredChanged: console.log("entered :: " + backDropArea.dragInfo.entered + " _ " + foreDropArea.dragInfo.entered ); + } property bool containsOnlyPlasmaTasks: false //this is flag to indicate when from tasks only a plasma based one is found property bool dockContainsMouse: latteView && latteView.visibility ? latteView.visibility.containsMouse : false @@ -393,6 +398,7 @@ DragDrop.DropArea { readonly property Item indicatorsManager: indicators readonly property Item parabolicManager: _parabolicManager readonly property Item maskManager: visibilityManager + readonly property Item layoutsContainerItem: layoutsContainer property QtObject latteView: null property QtObject shortcutsEngine: null @@ -665,130 +671,6 @@ DragDrop.DropArea { } } - onDragEnter: { - var isTask = event !== undefined - && event.mimeData !== undefined - && event.mimeData.formats !== undefined - && event.mimeData.formats.indexOf("application/x-orgkdeplasmataskmanager_taskbuttonitem") >= 0; - - var isSeparator = event !== undefined - && event.mimeData !== undefined - && ( latteView.mimeContainsPlasmoid(event.mimeData, "audoban.applet.separator") - || latteView.mimeContainsPlasmoid(event.mimeData, "org.kde.latte.separator") ); - - var isLatteTasks = event !== undefined - && event.mimeData !== undefined - && latteView.mimeContainsPlasmoid(event.mimeData, "org.kde.latte.plasmoid"); - - dragIsTask = isTask; - dragIsSeparator = isSeparator; - dragIsLatteTasks = isLatteTasks; - dragOnlyLaunchers = latteApplet ? latteApplet.launchersDrop(event) : false; - - if (dragIsTask || plasmoid.immutable || dockIsHidden || visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) { - event.ignore(); - return; - } - - if (latteApplet) { - if (dragOnlyLaunchers) { - root.addLaunchersMessage = true; - if (root.addLaunchersInTaskManager || root.latteAppletContainer.containsPos(event)) { - confirmedDragEntered = true - dndSpacer.opacity = 0; - dndSpacer.parent = root; - return; - } - } else { - if (dragIsSeparator && root.latteAppletContainer.containsPos(event)) { - confirmedDragEntered = true - dndSpacer.opacity = 0; - dndSpacer.parent = root; - return; - } - } - } - - if (!confirmedDragEntered) { - confirmedDragEntered = true; - slotAnimationsNeedLength(1); - } - - if (!latteApplet || (latteApplet && !dragIsLatteTasks)) { - LayoutManager.insertAtCoordinates2(dndSpacer, event.x, event.y) - dndSpacer.opacity = 1; - } - } - - onDragMove: { - if (dragIsTask) { - return; - } - - if (latteApplet && (dragOnlyLaunchers || dragIsSeparator)) { - if (dragOnlyLaunchers) { - root.addLaunchersMessage = true; - if (root.addLaunchersInTaskManager || root.latteAppletContainer.containsPos(event)) { - confirmedDragEntered = true - dndSpacer.opacity = 0; - dndSpacer.parent = root; - return; - } - } else { - if (dragIsSeparator && root.latteAppletContainer.containsPos(event)) { - confirmedDragEntered = true - dndSpacer.opacity = 0; - dndSpacer.parent = root; - return; - } - } - } - - if (!latteApplet || (latteApplet && !dragIsLatteTasks)) { - LayoutManager.insertAtCoordinates2(dndSpacer, event.x, event.y) - dndSpacer.opacity = 1; - } - } - - onDragLeave: { - /* dragIsTask = false; - dragIsSeparator = false; - dragIsLatteTasks = false; - dragOnlyLaunchers = false;*/ - - if (confirmedDragEntered) { - slotAnimationsNeedLength(-1); - confirmedDragEntered = false; - } - - root.addLaunchersMessage = false; - dndSpacer.opacity = 0; - dndSpacer.parent = root; - } - - onDrop: { - if (dragIsTask || dockIsHidden || visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) { - return; - } - - if (latteApplet && dragOnlyLaunchers && (root.addLaunchersInTaskManager || root.latteAppletContainer.containsPos(event))) { - latteApplet.launchersDropped(event.mimeData.urls); - } else if (!latteApplet || (latteApplet && !dragIsLatteTasks)) { - plasmoid.processMimeData(event.mimeData, event.x, event.y); - event.accept(event.proposedAction); - } - - if (confirmedDragEntered) { - slotAnimationsNeedLength(-1); - confirmedDragEntered = false; - } - - root.addLaunchersMessage = false; - dndSpacer.opacity = 0; - //! this line is very important because it positions correctly the new applets - //dndSpacer.parent = root; - } - onMaxLengthChanged: { layoutsContainer.updateSizeForAppletsInFill(); if (root.editMode) { @@ -1203,6 +1085,10 @@ DragDrop.DropArea { } } + function layoutManager() { + return LayoutManager; + } + function layoutManagerInsertBefore(place, item) { LayoutManager.insertBefore(place, item); } @@ -1799,17 +1685,6 @@ DragDrop.DropArea { // z: root.behaveAsPlasmaPanel ? 1 : 0 } - Item{ - id: panelBox - - anchors.fill:layoutsContainer - // z: root.behaveAsPlasmaPanel ? 0 : 1 - - PanelBox{ - id: panelBoxBackground - } - } - Item { id: lastSpacer parent: layoutsContainer.mainLayout @@ -1826,22 +1701,6 @@ DragDrop.DropArea { } } - Item { - id: dndSpacer - - property int normalSize: root.iconSize + root.thickMargins - 1 - - width: normalSize - height: normalSize - - Layout.preferredWidth: width - Layout.preferredHeight: height - opacity: 0 - z:10 - - AddWidgetVisual{} - } - Loader{ anchors.fill: parent active: root.debugMode @@ -1858,14 +1717,60 @@ DragDrop.DropArea { VisibilityManager{ id: visibilityManager } - Layouts.LayoutsContainer { - id: layoutsContainer + DragDropArea { + id: backDropArea + anchors.fill: parent + + Item{ + id: panelBox + + anchors.fill: layoutsContainer + // z: root.behaveAsPlasmaPanel ? 0 : 1 + + PanelBox{ + id: panelBoxBackground + } + } + + Layouts.LayoutsContainer { + id: layoutsContainer + } + + DragDropArea { + id: foreDropArea + anchors.fill: parent + visible: latteView && latteView.containsDrag && root.dragInfo.isPlasmoid && !root.dragInfo.isSeparator + isForeground: true + + /* Rectangle { + anchors.fill: parent + color: "blue" + opacity: 0.5 + }*/ + } } Colorizer.Manager { id: colorizerManager } + Item { + id: dndSpacer + + width: root.isHorizontal ? length : thickness + height: root.isHorizontal ? thickness : length + + readonly property int length: root.iconSize + root.lengthMargins + readonly property int thickness: root.iconSize + root.thickMargins + + Layout.preferredWidth: width + Layout.preferredHeight: height + opacity: 0 + z:1500 + + AddWidgetVisual{} + } + ///////////////END UI elements ///////////////BEGIN TIMER elements diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index 17d4ee9fe..82d942a81 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -150,9 +150,11 @@ Item { return ((iconSize + heightMargins) * zoomFactor) - maxSeparatorLength; } + readonly property alias containsDrag: mouseHandler.containsDrag readonly property bool dragAreaEnabled: latteView ? (root.dragSource !== null - || latteView.dragIsSeparator - || latteView.dragIsTask) + || latteView.dragInfo.isSeparator + || latteView.dragInfo.isTask + || !latteView.dragInfo.isPlasmoid) : true //! it is used to play the animation correct when the user removes a launcher @@ -1371,10 +1373,15 @@ Item { Task.VisualAddItem{ id: newDroppedLauncherVisual - anchors.fill: mouseHandler + width: !root.vertical ? length : thickness + height: !root.vertical ? thickness : length + anchors.centerIn: mouseHandler + + readonly property int length: root.iconSize + root.lengthMargins + readonly property int thickness: root.iconSize + root.thickMargins visible: opacity == 0 ? false : true - opacity: root.dropNewLauncher && mouseHandler.onlyLaunchers && (root.dragSource == null)? 1 : 0 + opacity: root.dropNewLauncher && mouseHandler.onlyLaunchers && (root.dragSource == null)? 0.7 : 0 } } diff --git a/plasmoid/package/contents/ui/task/IconItem.qml b/plasmoid/package/contents/ui/task/IconItem.qml index 00563ed76..0f7eba382 100644 --- a/plasmoid/package/contents/ui/task/IconItem.qml +++ b/plasmoid/package/contents/ui/task/IconItem.qml @@ -561,11 +561,18 @@ Item{ VisualAddItem{ id: dropFilesVisual - anchors.fill: iconGraphic + width: !root.vertical ? length : thickness + height: !root.vertical ? thickness : length + anchors.centerIn: parent + + readonly property int length: root.iconSize + root.lengthMargins + readonly property int thickness: root.iconSize + root.thickMargins + + //anchors.fill: iconGraphic visible: opacity == 0 ? false : true opacity: root.dropNewLauncher && !mouseHandler.onlyLaunchers - && (root.dragSource == null) && (mouseHandler.hoveredItem === taskItem) ? 1 : 0 + && (root.dragSource == null) && (mouseHandler.hoveredItem === taskItem) ? 0.7 : 0 } Component.onDestruction: { diff --git a/plasmoid/package/contents/ui/task/VisualAddItem.qml b/plasmoid/package/contents/ui/task/VisualAddItem.qml index 2c68c6ac0..a36ff966e 100644 --- a/plasmoid/package/contents/ui/task/VisualAddItem.qml +++ b/plasmoid/package/contents/ui/task/VisualAddItem.qml @@ -22,23 +22,31 @@ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore +import "../../code/ColorizerTools.js" as ColorizerTools + Item{ Rectangle{ - anchors.fill: parent - - anchors.bottom: (root.position === PlasmaCore.Types.TopPositioned) ? parent.bottom : undefined - anchors.top: (root.position === PlasmaCore.Types.BottomPositioned) ? parent.top : undefined - anchors.left: (root.position === PlasmaCore.Types.RightPositioned) ? parent.left : undefined - anchors.right: (root.position === PlasmaCore.Types.LeftPositioned) ? parent.right : undefined + width: Math.min(parent.width, parent.height) + height: width + anchors.centerIn: parent - radius: root.iconSize/10 + radius: Math.max(width,height)/2 - property color tempColor: "#aa222222" - color: tempColor + color: theme.backgroundColor // "#aa222222" border.width: 1 - border.color: "#ff656565" - - property int crossSize: Math.min(parent.width/2, parent.height/2) + border.color: outlineColor // "#ff656565" + + property int crossSize: Math.min(0.4*parent.width, 0.4 * parent.height) + + readonly property color outlineColorBase: theme.backgroundColor + readonly property real outlineColorBaseBrightness: ColorizerTools.colorBrightness(outlineColorBase) + readonly property color outlineColor: { + if (outlineColorBaseBrightness > 127.5) { + return Qt.darker(outlineColorBase, 1.5); + } else { + return Qt.lighter(outlineColorBase, 2.2); + } + } Rectangle{width: parent.crossSize; height: 4; anchors.centerIn: parent; color: theme.highlightColor} Rectangle{width: 4; height: parent.crossSize; anchors.centerIn: parent; color: theme.highlightColor} diff --git a/plasmoid/package/contents/ui/taskslayout/MouseHandler.qml b/plasmoid/package/contents/ui/taskslayout/MouseHandler.qml index 073d881d7..fe9dff93d 100644 --- a/plasmoid/package/contents/ui/taskslayout/MouseHandler.qml +++ b/plasmoid/package/contents/ui/taskslayout/MouseHandler.qml @@ -32,16 +32,17 @@ import "../../code/tools.js" as TaskTools Item { // signal urlDropped(url url) + id: dArea signal urlsDropped(var urls) property Item target property Item ignoredItem property bool moved: false + property bool containsDrag: false property alias hoveredItem: dropHandler.hoveredItem property alias onlyLaunchers: dropHandler.onlyLaunchers - Timer { id: ignoreItemTimer @@ -84,6 +85,8 @@ Item { } onDragEnter:{ + dArea.containsDrag = true; + if(root.dragSource == null){ onlyLaunchers = false; droppingSeparator = false; @@ -114,6 +117,7 @@ Item { } onDragMove: { + dArea.containsDrag = true; /* if(root.dragSource == null){ root.dropNewLauncher = true; } */ @@ -191,6 +195,7 @@ Item { } onDragLeave: { + dArea.containsDrag = false; hoveredItem = null; root.setHoveredIndex(-1); root.dropNewLauncher = false; @@ -201,6 +206,7 @@ Item { onDrop: { // Reject internal drops. + dArea.containsDrag = false; root.dropNewLauncher = false; onlyLaunchers = false; root.separatorsUpdated();