Commit 405c8492 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Ming Rui Zhang

messaging: implement full screen mode for html video player

Change-Id: I3e0616655e26597c8b577bcbe0bc209c605d0d67
parent f8627777
......@@ -76,7 +76,7 @@ MessageWebView::MessageWebView(QWidget *parent)
settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, false);
settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false);
settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, false);
settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, false);
settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, false);
settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, false);
......@@ -115,6 +115,21 @@ MessageWebView::MessageWebView(QWidget *parent)
}
});
connect(this->page(), &QWebEnginePage::fullScreenRequested,
[this](QWebEngineFullScreenRequest request) {
if (request.toggleOn()) {
if (fullScreenWebWidget_)
return;
request.accept();
fullScreenWebWidget_.reset(new FullScreenWebWidget(this));
} else {
if (!fullScreenWebWidget_)
return;
request.accept();
fullScreenWebWidget_.reset();
}
});
recordWidget_ = new RecordWidget(this);
recordWidget_->getContainer()->hide();
}
......@@ -771,3 +786,49 @@ PrivateBridging::saveSendMessageContent(const QString& arg)
return 0;
}
FullScreenWebWidget::FullScreenWebWidget(QWebEngineView *oldView, QWidget *parent)
: QWidget(parent)
, view_(new QWebEngineView(this))
, notification_(new FullScreenNotification(
tr("You are now in full screen mode. Press ESC to quit"),
this))
, oldView_(oldView)
, savedGeometry_(oldView->window()->geometry())
{
view_->stackUnder(notification_);
auto exitAction = new QAction(this);
exitAction->setShortcut(Qt::Key_Escape);
connect(exitAction, &QAction::triggered,
[this]() {
view_->triggerPageAction(QWebEnginePage::ExitFullScreen);
});
addAction(exitAction);
view_->setPage(oldView_->page());
setGeometry(savedGeometry_);
showFullScreen();
oldView_->window()->hide();
}
FullScreenWebWidget::~FullScreenWebWidget()
{
oldView_->setPage(view_->page());
oldView_->window()->setGeometry(savedGeometry_);
oldView_->window()->show();
hide();
}
void
FullScreenWebWidget::resizeEvent(QResizeEvent* event)
{
QRect viewGeometry(QPoint(0, 0), size());
view_->setGeometry(viewGeometry);
QRect notificationGeometry(QPoint(0, 0), notification_->sizeHint());
notificationGeometry.moveCenter(viewGeometry.center());
notification_->setGeometry(notificationGeometry);
QWidget::resizeEvent(event);
};
\ No newline at end of file
......@@ -18,14 +18,23 @@
#pragma once
#include "widgethelpers.h"
#include "api/conversationmodel.h"
#include <QClipboard>
#include <QDebug>
#include <QLabel>
#include <QWebEngineView>
#include "api/conversationmodel.h"
#include <QPropertyAnimation>
#include <QWebEngineFullScreenRequest>
#include <QGraphicsOpacityEffect>
#include <QSequentialAnimationGroup>
#include <QAction>
#include <QTimer>
class RecordWidget;
class FullScreenWebWidget;
class PrivateBridging : public QObject
{
......@@ -132,4 +141,22 @@ private:
/*TODO: Generatic Popup Dialog setGeometry function corrsponding to spike alignment*/
const quint16 recordWidgetMargin_{ 15 };
QScopedPointer<FullScreenWebWidget> fullScreenWebWidget_;
};
class FullScreenWebWidget : public QWidget
{
Q_OBJECT
public:
explicit FullScreenWebWidget(QWebEngineView *oldView, QWidget *parent = nullptr);
~FullScreenWebWidget();
protected:
void resizeEvent(QResizeEvent* event) override;
private:
QWebEngineView *view_;
FullScreenNotification *notification_;
QWebEngineView* oldView_;
QRect savedGeometry_;
};
......@@ -414,7 +414,17 @@ del /s /q $(OutDir)\Jami.exp</Command>
<ClCompile Include="main.cpp" />
<ClCompile Include="mainwindow.cpp" />
<ClCompile Include="messagewebpage.cpp" />
<ClCompile Include="messagewebview.cpp" />
<ClCompile Include="messagewebview.cpp">
<OutputFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\%(Filename).moc</OutputFile>
<DynamicSource Condition="'$(Configuration)|$(Platform)'=='Release|x64'">input</DynamicSource>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath>
<OutputFile Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName)\%(Filename).moc</OutputFile>
<DynamicSource Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">input</DynamicSource>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath>
<OutputFile Condition="'$(Configuration)|$(Platform)'=='Beta|x64'">.\GeneratedFiles\$(ConfigurationName)\%(Filename).moc</OutputFile>
<DynamicSource Condition="'$(Configuration)|$(Platform)'=='Beta|x64'">input</DynamicSource>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Beta|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath>
</ClCompile>
<ClCompile Include="navwidget.cpp" />
<ClCompile Include="newwizardwidget.cpp" />
<ClCompile Include="passworddialog.cpp" />
......
......@@ -135,9 +135,6 @@
<ClCompile Include="currentaccountcombobox.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="messagewebview.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="messagewebpage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
......@@ -264,6 +261,9 @@
<ClCompile Include="recordwidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="messagewebview.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="aboutdialog.h">
......
......@@ -925,3 +925,11 @@ QPushButton#logCloseButton {
QPushButton#logCloseButton:pressed {
background-color: rgb(180, 180, 180);
}
FullScreenNotification {
font-size: 24px;
color: white;
background-color: black;
border: 2px solid white;
padding: 100px;
}
\ No newline at end of file
......@@ -21,6 +21,7 @@
#include "popupdialog.h"
#include <QWidget>
#include <QLabel>
#include <QTimer>
#include <QMouseEvent>
#include <QPainter>
......@@ -184,3 +185,33 @@ private:
QMetaObject::Connection connection_;
};
class FullScreenNotification : public QLabel
{
Q_OBJECT
public:
FullScreenNotification(const QString& text, QWidget *parent = nullptr)
: QLabel(parent)
{
setText(text);
setAttribute(Qt::WA_TransparentForMouseEvents);
fadeAnimation_ = new FadeAnimation(this, 1000, 0, 0.6f);
fadeTimer_.setSingleShot(true);
connect(&fadeTimer_, SIGNAL(timeout()), this, SLOT(slotTimeout()));
connect(fadeAnimation_, &QAbstractAnimation::finished,
[this]() { this->hide(); });
}
protected:
void showEvent(QShowEvent* event) override {
fadeTimer_.start(2000);
QLabel::showEvent(event);
};
private slots:
void slotTimeout() { fadeAnimation_->start(); };
private:
FadeAnimation* fadeAnimation_;
QTimer fadeTimer_;
};
\ No newline at end of file
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