1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Video: Embed video into chat

This commit is contained in:
TheSpiritXIII 2015-07-20 17:57:46 -04:00
parent b13cf301f9
commit 1b10672179
9 changed files with 143 additions and 8 deletions

View File

@ -493,7 +493,8 @@ SOURCES += \
src/widget/genericchatitemwidget.cpp \
src/widget/friendlistlayout.cpp \
src/widget/genericchatitemlayout.cpp \
src/widget/categorywidget.cpp
src/widget/categorywidget.cpp \
src/widget/tool/movablewidget.cpp
HEADERS += \
src/audio/audio.h \
@ -536,4 +537,5 @@ HEADERS += \
src/widget/genericchatitemwidget.h \
src/widget/friendlistlayout.h \
src/widget/genericchatitemlayout.h \
src/widget/categorywidget.h
src/widget/categorywidget.h \
src/widget/tool/movablewidget.h

View File

@ -22,6 +22,7 @@
#include "src/video/videosurface.h"
#include <QLabel>
#include <QHBoxLayout>
#include "src/widget/tool/movablewidget.h"
NetCamView::NetCamView(QWidget* parent)
: QWidget(parent)
@ -34,6 +35,10 @@ NetCamView::NetCamView(QWidget* parent)
videoSurface = new VideoSurface(this);
mainLayout->addWidget(videoSurface);
selfFrame = new MovableWidget(this);
selfFrame->setStyleSheet("background-color: red;");
selfFrame->show();
}
void NetCamView::show(VideoSource *source, const QString &title)
@ -60,3 +65,13 @@ void NetCamView::setTitle(const QString &title)
{
setWindowTitle(title);
}
void NetCamView::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);
float ratio = 1.33f;
int frameHeight = height() / 3.0f;
selfFrame->resize(frameHeight * ratio, frameHeight);
selfFrame->move(6, height() - selfFrame->height() - 6);
}

View File

@ -26,6 +26,7 @@ class QHBoxLayout;
struct vpx_image;
class VideoSurface;
class VideoSource;
class QFrame;
class NetCamView : public QWidget
{
@ -40,9 +41,13 @@ public:
void setSource(VideoSource* s);
void setTitle(const QString& title);
protected:
void resizeEvent(QResizeEvent* event) final override;
private:
QHBoxLayout* mainLayout;
VideoSurface* videoSurface;
QWidget* selfFrame;
};
#endif // NETCAMVIEW_H

View File

@ -6,14 +6,14 @@
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.
(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
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
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
@ -105,7 +105,7 @@ void VideoSurface::paintEvent(QPaintEvent*)
}
QPainter painter(this);
painter.fillRect(painter.viewport(), Qt::black);
//painter.fillRect(painter.viewport(), Qt::blue);
if (lastFrame)
{
QSize frameSize = lastFrame->getSize();

View File

@ -1062,12 +1062,13 @@ void ChatForm::SendMessageStr(QString msg)
Widget::getInstance()->updateFriendActivity(f);
}
}
#include <QSplitter>
void ChatForm::showNetcam()
{
if (!netcam)
netcam = new NetCamView();
netcam->show(Core::getInstance()->getVideoSourceFromCall(callId), f->getDisplayedName());
bodySplitter->insertWidget(0, netcam);
}
void ChatForm::hideNetcam()

View File

@ -25,6 +25,7 @@
#include <QDebug>
#include <QShortcut>
#include <QKeyEvent>
#include <QSplitter>
#include "src/persistence/smileypack.h"
#include "src/widget/emoticonswidget.h"
@ -125,7 +126,11 @@ GenericChatForm::GenericChatForm(QWidget *parent)
micButton->setStyleSheet(micButtonStylesheet);
setLayout(mainLayout);
mainLayout->addWidget(chatWidget);
bodySplitter = new QSplitter(Qt::Vertical, this);
bodySplitter->addWidget(chatWidget);
mainLayout->addWidget(bodySplitter);
mainLayout->addLayout(mainFootLayout);
mainLayout->setMargin(0);

View File

@ -40,6 +40,7 @@ class ChatLog;
class MaskablePixmapWidget;
class Widget;
class FlyoutOverlayWidget;
class QSplitter;
namespace Ui {
class MainWindow;
@ -119,6 +120,7 @@ protected:
QDateTime historyBaselineDate = QDateTime::currentDateTime(); // used by HistoryKeeper to load messages from t to historyBaselineDate (excluded)
bool audioInputFlag;
bool audioOutputFlag;
QSplitter* bodySplitter;
};
#endif // GENERICCHATFORM_H

View File

@ -0,0 +1,65 @@
/*
Copyright © 2015 by The qTox Project
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 "movablewidget.h"
#include <QMouseEvent>
MovableWidget::MovableWidget(QWidget *parent)
: QWidget(parent)
{
}
void MovableWidget::mousePressEvent(QMouseEvent* event)
{
if (event->buttons() & Qt::LeftButton)
{
moving = true;
lastPoint = event->globalPos();
}
}
void MovableWidget::mouseMoveEvent(QMouseEvent* event)
{
if (moving)
{
QPoint moveTo = pos() - (lastPoint - event->globalPos());
if (moveTo.x() < 0)
moveTo.setX(0);
if (moveTo.y() < 0)
moveTo.setY(0);
if (moveTo.x() + width() > parentWidget()->width())
moveTo.setX(parentWidget()->width() - width());
if (moveTo.y() + height() > parentWidget()->height())
moveTo.setY(parentWidget()->height() - height());
move(moveTo);
lastPoint = event->globalPos();
}
}
void MovableWidget::mouseReleaseEvent(QMouseEvent* event)
{
if (!(event->buttons() & Qt::LeftButton))
moving = false;
}

View File

@ -0,0 +1,40 @@
/*
Copyright © 2015 by The qTox Project
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 MOVABLEWIDGET_H
#define MOVABLEWIDGET_H
#include <QWidget>
class MovableWidget : public QWidget
{
public:
MovableWidget(QWidget* parent = 0);
protected:
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
private:
bool moving = false;
QPoint lastPoint;
};
#endif // MOVABLEWIDGET_H