|
41 | 41 | #include <QApplication> |
42 | 42 | #include <QCursor> |
43 | 43 | #include <QIcon> |
| 44 | +#include <QInputDialog> |
44 | 45 | #include <QLineEdit> |
45 | 46 | #include <QMessageBox> |
46 | 47 | #include <QMouseEvent> |
@@ -850,23 +851,55 @@ void WebContentView::notify_server_did_request_image_context_menu(Badge<WebConte |
850 | 851 |
|
851 | 852 | void WebContentView::notify_server_did_request_alert(Badge<WebContentClient>, String const& message) |
852 | 853 | { |
853 | | - QMessageBox::warning(this, "Ladybird", qstring_from_akstring(message)); |
| 854 | + m_dialog = new QMessageBox(QMessageBox::Icon::Warning, "Ladybird", qstring_from_akstring(message), QMessageBox::StandardButton::Ok, this); |
| 855 | + m_dialog->exec(); |
| 856 | + |
| 857 | + client().async_alert_closed(); |
| 858 | + m_dialog = nullptr; |
854 | 859 | } |
855 | 860 |
|
856 | | -bool WebContentView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) |
| 861 | +void WebContentView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) |
857 | 862 | { |
858 | | - auto result = QMessageBox::question(this, "Ladybird", qstring_from_akstring(message), |
859 | | - QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel); |
| 863 | + m_dialog = new QMessageBox(QMessageBox::Icon::Question, "Ladybird", qstring_from_akstring(message), QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel, this); |
| 864 | + auto result = m_dialog->exec(); |
860 | 865 |
|
861 | | - return result == QMessageBox::StandardButton::Ok; |
| 866 | + client().async_confirm_closed(result == QMessageBox::StandardButton::Ok || result == QDialog::Accepted); |
| 867 | + m_dialog = nullptr; |
862 | 868 | } |
863 | 869 |
|
864 | | -String WebContentView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) |
| 870 | +void WebContentView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) |
865 | 871 | { |
866 | | - // FIXME |
867 | | - (void)message; |
868 | | - (void)default_; |
869 | | - return String::empty(); |
| 872 | + m_dialog = new QInputDialog(this); |
| 873 | + auto& dialog = static_cast<QInputDialog&>(*m_dialog); |
| 874 | + |
| 875 | + dialog.setWindowTitle("Ladybird"); |
| 876 | + dialog.setLabelText(qstring_from_akstring(message)); |
| 877 | + dialog.setTextValue(qstring_from_akstring(default_)); |
| 878 | + |
| 879 | + if (dialog.exec() == QDialog::Accepted) |
| 880 | + client().async_prompt_closed(akstring_from_qstring(dialog.textValue())); |
| 881 | + else |
| 882 | + client().async_prompt_closed({}); |
| 883 | + |
| 884 | + m_dialog = nullptr; |
| 885 | +} |
| 886 | + |
| 887 | +void WebContentView::notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) |
| 888 | +{ |
| 889 | + if (m_dialog && is<QInputDialog>(*m_dialog)) |
| 890 | + static_cast<QInputDialog&>(*m_dialog).setTextValue(qstring_from_akstring(message)); |
| 891 | +} |
| 892 | + |
| 893 | +void WebContentView::notify_server_did_request_accept_dialog(Badge<WebContentClient>) |
| 894 | +{ |
| 895 | + if (m_dialog) |
| 896 | + m_dialog->accept(); |
| 897 | +} |
| 898 | + |
| 899 | +void WebContentView::notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) |
| 900 | +{ |
| 901 | + if (m_dialog) |
| 902 | + m_dialog->reject(); |
870 | 903 | } |
871 | 904 |
|
872 | 905 | void WebContentView::get_source() |
|
0 commit comments