diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index acd2997db..a8728f1a1 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -35,6 +35,7 @@ #include "src/persistence/settings.h" #include "src/video/netcamview.h" #include "src/widget/chatformheader.h" +#include "src/widget/contentdialogmanager.h" #include "src/widget/form/loadhistorydialog.h" #include "src/widget/maskablepixmapwidget.h" #include "src/widget/searchform.h" @@ -708,3 +709,39 @@ void ChatForm::retranslateUi() netcam->setShowMessages(chatWidget->isVisible()); } } + +void ChatForm::showNetcam() +{ + if (!netcam) { + netcam = createNetcam(); + } + + connect(netcam, &GenericNetCamView::showMessageClicked, this, + &ChatForm::onShowMessagesClicked); + + bodySplitter->insertWidget(0, netcam); + bodySplitter->setCollapsible(0, false); + + QSize minSize = netcam->getSurfaceMinSize(); + ContentDialog* current = ContentDialogManager::getInstance()->current(); + if (current) { + current->onVideoShow(minSize); + } +} + +void ChatForm::hideNetcam() +{ + if (!netcam) { + return; + } + + ContentDialog* current = ContentDialogManager::getInstance()->current(); + if (current) { + current->onVideoHide(); + } + + netcam->close(); + netcam->hide(); + delete netcam; + netcam = nullptr; +} diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index 4b12c49ce..0dd024724 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -107,9 +107,11 @@ private: void startCounter(); void stopCounter(bool error = false); void updateCallButtons(); + void showNetcam(); + void hideNetcam(); protected: - GenericNetCamView* createNetcam() final; + GenericNetCamView* createNetcam(); void insertChatMessage(ChatMessage::Ptr msg) final; void dragEnterEvent(QDragEnterEvent* ev) final; void dropEvent(QDropEvent* ev) final; diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 2d332fefb..33e0af7aa 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -1226,35 +1226,3 @@ void GenericChatForm::retranslateUi() loadHistoryAction->setText(tr("Load chat history...")); exportChatAction->setText(tr("Export to file")); } - -void GenericChatForm::showNetcam() -{ - if (!netcam) - netcam = createNetcam(); - - connect(netcam, &GenericNetCamView::showMessageClicked, this, - &GenericChatForm::onShowMessagesClicked); - - bodySplitter->insertWidget(0, netcam); - bodySplitter->setCollapsible(0, false); - - QSize minSize = netcam->getSurfaceMinSize(); - ContentDialog* current = ContentDialogManager::getInstance()->current(); - if (current) - current->onVideoShow(minSize); -} - -void GenericChatForm::hideNetcam() -{ - if (!netcam) - return; - - ContentDialog* current = ContentDialogManager::getInstance()->current(); - if (current) - current->onVideoHide(); - - netcam->close(); - netcam->hide(); - delete netcam; - netcam = nullptr; -} diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index 27febd7dc..3c3d451b2 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -142,9 +142,6 @@ protected: ChatMessage::Ptr createMessage(const ToxPk& author, const QString& message, const QDateTime& datetime, bool isAction, bool isSent, bool colorizeName = false); bool needsToHideName(ChatLogIdx idx) const; - void showNetcam(); - void hideNetcam(); - virtual GenericNetCamView* createNetcam() = 0; virtual void insertChatMessage(ChatMessage::Ptr msg); void adjustFileMenuPosition(); void hideEvent(QHideEvent* event) override; diff --git a/src/widget/form/groupchatform.cpp b/src/widget/form/groupchatform.cpp index c95700dfb..c525fb295 100644 --- a/src/widget/form/groupchatform.cpp +++ b/src/widget/form/groupchatform.cpp @@ -345,11 +345,6 @@ void GroupChatForm::onCallClicked() headWidget->updateMuteVolButton(inCall, outMute); } -GenericNetCamView* GroupChatForm::createNetcam() -{ - return static_cast(nullptr); -} - void GroupChatForm::keyPressEvent(QKeyEvent* ev) { // Push to talk (CTRL+P) diff --git a/src/widget/form/groupchatform.h b/src/widget/form/groupchatform.h index c49a9e547..ccb1bdeac 100644 --- a/src/widget/form/groupchatform.h +++ b/src/widget/form/groupchatform.h @@ -57,7 +57,6 @@ private slots: void onLabelContextMenuRequested(const QPoint& localPos); protected: - GenericNetCamView* createNetcam() final; void keyPressEvent(QKeyEvent* ev) final; void keyReleaseEvent(QKeyEvent* ev) final; // drag & drop