mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +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
|
@ -17,4 +17,4 @@ set(GENERATED_SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(VideoPlayer ICON app-video-player)
|
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
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibFileSystemAccessClient/Client.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
#include <LibGUI/FilePicker.h>
|
#include <LibGUI/FilePicker.h>
|
||||||
|
@ -265,6 +266,26 @@ void VideoPlayerWidget::event(Core::Event& event)
|
||||||
Widget::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()
|
void VideoPlayerWidget::cycle_sizing_modes()
|
||||||
{
|
{
|
||||||
auto sizing_mode = m_video_display->sizing_mode();
|
auto sizing_mode = m_video_display->sizing_mode();
|
||||||
|
|
|
@ -53,6 +53,8 @@ private:
|
||||||
|
|
||||||
void event(Core::Event&) override;
|
void event(Core::Event&) override;
|
||||||
|
|
||||||
|
virtual void drop_event(GUI::DropEvent&) override;
|
||||||
|
|
||||||
DeprecatedString m_path;
|
DeprecatedString m_path;
|
||||||
|
|
||||||
RefPtr<VideoFrameWidget> m_video_display;
|
RefPtr<VideoFrameWidget> m_video_display;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue