claude: acabat de posar tot lo que deia i reventa. Debuggar

This commit is contained in:
2025-08-06 20:31:47 +02:00
parent 6d36291f51
commit 49145905e3
8 changed files with 131 additions and 67 deletions

View File

@@ -174,3 +174,37 @@ class ActionOption : public MenuOption {
private:
std::function<void()> action_;
};
// Opción de lista con acción
class ActionListOption : public MenuOption {
public:
using ValueGetter = std::function<std::string()>;
using ValueSetter = std::function<void(const std::string&)>;
using ActionExecutor = std::function<void()>;
ActionListOption(const std::string& caption, ServiceMenu::SettingsGroup group,
std::vector<std::string> options, ValueGetter getter, ValueSetter setter,
ActionExecutor action_executor, bool hidden = false)
: MenuOption(caption, group, hidden), options_(std::move(options)),
value_getter_(std::move(getter)), value_setter_(std::move(setter)),
action_executor_(std::move(action_executor)), current_index_(0) {
updateCurrentIndex();
}
[[nodiscard]] auto getBehavior() const -> Behavior override { return Behavior::BOTH; }
[[nodiscard]] auto getValueAsString() const -> std::string override;
[[nodiscard]] auto getMaxValueWidth(Text* text) const -> int override;
void adjustValue(bool up) override;
void executeAction() override;
void sync(); // Sincroniza con el valor actual
private:
std::vector<std::string> options_;
ValueGetter value_getter_;
ValueSetter value_setter_;
ActionExecutor action_executor_;
size_t current_index_;
void updateCurrentIndex();
[[nodiscard]] auto findCurrentIndex() const -> size_t;
};