mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:07:34 +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
|
@ -136,7 +136,7 @@ Tab::Tab(BrowserWindow& window)
|
|||
};
|
||||
|
||||
m_location_box->add_custom_context_menu_action(GUI::Action::create("Paste && Go", [this](auto&) {
|
||||
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;
|
||||
auto const& paste_text = data;
|
||||
|
|
|
@ -58,7 +58,7 @@ int main(int argc, char** argv)
|
|||
GUI::Clipboard::the().set_plain_text(widget.get_entry());
|
||||
}));
|
||||
edit_menu.add_action(GUI::CommonActions::make_paste_action([&](auto&) {
|
||||
auto clipboard = GUI::Clipboard::the().data_and_type();
|
||||
auto clipboard = GUI::Clipboard::the().fetch_data_and_type();
|
||||
if (clipboard.mime_type == "text/plain") {
|
||||
if (!clipboard.data.is_empty()) {
|
||||
auto data = atof(StringView(clipboard.data).to_string().characters());
|
||||
|
|
|
@ -151,7 +151,7 @@ void do_copy(Vector<String> const& selected_file_paths, FileOperation file_opera
|
|||
|
||||
void do_paste(String const& target_directory, GUI::Window* window)
|
||||
{
|
||||
auto data_and_type = GUI::Clipboard::the().data_and_type();
|
||||
auto data_and_type = GUI::Clipboard::the().fetch_data_and_type();
|
||||
if (data_and_type.mime_type != "text/uri-list") {
|
||||
dbgln("Cannot paste clipboard type {}", data_and_type.mime_type);
|
||||
return;
|
||||
|
@ -345,7 +345,7 @@ int run_in_desktop_mode()
|
|||
do_paste(directory_view.path(), directory_view.window());
|
||||
},
|
||||
window);
|
||||
paste_action->set_enabled(GUI::Clipboard::the().mime_type() == "text/uri-list" && access(directory_view.path().characters(), W_OK) == 0);
|
||||
paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "text/uri-list" && access(directory_view.path().characters(), W_OK) == 0);
|
||||
|
||||
GUI::Clipboard::the().on_change = [&](String const& data_type) {
|
||||
paste_action->set_enabled(data_type == "text/uri-list" && access(directory_view.path().characters(), W_OK) == 0);
|
||||
|
@ -1007,7 +1007,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
|
|||
|
||||
mkdir_action->set_enabled(can_write_in_path);
|
||||
touch_action->set_enabled(can_write_in_path);
|
||||
paste_action->set_enabled(can_write_in_path && GUI::Clipboard::the().mime_type() == "text/uri-list");
|
||||
paste_action->set_enabled(can_write_in_path && GUI::Clipboard::the().fetch_mime_type() == "text/uri-list");
|
||||
go_forward_action->set_enabled(directory_view.path_history_position() < directory_view.path_history_size() - 1);
|
||||
go_back_action->set_enabled(directory_view.path_history_position() > 0);
|
||||
open_parent_directory_action->set_enabled(new_path != "/");
|
||||
|
@ -1089,7 +1089,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
|
|||
auto& node = directory_view.node(index);
|
||||
|
||||
if (node.is_directory()) {
|
||||
auto should_get_enabled = access(node.full_path().characters(), W_OK) == 0 && GUI::Clipboard::the().mime_type() == "text/uri-list";
|
||||
auto should_get_enabled = access(node.full_path().characters(), W_OK) == 0 && GUI::Clipboard::the().fetch_mime_type() == "text/uri-list";
|
||||
folder_specific_paste_action->set_enabled(should_get_enabled);
|
||||
directory_context_menu->popup(event.screen_position(), directory_open_action);
|
||||
} else {
|
||||
|
@ -1207,7 +1207,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
|
|||
directory_view.open(initial_location);
|
||||
directory_view.set_focus(true);
|
||||
|
||||
paste_action->set_enabled(GUI::Clipboard::the().mime_type() == "text/uri-list" && access(initial_location.characters(), W_OK) == 0);
|
||||
paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "text/uri-list" && access(initial_location.characters(), W_OK) == 0);
|
||||
|
||||
window->set_rect({ left, top, width, height });
|
||||
if (was_maximized)
|
||||
|
|
|
@ -202,7 +202,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
|
|||
m_glyph_editor_widget->paste_glyph();
|
||||
m_glyph_map_widget->update_glyph(m_glyph_map_widget->selected_glyph());
|
||||
});
|
||||
m_paste_action->set_enabled(GUI::Clipboard::the().mime_type() == "glyph/x-fonteditor");
|
||||
m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "glyph/x-fonteditor");
|
||||
m_delete_action = GUI::CommonActions::make_delete_action([this](auto&) {
|
||||
if (m_glyph_editor_widget->is_glyph_empty() && m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph()) == 0)
|
||||
return;
|
||||
|
|
|
@ -84,7 +84,7 @@ void GlyphEditorWidget::copy_glyph()
|
|||
|
||||
void GlyphEditorWidget::paste_glyph()
|
||||
{
|
||||
auto [data, mime_type, metadata] = GUI::Clipboard::the().data_and_type();
|
||||
auto [data, mime_type, metadata] = GUI::Clipboard::the().fetch_data_and_type();
|
||||
if (!mime_type.starts_with("glyph/"))
|
||||
return;
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
|||
auto* editor = current_image_editor();
|
||||
if (!editor)
|
||||
return;
|
||||
auto bitmap = GUI::Clipboard::the().data_and_type().as_bitmap();
|
||||
auto bitmap = GUI::Clipboard::the().fetch_data_and_type().as_bitmap();
|
||||
if (!bitmap)
|
||||
return;
|
||||
|
||||
|
@ -226,7 +226,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::Clipboard::the().on_change = [&](auto& mime_type) {
|
||||
m_paste_action->set_enabled(mime_type == "image/x-serenityos");
|
||||
};
|
||||
m_paste_action->set_enabled(GUI::Clipboard::the().mime_type() == "image/x-serenityos");
|
||||
m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "image/x-serenityos");
|
||||
|
||||
m_undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
|
||||
if (auto* editor = current_image_editor())
|
||||
|
|
|
@ -170,7 +170,7 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s
|
|||
auto& sheet = *worksheet_ptr;
|
||||
auto& cells = sheet.selected_cells();
|
||||
VERIFY(!cells.is_empty());
|
||||
const auto& data = GUI::Clipboard::the().data_and_type();
|
||||
const auto& data = GUI::Clipboard::the().fetch_data_and_type();
|
||||
if (auto spreadsheet_data = data.metadata.get("text/x-spreadsheet-data"); spreadsheet_data.has_value()) {
|
||||
Vector<Spreadsheet::Position> source_positions, target_positions;
|
||||
auto lines = spreadsheet_data.value().split_view('\n');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue