mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 22:15:38 -05:00
@@ -16,7 +16,8 @@ Singleton {
|
|||||||
selectedGpuIndex: 0,
|
selectedGpuIndex: 0,
|
||||||
pciId: "",
|
pciId: "",
|
||||||
mountPath: "/",
|
mountPath: "/",
|
||||||
minimumWidth: true
|
minimumWidth: true,
|
||||||
|
showSwap: false
|
||||||
}
|
}
|
||||||
leftModel.append(dummy)
|
leftModel.append(dummy)
|
||||||
centerModel.append(dummy)
|
centerModel.append(dummy)
|
||||||
@@ -37,6 +38,7 @@ Singleton {
|
|||||||
var pciId = typeof order[i] === "string" ? undefined : order[i].pciId
|
var pciId = typeof order[i] === "string" ? undefined : order[i].pciId
|
||||||
var mountPath = typeof order[i] === "string" ? undefined : order[i].mountPath
|
var mountPath = typeof order[i] === "string" ? undefined : order[i].mountPath
|
||||||
var minimumWidth = typeof order[i] === "string" ? undefined : order[i].minimumWidth
|
var minimumWidth = typeof order[i] === "string" ? undefined : order[i].minimumWidth
|
||||||
|
var showSwap = typeof order[i] === "string" ? undefined : order[i].showSwap
|
||||||
var item = {
|
var item = {
|
||||||
widgetId: widgetId,
|
widgetId: widgetId,
|
||||||
enabled: enabled
|
enabled: enabled
|
||||||
@@ -46,6 +48,7 @@ Singleton {
|
|||||||
if (pciId !== undefined) item.pciId = pciId
|
if (pciId !== undefined) item.pciId = pciId
|
||||||
if (mountPath !== undefined) item.mountPath = mountPath
|
if (mountPath !== undefined) item.mountPath = mountPath
|
||||||
if (minimumWidth !== undefined) item.minimumWidth = minimumWidth
|
if (minimumWidth !== undefined) item.minimumWidth = minimumWidth
|
||||||
|
if (showSwap !== undefined) item.showSwap = showSwap
|
||||||
|
|
||||||
model.append(item)
|
model.append(item)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ BasePill {
|
|||||||
property var popoutTarget: null
|
property var popoutTarget: null
|
||||||
property var widgetData: null
|
property var widgetData: null
|
||||||
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
|
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
|
||||||
|
property bool showSwap: (widgetData && widgetData.showSwap !== undefined) ? widgetData.showSwap : false
|
||||||
|
readonly property real swapUsage: DgopService.totalSwapKB > 0 ? (DgopService.usedSwapKB / DgopService.totalSwapKB) * 100 : 0
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
DgopService.addRef(["memory"]);
|
DgopService.addRef(["memory"]);
|
||||||
@@ -62,6 +64,14 @@ BasePill {
|
|||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
visible: root.showSwap && DgopService.totalSwapKB > 0
|
||||||
|
text: root.swapUsage.toFixed(0)
|
||||||
|
font.pixelSize: Theme.barTextSize(root.barThickness)
|
||||||
|
color: Theme.surfaceVariantText
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
@@ -93,18 +103,31 @@ BasePill {
|
|||||||
return "--%";
|
return "--%";
|
||||||
}
|
}
|
||||||
|
|
||||||
return DgopService.memoryUsage.toFixed(0) + "%";
|
let ramText = DgopService.memoryUsage.toFixed(0) + "%";
|
||||||
|
if (root.showSwap && DgopService.totalSwapKB > 0) {
|
||||||
|
return ramText + " · " + root.swapUsage.toFixed(0) + "%";
|
||||||
|
}
|
||||||
|
return ramText;
|
||||||
}
|
}
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness)
|
font.pixelSize: Theme.barTextSize(root.barThickness)
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
elide: Text.ElideNone
|
elide: Text.ElideNone
|
||||||
|
wrapMode: Text.NoWrap
|
||||||
|
|
||||||
StyledTextMetrics {
|
StyledTextMetrics {
|
||||||
id: ramBaseline
|
id: ramBaseline
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness)
|
font.pixelSize: Theme.barTextSize(root.barThickness)
|
||||||
text: "100%"
|
text: {
|
||||||
|
if (!root.showSwap) {
|
||||||
|
return "100%";
|
||||||
|
}
|
||||||
|
if (root.swapUsage < 10) {
|
||||||
|
return "100% · 0%";
|
||||||
|
}
|
||||||
|
return "100% · 100%";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
width: root.minimumWidth ? Math.max(ramBaseline.width, paintedWidth) : paintedWidth
|
width: root.minimumWidth ? Math.max(ramBaseline.width, paintedWidth) : paintedWidth
|
||||||
|
|||||||
@@ -541,6 +541,58 @@ Item {
|
|||||||
newWidget.pciId = widget.pciId
|
newWidget.pciId = widget.pciId
|
||||||
if (widget.mountPath !== undefined)
|
if (widget.mountPath !== undefined)
|
||||||
newWidget.mountPath = widget.mountPath
|
newWidget.mountPath = widget.mountPath
|
||||||
|
if (widget.showSwap !== undefined)
|
||||||
|
newWidget.showSwap = widget.showSwap
|
||||||
|
if (widget.id === "controlCenterButton") {
|
||||||
|
newWidget.showNetworkIcon = widget.showNetworkIcon !== undefined ? widget.showNetworkIcon : true
|
||||||
|
newWidget.showBluetoothIcon = widget.showBluetoothIcon !== undefined ? widget.showBluetoothIcon : true
|
||||||
|
newWidget.showAudioIcon = widget.showAudioIcon !== undefined ? widget.showAudioIcon : true
|
||||||
|
}
|
||||||
|
widgets[widgetIndex] = newWidget
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sectionId === "left")
|
||||||
|
SettingsData.setDankBarLeftWidgets(widgets)
|
||||||
|
else if (sectionId === "center")
|
||||||
|
SettingsData.setDankBarCenterWidgets(widgets)
|
||||||
|
else if (sectionId === "right")
|
||||||
|
SettingsData.setDankBarRightWidgets(widgets)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleShowSwapChanged(sectionId, widgetIndex, enabled) {
|
||||||
|
var widgets = []
|
||||||
|
if (sectionId === "left")
|
||||||
|
widgets = SettingsData.dankBarLeftWidgets.slice()
|
||||||
|
else if (sectionId === "center")
|
||||||
|
widgets = SettingsData.dankBarCenterWidgets.slice()
|
||||||
|
else if (sectionId === "right")
|
||||||
|
widgets = SettingsData.dankBarRightWidgets.slice()
|
||||||
|
|
||||||
|
if (widgetIndex >= 0 && widgetIndex < widgets.length) {
|
||||||
|
var widget = widgets[widgetIndex]
|
||||||
|
if (typeof widget === "string") {
|
||||||
|
widgets[widgetIndex] = {
|
||||||
|
"id": widget,
|
||||||
|
"enabled": true,
|
||||||
|
"showSwap": enabled
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var newWidget = {
|
||||||
|
"id": widget.id,
|
||||||
|
"enabled": widget.enabled,
|
||||||
|
"showSwap": enabled
|
||||||
|
}
|
||||||
|
if (widget.size !== undefined)
|
||||||
|
newWidget.size = widget.size
|
||||||
|
if (widget.selectedGpuIndex !== undefined)
|
||||||
|
newWidget.selectedGpuIndex = widget.selectedGpuIndex
|
||||||
|
if (widget.pciId !== undefined)
|
||||||
|
newWidget.pciId = widget.pciId
|
||||||
|
if (widget.mountPath !== undefined)
|
||||||
|
newWidget.mountPath = widget.mountPath
|
||||||
|
if (widget.minimumWidth !== undefined)
|
||||||
|
newWidget.minimumWidth = widget.minimumWidth
|
||||||
if (widget.id === "controlCenterButton") {
|
if (widget.id === "controlCenterButton") {
|
||||||
newWidget.showNetworkIcon = widget.showNetworkIcon !== undefined ? widget.showNetworkIcon : true
|
newWidget.showNetworkIcon = widget.showNetworkIcon !== undefined ? widget.showNetworkIcon : true
|
||||||
newWidget.showBluetoothIcon = widget.showBluetoothIcon !== undefined ? widget.showBluetoothIcon : true
|
newWidget.showBluetoothIcon = widget.showBluetoothIcon !== undefined ? widget.showBluetoothIcon : true
|
||||||
@@ -582,6 +634,7 @@ Item {
|
|||||||
var widgetShowBluetoothIcon = typeof widget === "string" ? undefined : widget.showBluetoothIcon
|
var widgetShowBluetoothIcon = typeof widget === "string" ? undefined : widget.showBluetoothIcon
|
||||||
var widgetShowAudioIcon = typeof widget === "string" ? undefined : widget.showAudioIcon
|
var widgetShowAudioIcon = typeof widget === "string" ? undefined : widget.showAudioIcon
|
||||||
var widgetMinimumWidth = typeof widget === "string" ? undefined : widget.minimumWidth
|
var widgetMinimumWidth = typeof widget === "string" ? undefined : widget.minimumWidth
|
||||||
|
var widgetShowSwap = typeof widget === "string" ? undefined : widget.showSwap
|
||||||
var widgetDef = baseWidgetDefinitions.find(w => {
|
var widgetDef = baseWidgetDefinitions.find(w => {
|
||||||
return w.id === widgetId
|
return w.id === widgetId
|
||||||
})
|
})
|
||||||
@@ -604,6 +657,8 @@ Item {
|
|||||||
item.showAudioIcon = widgetShowAudioIcon
|
item.showAudioIcon = widgetShowAudioIcon
|
||||||
if (widgetMinimumWidth !== undefined)
|
if (widgetMinimumWidth !== undefined)
|
||||||
item.minimumWidth = widgetMinimumWidth
|
item.minimumWidth = widgetMinimumWidth
|
||||||
|
if (widgetShowSwap !== undefined)
|
||||||
|
item.showSwap = widgetShowSwap
|
||||||
|
|
||||||
widgets.push(item)
|
widgets.push(item)
|
||||||
}
|
}
|
||||||
@@ -1802,6 +1857,10 @@ Item {
|
|||||||
dankBarTab.handleMinimumWidthChanged(
|
dankBarTab.handleMinimumWidthChanged(
|
||||||
sectionId, widgetIndex, enabled)
|
sectionId, widgetIndex, enabled)
|
||||||
}
|
}
|
||||||
|
onShowSwapChanged: (sectionId, widgetIndex, enabled) => {
|
||||||
|
dankBarTab.handleShowSwapChanged(
|
||||||
|
sectionId, widgetIndex, enabled)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1881,6 +1940,10 @@ Item {
|
|||||||
dankBarTab.handleMinimumWidthChanged(
|
dankBarTab.handleMinimumWidthChanged(
|
||||||
sectionId, widgetIndex, enabled)
|
sectionId, widgetIndex, enabled)
|
||||||
}
|
}
|
||||||
|
onShowSwapChanged: (sectionId, widgetIndex, enabled) => {
|
||||||
|
dankBarTab.handleShowSwapChanged(
|
||||||
|
sectionId, widgetIndex, enabled)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1960,6 +2023,10 @@ Item {
|
|||||||
dankBarTab.handleMinimumWidthChanged(
|
dankBarTab.handleMinimumWidthChanged(
|
||||||
sectionId, widgetIndex, enabled)
|
sectionId, widgetIndex, enabled)
|
||||||
}
|
}
|
||||||
|
onShowSwapChanged: (sectionId, widgetIndex, enabled) => {
|
||||||
|
dankBarTab.handleShowSwapChanged(
|
||||||
|
sectionId, widgetIndex, enabled)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ Column {
|
|||||||
signal diskMountSelectionChanged(string sectionId, int widgetIndex, string mountPath)
|
signal diskMountSelectionChanged(string sectionId, int widgetIndex, string mountPath)
|
||||||
signal controlCenterSettingChanged(string sectionId, int widgetIndex, string settingName, bool value)
|
signal controlCenterSettingChanged(string sectionId, int widgetIndex, string settingName, bool value)
|
||||||
signal minimumWidthChanged(string sectionId, int widgetIndex, bool enabled)
|
signal minimumWidthChanged(string sectionId, int widgetIndex, bool enabled)
|
||||||
|
signal showSwapChanged(string sectionId, int widgetIndex, bool enabled)
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
@@ -315,6 +316,34 @@ Column {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DankActionButton {
|
||||||
|
id: showSwapButton
|
||||||
|
buttonSize: 28
|
||||||
|
visible: modelData.id === "memUsage"
|
||||||
|
iconName: "swap_horiz"
|
||||||
|
iconSize: 16
|
||||||
|
iconColor: (modelData.showSwap !== undefined ? modelData.showSwap : false) ? Theme.primary : Theme.outline
|
||||||
|
onClicked: {
|
||||||
|
var currentEnabled = modelData.showSwap !== undefined ? modelData.showSwap : false
|
||||||
|
root.showSwapChanged(root.sectionId, index, !currentEnabled)
|
||||||
|
}
|
||||||
|
onEntered: {
|
||||||
|
showSwapTooltipLoader.active = true
|
||||||
|
if (showSwapTooltipLoader.item) {
|
||||||
|
var currentEnabled = modelData.showSwap !== undefined ? modelData.showSwap : false
|
||||||
|
const tooltipText = currentEnabled ? "Hide Swap" : "Show Swap"
|
||||||
|
const p = showSwapButton.mapToItem(null, showSwapButton.width / 2, 0)
|
||||||
|
showSwapTooltipLoader.item.show(tooltipText, p.x, p.y - 40, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
if (showSwapTooltipLoader.item) {
|
||||||
|
showSwapTooltipLoader.item.hide()
|
||||||
|
}
|
||||||
|
showSwapTooltipLoader.active = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
visible: modelData.id === "clock"
|
visible: modelData.id === "clock"
|
||||||
@@ -974,4 +1003,10 @@ Column {
|
|||||||
active: false
|
active: false
|
||||||
sourceComponent: DankTooltip {}
|
sourceComponent: DankTooltip {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: showSwapTooltipLoader
|
||||||
|
active: false
|
||||||
|
sourceComponent: DankTooltip {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user