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:
@@ -77,9 +77,9 @@ auto Language::update() -> void {
|
||||
|
||||
if (!format_.empty()) {
|
||||
label_.show();
|
||||
label_.set_markup(layoutName);
|
||||
setLabelMarkup(layoutName);
|
||||
if (tooltip_enabled) {
|
||||
label_.set_tooltip_markup(tooltipContent);
|
||||
setTooltipMarkup(tooltipContent);
|
||||
}
|
||||
} else {
|
||||
label_.hide();
|
||||
@@ -93,12 +93,11 @@ auto Language::update() -> void {
|
||||
} else {
|
||||
tooltipFormat = "{long}";
|
||||
}
|
||||
auto tooltipText = trim(fmt::format(
|
||||
fmt::runtime(tooltipFormat),
|
||||
fmt::arg("long", layout_.full_name),
|
||||
fmt::arg("short", layout_.short_name),
|
||||
fmt::arg("shortDescription", layout_.short_description),
|
||||
fmt::arg("variant", layout_.variant)));
|
||||
auto tooltipText =
|
||||
trim(fmt::format(fmt::runtime(tooltipFormat), fmt::arg("long", layout_.full_name),
|
||||
fmt::arg("short", layout_.short_name),
|
||||
fmt::arg("shortDescription", layout_.short_description),
|
||||
fmt::arg("variant", layout_.variant)));
|
||||
label_.set_tooltip_text(tooltipText);
|
||||
} else {
|
||||
label_.set_tooltip_text("");
|
||||
@@ -185,7 +184,8 @@ void Language::initLanguage() {
|
||||
|
||||
auto Language::removeXkbLayoutCssClass() -> void {
|
||||
label_.get_style_context()->remove_class(layout_.short_name);
|
||||
spdlog::debug("hyprland language try to remove currently short_name css class {}", layout_.short_name);
|
||||
spdlog::debug("hyprland language try to remove currently short_name css class {}",
|
||||
layout_.short_name);
|
||||
}
|
||||
auto Language::addXkbLayoutCssClass() -> void {
|
||||
label_.get_style_context()->add_class(layout_.short_name);
|
||||
|
||||
@@ -67,7 +67,7 @@ auto Window::update() -> void {
|
||||
fmt::arg("class", windowData_.class_name),
|
||||
fmt::arg("initialClass", windowData_.initial_class_name)),
|
||||
config_["rewrite"]);
|
||||
label_.set_markup(label_text);
|
||||
setLabelMarkup(label_text);
|
||||
} else {
|
||||
label_.hide();
|
||||
}
|
||||
@@ -78,13 +78,12 @@ auto Window::update() -> void {
|
||||
tooltip_format = config_["tooltip-format"].asString();
|
||||
}
|
||||
if (!tooltip_format.empty()) {
|
||||
label_.set_tooltip_markup(
|
||||
fmt::format(fmt::runtime(tooltip_format), fmt::arg("title", windowName),
|
||||
fmt::arg("initialTitle", windowData_.initial_title),
|
||||
fmt::arg("class", windowData_.class_name),
|
||||
fmt::arg("initialClass", windowData_.initial_class_name)));
|
||||
setTooltipMarkup(fmt::format(fmt::runtime(tooltip_format), fmt::arg("title", windowName),
|
||||
fmt::arg("initialTitle", windowData_.initial_title),
|
||||
fmt::arg("class", windowData_.class_name),
|
||||
fmt::arg("initialClass", windowData_.initial_class_name)));
|
||||
} else if (!label_text.empty()) {
|
||||
label_.set_tooltip_markup(label_text);
|
||||
setTooltipMarkup(label_text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,9 +221,9 @@ void Window::queryActiveWorkspace() {
|
||||
std::vector<Json::Value> visibleWindows;
|
||||
std::ranges::copy_if(workspaceWindows, std::back_inserter(visibleWindows),
|
||||
[&](const Json::Value& window) { return !window["hidden"].asBool(); });
|
||||
solo_ = 1 == std::count_if(
|
||||
visibleWindows.begin(), visibleWindows.end(),
|
||||
[&](const Json::Value& window) { return !window["floating"].asBool(); });
|
||||
solo_ =
|
||||
1 == std::count_if(visibleWindows.begin(), visibleWindows.end(),
|
||||
[&](const Json::Value& window) { return !window["floating"].asBool(); });
|
||||
allFloating_ = std::ranges::all_of(
|
||||
visibleWindows, [&](const Json::Value& window) { return window["floating"].asBool(); });
|
||||
fullscreen_ = windowData_.fullscreen;
|
||||
|
||||
Reference in New Issue
Block a user