mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +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
3 changed files with 24 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue