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:
parent
91bcd211a7
commit
4c816b1bff
|
@ -35,6 +35,7 @@
|
||||||
#include "src/persistence/settings.h"
|
#include "src/persistence/settings.h"
|
||||||
#include "src/video/netcamview.h"
|
#include "src/video/netcamview.h"
|
||||||
#include "src/widget/chatformheader.h"
|
#include "src/widget/chatformheader.h"
|
||||||
|
#include "src/widget/contentdialogmanager.h"
|
||||||
#include "src/widget/form/loadhistorydialog.h"
|
#include "src/widget/form/loadhistorydialog.h"
|
||||||
#include "src/widget/maskablepixmapwidget.h"
|
#include "src/widget/maskablepixmapwidget.h"
|
||||||
#include "src/widget/searchform.h"
|
#include "src/widget/searchform.h"
|
||||||
|
@ -708,3 +709,39 @@ void ChatForm::retranslateUi()
|
||||||
netcam->setShowMessages(chatWidget->isVisible());
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -107,9 +107,11 @@ private:
|
||||||
void startCounter();
|
void startCounter();
|
||||||
void stopCounter(bool error = false);
|
void stopCounter(bool error = false);
|
||||||
void updateCallButtons();
|
void updateCallButtons();
|
||||||
|
void showNetcam();
|
||||||
|
void hideNetcam();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GenericNetCamView* createNetcam() final;
|
GenericNetCamView* createNetcam();
|
||||||
void insertChatMessage(ChatMessage::Ptr msg) final;
|
void insertChatMessage(ChatMessage::Ptr msg) final;
|
||||||
void dragEnterEvent(QDragEnterEvent* ev) final;
|
void dragEnterEvent(QDragEnterEvent* ev) final;
|
||||||
void dropEvent(QDropEvent* ev) final;
|
void dropEvent(QDropEvent* ev) final;
|
||||||
|
|
|
@ -1226,35 +1226,3 @@ void GenericChatForm::retranslateUi()
|
||||||
loadHistoryAction->setText(tr("Load chat history..."));
|
loadHistoryAction->setText(tr("Load chat history..."));
|
||||||
exportChatAction->setText(tr("Export to file"));
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -142,9 +142,6 @@ protected:
|
||||||
ChatMessage::Ptr createMessage(const ToxPk& author, const QString& message,
|
ChatMessage::Ptr createMessage(const ToxPk& author, const QString& message,
|
||||||
const QDateTime& datetime, bool isAction, bool isSent, bool colorizeName = false);
|
const QDateTime& datetime, bool isAction, bool isSent, bool colorizeName = false);
|
||||||
bool needsToHideName(ChatLogIdx idx) const;
|
bool needsToHideName(ChatLogIdx idx) const;
|
||||||
void showNetcam();
|
|
||||||
void hideNetcam();
|
|
||||||
virtual GenericNetCamView* createNetcam() = 0;
|
|
||||||
virtual void insertChatMessage(ChatMessage::Ptr msg);
|
virtual void insertChatMessage(ChatMessage::Ptr msg);
|
||||||
void adjustFileMenuPosition();
|
void adjustFileMenuPosition();
|
||||||
void hideEvent(QHideEvent* event) override;
|
void hideEvent(QHideEvent* event) override;
|
||||||
|
|
|
@ -345,11 +345,6 @@ void GroupChatForm::onCallClicked()
|
||||||
headWidget->updateMuteVolButton(inCall, outMute);
|
headWidget->updateMuteVolButton(inCall, outMute);
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericNetCamView* GroupChatForm::createNetcam()
|
|
||||||
{
|
|
||||||
return static_cast<GenericNetCamView*>(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupChatForm::keyPressEvent(QKeyEvent* ev)
|
void GroupChatForm::keyPressEvent(QKeyEvent* ev)
|
||||||
{
|
{
|
||||||
// Push to talk (CTRL+P)
|
// Push to talk (CTRL+P)
|
||||||
|
|
|
@ -57,7 +57,6 @@ private slots:
|
||||||
void onLabelContextMenuRequested(const QPoint& localPos);
|
void onLabelContextMenuRequested(const QPoint& localPos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GenericNetCamView* createNetcam() final;
|
|
||||||
void keyPressEvent(QKeyEvent* ev) final;
|
void keyPressEvent(QKeyEvent* ev) final;
|
||||||
void keyReleaseEvent(QKeyEvent* ev) final;
|
void keyReleaseEvent(QKeyEvent* ev) final;
|
||||||
// drag & drop
|
// drag & drop
|
||||||
|
|
Loading…
Reference in New Issue
Block a user