mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-02-16 02:30:52 +00:00
26 lines
674 B
QML
26 lines
674 B
QML
import QtQuick 2.9
|
|
import QtQuick.Controls 2.2
|
|
|
|
GridView {
|
|
property int minMargin: 10
|
|
property real availableWidth: (parent.width - 2 * minMargin)
|
|
property int itemsPerRow: availableWidth / cellWidth
|
|
property real horizontalMargin: itemsPerRow < count && availableWidth >= cellWidth ?
|
|
(availableWidth % cellWidth) / 2 : minMargin
|
|
|
|
function updateMargins() {
|
|
leftMargin = horizontalMargin
|
|
rightMargin = horizontalMargin
|
|
}
|
|
|
|
onHorizontalMarginChanged: {
|
|
updateMargins()
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
updateMargins()
|
|
}
|
|
|
|
boundsBehavior: Flickable.OvershootBounds
|
|
}
|