FontEditor: Accept file drops

This commit is contained in:
Karol Kosek 2021-10-13 22:16:25 +02:00 committed by Linus Groh
parent a0cb8cfefd
commit 0a54a86a8b
2 changed files with 19 additions and 0 deletions

View file

@ -714,3 +714,20 @@ void FontEditorWidget::update_preview()
if (m_font_preview_window)
m_font_preview_window->update();
}
void FontEditorWidget::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();
if (!request_close())
return;
open_file(urls.first().path());
}
}

View file

@ -37,6 +37,8 @@ public:
private:
FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&);
virtual void drop_event(GUI::DropEvent&) override;
void open_file(String const&);
void undo();
void redo();