mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(netcam): remove GenericNetCamView, merge into NetCamview
Without GroupNetCamView, the split in arbitrary.
This commit is contained in:
parent
41d8f66e08
commit
89913e0f9a
|
@ -408,8 +408,6 @@ set(${PROJECT_NAME}_SOURCES
|
|||
src/video/camerasource.h
|
||||
src/video/corevideosource.cpp
|
||||
src/video/corevideosource.h
|
||||
src/video/genericnetcamview.cpp
|
||||
src/video/genericnetcamview.h
|
||||
src/video/ivideosettings.h
|
||||
src/video/netcamview.cpp
|
||||
src/video/netcamview.h
|
||||
|
|
|
@ -1,228 +0,0 @@
|
|||
/*
|
||||
Copyright © 2015-2019 by The qTox Project Contributors
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
qTox is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
qTox is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "genericnetcamview.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QBoxLayout>
|
||||
#include <QDesktopWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QPushButton>
|
||||
#include <QVariant>
|
||||
|
||||
namespace
|
||||
{
|
||||
const auto BTN_STATE_NONE = QVariant("none");
|
||||
const auto BTN_STATE_RED = QVariant("red");
|
||||
const int BTN_PANEL_HEIGHT = 55;
|
||||
const int BTN_PANEL_WIDTH = 250;
|
||||
const auto BTN_STYLE_SHEET_PATH = QStringLiteral("chatForm/fullScreenButtons.css");
|
||||
}
|
||||
|
||||
GenericNetCamView::GenericNetCamView(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
verLayout = new QVBoxLayout(this);
|
||||
setWindowTitle(tr("Tox video"));
|
||||
|
||||
buttonLayout = new QHBoxLayout();
|
||||
|
||||
toggleMessagesButton = new QPushButton();
|
||||
enterFullScreenButton = new QPushButton();
|
||||
enterFullScreenButton->setText(tr("Full Screen"));
|
||||
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(toggleMessagesButton);
|
||||
buttonLayout->addWidget(enterFullScreenButton);
|
||||
|
||||
connect(toggleMessagesButton, &QPushButton::clicked, this, &GenericNetCamView::showMessageClicked);
|
||||
connect(enterFullScreenButton, &QPushButton::clicked, this, &GenericNetCamView::toggleFullScreen);
|
||||
|
||||
verLayout->addLayout(buttonLayout);
|
||||
verLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
setShowMessages(false);
|
||||
|
||||
setStyleSheet("NetCamView { background-color: #c1c1c1; }");
|
||||
buttonPanel = new QFrame(this);
|
||||
buttonPanel->setStyleSheet(Style::getStylesheet(BTN_STYLE_SHEET_PATH));
|
||||
buttonPanel->setGeometry(0, 0, BTN_PANEL_WIDTH, BTN_PANEL_HEIGHT);
|
||||
|
||||
QHBoxLayout* buttonPanelLayout = new QHBoxLayout(buttonPanel);
|
||||
buttonPanelLayout->setContentsMargins(20, 0, 20, 0);
|
||||
|
||||
videoPreviewButton = createButton("videoPreviewButton", "none");
|
||||
videoPreviewButton->setToolTip(tr("Toggle video preview"));
|
||||
|
||||
volumeButton = createButton("volButtonFullScreen", "none");
|
||||
volumeButton->setToolTip(tr("Mute audio"));
|
||||
|
||||
microphoneButton = createButton("micButtonFullScreen", "none");
|
||||
microphoneButton->setToolTip(tr("Mute microphone"));
|
||||
|
||||
endVideoButton = createButton("videoButtonFullScreen", "none");
|
||||
endVideoButton->setToolTip(tr("End video call"));
|
||||
|
||||
exitFullScreenButton = createButton("exitFullScreenButton", "none");
|
||||
exitFullScreenButton->setToolTip(tr("Exit full screen"));
|
||||
|
||||
connect(videoPreviewButton, &QPushButton::clicked, this, &GenericNetCamView::toggleVideoPreview);
|
||||
connect(volumeButton, &QPushButton::clicked, this, &GenericNetCamView::volMuteToggle);
|
||||
connect(microphoneButton, &QPushButton::clicked, this, &GenericNetCamView::micMuteToggle);
|
||||
connect(endVideoButton, &QPushButton::clicked, this, &GenericNetCamView::endVideoCall);
|
||||
connect(exitFullScreenButton, &QPushButton::clicked, this, &GenericNetCamView::toggleFullScreen);
|
||||
|
||||
buttonPanelLayout->addStretch();
|
||||
buttonPanelLayout->addWidget(videoPreviewButton);
|
||||
buttonPanelLayout->addWidget(volumeButton);
|
||||
buttonPanelLayout->addWidget(microphoneButton);
|
||||
buttonPanelLayout->addWidget(endVideoButton);
|
||||
buttonPanelLayout->addWidget(exitFullScreenButton);
|
||||
buttonPanelLayout->addStretch();
|
||||
}
|
||||
|
||||
QSize GenericNetCamView::getSurfaceMinSize()
|
||||
{
|
||||
QSize surfaceSize = videoSurface->minimumSize();
|
||||
QSize buttonSize = toggleMessagesButton->size();
|
||||
QSize panelSize(0, 45);
|
||||
|
||||
return surfaceSize + buttonSize + panelSize;
|
||||
}
|
||||
|
||||
void GenericNetCamView::setShowMessages(bool show, bool notify)
|
||||
{
|
||||
if (!show) {
|
||||
toggleMessagesButton->setText(tr("Hide messages"));
|
||||
toggleMessagesButton->setIcon(QIcon());
|
||||
return;
|
||||
}
|
||||
|
||||
toggleMessagesButton->setText(tr("Show messages"));
|
||||
|
||||
if (notify) {
|
||||
toggleMessagesButton->setIcon(QIcon(Style::getImagePath("chatArea/info.svg")));
|
||||
}
|
||||
}
|
||||
|
||||
void GenericNetCamView::toggleFullScreen()
|
||||
{
|
||||
if (isFullScreen()) {
|
||||
exitFullScreen();
|
||||
} else {
|
||||
enterFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void GenericNetCamView::enterFullScreen()
|
||||
{
|
||||
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
|
||||
showFullScreen();
|
||||
enterFullScreenButton->hide();
|
||||
toggleMessagesButton->hide();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
const auto screenSize = QGuiApplication::screenAt(this->pos())->geometry();
|
||||
#else
|
||||
const QRect screenSize = QApplication::desktop()->screenGeometry(this);
|
||||
#endif
|
||||
buttonPanel->setGeometry((screenSize.width() / 2) - buttonPanel->width() / 2,
|
||||
screenSize.height() - BTN_PANEL_HEIGHT - 25, BTN_PANEL_WIDTH, BTN_PANEL_HEIGHT);
|
||||
buttonPanel->show();
|
||||
buttonPanel->activateWindow();
|
||||
buttonPanel->raise();
|
||||
}
|
||||
|
||||
void GenericNetCamView::exitFullScreen()
|
||||
{
|
||||
setWindowFlags(Qt::Widget);
|
||||
showNormal();
|
||||
buttonPanel->hide();
|
||||
enterFullScreenButton->show();
|
||||
toggleMessagesButton->show();
|
||||
}
|
||||
|
||||
void GenericNetCamView::endVideoCall()
|
||||
{
|
||||
toggleFullScreen();
|
||||
emit videoCallEnd();
|
||||
}
|
||||
|
||||
void GenericNetCamView::toggleVideoPreview()
|
||||
{
|
||||
toggleButtonState(videoPreviewButton);
|
||||
emit videoPreviewToggle();
|
||||
}
|
||||
|
||||
QPushButton *GenericNetCamView::createButton(const QString& name, const QString& state)
|
||||
{
|
||||
QPushButton* btn = new QPushButton();
|
||||
btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
btn->setObjectName(name);
|
||||
btn->setProperty("state", QVariant(state));
|
||||
btn->setStyleSheet(Style::getStylesheet(BTN_STYLE_SHEET_PATH));
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
void GenericNetCamView::updateMuteVolButton(bool isMuted)
|
||||
{
|
||||
updateButtonState(volumeButton, !isMuted);
|
||||
}
|
||||
|
||||
void GenericNetCamView::updateMuteMicButton(bool isMuted)
|
||||
{
|
||||
updateButtonState(microphoneButton, !isMuted);
|
||||
}
|
||||
|
||||
void GenericNetCamView::toggleButtonState(QPushButton* btn)
|
||||
{
|
||||
if (btn->property("state") == BTN_STATE_RED) {
|
||||
btn->setProperty("state", BTN_STATE_NONE);
|
||||
} else {
|
||||
btn->setProperty("state", BTN_STATE_RED);
|
||||
}
|
||||
|
||||
btn->setStyleSheet(Style::getStylesheet(BTN_STYLE_SHEET_PATH));
|
||||
}
|
||||
|
||||
void GenericNetCamView::updateButtonState(QPushButton* btn, bool active)
|
||||
{
|
||||
if (active) {
|
||||
btn->setProperty("state", BTN_STATE_NONE);
|
||||
} else {
|
||||
btn->setProperty("state", BTN_STATE_RED);
|
||||
}
|
||||
|
||||
btn->setStyleSheet(Style::getStylesheet(BTN_STYLE_SHEET_PATH));
|
||||
}
|
||||
|
||||
void GenericNetCamView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
int key = event->key();
|
||||
if (key == Qt::Key_Escape && isFullScreen()) {
|
||||
exitFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void GenericNetCamView::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
exitFullScreen();
|
||||
event->ignore();
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
Copyright © 2015-2019 by The qTox Project Contributors
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
qTox is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
qTox is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GENERICNETCAMVIEW_H
|
||||
#define GENERICNETCAMVIEW_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
#include "src/video/videosurface.h"
|
||||
#include "src/widget/style.h"
|
||||
|
||||
class GenericNetCamView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GenericNetCamView(QWidget* parent);
|
||||
QSize getSurfaceMinSize();
|
||||
|
||||
signals:
|
||||
void showMessageClicked();
|
||||
void videoCallEnd();
|
||||
void volMuteToggle();
|
||||
void micMuteToggle();
|
||||
void videoPreviewToggle();
|
||||
|
||||
public slots:
|
||||
void setShowMessages(bool show, bool notify = false);
|
||||
void updateMuteVolButton(bool isMuted);
|
||||
void updateMuteMicButton(bool isMuted);
|
||||
|
||||
protected:
|
||||
QVBoxLayout* verLayout;
|
||||
VideoSurface* videoSurface;
|
||||
QPushButton* enterFullScreenButton = nullptr;
|
||||
|
||||
private:
|
||||
QHBoxLayout* buttonLayout = nullptr;
|
||||
QPushButton* toggleMessagesButton = nullptr;
|
||||
QFrame* buttonPanel = nullptr;
|
||||
QPushButton* videoPreviewButton = nullptr;
|
||||
QPushButton* volumeButton = nullptr;
|
||||
QPushButton* microphoneButton = nullptr;
|
||||
QPushButton* endVideoButton = nullptr;
|
||||
QPushButton* exitFullScreenButton = nullptr;
|
||||
|
||||
private:
|
||||
QPushButton* createButton(const QString& name, const QString& state);
|
||||
void toggleFullScreen();
|
||||
void enterFullScreen();
|
||||
void exitFullScreen();
|
||||
void endVideoCall();
|
||||
void toggleVideoPreview();
|
||||
void toggleButtonState(QPushButton* btn);
|
||||
void updateButtonState(QPushButton* btn, bool active);
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // GENERICNETCAMVIEW_H
|
|
@ -27,16 +27,89 @@
|
|||
#include "src/persistence/settings.h"
|
||||
#include "src/video/videosurface.h"
|
||||
#include "src/widget/tool/movablewidget.h"
|
||||
#include "src/widget/style.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
#include <QScreen>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QCloseEvent>
|
||||
#include <QPushButton>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
namespace
|
||||
{
|
||||
const auto BTN_STATE_NONE = QVariant("none");
|
||||
const auto BTN_STATE_RED = QVariant("red");
|
||||
const int BTN_PANEL_HEIGHT = 55;
|
||||
const int BTN_PANEL_WIDTH = 250;
|
||||
const auto BTN_STYLE_SHEET_PATH = QStringLiteral("chatForm/fullScreenButtons.css");
|
||||
}
|
||||
|
||||
NetCamView::NetCamView(ToxPk friendPk, QWidget* parent)
|
||||
: GenericNetCamView(parent)
|
||||
, selfFrame{nullptr}
|
||||
: selfFrame{nullptr}
|
||||
, friendPk{friendPk}
|
||||
, e(false)
|
||||
{
|
||||
verLayout = new QVBoxLayout(this);
|
||||
setWindowTitle(tr("Tox video"));
|
||||
|
||||
buttonLayout = new QHBoxLayout();
|
||||
|
||||
toggleMessagesButton = new QPushButton();
|
||||
enterFullScreenButton = new QPushButton();
|
||||
enterFullScreenButton->setText(tr("Full Screen"));
|
||||
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(toggleMessagesButton);
|
||||
buttonLayout->addWidget(enterFullScreenButton);
|
||||
|
||||
connect(toggleMessagesButton, &QPushButton::clicked, this, &NetCamView::showMessageClicked);
|
||||
connect(enterFullScreenButton, &QPushButton::clicked, this, &NetCamView::toggleFullScreen);
|
||||
|
||||
verLayout->addLayout(buttonLayout);
|
||||
verLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
setShowMessages(false);
|
||||
|
||||
setStyleSheet("NetCamView { background-color: #c1c1c1; }");
|
||||
buttonPanel = new QFrame(this);
|
||||
buttonPanel->setStyleSheet(Style::getStylesheet(BTN_STYLE_SHEET_PATH));
|
||||
buttonPanel->setGeometry(0, 0, BTN_PANEL_WIDTH, BTN_PANEL_HEIGHT);
|
||||
|
||||
QHBoxLayout* buttonPanelLayout = new QHBoxLayout(buttonPanel);
|
||||
buttonPanelLayout->setContentsMargins(20, 0, 20, 0);
|
||||
|
||||
videoPreviewButton = createButton("videoPreviewButton", "none");
|
||||
videoPreviewButton->setToolTip(tr("Toggle video preview"));
|
||||
|
||||
volumeButton = createButton("volButtonFullScreen", "none");
|
||||
volumeButton->setToolTip(tr("Mute audio"));
|
||||
|
||||
microphoneButton = createButton("micButtonFullScreen", "none");
|
||||
microphoneButton->setToolTip(tr("Mute microphone"));
|
||||
|
||||
endVideoButton = createButton("videoButtonFullScreen", "none");
|
||||
endVideoButton->setToolTip(tr("End video call"));
|
||||
|
||||
exitFullScreenButton = createButton("exitFullScreenButton", "none");
|
||||
exitFullScreenButton->setToolTip(tr("Exit full screen"));
|
||||
|
||||
connect(videoPreviewButton, &QPushButton::clicked, this, &NetCamView::genericToggleVideoPreview);
|
||||
connect(volumeButton, &QPushButton::clicked, this, &NetCamView::volMuteToggle);
|
||||
connect(microphoneButton, &QPushButton::clicked, this, &NetCamView::micMuteToggle);
|
||||
connect(endVideoButton, &QPushButton::clicked, this, &NetCamView::endVideoCall);
|
||||
connect(exitFullScreenButton, &QPushButton::clicked, this, &NetCamView::toggleFullScreen);
|
||||
|
||||
buttonPanelLayout->addStretch();
|
||||
buttonPanelLayout->addWidget(videoPreviewButton);
|
||||
buttonPanelLayout->addWidget(volumeButton);
|
||||
buttonPanelLayout->addWidget(microphoneButton);
|
||||
buttonPanelLayout->addWidget(endVideoButton);
|
||||
buttonPanelLayout->addWidget(exitFullScreenButton);
|
||||
buttonPanelLayout->addStretch();
|
||||
|
||||
videoSurface = new VideoSurface(Nexus::getProfile()->loadAvatar(friendPk), this);
|
||||
videoSurface->setMinimumHeight(256);
|
||||
|
||||
|
@ -152,3 +225,132 @@ void NetCamView::toggleVideoPreview()
|
|||
selfFrame->hide();
|
||||
}
|
||||
}
|
||||
|
||||
QSize NetCamView::getSurfaceMinSize()
|
||||
{
|
||||
QSize surfaceSize = videoSurface->minimumSize();
|
||||
QSize buttonSize = toggleMessagesButton->size();
|
||||
QSize panelSize(0, 45);
|
||||
|
||||
return surfaceSize + buttonSize + panelSize;
|
||||
}
|
||||
|
||||
void NetCamView::setShowMessages(bool show, bool notify)
|
||||
{
|
||||
if (!show) {
|
||||
toggleMessagesButton->setText(tr("Hide messages"));
|
||||
toggleMessagesButton->setIcon(QIcon());
|
||||
return;
|
||||
}
|
||||
|
||||
toggleMessagesButton->setText(tr("Show messages"));
|
||||
|
||||
if (notify) {
|
||||
toggleMessagesButton->setIcon(QIcon(Style::getImagePath("chatArea/info.svg")));
|
||||
}
|
||||
}
|
||||
|
||||
void NetCamView::toggleFullScreen()
|
||||
{
|
||||
if (isFullScreen()) {
|
||||
exitFullScreen();
|
||||
} else {
|
||||
enterFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void NetCamView::enterFullScreen()
|
||||
{
|
||||
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
|
||||
showFullScreen();
|
||||
enterFullScreenButton->hide();
|
||||
toggleMessagesButton->hide();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
const auto screenSize = QGuiApplication::screenAt(this->pos())->geometry();
|
||||
#else
|
||||
const QRect screenSize = QApplication::desktop()->screenGeometry(this);
|
||||
#endif
|
||||
buttonPanel->setGeometry((screenSize.width() / 2) - buttonPanel->width() / 2,
|
||||
screenSize.height() - BTN_PANEL_HEIGHT - 25, BTN_PANEL_WIDTH, BTN_PANEL_HEIGHT);
|
||||
buttonPanel->show();
|
||||
buttonPanel->activateWindow();
|
||||
buttonPanel->raise();
|
||||
}
|
||||
|
||||
void NetCamView::exitFullScreen()
|
||||
{
|
||||
setWindowFlags(Qt::Widget);
|
||||
showNormal();
|
||||
buttonPanel->hide();
|
||||
enterFullScreenButton->show();
|
||||
toggleMessagesButton->show();
|
||||
}
|
||||
|
||||
void NetCamView::endVideoCall()
|
||||
{
|
||||
toggleFullScreen();
|
||||
emit videoCallEnd();
|
||||
}
|
||||
|
||||
void NetCamView::genericToggleVideoPreview()
|
||||
{
|
||||
toggleButtonState(videoPreviewButton);
|
||||
emit videoPreviewToggle();
|
||||
}
|
||||
|
||||
QPushButton* NetCamView::createButton(const QString& name, const QString& state)
|
||||
{
|
||||
QPushButton* btn = new QPushButton();
|
||||
btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
btn->setObjectName(name);
|
||||
btn->setProperty("state", QVariant(state));
|
||||
btn->setStyleSheet(Style::getStylesheet(BTN_STYLE_SHEET_PATH));
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
void NetCamView::updateMuteVolButton(bool isMuted)
|
||||
{
|
||||
updateButtonState(volumeButton, !isMuted);
|
||||
}
|
||||
|
||||
void NetCamView::updateMuteMicButton(bool isMuted)
|
||||
{
|
||||
updateButtonState(microphoneButton, !isMuted);
|
||||
}
|
||||
|
||||
void NetCamView::toggleButtonState(QPushButton* btn)
|
||||
{
|
||||
if (btn->property("state") == BTN_STATE_RED) {
|
||||
btn->setProperty("state", BTN_STATE_NONE);
|
||||
} else {
|
||||
btn->setProperty("state", BTN_STATE_RED);
|
||||
}
|
||||
|
||||
btn->setStyleSheet(Style::getStylesheet(BTN_STYLE_SHEET_PATH));
|
||||
}
|
||||
|
||||
void NetCamView::updateButtonState(QPushButton* btn, bool active)
|
||||
{
|
||||
if (active) {
|
||||
btn->setProperty("state", BTN_STATE_NONE);
|
||||
} else {
|
||||
btn->setProperty("state", BTN_STATE_RED);
|
||||
}
|
||||
|
||||
btn->setStyleSheet(Style::getStylesheet(BTN_STYLE_SHEET_PATH));
|
||||
}
|
||||
|
||||
void NetCamView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
int key = event->key();
|
||||
if (key == Qt::Key_Escape && isFullScreen()) {
|
||||
exitFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void NetCamView::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
exitFullScreen();
|
||||
event->ignore();
|
||||
}
|
||||
|
|
|
@ -21,16 +21,22 @@
|
|||
#define NETCAMVIEW_H
|
||||
|
||||
#include "src/core/toxpk.h"
|
||||
#include "genericnetcamview.h"
|
||||
#include <QVector>
|
||||
#include <QWidget>
|
||||
|
||||
class QHBoxLayout;
|
||||
struct vpx_image;
|
||||
class VideoSource;
|
||||
class QFrame;
|
||||
class MovableWidget;
|
||||
class QVBoxLayout;
|
||||
class VideoSurface;
|
||||
class QPushButton;
|
||||
class QKeyEvent;
|
||||
class QCloseEvent;
|
||||
class QShowEvent;
|
||||
|
||||
class NetCamView : public GenericNetCamView
|
||||
class NetCamView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -44,21 +50,54 @@ public:
|
|||
void setSource(VideoSource* s);
|
||||
void setTitle(const QString& title);
|
||||
void toggleVideoPreview();
|
||||
QSize getSurfaceMinSize();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) final;
|
||||
void showEvent(QShowEvent* event);
|
||||
QVBoxLayout* verLayout;
|
||||
VideoSurface* videoSurface;
|
||||
QPushButton* enterFullScreenButton = nullptr;
|
||||
|
||||
signals:
|
||||
void showMessageClicked();
|
||||
void videoCallEnd();
|
||||
void volMuteToggle();
|
||||
void micMuteToggle();
|
||||
void videoPreviewToggle();
|
||||
|
||||
public slots:
|
||||
void setShowMessages(bool show, bool notify = false);
|
||||
void updateMuteVolButton(bool isMuted);
|
||||
void updateMuteMicButton(bool isMuted);
|
||||
|
||||
private slots:
|
||||
void updateRatio();
|
||||
|
||||
private:
|
||||
void updateFrameSize(QSize size);
|
||||
|
||||
QPushButton* createButton(const QString& name, const QString& state);
|
||||
void toggleFullScreen();
|
||||
void enterFullScreen();
|
||||
void exitFullScreen();
|
||||
void endVideoCall();
|
||||
void genericToggleVideoPreview();
|
||||
void toggleButtonState(QPushButton* btn);
|
||||
void updateButtonState(QPushButton* btn, bool active);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
VideoSurface* selfVideoSurface;
|
||||
MovableWidget* selfFrame;
|
||||
ToxPk friendPk;
|
||||
bool e;
|
||||
QVector<QMetaObject::Connection> connections;
|
||||
QHBoxLayout* buttonLayout = nullptr;
|
||||
QPushButton* toggleMessagesButton = nullptr;
|
||||
QFrame* buttonPanel = nullptr;
|
||||
QPushButton* videoPreviewButton = nullptr;
|
||||
QPushButton* volumeButton = nullptr;
|
||||
QPushButton* microphoneButton = nullptr;
|
||||
QPushButton* endVideoButton = nullptr;
|
||||
QPushButton* exitFullScreenButton = nullptr;
|
||||
};
|
||||
|
||||
#endif // NETCAMVIEW_H
|
||||
|
|
|
@ -486,10 +486,10 @@ std::unique_ptr<NetCamView> ChatForm::createNetcam()
|
|||
CoreAV* av = Core::getInstance()->getAv();
|
||||
VideoSource* source = av->getVideoSourceFromCall(friendId);
|
||||
view->show(source, f->getDisplayedName());
|
||||
connect(view.get(), &GenericNetCamView::videoCallEnd, this, &ChatForm::onVideoCallTriggered);
|
||||
connect(view.get(), &GenericNetCamView::volMuteToggle, this, &ChatForm::onVolMuteToggle);
|
||||
connect(view.get(), &GenericNetCamView::micMuteToggle, this, &ChatForm::onMicMuteToggle);
|
||||
connect(view.get(), &GenericNetCamView::videoPreviewToggle, view.get(), &NetCamView::toggleVideoPreview);
|
||||
connect(view.get(), &NetCamView::videoCallEnd, this, &ChatForm::onVideoCallTriggered);
|
||||
connect(view.get(), &NetCamView::volMuteToggle, this, &ChatForm::onVolMuteToggle);
|
||||
connect(view.get(), &NetCamView::micMuteToggle, this, &ChatForm::onMicMuteToggle);
|
||||
connect(view.get(), &NetCamView::videoPreviewToggle, view.get(), &NetCamView::toggleVideoPreview);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -716,7 +716,7 @@ void ChatForm::showNetcam()
|
|||
netcam = createNetcam();
|
||||
}
|
||||
|
||||
connect(netcam.get(), &GenericNetCamView::showMessageClicked, this,
|
||||
connect(netcam.get(), &NetCamView::showMessageClicked, this,
|
||||
&ChatForm::onShowMessagesClicked);
|
||||
|
||||
bodySplitter->insertWidget(0, netcam.get());
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "src/model/group.h"
|
||||
#include "src/persistence/settings.h"
|
||||
#include "src/persistence/smileypack.h"
|
||||
#include "src/video/genericnetcamview.h"
|
||||
#include "src/widget/chatformheader.h"
|
||||
#include "src/widget/contentdialog.h"
|
||||
#include "src/widget/contentdialogmanager.h"
|
||||
|
|
Loading…
Reference in New Issue
Block a user