From 7f418a5c6a21c35767ed10cbf0b701272f33a350 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Mon, 12 Jul 2021 15:42:00 +0200 Subject: [PATCH] HexEditor: Accept file drops --- Userland/Applications/HexEditor/HexEditorWidget.cpp | 13 +++++++++++++ Userland/Applications/HexEditor/HexEditorWidget.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index 5534ebe744..87b62384a5 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -372,3 +372,16 @@ void HexEditorWidget::set_search_results_visible(bool visible) m_layout_search_results_action->set_checked(visible); m_search_results_container->set_visible(visible); } + +void HexEditorWidget::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(); + open_file(urls.first().path()); + } +} diff --git a/Userland/Applications/HexEditor/HexEditorWidget.h b/Userland/Applications/HexEditor/HexEditorWidget.h index c2a689461f..2753ec62e8 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.h +++ b/Userland/Applications/HexEditor/HexEditorWidget.h @@ -31,6 +31,8 @@ private: void update_title(); void set_search_results_visible(bool visible); + virtual void drop_event(GUI::DropEvent&) override; + RefPtr m_config; RefPtr m_editor;