diff --git a/containments/desktop/package/contents/ui/FolderView.qml b/containments/desktop/package/contents/ui/FolderView.qml --- a/containments/desktop/package/contents/ui/FolderView.qml +++ b/containments/desktop/package/contents/ui/FolderView.qml @@ -484,6 +484,9 @@ focus: true + readonly property int viewportWidth: viewport ? Math.ceil(viewport.width) : 0 + readonly property int viewportHeight: viewport ? Math.ceil(viewport.height) : 0 + GridView { id: gridView @@ -512,23 +515,41 @@ keyNavigationWraps: false boundsBehavior: Flickable.StopAtBounds + function calcExtraSpacing(cellSize, containerSize) { + var availableColumns = Math.floor(containerSize / cellSize); + var extraSpacing = 0; + if (availableColumns > 0) { + var allColumnSize = availableColumns * cellSize; + var extraSpace = Math.max(containerSize - allColumnSize); + extraSpacing = extraSpace / availableColumns; + } + return extraSpacing; + } + + readonly property int iconWidth: iconSize + (2 * units.largeSpacing) + (2 * units.smallSpacing) + readonly property real extraWidth: calcExtraSpacing(iconWidth, scrollArea.viewportWidth) cellWidth: { if (root.useListViewMode) { return gridView.width; + } else if (root.isContainment) { + return iconWidth + extraWidth; + } else { + return iconWidth; } - - return iconSize + (2 * units.largeSpacing) + (2 * units.smallSpacing); } + readonly property int iconHeight: (iconSize + (theme.mSize(theme.defaultFont).height * plasmoid.configuration.textLines) + (6 * units.smallSpacing)) + readonly property real extraHeight: calcExtraSpacing(iconHeight, scrollArea.viewportHeight) cellHeight: { if (root.useListViewMode) { return Math.ceil((Math.max(theme.mSize(theme.defaultFont).height, iconSize) + Math.max(highlightItemSvg.margins.top + highlightItemSvg.margins.bottom, listItemSvg.margins.top + listItemSvg.margins.bottom)) / 2) * 2; + } else if (root.isContainment) { + return iconHeight + extraHeight; + } else { + return iconHeight; } - - return (iconSize + (theme.mSize(theme.defaultFont).height * plasmoid.configuration.textLines) - + (6 * units.smallSpacing)); } delegate: FolderItemDelegate { diff --git a/containments/desktop/package/contents/ui/main.qml b/containments/desktop/package/contents/ui/main.qml --- a/containments/desktop/package/contents/ui/main.qml +++ b/containments/desktop/package/contents/ui/main.qml @@ -82,16 +82,10 @@ leftMargin: (isContainment && plasmoid.availableScreenRect) ? plasmoid.availableScreenRect.x : 0 topMargin: (isContainment && plasmoid.availableScreenRect) ? plasmoid.availableScreenRect.y : 0 - // Don't apply the right margin if the folderView is in column mode and not overflowing. - // In this way, the last column remains droppable even if a small part of the icon is behind a panel. - rightMargin: folderViewLayer.ready && (folderViewLayer.view.overflowing || folderViewLayer.view.flow == GridView.FlowLeftToRight - || folderViewLayer.view.layoutDirection == Qt.RightToLeft) - && (isContainment && plasmoid.availableScreenRect) && parent + rightMargin: (isContainment && plasmoid.availableScreenRect) && parent ? parent.width - (plasmoid.availableScreenRect.x + plasmoid.availableScreenRect.width) : 0 - // Same mechanism as the right margin but applied here to the bottom when the folderView is in row mode. - bottomMargin: folderViewLayer.ready && (folderViewLayer.view.overflowing || folderViewLayer.view.flow == GridView.FlowTopToBottom) - && (isContainment && plasmoid.availableScreenRect) && parent + bottomMargin: (isContainment && plasmoid.availableScreenRect) && parent ? parent.height - (plasmoid.availableScreenRect.y + plasmoid.availableScreenRect.height) : 0 }