mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-09 17:18:11 +03:00
hide internal separators in some cases
--hide internal separators when overlap and show only one --hide internal separators at start or end of the plasmoid, the user can us separator applet in those places --add safety array checkes in order to avoid any crashes from accessing out-of-arrays elements
This commit is contained in:
parent
c25a088c5e
commit
83c901de0e
@ -57,22 +57,9 @@ Item{
|
||||
onSeparatorsUpdated: updateNeighbour();
|
||||
}
|
||||
|
||||
Connections{
|
||||
target: root.latteApplet ? root.latteApplet : null
|
||||
onSeparatorsUpdated: updateNeighbour();
|
||||
}
|
||||
|
||||
function updateNeighbour() {
|
||||
var gAppN = parabolicManager.availableHigherId(index+1);
|
||||
var lAppN = parabolicManager.availableLowerId(index-1);
|
||||
|
||||
var latteNeighbour = root.latteApplet && ((gAppN === root.latteAppletPos) || (lAppN === root.latteAppletPos ));
|
||||
|
||||
hiddenSpacer.neighbourSeparator = hiddenSpacer.rightSpacer ?
|
||||
parabolicManager.isSeparator(index+1)
|
||||
|| (latteNeighbour && gAppN===root.latteAppletPos && root.latteApplet.parabolicManager.taskIsSeparator(0)) :
|
||||
parabolicManager.isSeparator(index-1)
|
||||
|| (latteNeighbour && lAppN===root.latteAppletPos && root.latteApplet.parabolicManager.taskIsSeparator(root.tasksCount-1)) ;
|
||||
parabolicManager.isSeparator(index+1) : parabolicManager.isSeparator(index-1)
|
||||
}
|
||||
|
||||
/* Rectangle{
|
||||
|
@ -42,6 +42,16 @@ Item {
|
||||
//(launcherUrl, index)
|
||||
property variant separators: []
|
||||
|
||||
Connections{
|
||||
target: root
|
||||
onTasksCountChanged:{
|
||||
firstRealTaskIndex = firstRealTask();
|
||||
lastRealTaskIndex = lastRealTask();
|
||||
|
||||
root.separatorsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
//!this is used in order to update the index when the signal is for applets
|
||||
//!outside the latte plasmoid
|
||||
function updateIdSendScale(index, zScale, zStep){
|
||||
@ -285,8 +295,13 @@ Item {
|
||||
|
||||
function separatorArrayPos(launcher) {
|
||||
var res = -1;
|
||||
var sLength = separators.length;
|
||||
|
||||
for (var i=0; i<sLength; ++i) {
|
||||
//!safety checker
|
||||
if (i>=separators.length)
|
||||
return false;
|
||||
|
||||
for (var i=0; i<separators.length; ++i) {
|
||||
if (separators[i].launcherUrl === launcher)
|
||||
return i;
|
||||
}
|
||||
@ -317,7 +332,13 @@ Item {
|
||||
}
|
||||
|
||||
function taskIsSeparator(taskIndex){
|
||||
for (var i=0; i<separators.length; ++i) {
|
||||
var sLength = separators.length;
|
||||
|
||||
for (var i=0; i<sLength; ++i) {
|
||||
//!safety checker
|
||||
if (i>=separators.length)
|
||||
return false;
|
||||
|
||||
if (separators[i].index === taskIndex)
|
||||
return true;
|
||||
}
|
||||
@ -329,7 +350,13 @@ Item {
|
||||
if (!isSeparator(separator))
|
||||
return false;
|
||||
|
||||
for (var i=0; i<separators.length; ++i) {
|
||||
var sLength = separators.length;
|
||||
|
||||
for (var i=0; i<sLength; ++i) {
|
||||
//!safety checker
|
||||
if (i>=separators.length)
|
||||
return false;
|
||||
|
||||
if (separators[i].launcherUrl.indexOf(separator)>=0)
|
||||
return true;
|
||||
}
|
||||
@ -436,7 +463,13 @@ Item {
|
||||
var max = -1;
|
||||
var arrayPos = -1;
|
||||
|
||||
for (var i=0; i<separators.length; ++i) {
|
||||
var sLength = separators.length;
|
||||
|
||||
for (var i=0; i<sLength; ++i) {
|
||||
//!safety checker
|
||||
if (i>=separators.length)
|
||||
return false;
|
||||
|
||||
if (separators[i].index > max) {
|
||||
max = separators[i].index;
|
||||
arrayPos = i;
|
||||
|
@ -240,7 +240,7 @@ MouseArea{
|
||||
anchors.bottom: root.position === PlasmaCore.Types.BottomPositioned ? parent.bottom : undefined;
|
||||
|
||||
//opacity: separatorShadow.active || root.internalSeparatorHidden ? 0 : 0.4
|
||||
opacity: separatorShadow.active ? 0 : 0.4
|
||||
opacity: separatorShadow.active || forceHiddenState ? 0 : 0.4
|
||||
|
||||
visible: mainItemContainer.isSeparator
|
||||
|
||||
@ -249,10 +249,33 @@ MouseArea{
|
||||
|
||||
property int localThickMargin: root.statesLineSize + root.thickMarginBase + 4
|
||||
|
||||
property bool forceHiddenState: false
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: root.durationTime*units.longDuration }
|
||||
}
|
||||
|
||||
function updateForceHiddenState() {
|
||||
if (!isSeparator || root.editMode || root.dragSource) {
|
||||
forceHiddenState = false;
|
||||
} else {
|
||||
var firstPosition = (index === 0);
|
||||
var sepNeighbour = parabolicManager.taskIsSeparator(index-1);
|
||||
var firstSepFromLastSeparatorsGroup = (itemIndex === parabolicManager.lastRealTaskIndex+1);
|
||||
|
||||
forceHiddenState = (firstPosition || sepNeighbour || firstSepFromLastSeparatorsGroup);
|
||||
}
|
||||
}
|
||||
|
||||
onForceHiddenStateChanged: root.separatorsUpdated();
|
||||
|
||||
Connections{
|
||||
target: root
|
||||
onEditModeChanged: separatorItem.updateForceHiddenState();
|
||||
onDragSourceChanged: separatorItem.updateForceHiddenState();
|
||||
onSeparatorsUpdated: separatorItem.updateForceHiddenState();
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.horizontalCenter: !root.vertical ? parent.horizontalCenter : undefined
|
||||
anchors.verticalCenter: root.vertical ? parent.verticalCenter : undefined
|
||||
@ -274,8 +297,7 @@ MouseArea{
|
||||
id: separatorShadow
|
||||
anchors.fill: separatorItem
|
||||
active: root.enableShadows && isSeparator
|
||||
//opacity: root.internalSeparatorHidden ? 0 : 0.4
|
||||
opacity: 0.4
|
||||
opacity: separatorItem.forceHiddenState ? 0 : 0.4
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: root.durationTime*units.longDuration }
|
||||
|
@ -57,10 +57,10 @@ Item{
|
||||
neighbourSeparator = false;
|
||||
} else if (latteDock && index!==-1) {
|
||||
if (!rightSpacer) {
|
||||
neighbourSeparator = (parabolicManager.taskIsSeparator(itemIndex-1) && !isSeparator)
|
||||
neighbourSeparator = (parabolicManager.taskIsSeparator(itemIndex-1) && !isSeparator && itemIndex!==parabolicManager.firstRealTaskIndex)
|
||||
|| (latteDock.parabolicManager.isSeparator(latteDock.latteAppletPos-1) && parabolicManager.firstRealTaskIndex === itemIndex);
|
||||
} else {
|
||||
neighbourSeparator = (parabolicManager.taskIsSeparator(itemIndex+1) && !isSeparator)
|
||||
neighbourSeparator = (parabolicManager.taskIsSeparator(itemIndex+1) && !isSeparator && itemIndex!==parabolicManager.lastRealTaskIndex)
|
||||
|| (latteDock.parabolicManager.isSeparator(latteDock.latteAppletPos+1) && parabolicManager.lastRealTaskIndex === itemIndex );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user