mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
VideoPlayer: Add drag and drop support
This patch makes it so that we view clips by dropping them on an open VideoPlayer window.
This commit is contained in:
parent
03c225b023
commit
f0ceaca2f4
Notes:
sideshowbarker
2024-07-16 23:52:10 +09:00
Author: https://github.com/juniorrantila Commit: https://github.com/SerenityOS/serenity/commit/f0ceaca2f4 Pull-request: https://github.com/SerenityOS/serenity/pull/17948 Reviewed-by: https://github.com/gmta ✅
3 changed files with 24 additions and 1 deletions
|
@ -17,4 +17,4 @@ set(GENERATED_SOURCES
|
|||
)
|
||||
|
||||
serenity_app(VideoPlayer ICON app-video-player)
|
||||
target_link_libraries(VideoPlayer PRIVATE LibVideo LibAudio LibCore LibGfx LibGUI LibMain)
|
||||
target_link_libraries(VideoPlayer PRIVATE LibVideo LibAudio LibCore LibGfx LibGUI LibMain LibFileSystemAccessClient)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibFileSystemAccessClient/Client.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/FilePicker.h>
|
||||
|
@ -265,6 +266,26 @@ void VideoPlayerWidget::event(Core::Event& event)
|
|||
Widget::event(event);
|
||||
}
|
||||
|
||||
void VideoPlayerWidget::drop_event(GUI::DropEvent& event)
|
||||
{
|
||||
event.accept();
|
||||
window()->move_to_front();
|
||||
|
||||
if (event.mime_data().has_urls()) {
|
||||
auto urls = event.mime_data().urls();
|
||||
if (urls.is_empty())
|
||||
return;
|
||||
if (urls.size() > 1) {
|
||||
GUI::MessageBox::show_error(window(), "VideoPlayer can only view one clip at a time!"sv);
|
||||
return;
|
||||
}
|
||||
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), urls.first().path());
|
||||
if (response.is_error())
|
||||
return;
|
||||
open_file(response.value().filename());
|
||||
}
|
||||
}
|
||||
|
||||
void VideoPlayerWidget::cycle_sizing_modes()
|
||||
{
|
||||
auto sizing_mode = m_video_display->sizing_mode();
|
||||
|
|
|
@ -53,6 +53,8 @@ private:
|
|||
|
||||
void event(Core::Event&) override;
|
||||
|
||||
virtual void drop_event(GUI::DropEvent&) override;
|
||||
|
||||
DeprecatedString m_path;
|
||||
|
||||
RefPtr<VideoFrameWidget> m_video_display;
|
||||
|
|
Loading…
Reference in a new issue