diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index 116fef232f..51e5806c75 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -773,4 +773,26 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr image) return image_editor; } +void MainWidget::drop_event(GUI::DropEvent& event) +{ + if (!event.mime_data().has_urls()) + return; + + event.accept(); + + if (event.mime_data().urls().is_empty()) + return; + + for (auto& url : event.mime_data().urls()) { + if (url.protocol() != "file") + continue; + + auto result = FileSystemAccessClient::Client::the().request_file(window()->window_id(), url.path(), Core::OpenMode::ReadOnly); + if (result.error != 0) + continue; + + open_image_fd(*result.fd, *result.chosen_file); + } +} + } diff --git a/Userland/Applications/PixelPaint/MainWidget.h b/Userland/Applications/PixelPaint/MainWidget.h index 4294608499..970a157d23 100644 --- a/Userland/Applications/PixelPaint/MainWidget.h +++ b/Userland/Applications/PixelPaint/MainWidget.h @@ -43,6 +43,8 @@ private: ImageEditor* current_image_editor(); ImageEditor& create_new_editor(NonnullRefPtr); + virtual void drop_event(GUI::DropEvent&) override; + ProjectLoader m_loader; RefPtr m_toolbox;