1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-27 13:35:18 -04:00

Compare commits

...

3 Commits

Author SHA1 Message Date
jbwfu 2b661e241d fix(settings): support localized settings search (#2521) 2026-05-30 01:55:46 -04:00
Kyunghyun Park d7df3800c2 keybinds: add missing XF86 key mappings (#2500) 2026-05-30 01:31:58 -04:00
Bogdan f2961f9b6a feat(DiskUsage): updated dynamic width options for DiskUsage widget (#2517)
* feat(WidgetsTabSection.qml): added dynamic width and static padding for DiskUsage

* feat(DiskUsage.qml):added functionality for dynamic width and static padding, also changed spacing to work like in cpu and ram monitor. Now they look complete and same

* fix(DiskUsage): restore display modes & formatting

---------

Co-authored-by: purian23 <purian23@gmail.com>
2026-05-30 01:02:15 -04:00
5 changed files with 138 additions and 46 deletions
+10
View File
@@ -57,9 +57,15 @@ const KEY_MAP = {
16842802: "XF86Eject",
16842791: "XF86Calculator",
16842806: "XF86Explorer",
16777360: "XF86HomePage",
16842794: "XF86HomePage",
16777362: "XF86Search",
16777426: "XF86Search",
16777376: "XF86Mail",
16777427: "XF86Mail",
16777377: "XF86AudioMedia",
16777419: "XF86Calculator",
16777429: "XF86Explorer",
16777442: "XF86Launch0",
16777443: "XF86Launch1",
33: "1",
@@ -129,6 +135,10 @@ function xkbKeyFromQtKey(qk) {
return String.fromCharCode(qk);
if (qk >= 16777264 && qk <= 16777298)
return "F" + (qk - 16777264 + 1);
if (qk >= 16777378 && qk <= 16777387)
return "XF86Launch" + (qk - 16777378);
if (qk >= 16777388 && qk <= 16777393)
return "XF86Launch" + String.fromCharCode(65 + qk - 16777388);
return KEY_MAP[qk] || "";
}
@@ -12,6 +12,7 @@ BasePill {
property int diskUsageMode: (widgetData && widgetData.diskUsageMode !== undefined) ? widgetData.diskUsageMode : 0
property bool isHovered: mouseArea.containsMouse
property bool isAutoHideBar: false
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
property var selectedMount: {
if (!DgopService.diskMounts || DgopService.diskMounts.length === 0) {
@@ -69,6 +70,8 @@ BasePill {
}
Connections {
target: SettingsData
function onWidgetDataChanged() {
root.mountPath = Qt.binding(() => {
return (root.widgetData && root.widgetData.mountPath !== undefined) ? root.widgetData.mountPath : "/";
@@ -96,14 +99,12 @@ BasePill {
return DgopService.diskMounts[0] || null;
});
}
target: SettingsData
}
content: Component {
Item {
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : diskContent.implicitWidth
implicitHeight: root.isVerticalOrientation ? diskColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
implicitHeight: root.isVerticalOrientation ? diskColumn.implicitHeight : diskContent.implicitHeight
Column {
id: diskColumn
@@ -118,10 +119,12 @@ BasePill {
if (root.diskUsagePercent > 90) {
return Theme.tempDanger;
}
if (root.diskUsagePercent > 75) {
return Theme.tempWarning;
}
return Theme.surfaceText;
return Theme.widgetIconColor;
}
anchors.horizontalCenter: parent.horizontalCenter
}
@@ -154,24 +157,28 @@ BasePill {
id: diskContent
visible: !root.isVerticalOrientation
anchors.centerIn: parent
spacing: 3
spacing: Theme.spacingXS
DankIcon {
id: diskIcon
name: "storage"
size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
color: {
if (root.diskUsagePercent > 90) {
return Theme.tempDanger;
}
if (root.diskUsagePercent > 75) {
return Theme.tempWarning;
}
return Theme.surfaceText;
return Theme.widgetIconColor;
}
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
id: mountText
text: {
if (!root.selectedMount) {
return "--";
@@ -182,32 +189,20 @@ BasePill {
color: Theme.widgetTextColor
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
wrapMode: Text.NoWrap
}
StyledText {
text: {
if (root.diskUsagePercent === undefined || root.diskUsagePercent === null || root.diskUsagePercent === 0) {
return "--%";
}
if (!root.selectedMount)
return "--%";
switch (root.diskUsageMode) {
case 1:
return root.selectedMount.size || "--";
case 2:
return root.selectedMount.avail || "--";
case 3:
return (root.selectedMount.avail || "--") + " / " + (root.selectedMount.size || "--");
default:
return root.diskUsagePercent.toFixed(0) + "%";
}
}
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText)
color: Theme.widgetTextColor
Item {
id: textBox
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignLeft
elide: Text.ElideNone
implicitWidth: root.minimumWidth ? Math.max(diskBaseline.width, diskCurrent.width) : diskCurrent.width
implicitHeight: diskText.implicitHeight
width: implicitWidth
height: implicitHeight
StyledTextMetrics {
id: diskBaseline
@@ -225,7 +220,40 @@ BasePill {
}
}
width: Math.max(diskBaseline.width, paintedWidth)
StyledTextMetrics {
id: diskCurrent
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText)
text: diskText.text
}
StyledText {
id: diskText
text: {
if (root.diskUsagePercent === undefined || root.diskUsagePercent === null || root.diskUsagePercent === 0) {
return "--%";
}
if (!root.selectedMount)
return "--%";
switch (root.diskUsageMode) {
case 1:
return root.selectedMount.size || "--";
case 2:
return root.selectedMount.avail || "--";
case 3:
return (root.selectedMount.avail || "--") + " / " + (root.selectedMount.size || "--");
default:
return root.diskUsagePercent.toFixed(0) + "%";
}
}
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText)
color: Theme.widgetTextColor
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
wrapMode: Text.NoWrap
}
}
}
}
+1 -1
View File
@@ -404,7 +404,7 @@ Item {
widgetObj.mountPath = "/";
widgetObj.diskUsageMode = 0;
}
if (widgetId === "cpuUsage" || widgetId === "memUsage" || widgetId === "cpuTemp" || widgetId === "gpuTemp")
if (widgetId === "cpuUsage" || widgetId === "memUsage" || widgetId === "cpuTemp" || widgetId === "gpuTemp" || widgetId === "diskUsage")
widgetObj.minimumWidth = true;
if (widgetId === "memUsage")
widgetObj.showInGb = false;
@@ -320,7 +320,7 @@ Column {
DankActionButton {
id: minimumWidthButton
buttonSize: 28
visible: modelData.id === "cpuUsage" || modelData.id === "memUsage" || modelData.id === "cpuTemp" || modelData.id === "gpuTemp"
visible: modelData.id === "cpuUsage" || modelData.id === "memUsage" || modelData.id === "cpuTemp" || modelData.id === "gpuTemp" || modelData.id === "diskUsage"
iconName: "straighten"
iconSize: 16
iconColor: (modelData.minimumWidth !== undefined ? modelData.minimumWidth : true) ? Theme.primary : Theme.outline
+69 -15
View File
@@ -20,6 +20,18 @@ Singleton {
property bool indexLoaded: false
property var _translatedCache: []
Connections {
target: I18n
function onTranslationsChanged() {
root._refreshTranslatedCache();
}
function onTranslationsLoadedChanged() {
root._refreshTranslatedCache();
}
}
readonly property var conditionMap: ({
"isNiri": () => CompositorService.isNiri,
"isHyprland": () => CompositorService.isHyprland,
@@ -143,6 +155,7 @@ Singleton {
for (var i = 0; i < settingsIndex.length; i++) {
var item = settingsIndex[i];
var t = translateItem(item);
var sourceDescription = item.description || "";
cache.push({
section: t.section,
label: t.label,
@@ -152,13 +165,58 @@ Singleton {
icon: t.icon,
description: t.description,
conditionKey: t.conditionKey,
labelLower: t.label.toLowerCase(),
categoryLower: t.category.toLowerCase()
labelSearch: _lowerVariants([item.label, t.label]),
categorySearch: _lowerVariants([item.category, t.category]),
descriptionSearch: _lowerVariants([sourceDescription, t.description])
});
}
_translatedCache = cache;
}
function _lowerVariants(values) {
var out = [];
for (var i = 0; i < values.length; i++) {
var value = values[i];
if (!value)
continue;
var lower = String(value).toLowerCase();
if (out.indexOf(lower) === -1)
out.push(lower);
}
return out;
}
function _bestFieldScore(fields, queryLower, exactScore, prefixScore, includesScore) {
var score = 0;
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
if (field === queryLower) {
score = Math.max(score, exactScore);
} else if (field.startsWith(queryLower)) {
score = Math.max(score, prefixScore);
} else if (field.includes(queryLower)) {
score = Math.max(score, includesScore);
}
}
return score;
}
function _fieldsContainWord(fields, word) {
for (var i = 0; i < fields.length; i++) {
if (fields[i].includes(word))
return true;
}
return false;
}
function _refreshTranslatedCache() {
if (!indexLoaded)
return;
_rebuildTranslationCache();
if (query)
results = _searchEntries(query, 15);
}
function _searchEntries(text, maxResults) {
if (!text)
return [];
@@ -174,19 +232,11 @@ Singleton {
if (!checkCondition(entry))
continue;
var labelLower = entry.labelLower;
var categoryLower = entry.categoryLower;
var score = 0;
if (labelLower === queryLower) {
score = 10000;
} else if (labelLower.startsWith(queryLower)) {
score = 5000;
} else if (labelLower.includes(queryLower)) {
score = 1000;
} else if (categoryLower.includes(queryLower)) {
score = 500;
}
score = Math.max(score, _bestFieldScore(entry.labelSearch, queryLower, 10000, 5000, 1000));
score = Math.max(score, _bestFieldScore(entry.categorySearch, queryLower, 500, 500, 500));
score = Math.max(score, _bestFieldScore(entry.descriptionSearch, queryLower, 250, 250, 250));
if (score === 0) {
var keywords = entry.keywords;
@@ -205,7 +255,11 @@ Singleton {
var allMatch = true;
for (var w = 0; w < queryWords.length; w++) {
var word = queryWords[w];
if (labelLower.includes(word))
if (_fieldsContainWord(entry.labelSearch, word))
continue;
if (_fieldsContainWord(entry.descriptionSearch, word))
continue;
if (_fieldsContainWord(entry.categorySearch, word))
continue;
var inKeywords = false;
for (var k = 0; k < entry.keywords.length; k++) {
@@ -214,7 +268,7 @@ Singleton {
break;
}
}
if (!inKeywords && !categoryLower.includes(word)) {
if (!inKeywords) {
allMatch = false;
break;
}