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,35 @@ 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; } - - return iconSize + (2 * units.largeSpacing) + (2 * units.smallSpacing); + return iconWidth + extraWidth; } + 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; } - - return (iconSize + (theme.mSize(theme.defaultFont).height * plasmoid.configuration.textLines) - + (6 * units.smallSpacing)); + return iconHeight + extraHeight; } 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 @@ -84,13 +84,12 @@ // 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) + rightMargin: folderViewLayer.ready && (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) + bottomMargin: folderViewLayer.ready && (isContainment && plasmoid.availableScreenRect) && parent ? parent.height - (plasmoid.availableScreenRect.y + plasmoid.availableScreenRect.height) : 0 }