1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-02-05 17:47:23 +03:00

fix Tasks AddingArea positioning

This commit is contained in:
Michail Vourlakos 2020-05-02 20:58:42 +03:00
parent 22f9bdd6a7
commit db60035917
2 changed files with 161 additions and 24 deletions

View File

@ -21,7 +21,6 @@ import QtQuick 2.7
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import "code/ColorizerTools.js" as ColorizerTools
@ -45,40 +44,110 @@ Rectangle{
property real duration: 2
property string title: ""
Behavior on opacity{
NumberAnimation { duration: 2*addingArea.duration*appletItem.animationTime }
}
PlasmaExtras.Heading {
id: heading
width: parent.width
height: parent.height * 0.4
text: title
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
elide: Text.ElideRight
fontSizeMode: Text.Fit
Label {
id: heading
text: title
color: theme.textColor
font.bold: true
rotation: {
if (plasmoid.formFactor === PlasmaCore.Types.Horizontal)
return 0;
else if (plasmoid.location === PlasmaCore.Types.LeftEdge)
return -90;
else if (plasmoid.location === PlasmaCore.Types.RightEdge)
if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
return 90;
} else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
return -90;
}
return 0;
}
transformOrigin: {
if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
return Item.TopLeft;
} else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
return Item.TopRight;
}
return Item.Center;
}
readonly property int lengthEdge: addingArea.radius + units.smallSpacing
states: [
///Bottom Edge
State {
name: "left"
when: plasmoid.location === PlasmaCore.Types.LeftEdge
AnchorChanges {
target: heading
anchors{ top:parent.top; bottom:undefined; left:parent.right; right:undefined;}
}
PropertyChanges {
target: heading
anchors{ topMargin: heading.lengthEdge; bottomMargin:0; leftMargin:-units.smallSpacing; rightMargin:-0;}
}
},
State {
name: "right"
when: plasmoid.location === PlasmaCore.Types.RightEdge
AnchorChanges {
target: heading
anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.left;}
}
PropertyChanges {
target: heading
anchors{ topMargin:heading.lengthEdge; bottomMargin:0; leftMargin: 0; rightMargin:-units.smallSpacing;}
}
},
State {
name: "top"
when: plasmoid.location === PlasmaCore.Types.TopEdge
AnchorChanges {
target: heading
anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined;}
}
PropertyChanges {
target: heading
anchors{ topMargin:0; bottomMargin:units.smallSpacing; leftMargin: heading.lengthEdge; rightMargin:0;}
}
},
State {
name: "bottom"
when: plasmoid.location !== PlasmaCore.Types.TopEdge
&& plasmoid.location !== PlasmaCore.Types.LeftEdge
&& plasmoid.location !== PlasmaCore.Types.RightEdge
AnchorChanges {
target: heading
anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined;}
}
PropertyChanges {
target: heading
anchors{ topMargin:units.smallSpacing; bottomMargin:0; leftMargin: heading.lengthEdge; rightMargin:0;}
}
}
]
}
AddItem {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: heading.bottom
anchors.topMargin: units.smallSpacing
anchors.centerIn: parent
width: height
height: (parent.height * 0.5) - 2 * units.smallSpacing
width: thickness
height: thickness
readonly property int thickness: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? (parent.height - freeSpace):(parent.width - freeSpace)
readonly property int freeSpace: Math.max(16, (heading.implicitHeight + units.smallSpacing*2))
}
}

View File

@ -1098,7 +1098,7 @@ Item {
width: ( icList.orientation === Qt.Horizontal ) ? icList.width + spacing : smallSize
height: ( icList.orientation === Qt.Vertical ) ? icList.height + spacing : smallSize
property int spacing: latteView ? 0 : metrics.iconSize / 2
property int spacing: latteBridge ? 0 : metrics.iconSize / 2
property int smallSize: Math.max(0.10 * metrics.iconSize, 16)
Behavior on opacity{
@ -1382,13 +1382,81 @@ Item {
LatteComponents.AddingArea {
id: newDroppedLauncherVisual
anchors.fill: parent
width: root.vertical ? metrics.totals.thickness : mouseHandler.width
height: root.vertical ? mouseHandler.height : metrics.totals.thickness
visible: backgroundOpacity > 0
radius: metrics.iconSize/10
backgroundOpacity: root.dropNewLauncher && mouseHandler.onlyLaunchers && (root.dragSource == null)? 0.75 : 0
duration: animations.speedFactor.current
title: i18n("Tasks Area")
states: [
///Bottom Edge
State {
name: "left"
when: root.location===PlasmaCore.Types.LeftEdge
AnchorChanges {
target: newDroppedLauncherVisual
anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined;
horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
}
PropertyChanges {
target: newDroppedLauncherVisual
anchors{ topMargin:0; bottomMargin:0; leftMargin:metrics.margin.screenEdge; rightMargin:0;}
}
},
State {
name: "right"
when: root.location===PlasmaCore.Types.RightEdge
AnchorChanges {
target: newDroppedLauncherVisual
anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right;
horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
}
PropertyChanges {
target: newDroppedLauncherVisual
anchors{ topMargin:0; bottomMargin:0; leftMargin:0; rightMargin:metrics.margin.screenEdge;}
}
},
State {
name: "top"
when: root.location===PlasmaCore.Types.TopEdge
AnchorChanges {
target: newDroppedLauncherVisual
anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right;
horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
}
PropertyChanges {
target: newDroppedLauncherVisual
anchors{ topMargin:metrics.margin.screenEdge; bottomMargin:0; leftMargin:0; rightMargin:0;}
}
},
State {
name: "bottom"
when: root.location!==PlasmaCore.Types.TopEdge
&& root.location !== PlasmaCore.Types.LeftEdge
&& root.location !== PlasmaCore.Types.RightEdge
AnchorChanges {
target: newDroppedLauncherVisual
anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right;
horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
}
PropertyChanges {
target: newDroppedLauncherVisual
anchors{ topMargin:0; bottomMargin:metrics.margin.screenEdge; leftMargin:0; rightMargin:0;}
}
}
]
}
}