1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-27 02:50:22 +03:00

provide SeparatorItem for BasicItem

This commit is contained in:
Michail Vourlakos 2021-02-04 19:15:39 +02:00
parent 1d7e939356
commit 0c273fcaf2
2 changed files with 109 additions and 65 deletions

View File

@ -47,7 +47,7 @@ Item{
return 0;
if (isSeparator) {
if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {
if (abilityItem.isVertical) {
return abilityItem.abilities.metrics.totals.thickness + abilityItem.abilities.metrics.margin.screenEdge;
} else {
if (isSeparatorInRealLength || !abilityItem.abilities.parabolic.isEnabled) {
@ -96,6 +96,8 @@ Item{
property bool isHidden: false
property bool isSeparator: false
property bool isSeparatorInRealLength: false
property bool isSeparatorHidden: false
readonly property bool isSeparatorVisible: isSeparator && !isSeparatorHidden && !tailItemIsSeparator
property bool containsMouse: false
@ -108,6 +110,16 @@ Item{
readonly property bool isVertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
readonly property bool parabolicAreaContainsMouse: parabolicEventsAreaLoader.active && parabolicEventsAreaLoader.item.containsMouse
readonly property int location: {
if (plasmoid.location === PlasmaCore.Types.LeftEdge
|| plasmoid.location === PlasmaCore.Types.RightEdge
|| plasmoid.location === PlasmaCore.Types.TopEdge) {
return plasmoid.location;
}
return PlasmaCore.Types.BottomEdge;
}
readonly property int itemIndex: index
readonly property int animationTime: (abilityItem.abilities.animations.active ? abilityItem.abilities.animations.speedFactor.current : 2) * (1.2 * abilityItem.abilities.animations.duration.small)
readonly property int iconOffsetX: indicatorBackLayer.level.requested.iconOffsetX
@ -210,70 +222,7 @@ Item{
}
}
Item{
id:separatorItem
anchors.bottom: (plasmoid.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined
anchors.top: (plasmoid.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined
anchors.left: (plasmoid.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined
anchors.right: (plasmoid.location === PlasmaCore.Types.RightEdge) ? parent.right : undefined
anchors.horizontalCenter: abilityItem.isHorizontal ? parent.horizontalCenter : undefined
anchors.verticalCenter: abilityItem.isHorizontal ? undefined : parent.verticalCenter
anchors.bottomMargin: (plasmoid.location === PlasmaCore.Types.BottomEdge) ? margin : 0
anchors.topMargin: (plasmoid.location === PlasmaCore.Types.TopEdge) ? margin : 0
anchors.leftMargin: (plasmoid.location === PlasmaCore.Types.LeftEdge) ? margin : 0
anchors.rightMargin: (plasmoid.location === PlasmaCore.Types.RightEdge) ? margin : 0
opacity: (separatorShadow.active) || forceHiddenState ? 0 : 0.4
visible: abilityItem.isSeparator
width: abilityItem.isVertical ?
abilityItem.abilities.metrics.iconSize :
(isSeparatorInRealLength ? LatteCore.Environment.separatorLength+abilityItem.abilities.metrics.totals.lengthEdges: 1)
height: abilityItem.isHorizontal ?
abilityItem.abilities.metrics.iconSize :
(isSeparatorInRealLength ? LatteCore.Environment.separatorLength+abilityItem.abilities.metrics.totals.lengthEdges: 1)
property bool forceHiddenState: false
readonly property int margin: abilityItem.abilities.metrics.margin.screenEdge + abilityItem.abilities.metrics.margin.thickness
Behavior on opacity {
NumberAnimation { duration: abilityItem.abilities.animations.speedFactor.current * abilityItem.abilities.animations.duration.large }
}
Rectangle {
anchors.centerIn: parent
width: abilityItem.isVertical ? abilityItem.abilities.metrics.iconSize - 4 : 1
height: abilityItem.isHorizontal ? abilityItem.abilities.metrics.iconSize - 4 : 1
color: abilityItem.abilities.myView.palette.textColor
}
}
///Shadow in separator
Loader{
id: separatorShadow
anchors.fill: separatorItem
active: abilityItem.abilities.myView.itemShadow.isEnabled
&& isSeparator
&& abilityItem.abilities.environment.isGraphicsSystemAccelerated
opacity: separatorItem.forceHiddenState ? 0 : 0.4
Behavior on opacity {
NumberAnimation { duration: abilityItem.abilities.animations.speedFactor.current * abilityItem.abilities.animations.duration.large }
}
sourceComponent: DropShadow{
anchors.fill: parent
color: abilityItem.abilities.myView.itemShadow.shadowColor
fast: true
samples: 2 * radius
source: separatorItem
radius: abilityItem.abilities.myView.itemShadow.size
verticalOffset: 2
}
}
BasicItemParts.SeparatorItem {}
Flow{
width: parent.width

View File

@ -0,0 +1,95 @@
/*
* Copyright 2021 Michail Vourlakos <mvourlakos@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.8
import QtGraphicalEffects 1.0
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.latte.core 0.2 as LatteCore
Loader {
anchors.bottom: (abilityItem.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined
anchors.top: (abilityItem.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined
anchors.left: (abilityItem.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined
anchors.right: (abilityItem.location === PlasmaCore.Types.RightEdge) ? parent.right : undefined
anchors.horizontalCenter: abilityItem.isHorizontal ? parent.horizontalCenter : undefined
anchors.verticalCenter: abilityItem.isHorizontal ? undefined : parent.verticalCenter
anchors.bottomMargin: (abilityItem.location === PlasmaCore.Types.BottomEdge) ? margin : 0
anchors.topMargin: (abilityItem.location === PlasmaCore.Types.TopEdge) ? margin : 0
anchors.leftMargin: (abilityItem.location === PlasmaCore.Types.LeftEdge) ? margin : 0
anchors.rightMargin: (abilityItem.location === PlasmaCore.Types.RightEdge) ? margin : 0
width: abilityItem.isVertical ?
abilityItem.abilities.metrics.iconSize :
(isSeparatorInRealLength ? LatteCore.Environment.separatorLength+abilityItem.abilities.metrics.totals.lengthEdges: 2)
height: abilityItem.isHorizontal ?
abilityItem.abilities.metrics.iconSize :
(isSeparatorInRealLength ? LatteCore.Environment.separatorLength+abilityItem.abilities.metrics.totals.lengthEdges: 2)
opacity: 0.4
readonly property int margin: abilityItem.abilities.metrics.margin.screenEdge + abilityItem.abilities.metrics.margin.thickness
active: abilityItem.isSeparatorVisible
sourceComponent: Item {
///Shadow for separator
Loader{
anchors.fill: separatorItem
active: abilityItem.isSeparatorVisible
&& abilityItem.abilities.myView.itemShadow.isEnabled
&& abilityItem.abilities.environment.isGraphicsSystemAccelerated
opacity: 1.0
Behavior on opacity {
NumberAnimation { duration: abilityItem.abilities.animations.speedFactor.current * abilityItem.abilities.animations.duration.large }
}
sourceComponent: DropShadow{
anchors.fill: parent
color: abilityItem.abilities.myView.itemShadow.shadowColor
fast: true
samples: 2 * radius
source: separatorItem
radius: abilityItem.abilities.myView.itemShadow.size
verticalOffset: 2
}
}
Item{
id:separatorItem
anchors.fill: parent
Behavior on opacity {
NumberAnimation { duration: abilityItem.abilities.animations.speedFactor.current * abilityItem.abilities.animations.duration.large }
}
Rectangle {
anchors.centerIn: parent
width: abilityItem.isVertical ? abilityItem.abilities.metrics.iconSize - 4 : 1
height: abilityItem.isHorizontal ? abilityItem.abilities.metrics.iconSize - 4 : 1
color: abilityItem.abilities.myView.palette.textColor
}
}
}
}