tooltip functionality on hyprland/language module
This commit is contained in:
@@ -35,6 +35,7 @@ class Language : public waybar::ALabel, public EventHandler {
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
util::JsonParser parser_;
|
||||
const bool tooltip_format_enabled_;
|
||||
|
||||
Layout layout_;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
namespace waybar::modules::hyprland {
|
||||
|
||||
Language::Language(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: ALabel(config, "language", id, "{}", 0, true), bar_(bar) {
|
||||
: ALabel(config, "language", id, "{}", 0, true),
|
||||
bar_(bar),
|
||||
tooltip_format_enabled_{config_["tooltip-format"].isString()} {
|
||||
modulesReady = true;
|
||||
|
||||
if (!gIPC) {
|
||||
@@ -57,9 +59,27 @@ auto Language::update() -> void {
|
||||
|
||||
spdlog::debug("hyprland language formatted layout name {}", layoutName);
|
||||
|
||||
std::string tooltipContent = std::string{};
|
||||
if (tooltipEnabled()) {
|
||||
if (tooltip_format_enabled_) {
|
||||
auto tooltip_format = config_["tooltip-format"].asString();
|
||||
tooltipContent = fmt::format(fmt::runtime(tooltip_format),
|
||||
fmt::arg("long", layout_.full_name),
|
||||
fmt::arg("short", layout_.short_name),
|
||||
fmt::arg("shortDescription", layout_.short_description),
|
||||
fmt::arg("variant", layout_.variant));
|
||||
|
||||
} else {
|
||||
tooltipContent = layoutName;
|
||||
}
|
||||
}
|
||||
|
||||
spdlog::debug("hyprland language formatted tooltip content {}", tooltipContent);
|
||||
|
||||
if (!format_.empty()) {
|
||||
label_.show();
|
||||
label_.set_markup(layoutName);
|
||||
label_.set_tooltip_markup(tooltipContent);
|
||||
} else {
|
||||
label_.hide();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user