From 1631077b74c6acd7786501e15ccf32aef05bd040 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 13 May 2020 14:48:17 +0200 Subject: [PATCH] PaintBrush: Put all the tool buttons into an action group This allows us to easily make them exclusive and uncheckable. :^) --- Applications/PaintBrush/ToolboxWidget.cpp | 4 ++++ Applications/PaintBrush/ToolboxWidget.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/Applications/PaintBrush/ToolboxWidget.cpp b/Applications/PaintBrush/ToolboxWidget.cpp index 1890c8e0f32..c548755a76f 100644 --- a/Applications/PaintBrush/ToolboxWidget.cpp +++ b/Applications/PaintBrush/ToolboxWidget.cpp @@ -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(); 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) { auto& button = add(*this, name, shortcut, move(tool)); button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); diff --git a/Applications/PaintBrush/ToolboxWidget.h b/Applications/PaintBrush/ToolboxWidget.h index 561951742e0..4f71565dc77 100644 --- a/Applications/PaintBrush/ToolboxWidget.h +++ b/Applications/PaintBrush/ToolboxWidget.h @@ -26,6 +26,7 @@ #pragma once +#include #include namespace PaintBrush { @@ -40,7 +41,11 @@ public: Function on_tool_selection; private: + friend class ToolButton; + explicit ToolboxWidget(); + + GUI::ActionGroup m_action_group; }; }