diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-14 13:18:34 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-14 13:18:59 +0100 |
commit | 814d59f462cfbcce14b16703a4933ea088800e69 (patch) | |
tree | d85a86b8afa30027030104878ceb9e5b8485777b /Libraries/LibVT | |
parent | 3cba9c3c251145181c9bf9590cf6c9a6250b7edb (diff) | |
download | serenity-814d59f462cfbcce14b16703a4933ea088800e69.zip |
LibGUI: Port the drag&drop code to Core::MimeData
Diffstat (limited to 'Libraries/LibVT')
-rw-r--r-- | Libraries/LibVT/TerminalWidget.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp index 4e6f9614cc..8cd6ea76d4 100644 --- a/Libraries/LibVT/TerminalWidget.cpp +++ b/Libraries/LibVT/TerminalWidget.cpp @@ -30,7 +30,7 @@ #include <AK/String.h> #include <AK/StringBuilder.h> #include <Kernel/KeyCode.h> -#include <LibGfx/Font.h> +#include <LibCore/MimeData.h> #include <LibGUI/Action.h> #include <LibGUI/Application.h> #include <LibGUI/Clipboard.h> @@ -38,6 +38,7 @@ #include <LibGUI/Painter.h> #include <LibGUI/ScrollBar.h> #include <LibGUI/Window.h> +#include <LibGfx/Font.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -698,21 +699,23 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event) void TerminalWidget::drop_event(GUI::DropEvent& event) { - if (event.data_type() == "text") { + if (event.mime_data().has_text()) { event.accept(); - write(m_ptm_fd, event.data().characters(), event.data().length()); - } else if (event.data_type() == "url-list") { + auto text = event.mime_data().text(); + write(m_ptm_fd, text.characters(), text.length()); + } else if (event.mime_data().has_urls()) { event.accept(); - auto lines = event.data().split('\n'); + auto urls = event.mime_data().urls(); bool first = true; - for (auto& line : lines) { - if (!first) + for (auto& url : event.mime_data().urls()) { + if (!first) { write(m_ptm_fd, " ", 1); - first = false; - - if (line.starts_with("file://")) - line = line.substring(7, line.length() - 7); - write(m_ptm_fd, line.characters(), line.length()); + first = false; + } + if (url.protocol() == "file") + write(m_ptm_fd, url.path().characters(), url.path().length()); + else + write(m_ptm_fd, url.to_string().characters(), url.to_string().length()); } } } |