Browser: Add support for color pickers

This commit is contained in:
circl 2023-09-04 14:12:39 +02:00 committed by Sam Atkins
parent 2995a2e212
commit 3e1a154440
Notes: sideshowbarker 2024-07-17 07:09:53 +09:00

View file

@ -28,6 +28,7 @@
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
#include <LibGUI/Clipboard.h>
#include <LibGUI/ColorPicker.h>
#include <LibGUI/Dialog.h>
#include <LibGUI/InputBox.h>
#include <LibGUI/Menu.h>
@ -566,6 +567,23 @@ Tab::Tab(BrowserWindow& window)
m_dialog->done(GUI::Dialog::ExecResult::Cancel);
};
view().on_request_color_picker = [this](Color current_color) {
auto& window = this->window();
m_dialog = GUI::ColorPicker::construct(current_color, &window);
auto& dialog = static_cast<GUI::ColorPicker&>(*m_dialog);
dialog.set_icon(window.icon());
dialog.set_color_has_alpha_channel(false);
if (dialog.exec() == GUI::ColorPicker::ExecResult::OK)
view().color_picker_closed(dialog.color());
else
view().color_picker_closed({});
m_dialog = nullptr;
};
view().on_received_source = [this](auto& url, auto& source) {
view_source(url, source);
};