Commit 20ba491c authored by Zren (Chris Holland)'s avatar Zren (Chris Holland)

[Folder View] Pad cellWidth/cellHeight with the extra space

The right/bottom corners of the desktop will have an empty area where
icons should be touching. Dropping an icon there will cause a scrollbar.
https://bugs.kde.org/show_bug.cgi?id=380424

When when in a containment, use a floating point cellWidth/cellHeight
based on the avaiable space left. Folder widgets will still use a fixed
size based on the icon.

Note: We no longer attempt to fit the last column/row of icons under
the panels if there's just barely space for it. So this might cause
a scrollbar for those users.

Differential Revision: https://phabricator.kde.org/D6188
parent 94c5a973
......@@ -484,6 +484,9 @@ Item {
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 @@ Item {
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 {
......
......@@ -82,16 +82,10 @@ FolderViewDropArea {
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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment