diff --git a/videoview.cpp b/videoview.cpp index f15af67ed18e85653d985f3e1e39c9bcc61f0b24..66bbc3382b3136ba665dba482969ea14174b135a 100644 --- a/videoview.cpp +++ b/videoview.cpp @@ -67,6 +67,7 @@ VideoView::VideoView(QWidget* parent) : this, SLOT(showContextMenu(const QPoint&))); connect(overlay_, &VideoOverlay::setChatVisibility, [=](bool visible) { emit this->setChatVisibility(visible); + connect(this, SIGNAL(toggleFullScreenClicked()), ui->videoWidget, SLOT(slotToggleFullScreenClicked())); }); } @@ -81,6 +82,7 @@ VideoView::~VideoView() void VideoView::resizeEvent(QResizeEvent* event) { + int marginWidth = ui->videoWidget->getPreviewMargin(); QRect& previewRect = ui->videoWidget->getPreviewRect(); int deltaW = event->size().width() - event->oldSize().width(); int deltaH = event->size().height() - event->oldSize().height(); @@ -102,16 +104,20 @@ VideoView::resizeEvent(QResizeEvent* event) } if (previewRect.left() <= 0) - previewRect.moveLeft(1); + previewRect.moveLeft(marginWidth); + previewRect.moveRight(width() - marginWidth); if (previewRect.right() >= width()) - previewRect.moveRight(width() - 1); + previewRect.moveRight(width() - marginWidth); if (previewRect.top() <= 0) - previewRect.moveTop(1); + previewRect.moveTop(marginWidth); + previewRect.moveBottom(height() - marginWidth); if (previewRect.bottom() >= height()) - previewRect.moveBottom(height() - 1); + previewRect.moveBottom(height() - marginWidth); + + ui->videoWidget->resetPreview(); overlay_->resize(this->size()); overlay_->show(); @@ -164,8 +170,10 @@ VideoView::slotCallStatusChanged(const std::string& callId) } return; } - default: + case Status::ENDED: emit closing(call.id); + default: + //emit closing(call.id); break; } QObject::disconnect(timerConnection_); diff --git a/videowidget.cpp b/videowidget.cpp index 88ebab930208a8ac1b54afa59d3da624b3584cac..a7ccf79e09821702ffda99b18863e8c0c75be592 100644 --- a/videowidget.cpp +++ b/videowidget.cpp @@ -109,6 +109,12 @@ VideoWidget::renderFrame(const std::string& id) } } +void +VideoWidget::slotToggleFullScreenClicked() +{ + this->update(); +} + void VideoWidget::paintEvent(QPaintEvent* e) { @@ -154,9 +160,9 @@ VideoWidget::paintEvent(QPaintEvent* e) hasFrame_ = true; } if (previewImage_) { - if(resetPreview_) { - auto previewHeight = fullPreview_ ? height() : height() / 4; - auto previewWidth = fullPreview_ ? width() : width() / 4; + if (resetPreview_) { + auto previewHeight = fullPreview_ ? height() : height() / 6; + auto previewWidth = fullPreview_ ? width() : width() / 6; QImage scaledPreview; if (photoMode_) scaledPreview = Utils::getCirclePhoto(*previewImage_, previewHeight); @@ -164,8 +170,8 @@ VideoWidget::paintEvent(QPaintEvent* e) scaledPreview = previewImage_->scaled(previewWidth, previewHeight, Qt::KeepAspectRatio); auto xDiff = (previewWidth - scaledPreview.width()) / 2; auto yDiff = (previewHeight - scaledPreview.height()) / 2; - auto yPos = fullPreview_ ? yDiff : height() - previewHeight - previewMargin_; auto xPos = fullPreview_ ? xDiff : width() - scaledPreview.width() - previewMargin_; + auto yPos = fullPreview_ ? yDiff : height() - scaledPreview.height() - previewMargin_; previewGeometry_.setRect(xPos, yPos, scaledPreview.width(), scaledPreview.height()); painter.drawImage(previewGeometry_, scaledPreview); resetPreview_ = false; diff --git a/videowidget.h b/videowidget.h index 9c1364b6b69fed2afefbe787170bdead72016f95..4bb4ad660281b2b14bc66b90ca145a8132094426 100644 --- a/videowidget.h +++ b/videowidget.h @@ -43,11 +43,14 @@ public: inline void setResetPreview(bool reset) { resetPreview_ = reset; hasFrame_=false; } void setPhotoMode(bool isPhotoMode); QImage takePhoto(); + int getPreviewMargin(){ return previewMargin_; } + void resetPreview() { resetPreview_ = true; } protected: void paintEvent(QPaintEvent* e); public slots: + void slotToggleFullScreenClicked(); void slotRendererStarted(const std::string& id); void renderFrame(const std::string& id); inline QRect& getPreviewRect(){ return previewGeometry_; } @@ -57,6 +60,8 @@ private: QMetaObject::Connection started, stopped, updated; } rendererConnections_; + void paintBackgroundColor(QPainter* painter, QColor color); + video::Renderer* previewRenderer_; video::Frame previewFrame_; std::unique_ptr<QImage> previewImage_; @@ -77,7 +82,4 @@ private: bool hasFrame_ = false; constexpr static int previewMargin_ = 15; - -private: - void paintBackgroundColor(QPainter* painter, QColor color); };