forked from Shinonome/dots-hyprland
waffles: start: limit clipboard results to prevent lag, adjust btn
This commit is contained in:
+4
-1
@@ -44,7 +44,7 @@ WChoiceButton {
|
||||
Layout.fillHeight: true
|
||||
horizontalPadding: 10
|
||||
verticalPadding: 11
|
||||
implicitHeight: root.firstEntry ? 62 : 36
|
||||
implicitHeight: Math.max(root.firstEntry ? 62 : 36, entryContentRow.implicitHeight + 8 * 2)
|
||||
implicitWidth: entryContentRow.implicitWidth + leftPadding + rightPadding
|
||||
topRightRadius: 0
|
||||
bottomRightRadius: 0
|
||||
@@ -54,6 +54,7 @@ WChoiceButton {
|
||||
id: entryContentRow
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
spacing: 8
|
||||
@@ -102,6 +103,7 @@ WChoiceButton {
|
||||
text: root.entry.name
|
||||
font.pixelSize: Looks.font.pixelSize.large
|
||||
maximumLineCount: 2
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
WText {
|
||||
@@ -109,6 +111,7 @@ WChoiceButton {
|
||||
visible: root.firstEntry
|
||||
text: root.entry.type
|
||||
color: Looks.colors.accentUnfocused
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ RowLayout {
|
||||
id: root
|
||||
|
||||
property int maxResultsPerCategory: 4
|
||||
property int resultLimit: 20
|
||||
property StartMenuContext context
|
||||
property int currentIndex: context.currentIndex
|
||||
onCurrentIndexChanged: {
|
||||
@@ -99,21 +100,33 @@ RowLayout {
|
||||
|
||||
// Collect max 4 per category
|
||||
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;
|
||||
for (let i = 0; i < allResults.length; i++) {
|
||||
if (allResults[i].type === category) {
|
||||
if (totalCount >= root.resultLimit) {
|
||||
break;
|
||||
}
|
||||
const entry = allResults[i];
|
||||
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
|
||||
count++;
|
||||
totalCount++;
|
||||
if (count >= root.maxResultsPerCategory) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (totalCount >= root.resultLimit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// print(JSON.stringify(categorizedResults, null, 2));
|
||||
return categorizedResults;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user