Commit 303bbf14 authored by Edric Milaret's avatar Edric Milaret Committed by Guillaume Roguez

video: add share file features

- share file action on context menu or drag-n-drop

Refs #76120

Change-Id: I0f6330115a190e6ed8bc63c05c54132e6d2cdf16
parent 83b248c3
......@@ -10,6 +10,9 @@
<height>507</height>
</rect>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
......
......@@ -27,6 +27,8 @@
#include <QPropertyAnimation>
#include <QDesktopWidget>
#include <QMenu>
#include <QFileDialog>
#include <QMimeData>
#include <memory>
......@@ -120,6 +122,18 @@ VideoView::mouseDoubleClickEvent(QMouseEvent* e) {
toggleFullScreen();
}
void VideoView::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void VideoView::dropEvent(QDropEvent *event)
{
auto urls = event->mimeData()->urls();
Video::SourceModel::instance()->setFile(urls.at(0));
}
void
VideoView::toggleFullScreen()
{
......@@ -171,6 +185,17 @@ VideoView::showContextMenu(const QPoint& pos)
SelectAreaDialog selec;
selec.exec();
});
auto shareFileAction = new QAction("Share file", this);
menu.addAction(shareFileAction);
connect(shareFileAction, &QAction::triggered, [=]() {
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
QStringList fileNames;
if (!dialog.exec())
return;
fileNames = dialog.selectedFiles();
Video::SourceModel::instance()->setFile(QUrl::fromLocalFile(fileNames.at(0)));
});
menu.exec(globalPos);
}
......
......@@ -43,6 +43,8 @@ protected:
void enterEvent(QEvent* event);
void leaveEvent(QEvent* event);
void mouseDoubleClickEvent(QMouseEvent *e);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
private slots:
void callStateChanged(Call *call, Call::State previousState);
......
......@@ -10,6 +10,9 @@
<height>522</height>
</rect>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
......@@ -31,6 +34,9 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment