refactor(tooltip): migrate modules to ALabel generic tooltip helper
Migrate idle_inhibitor, sway/language, sway/scratchpad, hyprland/language and hyprland/window to the shared label/tooltip setters. idle_inhibitor uses updateLabelAndTooltipForState; the others keep their custom label/tooltip resolution (trim, precomputed tooltip, rewriteString, per-lang/variant formats) and switch to the dedup-aware setLabelMarkup/setTooltipMarkup.
This commit is contained in:
@@ -63,16 +63,9 @@ auto waybar::modules::IdleInhibitor::update() -> void {
|
||||
}
|
||||
|
||||
std::string status_text = status ? "activated" : "deactivated";
|
||||
label_.set_markup(fmt::format(fmt::runtime(format_), fmt::arg("status", status_text),
|
||||
fmt::arg("icon", getIcon(0, status_text))));
|
||||
updateLabelAndTooltipForState(status_text, format_, "{status}", fmt::arg("status", status_text),
|
||||
fmt::arg("icon", getIcon(0, status_text)));
|
||||
label_.get_style_context()->add_class(status_text);
|
||||
if (tooltipEnabled()) {
|
||||
auto config = config_[status ? "tooltip-format-activated" : "tooltip-format-deactivated"];
|
||||
auto tooltip_format = config.isString() ? config.asString() : "{status}";
|
||||
label_.set_tooltip_markup(fmt::format(fmt::runtime(tooltip_format),
|
||||
fmt::arg("status", status_text),
|
||||
fmt::arg("icon", getIcon(0, status_text))));
|
||||
}
|
||||
// Call parent update
|
||||
ALabel::update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user