Commit 478db842 authored by Ismael Asensio's avatar Ismael Asensio
Browse files

[cuttlefish] Use Gridlayout to simplify delegate repetition

Simple refactor of the icon prevew grid to avoid repeating
the delegate code only for the last item.
parent f1226958
......@@ -107,12 +107,18 @@ Rectangle {
id: previewGrid
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
RowLayout {
GridLayout {
id: previewGridLayout
Layout.alignment: Qt.AlignHCenter
columns: cuttlefish.iconSizes.length - 1
Repeater {
model: cuttlefish.iconSizes.slice(0, cuttlefish.iconSizes.length - 1)
model: cuttlefish.iconSizes
delegate: ColumnLayout {
Layout.alignment: Qt.AlignBottom
readonly property bool isLastItem: (index == previewGridLayout.columns)
Layout.alignment: Qt.AlignBottom | Qt.AlignHCenter
Layout.row: isLastItem ? 1 : 0
Layout.column: isLastItem ? 0 : index
Layout.columnSpan: isLastItem ? previewGridLayout.columns : 1
Kirigami.Icon {
source: preview.iconName
implicitWidth: modelData
......@@ -130,23 +136,6 @@ Rectangle {
}
}
}
ColumnLayout {
Layout.alignment: Qt.AlignHCenter
Kirigami.Icon {
source: preview.iconName
implicitWidth: cuttlefish.iconSizes[cuttlefish.iconSizes.length - 1]
implicitHeight: implicitWidth
}
QQC2.Label {
Layout.alignment: Qt.AlignHCenter
text: cuttlefish.iconSizes[cuttlefish.iconSizes.length - 1]
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
}
}
}
}
}
Row {
opacity: iconPreview.screenshotting ? 1 : 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