mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-25 19:21:41 +03:00
introduce Indexer ContainerAbility
This commit is contained in:
parent
a622485a47
commit
df4df914ca
27
containment/package/contents/ui/abilities/Indexer.qml
Normal file
27
containment/package/contents/ui/abilities/Indexer.qml
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2020 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.7
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
|
||||
import "./privates" as Ability
|
||||
|
||||
Ability.IndexerPrivate {
|
||||
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2020 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.7
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
|
||||
import org.kde.latte.abilities.containers 0.1 as ContainerAbility
|
||||
|
||||
Item {
|
||||
id: indxr
|
||||
|
||||
property Item layouts: null
|
||||
|
||||
readonly property var separators: {
|
||||
var seps = [];
|
||||
|
||||
var sLayout = layouts.startLayout;
|
||||
for (var i=0; i<sLayout.children.length; ++i){
|
||||
var appletItem = sLayout.children[i];
|
||||
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
|
||||
seps.push(appletItem.index);
|
||||
}
|
||||
}
|
||||
|
||||
var mLayout = layouts.mainLayout;
|
||||
for (var i=0; i<mLayout.children.length; ++i){
|
||||
var appletItem = mLayout.children[i];
|
||||
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
|
||||
seps.push(appletItem.index);
|
||||
}
|
||||
}
|
||||
|
||||
var eLayout = layouts.endLayout;
|
||||
for (var i=0; i<eLayout.children.length; ++i){
|
||||
var appletItem = eLayout.children[i];
|
||||
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
|
||||
seps.push(appletItem.index);
|
||||
}
|
||||
}
|
||||
|
||||
return seps;
|
||||
}
|
||||
|
||||
readonly property var hidden: {
|
||||
var hdn = [];
|
||||
|
||||
var sLayout = layouts.startLayout;
|
||||
for (var i=0; i<sLayout.children.length; ++i){
|
||||
var appletItem = sLayout.children[i];
|
||||
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
|
||||
hdn.push(appletItem.index);
|
||||
}
|
||||
}
|
||||
|
||||
var mLayout = layouts.mainLayout;
|
||||
for (var i=0; i<mLayout.children.length; ++i){
|
||||
var appletItem = mLayout.children[i];
|
||||
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
|
||||
hdn.push(appletItem.index);
|
||||
}
|
||||
}
|
||||
|
||||
var eLayout = layouts.endLayout;
|
||||
for (var i=0; i<eLayout.children.length; ++i){
|
||||
var appletItem = eLayout.children[i];
|
||||
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
|
||||
hdn.push(appletItem.index);
|
||||
}
|
||||
}
|
||||
|
||||
return hdn;
|
||||
}
|
||||
}
|
@ -223,6 +223,7 @@ Item {
|
||||
readonly property alias wrapper: _wrapper
|
||||
|
||||
property Item animations: null
|
||||
property Item indexer: null
|
||||
property Item metrics: null
|
||||
property Item parabolic: null
|
||||
|
||||
@ -458,14 +459,6 @@ Item {
|
||||
root.latteAppletPos = index;
|
||||
}
|
||||
|
||||
if (isHidden) {
|
||||
parabolicManager.setHidden(previousIndex, index);
|
||||
}
|
||||
|
||||
if (isSeparator) {
|
||||
parabolicManager.setSeparator(previousIndex, index);
|
||||
}
|
||||
|
||||
if (index>-1) {
|
||||
previousIndex = index;
|
||||
}
|
||||
@ -477,23 +470,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
onIsHiddenChanged: {
|
||||
if (isHidden) {
|
||||
parabolicManager.setHidden(-1, index);
|
||||
} else {
|
||||
parabolicManager.setHidden(index, -1);
|
||||
}
|
||||
}
|
||||
|
||||
onIsSeparatorChanged: {
|
||||
if (isSeparator) {
|
||||
parabolicManager.setSeparator(-1, index);
|
||||
} else {
|
||||
parabolicManager.setSeparator(index, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onIsSystrayChanged: {
|
||||
checkCanBeHovered();
|
||||
}
|
||||
@ -523,14 +499,6 @@ Item {
|
||||
Component.onDestruction: {
|
||||
appletItem.animations.needBothAxis.removeEvent(appletItem);
|
||||
|
||||
if (isSeparator){
|
||||
parabolicManager.setSeparator(previousIndex, -1);
|
||||
}
|
||||
|
||||
if (isHidden) {
|
||||
parabolicManager.setHidden(previousIndex, -1);
|
||||
}
|
||||
|
||||
if(root.latteAppletPos>=0 && root.latteAppletPos === index){
|
||||
root.latteApplet = null;
|
||||
root.latteAppletContainer = null;
|
||||
|
@ -32,7 +32,27 @@ Item{
|
||||
///check also if this is the first/last plasmoid in anylayout
|
||||
visible: (rightSpacer ? appletItem.lastAppletInContainer : appletItem.firstAppletInContainer) || separatorSpace>0
|
||||
|
||||
property bool neighbourSeparator: false;
|
||||
property bool neighbourSeparator: {
|
||||
if (appletItem.isSeparator || index === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rightSpacer) {
|
||||
var step = index + 1;
|
||||
while(step>=0 && appletItem.indexer.hidden.indexOf(step)>=0) {
|
||||
step = step + 1;
|
||||
}
|
||||
|
||||
return (appletItem.indexer.separators.indexOf(step)>=0);
|
||||
} else {
|
||||
var step = index - 1;
|
||||
while(step>=0 && appletItem.indexer.hidden.indexOf(step)>=0) {
|
||||
step = step - 1;
|
||||
}
|
||||
|
||||
return (appletItem.indexer.separators.indexOf(step)>=0);
|
||||
}
|
||||
}
|
||||
|
||||
property int separatorSpace: neighbourSeparator && !appletItem.isSeparator && root.parabolicEffectEnabled
|
||||
&& !appletItem.latteApplet ? ((LatteCore.Environment.separatorLength/2)+appletItem.metrics.margin.length) : subtrackedMargins
|
||||
@ -70,11 +90,6 @@ Item{
|
||||
NumberAnimation { duration: 0 }
|
||||
}
|
||||
|
||||
Connections{
|
||||
target: root
|
||||
onSeparatorsUpdated: updateNeighbour();
|
||||
}
|
||||
|
||||
Connections{
|
||||
target: appletItem
|
||||
onContainsMouseChanged: {
|
||||
@ -84,11 +99,6 @@ Item{
|
||||
}
|
||||
}
|
||||
|
||||
function updateNeighbour() {
|
||||
hiddenSpacer.neighbourSeparator = hiddenSpacer.rightSpacer ?
|
||||
parabolicManager.isSeparator(index+1) : parabolicManager.isSeparator(index-1)
|
||||
}
|
||||
|
||||
Loader{
|
||||
active: root.debugModeSpacers
|
||||
|
||||
|
@ -410,6 +410,7 @@ Item {
|
||||
|
||||
readonly property alias animations: _animations
|
||||
readonly property alias autosize: _autosize
|
||||
readonly property alias indexer: _indexer
|
||||
readonly property alias indicatorsManager: indicators
|
||||
readonly property alias metrics: _metrics
|
||||
readonly property alias parabolic: _parabolic
|
||||
@ -1327,6 +1328,7 @@ Item {
|
||||
id: appletContainerComponent
|
||||
Applet.AppletItem{
|
||||
animations: _animations
|
||||
indexer: _indexer
|
||||
metrics: _metrics
|
||||
parabolic: _parabolic
|
||||
}
|
||||
@ -1549,6 +1551,11 @@ Item {
|
||||
visibility: visibilityManager
|
||||
}
|
||||
|
||||
Ability.Indexer {
|
||||
id: _indexer
|
||||
layouts: layoutsContainer
|
||||
}
|
||||
|
||||
Ability.Metrics {
|
||||
id: _metrics
|
||||
animations: _animations
|
||||
|
Loading…
Reference in New Issue
Block a user