67 lines
2.1 KiB
QML
67 lines
2.1 KiB
QML
/*
|
|
SPDX-FileCopyrightText: 2012-2013 Eike Hein <hein@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import org.kde.plasma.plasmoid
|
|
import "code/layoutmetrics.js" as LayoutMetrics
|
|
|
|
GridLayout {
|
|
property bool animating: false
|
|
|
|
// Prevent clipping of zoomed icons
|
|
clip: false
|
|
|
|
rowSpacing: 0
|
|
columnSpacing: 0
|
|
|
|
property int animationsRunning: 0
|
|
onAnimationsRunningChanged: {
|
|
animating = animationsRunning > 0;
|
|
}
|
|
|
|
// Simple direct calculation for minimum width - REMOVED CACHING TO FIX BINDING LOOPS
|
|
readonly property real minimumWidth: {
|
|
const visibleChildren = children.filter(item => item.visible && item.width > 0);
|
|
return visibleChildren.length > 0
|
|
? visibleChildren.reduce((min, item) => Math.min(min, item.width), Infinity)
|
|
: Infinity;
|
|
}
|
|
|
|
// Simple direct calculation for stripe count - REMOVED CACHING TO FIX BINDING LOOPS
|
|
readonly property int stripeCount: {
|
|
if (tasks.plasmoid.configuration.maxStripes === 1) {
|
|
return 1;
|
|
}
|
|
|
|
const firstChild = children[0];
|
|
if (!firstChild) {
|
|
return 1;
|
|
}
|
|
|
|
const stripeSizeLimit = tasks.vertical
|
|
? Math.floor(tasks.width / firstChild.implicitWidth)
|
|
: Math.floor(tasks.height / firstChild.implicitHeight);
|
|
const maxStripes = Math.min(tasks.plasmoid.configuration.maxStripes, stripeSizeLimit);
|
|
|
|
if (tasks.plasmoid.configuration.forceStripes) {
|
|
return maxStripes;
|
|
} else {
|
|
const maxTasksPerStripe = tasks.vertical
|
|
? Math.ceil(tasks.height / LayoutMetrics.preferredMinHeight())
|
|
: Math.ceil(tasks.width / LayoutMetrics.preferredMinWidth());
|
|
return Math.min(Math.ceil(tasksModel.count / maxTasksPerStripe), maxStripes);
|
|
}
|
|
}
|
|
|
|
readonly property int orthogonalCount: {
|
|
return Math.ceil(tasksModel.count / stripeCount);
|
|
}
|
|
|
|
rows: tasks.vertical ? orthogonalCount : stripeCount
|
|
columns: tasks.vertical ? stripeCount : orthogonalCount
|
|
}
|