Deluge Firmware 1.3.0
Build date: 2026.02.12
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 arg_ = std::nullopt;
22 }
23 return title_;
24 }
25
26private:
27 l10n::String format_str_;
28 mutable std::string title_;
29 mutable std::optional<uint8_t> arg_;
30};
31} // namespace deluge::gui::menu_item