Ladybird/Qt: Add support for color pickers

This commit is contained in:
circl 2023-09-04 15:46:20 +02:00 committed by Sam Atkins
parent 3e1a154440
commit 84f845494e
Notes: sideshowbarker 2024-07-17 06:28:38 +09:00

View file

@ -15,6 +15,7 @@
#include <LibGfx/Painter.h>
#include <LibWebView/SourceHighlighter.h>
#include <QClipboard>
#include <QColorDialog>
#include <QCoreApplication>
#include <QCursor>
#include <QFileDialog>
@ -213,6 +214,21 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
m_dialog->reject();
};
view().on_request_color_picker = [this](Color current_color) {
m_dialog = new QColorDialog(QColor(current_color.red(), current_color.green(), current_color.blue()), &view());
auto& dialog = static_cast<QColorDialog&>(*m_dialog);
dialog.setWindowTitle("Ladybird");
dialog.setOption(QColorDialog::ShowAlphaChannel, false);
if (dialog.exec() == QDialog::Accepted)
view().color_picker_closed(Color(dialog.selectedColor().red(), dialog.selectedColor().green(), dialog.selectedColor().blue()));
else
view().color_picker_closed({});
m_dialog = nullptr;
};
QObject::connect(focus_location_editor_action, &QAction::triggered, this, &Tab::focus_location_editor);
view().on_received_source = [this](auto const& url, auto const& source) {