Skip to content

Commit

Permalink
fix(text): no show value is swap is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
orblazer committed May 31, 2021
1 parent 3a7e73e commit ae63d16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package/contents/ui/components/GraphItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Item {
case 'always':
case 'hover-hints':
firstLineValueLabel.visible = true
secondLineValueLabel.visible = secondLineInfoText != ''
secondLineValueLabel.visible = secondLineInfoText != '' && secondLineValueLabel.enabled
break
}
}
Expand All @@ -238,7 +238,7 @@ Item {
switch (displayment) {
case 'hover':
firstLineValueLabel.visible = true
secondLineValueLabel.visible = secondLineInfoText != ''
secondLineValueLabel.visible = secondLineInfoText != '' && secondLineValueLabel.enabled
break
case 'hover-hints':
firstLineInfoLabel.visible = true
Expand All @@ -263,7 +263,7 @@ Item {

if(secondLineInfoText != '') {
secondLineInfoLabel.visible = false
secondLineValueLabel.visible = true
secondLineValueLabel.visible = secondLineValueLabel.enabled
}
break
}
Expand Down
12 changes: 8 additions & 4 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Item {

// Settings properties
property bool verticalLayout: plasmoid.configuration.verticalLayout

property bool showCpuMonitor: plasmoid.configuration.showCpuMonitor
property bool showClock: plasmoid.configuration.showClock
property bool showRamMonitor: plasmoid.configuration.showRamMonitor
Expand Down Expand Up @@ -82,7 +83,7 @@ Item {
}

onFontPixelSizeChanged: {
for(var monitor of [cpuMonitor, ramMonitor, netMonitor]) {
for (var monitor of [cpuMonitor, ramMonitor, netMonitor]) {
monitor.firstLineInfoLabel.font.pixelSize = fontPixelSize
monitor.firstLineValueLabel.font.pixelSize = fontPixelSize
monitor.secondLineInfoLabel.font.pixelSize = fontPixelSize
Expand Down Expand Up @@ -224,11 +225,14 @@ Item {
Functions.addGraphData(ramGraphModel, totalRamProportion, graphGranularity)
Functions.addGraphData(swapGraphModel, totalSwapProportion, graphGranularity)

ramMonitor.firstLineValueLabel.text = showMemoryInPercent ? Math.round(totalRamProportion * 100) + '%' : Functions.getHumanReadableMemory(dataSource.ramUsedBytes)
ramMonitor.firstLineValueLabel.text = showMemoryInPercent ? Math.round(totalRamProportion * 100) + '%'
: Functions.getHumanReadableMemory(dataSource.ramUsedBytes)
ramMonitor.firstLineValueLabel.color = totalRamProportion > 0.9 ? warningColor : theme.textColor
ramMonitor.secondLineValueLabel.text = showMemoryInPercent ? Math.round(totalSwapProportion * 100) + '%' : Functions.getHumanReadableMemory(dataSource.swapUsedBytes)
ramMonitor.secondLineValueLabel.text = showMemoryInPercent ? Math.round(totalSwapProportion * 100) + '%'
: Functions.getHumanReadableMemory(dataSource.swapUsedBytes)
ramMonitor.secondLineValueLabel.color = totalSwapProportion > 0.9 ? warningColor : theme.textColor
ramMonitor.secondLineValueLabel.visible = !ramMonitor.secondLineInfoLabel.visible && totalSwapProportion > 0
ramMonitor.secondLineValueLabel.visible = ramMonitor.secondLineValueLabel.enabled =
!ramMonitor.secondLineInfoLabel.visible && totalSwapProportion > 0
}

if (showNetMonitor) {
Expand Down

0 comments on commit ae63d16

Please sign in to comment.