1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:47:34 +00:00

Userland: Accept drag_enter events for widgets supporting file drops

This patch will switch cursor to DragCopy when a user enters a widget
while dragging file(s), giving them a visual clue that it *might* be
dropped into this widget.

This is a rather naive approach, as the cursor icon will change for any
kind of file, as currently programs don't know the drag contents before
dropping it. But after all I think it's better than nothing. :^)
This commit is contained in:
Karol Kosek 2022-11-04 22:32:17 +01:00 committed by Andrew Kaster
parent 461ee18d64
commit 0b7f5bbdfb
21 changed files with 89 additions and 0 deletions

View file

@ -134,6 +134,13 @@ void PreviewWidget::resize_event(GUI::ResizeEvent&)
update_preview_window_locations();
}
void PreviewWidget::drag_enter_event(GUI::DragEvent& event)
{
auto const& mime_types = event.mime_types();
if (mime_types.contains_slow("text/uri-list"))
event.accept();
}
void PreviewWidget::drop_event(GUI::DropEvent& event)
{
event.accept();

View file

@ -33,6 +33,7 @@ private:
virtual void paint_preview(GUI::PaintEvent&) override;
virtual void second_paint_event(GUI::PaintEvent&) override;
virtual void resize_event(GUI::ResizeEvent&) override;
virtual void drag_enter_event(GUI::DragEvent&) override;
virtual void drop_event(GUI::DropEvent&) override;
virtual void palette_changed() override;