modules: Revert button to label

This commit is contained in:
Simon Plakolb
2022-11-24 12:28:52 +01:00
parent 74fa131ebe
commit 5e9bbe5c76
43 changed files with 270 additions and 265 deletions

View File

@ -3,7 +3,7 @@
#include <time.h>
waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
: AButton(config, "clock", id, "{:%H:%M}", 60) {
: ALabel(config, "clock", id, "{:%H:%M}", 60) {
thread_ = [this] {
dp.emit();
auto now = std::chrono::system_clock::now();
@ -19,17 +19,17 @@ auto waybar::modules::Clock::update() -> void {
auto now = std::chrono::system_clock::now();
auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now));
auto text = fmt::format(format_, localtime);
label_->set_markup(text);
label_.set_markup(text);
if (tooltipEnabled()) {
if (config_["tooltip-format"].isString()) {
auto tooltip_format = config_["tooltip-format"].asString();
auto tooltip_text = fmt::format(tooltip_format, localtime);
button_.set_tooltip_text(tooltip_text);
label_.set_tooltip_text(tooltip_text);
} else {
button_.set_tooltip_text(text);
label_.set_tooltip_text(text);
}
}
// Call parent update
AButton::update();
ALabel::update();
}