mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:17:35 +00:00
LibGUI+Everywhere: Make sync requests to Clipboard server more obvious
This commit is contained in:
parent
06f140a025
commit
f22c0ffe0c
13 changed files with 22 additions and 23 deletions
|
@ -50,7 +50,7 @@ Clipboard& Clipboard::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
Clipboard::DataAndType Clipboard::data_and_type() const
|
||||
Clipboard::DataAndType Clipboard::fetch_data_and_type() const
|
||||
{
|
||||
auto response = connection().get_clipboard_data();
|
||||
if (!response.data().is_valid())
|
||||
|
|
|
@ -39,9 +39,8 @@ public:
|
|||
static void initialize(Badge<Application>);
|
||||
static Clipboard& the();
|
||||
|
||||
DataAndType data_and_type() const;
|
||||
ByteBuffer data() const { return data_and_type().data; }
|
||||
String mime_type() const { return data_and_type().mime_type; }
|
||||
DataAndType fetch_data_and_type() const;
|
||||
String fetch_mime_type() const { return fetch_data_and_type().mime_type; }
|
||||
|
||||
void set_data(ReadonlyBytes data, String const& mime_type = "text/plain", HashMap<String, String> const& metadata = {});
|
||||
void set_plain_text(String const& text) { set_data(text.bytes()); }
|
||||
|
|
|
@ -83,7 +83,7 @@ void TextEditor::create_actions()
|
|||
m_cut_action->set_enabled(false);
|
||||
m_copy_action->set_enabled(false);
|
||||
m_paste_action = CommonActions::make_paste_action([&](auto&) { paste(); }, this);
|
||||
m_paste_action->set_enabled(is_editable() && Clipboard::the().mime_type().starts_with("text/"));
|
||||
m_paste_action->set_enabled(is_editable() && Clipboard::the().fetch_mime_type().starts_with("text/"));
|
||||
if (is_multi_line()) {
|
||||
m_go_to_line_action = Action::create(
|
||||
"Go to line...", { Mod_Ctrl, Key_L }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
|
@ -1453,7 +1453,7 @@ void TextEditor::paste()
|
|||
if (!is_editable())
|
||||
return;
|
||||
|
||||
auto [data, mime_type, _] = GUI::Clipboard::the().data_and_type();
|
||||
auto [data, mime_type, _] = GUI::Clipboard::the().fetch_data_and_type();
|
||||
if (!mime_type.starts_with("text/"))
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue