LibWebView: Add an engaged state to application menu actions

This will be used to update the displayed action icon for an upcoming
action to add/remove the current page from a bookmark store.
This commit is contained in:
Timothy Flynn
2026-03-22 21:49:04 -04:00
committed by Tim Flynn
parent 2ee6d3334f
commit ea27692e7b
Notes: github-actions[bot] 2026-03-24 16:06:51 +00:00
2 changed files with 16 additions and 0 deletions

View File

@@ -60,6 +60,16 @@ void Action::set_visible(bool visible)
observer->on_visible_state_changed(*this);
}
void Action::set_engaged(bool engaged)
{
if (m_engaged == engaged)
return;
m_engaged = engaged;
for (auto& observer : m_observers)
observer->on_engaged_state_changed(*this);
}
void Action::set_checked(bool checked)
{
set_checked_internal(checked);
@@ -91,6 +101,7 @@ void Action::add_observer(NonnullOwnPtr<Observer> observer)
observer->on_tooltip_changed(*this);
observer->on_enabled_state_changed(*this);
observer->on_visible_state_changed(*this);
observer->on_engaged_state_changed(*this);
if (is_checkable())
observer->on_checked_state_changed(*this);

View File

@@ -124,6 +124,9 @@ public:
bool visible() const { return m_visible; }
void set_visible(bool);
bool engaged() const { return m_engaged; }
void set_engaged(bool);
bool is_checkable() const { return m_checked.has_value(); }
bool checked() const { return *m_checked; }
void set_checked(bool);
@@ -135,6 +138,7 @@ public:
virtual void on_tooltip_changed(Action&) { }
virtual void on_enabled_state_changed(Action&) { }
virtual void on_visible_state_changed(Action&) { }
virtual void on_engaged_state_changed(Action&) { }
virtual void on_checked_state_changed(Action&) { }
};
@@ -160,6 +164,7 @@ private:
bool m_enabled { true };
bool m_visible { true };
bool m_engaged { false };
Optional<bool> m_checked;
Function<void()> m_action;