mirror of https://github.com/cutefishos/launcher
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
QML
52 lines
1.6 KiB
QML
import QtQuick 2.12
|
|
import QtQuick.Window 2.12
|
|
import FishUI 1.0 as FishUI
|
|
import Cutefish.Launcher 1.0
|
|
|
|
PageView {
|
|
id: gridView
|
|
|
|
property int iconSize: gridView.width > gridView.height ? gridView.width * 0.09 + root.horizontalSpacing * 2
|
|
: gridView.height * 0.09 + root.verticalSpacing * 2
|
|
|
|
property int cellWidth: {
|
|
var extraWidth = calcExtraSpacing(iconSize, gridView.width)
|
|
return iconSize + extraWidth
|
|
}
|
|
|
|
property int cellHeight: {
|
|
var extraHeight = calcExtraSpacing(iconSize, gridView.height)
|
|
return iconSize + extraHeight
|
|
}
|
|
|
|
columns: gridView.width / cellWidth
|
|
rows: gridView.height / cellHeight
|
|
|
|
model: launcherModel
|
|
|
|
delegate: Item {
|
|
width: cellWidth
|
|
height: cellHeight
|
|
|
|
LauncherGridDelegate {
|
|
id: delegate
|
|
anchors.fill: parent
|
|
anchors.leftMargin: root.horizontalSpacing * 1.5
|
|
anchors.rightMargin: root.horizontalSpacing * 1.5
|
|
anchors.topMargin: root.verticalSpacing * 1.5
|
|
anchors.bottomMargin: root.verticalSpacing * 1.5
|
|
}
|
|
}
|
|
|
|
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, 0);
|
|
extraSpacing = extraSpace / availableColumns;
|
|
}
|
|
return Math.floor(extraSpacing);
|
|
}
|
|
}
|