diff --git a/Userland/Applications/PixelPaint/FilterGallery.cpp b/Userland/Applications/PixelPaint/FilterGallery.cpp index 6105ef02dc..cddf2e3ff6 100644 --- a/Userland/Applications/PixelPaint/FilterGallery.cpp +++ b/Userland/Applications/PixelPaint/FilterGallery.cpp @@ -37,9 +37,16 @@ FilterGallery::FilterGallery(GUI::Window* parent_window, ImageEditor* editor) filter_tree->set_model(filter_model); filter_tree->expand_tree(); - apply_button->on_click = [this](auto) { - dbgln("Click!"); + apply_button->on_click = [this, filter_tree](auto) { + auto selected_index = filter_tree->selection().first(); + if (!selected_index.is_valid()) + done(ExecResult::ExecAborted); + auto selected_filter = static_cast(selected_index.internal_data()); + if (selected_filter->type != FilterModel::FilterInfo::Type::Filter) + done(ExecResult::ExecAborted); + + selected_filter->apply_filter(); done(ExecResult::ExecOK); }; diff --git a/Userland/Applications/PixelPaint/FilterModel.h b/Userland/Applications/PixelPaint/FilterModel.h index 30dd477ee6..01a7c25d2d 100644 --- a/Userland/Applications/PixelPaint/FilterModel.h +++ b/Userland/Applications/PixelPaint/FilterModel.h @@ -24,14 +24,16 @@ public: String text; + Function apply_filter; + NonnullRefPtrVector children; FilterInfo* parent; - static NonnullRefPtr create_filter(String const& text, FilterInfo* parent = nullptr) + static NonnullRefPtr create_filter(String const& text, Function apply_filter, FilterInfo* parent = nullptr) { auto filter = adopt_ref(*new FilterInfo(Type::Filter, text, parent)); filter->ref(); - + filter->apply_filter = move(apply_filter); if (parent) parent->children.append(filter); return filter;