Verified Commit 4d8f959f authored by Noah Davis's avatar Noah Davis 🌵 Committed by Fushan Wen
Browse files

Fix cellWidth binding loop, make delegates fill minimum available width

parent ed6895fe
Pipeline #184503 passed with stage
in 5 minutes and 20 seconds
......@@ -72,7 +72,7 @@ BasePage {
onShowSectionViewRequested: {
stackView.push(applicationsSectionViewComponent, {
"currentSection": sectionName,
"view.implicitWidth": applicationsListView.view.implicitWidth,
"parentView": applicationsListView
});
}
}
......
......@@ -11,19 +11,24 @@ import org.kde.plasma.components 3.0 as PC3
KickoffGridView {
id: root
view.cellWidth: Math.round(KickoffSingleton.listDelegateContentHeight * 2.5)
view.cellHeight: view.cellWidth
property string currentSection
property KickoffListView parentView
/**
* Request hiding the section view
*/
signal hideSectionViewRequested(int index)
property string currentSection
// prevent binding loops and preserve minimum popup size
view.implicitWidth: parentView.view.implicitWidth
view.implicitHeight: parentView.view.implicitHeight
delegate: PC3.AbstractButton {
id: sectionButton
// Using implicitWidth instead of width so that delegates don't
// become super big when using the new popup resizing feature.
view.cellWidth: Math.floor((view.implicitWidth - view.leftMargin - view.rightMargin) / 7)
view.cellHeight: view.cellWidth
delegate: PC3.AbstractButton {
width: view.cellWidth
height: view.cellHeight
......@@ -32,22 +37,35 @@ KickoffGridView {
root.view.currentIndex = index;
}
padding: fontMetrics.descent / 2
contentItem: PC3.Label {
anchors {
fill: parent
bottomMargin: KickoffSingleton.fontMetrics.descent
}
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
maximumLineCount: 1
elide: Text.ElideRight
font.pixelSize: KickoffSingleton.listDelegateContentHeight
// Sets max size for fontSizeMode, not true size.
// Also affects implicit size,
// so do not rely on this Label's implicit size.
font.pixelSize: fontMetrics.font.pixelSize
fontSizeMode: Text.VerticalFit
text: modelData["section"]
}
onClicked: root.hideSectionViewRequested(modelData["firstIndex"])
}
FontMetrics {
id: fontMetrics
// This size doesn't actually fill the cell height perfectly.
// It goes out of bounts and is slightly below center with Noto Sans.
// It's close enough for the calculations this will be used for.
// The calculations seem to work fairly well with other fonts too.
font.pixelSize: root.view.cellHeight
}
Component.onCompleted: {
for (let i = 0; i < model.length; i++) {
if (model[i]["section"] === root.currentSection) {
......
Supports Markdown
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