Deluge Firmware 1.3.0
Build date: 2025.09.27
Loading...
Searching...
No Matches
formatted_title.h
1#pragma once
2#include "gui/l10n/l10n.h"
3#include "util/functions.h"
4
5namespace deluge::gui::menu_item {
6
7// Mixin for a formatted title
8class FormattedTitle {
9public:
10 FormattedTitle(l10n::String format_str, std::optional<uint8_t> arg = std::nullopt)
11 : format_str_(format_str), arg_{arg} {}
12
13 void format(int32_t arg) const {
14 title_ = l10n::get(format_str_);
15 asterixToInt(title_.data(), arg);
16 }
17
18 [[nodiscard]] std::string_view title() const {
19 if (arg_.has_value()) {
20 format(arg_.value());
21 // We cannot do this only once, in case the display switches between 7-seg and OLED
22 // modes, and those have different strings.
23 }
24 return title_;
25 }
26
27private:
28 l10n::String format_str_;
29 mutable std::string title_;
30 mutable std::optional<uint8_t> arg_;
31};
32} // namespace deluge::gui::menu_item