waffles: start: limit clipboard results to prevent lag, adjust btn

This commit is contained in:
end-4
2025-12-20 11:45:10 +01:00
parent ed6a0204b4
commit e499f4f8f1
2 changed files with 20 additions and 4 deletions
@@ -44,7 +44,7 @@ WChoiceButton {
Layout.fillHeight: true Layout.fillHeight: true
horizontalPadding: 10 horizontalPadding: 10
verticalPadding: 11 verticalPadding: 11
implicitHeight: root.firstEntry ? 62 : 36 implicitHeight: Math.max(root.firstEntry ? 62 : 36, entryContentRow.implicitHeight + 8 * 2)
implicitWidth: entryContentRow.implicitWidth + leftPadding + rightPadding implicitWidth: entryContentRow.implicitWidth + leftPadding + rightPadding
topRightRadius: 0 topRightRadius: 0
bottomRightRadius: 0 bottomRightRadius: 0
@@ -54,6 +54,7 @@ WChoiceButton {
id: entryContentRow id: entryContentRow
anchors { anchors {
left: parent.left left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
spacing: 8 spacing: 8
@@ -102,6 +103,7 @@ WChoiceButton {
text: root.entry.name text: root.entry.name
font.pixelSize: Looks.font.pixelSize.large font.pixelSize: Looks.font.pixelSize.large
maximumLineCount: 2 maximumLineCount: 2
elide: Text.ElideRight
} }
WText { WText {
@@ -109,6 +111,7 @@ WChoiceButton {
visible: root.firstEntry visible: root.firstEntry
text: root.entry.type text: root.entry.type
color: Looks.colors.accentUnfocused color: Looks.colors.accentUnfocused
elide: Text.ElideRight
} }
} }
@@ -15,6 +15,7 @@ RowLayout {
id: root id: root
property int maxResultsPerCategory: 4 property int maxResultsPerCategory: 4
property int resultLimit: 20
property StartMenuContext context property StartMenuContext context
property int currentIndex: context.currentIndex property int currentIndex: context.currentIndex
onCurrentIndexChanged: { onCurrentIndexChanged: {
@@ -99,21 +100,33 @@ RowLayout {
// Collect max 4 per category // Collect max 4 per category
var categorizedResults = []; var categorizedResults = [];
categories.forEach(category => { let categoriesArray = Array.from(categories);
let totalCount = 0;
for (let c = 0; c < categoriesArray.length; c++) {
let category = categoriesArray[c];
let count = 0; let count = 0;
for (let i = 0; i < allResults.length; i++) { for (let i = 0; i < allResults.length; i++) {
if (allResults[i].type === category) { if (allResults[i].type === category) {
if (totalCount >= root.resultLimit) {
break;
}
const entry = allResults[i]; const entry = allResults[i];
const tweakedEntry = searchResultComp.createObject(null, Object.assign({}, entry)); const tweakedEntry = searchResultComp.createObject(null, Object.assign({}, entry));
tweakedEntry.category = categorizedResults.length === 0 ? Translation.tr("Best match") : entry.type tweakedEntry.category = categorizedResults.length === 0 ? Translation.tr("Best match") : entry.type;
categorizedResults.push(tweakedEntry); // Section header categorizedResults.push(tweakedEntry); // Section header
count++; count++;
totalCount++;
if (count >= root.maxResultsPerCategory) { if (count >= root.maxResultsPerCategory) {
break; break;
} }
} }
} }
}); if (totalCount >= root.resultLimit) {
break;
}
}
// print(JSON.stringify(categorizedResults, null, 2)); // print(JSON.stringify(categorizedResults, null, 2));
return categorizedResults; return categorizedResults;
} }