mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Ladybird/Qt: Add support for color pickers
This commit is contained in:
parent
3e1a154440
commit
84f845494e
Notes:
sideshowbarker
2024-07-17 06:28:38 +09:00
Author: https://github.com/circl-lastname Commit: https://github.com/SerenityOS/serenity/commit/84f845494e Pull-request: https://github.com/SerenityOS/serenity/pull/20951 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/trflynn89
1 changed files with 16 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue