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

refactor(chatform): move onMessagesClicked, onSplitterMoved to ChatForm

These API are only relevant for NetCamView, which is only used by ChatForm.
This commit is contained in:
Anthony Bilinski 2020-01-25 22:53:29 -08:00
parent 4c816b1bff
commit 8d8e75b800
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
4 changed files with 25 additions and 21 deletions

View File

@ -179,6 +179,8 @@ ChatForm::ChatForm(Friend* chatFriend, IChatLog& chatLog, IMessageDispatcher& me
[this] { onAnswerCallTriggered(lastCallIsVideo); });
connect(headWidget, &ChatFormHeader::callRejected, this, &ChatForm::onRejectCallTriggered);
connect(bodySplitter, &QSplitter::splitterMoved, this, &ChatForm::onSplitterMoved);
updateCallButtons();
setAcceptDrops(true);
@ -745,3 +747,24 @@ void ChatForm::hideNetcam()
delete netcam;
netcam = nullptr;
}
void ChatForm::onSplitterMoved(int, int)
{
if (netcam) {
netcam->setShowMessages(bodySplitter->sizes()[1] == 0);
}
}
void ChatForm::onShowMessagesClicked()
{
if (netcam) {
if (bodySplitter->sizes()[1] == 0) {
bodySplitter->setSizes({1, 1});
}
else {
bodySplitter->setSizes({1, 0});
}
onSplitterMoved(0, 0);
}
}

View File

@ -74,6 +74,8 @@ public slots:
void onAvatarChanged(const ToxPk& friendPk, const QPixmap& pic);
void onFileNameChanged(const ToxPk& friendPk);
void clearChatArea();
void onShowMessagesClicked();
void onSplitterMoved(int pos, int index);
private slots:
void updateFriendActivityForFile(const ToxFile& file);

View File

@ -297,7 +297,6 @@ GenericChatForm::GenericChatForm(const Contact* contact, IChatLog& chatLog,
msgEdit->setFrameStyle(QFrame::NoFrame);
bodySplitter = new QSplitter(Qt::Vertical, this);
connect(bodySplitter, &QSplitter::splitterMoved, this, &GenericChatForm::onSplitterMoved);
QWidget* contentWidget = new QWidget(this);
bodySplitter->addWidget(contentWidget);
@ -866,24 +865,6 @@ bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
return false;
}
void GenericChatForm::onSplitterMoved(int, int)
{
if (netcam)
netcam->setShowMessages(bodySplitter->sizes()[1] == 0);
}
void GenericChatForm::onShowMessagesClicked()
{
if (netcam) {
if (bodySplitter->sizes()[1] == 0)
bodySplitter->setSizes({1, 1});
else
bodySplitter->setSizes({1, 0});
onSplitterMoved(0, 0);
}
}
void GenericChatForm::quoteSelectedText()
{
QString selectedText = chatWidget->getSelectedText();

View File

@ -106,8 +106,6 @@ protected slots:
void onSelectAllClicked();
void showFileMenu();
void hideFileMenu();
void onShowMessagesClicked();
void onSplitterMoved(int pos, int index);
void quoteSelectedText();
void copyLink();
void onLoadHistory();