mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
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:
Notes:
github-actions[bot]
2026-03-24 16:06:51 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/ea27692e7bd Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8589 Reviewed-by: https://github.com/shannonbooth
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user