PaintBrush: Put all the tool buttons into an action group

This allows us to easily make them exclusive and uncheckable. :^)
This commit is contained in:
Andreas Kling 2020-05-13 14:48:17 +02:00
parent 0de3b1c4bf
commit 1631077b74
Notes: sideshowbarker 2024-07-19 06:40:40 +09:00
2 changed files with 9 additions and 0 deletions

View file

@ -63,6 +63,7 @@ public:
});
set_action(*m_action);
m_toolbox.m_action_group.add_action(*m_action);
}
const Tool& tool() const { return *m_tool; }
@ -96,6 +97,9 @@ ToolboxWidget::ToolboxWidget()
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins({ 4, 4, 4, 4 });
m_action_group.set_exclusive(true);
m_action_group.set_unchecking_allowed(false);
auto add_tool = [&](const StringView& name, const StringView& icon_name, const GUI::Shortcut& shortcut, NonnullOwnPtr<Tool> tool) {
auto& button = add<ToolButton>(*this, name, shortcut, move(tool));
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);

View file

@ -26,6 +26,7 @@
#pragma once
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Frame.h>
namespace PaintBrush {
@ -40,7 +41,11 @@ public:
Function<void(Tool*)> on_tool_selection;
private:
friend class ToolButton;
explicit ToolboxWidget();
GUI::ActionGroup m_action_group;
};
}