1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 13:55:08 +00:00

LibGUI+Browser: Do not paste bitmaps

This prevents GUI::TextBox and the `Paste & Go` action in the browser
from trying to paste a bitmap. Also, the paste action is enabled
and disabled on clipboard change to reflect if the clipboard data
can be pasted.
This commit is contained in:
TheFightingCatfish 2021-07-25 17:59:30 +08:00 committed by Andreas Kling
parent c4eaba6c88
commit 9b78ae5149
2 changed files with 12 additions and 1 deletions

View file

@ -98,6 +98,9 @@ void TextEditor::create_actions()
this);
}
m_select_all_action = CommonActions::make_select_all_action([this](auto&) { select_all(); }, this);
Clipboard::the().on_change = [this](auto const& mime_type) {
m_paste_action->set_enabled(is_editable() && mime_type.starts_with("text/") && !Clipboard::the().data().is_empty());
};
}
void TextEditor::set_text(StringView const& text)
@ -1397,6 +1400,9 @@ void TextEditor::paste()
if (!is_editable())
return;
if (!Clipboard::the().mime_type().starts_with("text/"))
return;
auto paste_text = Clipboard::the().data();
if (paste_text.is_empty())