Presenter: Accept file drops
This commit is contained in:
parent
feb0eb9309
commit
780d46c424
Notes:
sideshowbarker
2024-07-17 03:14:39 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/780d46c424 Pull-request: https://github.com/SerenityOS/serenity/pull/16713
2 changed files with 24 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "LibGUI/MessageBox.h"
|
||||
#include "Presentation.h"
|
||||
#include <AK/Format.h>
|
||||
#include <LibCore/MimeData.h>
|
||||
#include <LibFileSystemAccessClient/Client.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Event.h>
|
||||
|
@ -132,3 +133,24 @@ void PresenterWidget::paint_event([[maybe_unused]] GUI::PaintEvent& event)
|
|||
|
||||
m_current_presentation->paint(painter);
|
||||
}
|
||||
|
||||
void PresenterWidget::drag_enter_event(GUI::DragEvent& event)
|
||||
{
|
||||
auto const& mime_types = event.mime_types();
|
||||
if (mime_types.contains_slow("text/uri-list"))
|
||||
event.accept();
|
||||
}
|
||||
|
||||
void PresenterWidget::drop_event(GUI::DropEvent& event)
|
||||
{
|
||||
event.accept();
|
||||
|
||||
if (event.mime_data().has_urls()) {
|
||||
auto urls = event.mime_data().urls();
|
||||
if (urls.is_empty())
|
||||
return;
|
||||
|
||||
window()->move_to_front();
|
||||
set_file(urls.first().path());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
protected:
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
virtual void drag_enter_event(GUI::DragEvent&) override;
|
||||
virtual void drop_event(GUI::DropEvent&) override;
|
||||
|
||||
private:
|
||||
OwnPtr<Presentation> m_current_presentation;
|
||||
|
|
Loading…
Add table
Reference in a new issue