PixelPaint: Have ToolboxWidget keep track of active tool

Since there's only one global toolbox, it makes sense to store the
active tool in here, since we don't really have control over the
deletion of an editor.
This commit is contained in:
Mustafa Quraish 2021-09-12 21:36:01 -04:00 committed by Andreas Kling
commit ecf8f243a6
Notes: sideshowbarker 2024-07-18 04:02:58 +09:00
2 changed files with 7 additions and 2 deletions

View file

@ -53,10 +53,12 @@ void ToolboxWidget::setup_tools()
auto add_tool = [&](String name, StringView const& icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr<Tool> tool) {
auto action = GUI::Action::create_checkable(move(name), shortcut, Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name)),
[this, tool = tool.ptr()](auto& action) {
if (action.is_checked())
if (action.is_checked()) {
on_tool_selection(tool);
else
m_active_tool = tool;
} else {
on_tool_selection(nullptr);
}
});
m_action_group.add_action(action);
auto& button = m_toolbar->add_action(action);