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

refactor(chatform): move create/show/hide NetCamView API to ChatForm

Since NetCamView is now only used by ChatForm, GenericChatForm shouldn't have
any of its functionality.
This commit is contained in:
Anthony Bilinski 2020-01-25 21:01:07 -08:00
parent 91bcd211a7
commit 4c816b1bff
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
6 changed files with 40 additions and 42 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -345,11 +345,6 @@ void GroupChatForm::onCallClicked()
headWidget->updateMuteVolButton(inCall, outMute);
}
GenericNetCamView* GroupChatForm::createNetcam()
{
return static_cast<GenericNetCamView*>(nullptr);
}
void GroupChatForm::keyPressEvent(QKeyEvent* ev)
{
// Push to talk (CTRL+P)

View File

@ -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