video: add screen sharing
- add the ability to share screen entirely
or only a specific area with right click
Refs #74614
Change-Id: Ief64f88d862ede0fe7cd82af82a49e5b43d6532c
diff --git a/videowidget.cpp b/videowidget.cpp
index 16a8c2a..0774980 100644
--- a/videowidget.cpp
+++ b/videowidget.cpp
@@ -18,7 +18,10 @@
#include "videowidget.h"
-#include <QDebug>
+#include <QApplication>
+#include <QDesktopWidget>
+
+#include "selectareadialog.h"
VideoWidget::VideoWidget(QWidget *parent) :
QWidget(parent)
@@ -39,6 +42,10 @@
pal.setColor(QPalette::Background, Qt::black);
this->setAutoFillBackground(true);
this->setPalette(pal);
+
+ this->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
+ this, SLOT(showContextMenu(const QPoint&)));
}
VideoWidget::~VideoWidget()
@@ -155,3 +162,24 @@
this->show();
}
}
+void
+VideoWidget::showContextMenu(const QPoint& pos)
+{
+ QPoint globalPos = this->mapToGlobal(pos);
+
+ QMenu menu;
+
+ auto shareAction = new QAction("Share entire screen", this);
+ menu.addAction(shareAction);
+ connect(shareAction, &QAction::triggered, [=]() {
+ Video::SourceModel::instance()->setDisplay(0, QApplication::desktop()->rect());
+ });
+ auto shareAreaAction = new QAction("Share screen area", this);
+ menu.addAction(shareAreaAction);
+ connect(shareAreaAction, &QAction::triggered, [=]() {
+ SelectAreaDialog selec;
+ selec.exec();
+ });
+
+ menu.exec(globalPos);
+}