Skip to content

Commit fbd49a2

Browse files
authored
Merge pull request #3535 from Electronic-Mango/sysmon-widget-none-display-type
Add "None" display type to sysmon bar widget
2 parents 00bbc99 + 40fe66d commit fbd49a2

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/shell/bar/widget_factory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ std::unique_ptr<Widget> WidgetFactory::create(
518518
displayMode = SysmonDisplayMode::Text;
519519
else if (display == "graph")
520520
displayMode = SysmonDisplayMode::Graph;
521+
else if (display == "none")
522+
displayMode = SysmonDisplayMode::None;
521523
if (verticalBar && displayMode == SysmonDisplayMode::Graph) {
522524
displayMode = SysmonDisplayMode::Gauge;
523525
}

src/shell/bar/widgets/sysmon_widget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ namespace {
162162

163163
SysmonWidget::SysmonWidget(SystemMonitorService* monitor, ConfigService& configService, SysmonWidgetOptions options)
164164
: m_monitor(monitor), m_stat(options.stat), m_displayMode(options.displayMode),
165-
m_highlightColor(options.highlightColor), m_configService(configService), m_showLabel(options.showLabel),
165+
m_highlightColor(options.highlightColor), m_configService(configService),
166+
m_showLabel(options.showLabel && options.displayMode != SysmonDisplayMode::None),
166167
m_labelMinWidth(options.labelMinWidth), m_diskPath(std::move(options.diskPath)),
167168
m_networkInterface(std::move(options.networkInterface)), m_networkSpeedUnit(options.networkSpeedUnit),
168169
m_networkSpeedLabelStyle(options.networkSpeedLabelStyle), m_glyphOverride(std::move(options.glyph)),

src/shell/bar/widgets/sysmon_widget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum class SysmonStat {
3939
NetRx,
4040
NetTx
4141
};
42-
enum class SysmonDisplayMode { Text, Graph, Gauge };
42+
enum class SysmonDisplayMode { Text, Graph, Gauge, None };
4343

4444
struct SysmonWidgetOptions {
4545
SysmonStat stat = SysmonStat::CpuUsage;

src/shell/settings/widget_settings_registry.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ namespace settings {
666666
{"gauge", "settings.widgets.options.gauge"},
667667
{"graph", "settings.widgets.options.graph"},
668668
{"text", "settings.widgets.options.text"},
669+
{"none", "settings.widgets.options.none"},
669670
};
670671
const std::vector<WidgetSettingSelectOption> networkSpeedUnits = {
671672
{"auto", "settings.widgets.options.auto"},
@@ -917,11 +918,20 @@ namespace settings {
917918
}
918919
add(segmentedSpec("display", "gauge", sysmonDisplay));
919920
add(colorSpec("highlight_color", "error"));
920-
add(boolSpec("show_label", true));
921921
{
922-
auto minW = intSpec("label_min_width", 0, 0.0, 200.0, 1.0);
923-
minW.visibleWhen = WidgetSettingVisibility{"show_label", {"true"}};
924-
add(std::move(minW));
922+
auto showLabel = boolSpec("show_label", true);
923+
showLabel.visibleWhen = WidgetSettingVisibility{"display", {"gauge", "graph", "text"}};
924+
add(std::move(showLabel));
925+
}
926+
{
927+
auto minWidth = intSpec("label_min_width", 0, 0.0, 200.0, 1.0);
928+
WidgetSettingVisibility minWidthSettings;
929+
minWidthSettings.all = {
930+
WidgetSettingVisibilityCondition{"display", {"gauge", "graph", "text"}},
931+
WidgetSettingVisibilityCondition{"show_label", {"true"}},
932+
};
933+
minWidth.visibleWhen = minWidthSettings;
934+
add(std::move(minWidth));
925935
}
926936
} else if (type == "power_profile") {
927937
add(boolSpec("enable_scroll", true));

0 commit comments

Comments
 (0)