mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:37:35 +00:00
PixelPaint: Allow opening of files dropped onto application :^)
We can now drag-and-drop files onto PixelPaint to be able to open them. Each dropped file opens in a separate editor (which is the default behavior of Photoshop).
This commit is contained in:
parent
5a8c6b95e6
commit
f8570bd773
2 changed files with 24 additions and 0 deletions
|
@ -773,4 +773,26 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr<Image> image)
|
||||||
return image_editor;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ private:
|
||||||
ImageEditor* current_image_editor();
|
ImageEditor* current_image_editor();
|
||||||
ImageEditor& create_new_editor(NonnullRefPtr<Image>);
|
ImageEditor& create_new_editor(NonnullRefPtr<Image>);
|
||||||
|
|
||||||
|
virtual void drop_event(GUI::DropEvent&) override;
|
||||||
|
|
||||||
ProjectLoader m_loader;
|
ProjectLoader m_loader;
|
||||||
|
|
||||||
RefPtr<ToolboxWidget> m_toolbox;
|
RefPtr<ToolboxWidget> m_toolbox;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue