mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Implement new call confirm widget logic
Works, but does not have any styling at the moment
This commit is contained in:
parent
3f433f1176
commit
32bf56c7d9
6
qtox.pro
6
qtox.pro
|
@ -188,7 +188,8 @@ HEADERS += src/widget/form/addfriendform.h \
|
|||
src/autoupdate.h \
|
||||
src/misc/serialize.h \
|
||||
src/widget/form/settings/advancedform.h \
|
||||
src/audio.h
|
||||
src/audio.h \
|
||||
src/widget/callconfirmwidget.h
|
||||
|
||||
SOURCES += \
|
||||
src/widget/form/addfriendform.cpp \
|
||||
|
@ -255,7 +256,8 @@ SOURCES += \
|
|||
src/autoupdate.cpp \
|
||||
src/misc/serialize.cpp \
|
||||
src/widget/form/settings/advancedform.cpp \
|
||||
src/audio.cpp
|
||||
src/audio.cpp \
|
||||
src/widget/callconfirmwidget.cpp
|
||||
|
||||
contains(DEFINES, QTOX_FILTER_AUDIO) {
|
||||
HEADERS += src/audiofilterer.h
|
||||
|
|
|
@ -117,6 +117,7 @@ public slots:
|
|||
void pauseResumeFileRecv(int friendId, int fileNum);
|
||||
|
||||
void answerCall(int callId);
|
||||
void rejectCall(int callId);
|
||||
void hangupCall(int callId);
|
||||
void startCall(int friendId, bool video=false);
|
||||
void cancelCall(int callId, int friendId);
|
||||
|
|
|
@ -159,6 +159,13 @@ void Core::hangupCall(int callId)
|
|||
toxav_hangup(toxav, callId);
|
||||
}
|
||||
|
||||
void Core::rejectCall(int callId)
|
||||
{
|
||||
qDebug() << QString("Core: rejecting call %1").arg(callId);
|
||||
calls[callId].active = false;
|
||||
toxav_reject(toxav, callId, nullptr);
|
||||
}
|
||||
|
||||
void Core::startCall(int friendId, bool video)
|
||||
{
|
||||
int callId;
|
||||
|
@ -201,7 +208,7 @@ void Core::cancelCall(int callId, int friendId)
|
|||
{
|
||||
qDebug() << QString("Core: Cancelling call with %1").arg(friendId);
|
||||
calls[callId].active = false;
|
||||
toxav_cancel(toxav, callId, friendId, 0);
|
||||
toxav_cancel(toxav, callId, friendId, nullptr);
|
||||
}
|
||||
|
||||
void Core::cleanupCall(int callId)
|
||||
|
|
33
src/widget/callconfirmwidget.cpp
Normal file
33
src/widget/callconfirmwidget.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "callconfirmwidget.h"
|
||||
#include "widget.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
CallConfirmWidget::CallConfirmWidget(QWidget *anchor) :
|
||||
QWidget(Widget::getInstance())
|
||||
{
|
||||
Widget* w = Widget::getInstance();
|
||||
|
||||
setWindowFlags(Qt::SubWindow);
|
||||
setAutoFillBackground(true);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
QLabel *callLabel = new QLabel(tr("Incoming call..."), this);
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
||||
QPushButton *accept = new QPushButton("Y", this), *reject = new QPushButton("N", this);
|
||||
|
||||
buttonBox->addButton(accept, QDialogButtonBox::AcceptRole);
|
||||
buttonBox->addButton(reject, QDialogButtonBox::RejectRole);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &CallConfirmWidget::accepted);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &CallConfirmWidget::rejected);
|
||||
|
||||
layout->addWidget(callLabel);
|
||||
layout->addWidget(buttonBox);
|
||||
|
||||
setFixedSize(150,90);
|
||||
move(anchor->mapToGlobal({(anchor->width()-width())/2,anchor->height()})-w->mapToGlobal({0,0}));
|
||||
}
|
19
src/widget/callconfirmwidget.h
Normal file
19
src/widget/callconfirmwidget.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef CALLCONFIRMWIDGET_H
|
||||
#define CALLCONFIRMWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QMoveEvent;
|
||||
|
||||
class CallConfirmWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CallConfirmWidget(QWidget *anchor);
|
||||
|
||||
signals:
|
||||
void accepted();
|
||||
void rejected();
|
||||
};
|
||||
|
||||
#endif // CALLCONFIRMWIDGET_H
|
|
@ -24,22 +24,23 @@
|
|||
#include <QDragEnterEvent>
|
||||
#include <QBitmap>
|
||||
#include "chatform.h"
|
||||
#include "src/historykeeper.h"
|
||||
#include "src/widget/form/loadhistorydialog.h"
|
||||
#include "src/friend.h"
|
||||
#include "src/widget/friendwidget.h"
|
||||
#include "src/filetransferinstance.h"
|
||||
#include "src/widget/tool/chatactions/filetransferaction.h"
|
||||
#include "src/widget/netcamview.h"
|
||||
#include "src/widget/chatareawidget.h"
|
||||
#include "src/widget/tool/chattextedit.h"
|
||||
#include "src/core.h"
|
||||
#include "src/widget/widget.h"
|
||||
#include "src/widget/maskablepixmapwidget.h"
|
||||
#include "src/widget/croppinglabel.h"
|
||||
#include "src/friend.h"
|
||||
#include "src/filetransferinstance.h"
|
||||
#include "src/historykeeper.h"
|
||||
#include "src/misc/style.h"
|
||||
#include "src/misc/settings.h"
|
||||
#include "src/misc/cstring.h"
|
||||
#include "src/widget/callconfirmwidget.h"
|
||||
#include "src/widget/friendwidget.h"
|
||||
#include "src/widget/netcamview.h"
|
||||
#include "src/widget/chatareawidget.h"
|
||||
#include "src/widget/form/loadhistorydialog.h"
|
||||
#include "src/widget/tool/chattextedit.h"
|
||||
#include "src/widget/tool/chatactions/filetransferaction.h"
|
||||
#include "src/widget/widget.h"
|
||||
#include "src/widget/maskablepixmapwidget.h"
|
||||
#include "src/widget/croppinglabel.h"
|
||||
|
||||
ChatForm::ChatForm(Friend* chatFriend)
|
||||
: f(chatFriend)
|
||||
|
@ -54,6 +55,8 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
statusMessageLabel->setFont(Style::getFont(Style::Medium));
|
||||
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
||||
|
||||
callConfirm = nullptr;
|
||||
|
||||
isTypingLabel = new QLabel();
|
||||
QFont font = isTypingLabel->font();
|
||||
font.setItalic(true);
|
||||
|
@ -97,6 +100,7 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
ChatForm::~ChatForm()
|
||||
{
|
||||
delete netcam;
|
||||
delete callConfirm;
|
||||
}
|
||||
|
||||
void ChatForm::setStatusMessage(QString newMessage)
|
||||
|
@ -261,6 +265,12 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
|
|||
|
||||
qDebug() << "onAvInvite";
|
||||
|
||||
callConfirm = new CallConfirmWidget(callButton);
|
||||
if (isVisible())
|
||||
callConfirm->show();
|
||||
connect(callConfirm, SIGNAL(accepted()), this, SLOT(onAnswerCallTriggered()));
|
||||
connect(callConfirm, SIGNAL(rejected()), this, SLOT(onRejectCallTriggered()));
|
||||
|
||||
callId = CallId;
|
||||
callButton->disconnect();
|
||||
videoButton->disconnect();
|
||||
|
@ -329,12 +339,14 @@ void ChatForm::onAvStart(int FriendId, int CallId, bool video)
|
|||
|
||||
void ChatForm::onAvCancel(int FriendId, int)
|
||||
{
|
||||
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
||||
qDebug() << "onAvCancel";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
stopCounter();
|
||||
|
||||
audioInputFlag = false;
|
||||
|
@ -364,6 +376,9 @@ void ChatForm::onAvEnd(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvEnd";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -452,6 +467,9 @@ void ChatForm::onAvEnding(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvEnding";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -481,6 +499,9 @@ void ChatForm::onAvRequestTimeout(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvRequestTimeout";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -508,6 +529,9 @@ void ChatForm::onAvPeerTimeout(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvPeerTimeout";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -535,6 +559,9 @@ void ChatForm::onAvRejected(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvRejected";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -578,6 +605,12 @@ void ChatForm::onAnswerCallTriggered()
|
|||
{
|
||||
qDebug() << "onAnswerCallTriggered";
|
||||
|
||||
if (callConfirm)
|
||||
{
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
}
|
||||
|
||||
audioInputFlag = true;
|
||||
audioOutputFlag = true;
|
||||
emit answerCall(callId);
|
||||
|
@ -596,6 +629,25 @@ void ChatForm::onHangupCallTriggered()
|
|||
volButton->style()->polish(volButton);
|
||||
}
|
||||
|
||||
void ChatForm::onRejectCallTriggered()
|
||||
{
|
||||
qDebug() << "onRejectCallTriggered";
|
||||
|
||||
if (callConfirm)
|
||||
{
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
}
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
emit rejectCall(callId);
|
||||
micButton->setObjectName("green");
|
||||
micButton->style()->polish(micButton);
|
||||
volButton->setObjectName("green");
|
||||
volButton->style()->polish(volButton);
|
||||
}
|
||||
|
||||
void ChatForm::onCallTriggered()
|
||||
{
|
||||
qDebug() << "onCallTriggered";
|
||||
|
@ -625,6 +677,9 @@ void ChatForm::onAvCallFailed(int FriendId)
|
|||
|
||||
qDebug() << "onAvCallFailed";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
callButton->disconnect();
|
||||
|
@ -947,3 +1002,17 @@ void ChatForm::deliverOfflineMsgs()
|
|||
registerReceipt(rec, iter.key(), iter.value());
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::show(Ui::MainWindow &ui)
|
||||
{
|
||||
GenericChatForm::show(ui);
|
||||
|
||||
if (callConfirm)
|
||||
callConfirm->show();
|
||||
}
|
||||
|
||||
void ChatForm::hideEvent(QHideEvent*)
|
||||
{
|
||||
if (callConfirm)
|
||||
callConfirm->hide();
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ struct Friend;
|
|||
class FileTransferInstance;
|
||||
class NetCamView;
|
||||
class QPixmap;
|
||||
class CallConfirmWidget;
|
||||
class QHideEvent;
|
||||
class QMoveEvent;
|
||||
|
||||
class ChatForm : public GenericChatForm
|
||||
{
|
||||
|
@ -41,6 +44,8 @@ public:
|
|||
void dischargeReceipt(int receipt);
|
||||
void setFriendTyping(bool isTyping);
|
||||
|
||||
virtual void show(Ui::MainWindow &ui);
|
||||
|
||||
signals:
|
||||
void sendFile(int32_t friendId, QString, QString, long long);
|
||||
void startCall(int friendId);
|
||||
|
@ -48,6 +53,7 @@ signals:
|
|||
void answerCall(int callId);
|
||||
void hangupCall(int callId);
|
||||
void cancelCall(int callId, int friendId);
|
||||
void rejectCall(int callId);
|
||||
void micMuteToggle(int callId);
|
||||
void volMuteToggle(int callId);
|
||||
void aliasChanged(const QString& alias);
|
||||
|
@ -83,6 +89,7 @@ private slots:
|
|||
void onAnswerCallTriggered();
|
||||
void onHangupCallTriggered();
|
||||
void onCancelCallTriggered();
|
||||
void onRejectCallTriggered();
|
||||
void onFileTansBtnClicked(QString widgetName, QString buttonName);
|
||||
void onFileSendFailed(int FriendId, const QString &fname);
|
||||
void onLoadHistory();
|
||||
|
@ -92,6 +99,7 @@ protected:
|
|||
// drag & drop
|
||||
void dragEnterEvent(QDragEnterEvent* ev);
|
||||
void dropEvent(QDropEvent* ev);
|
||||
virtual void hideEvent(QHideEvent* event);
|
||||
void registerReceipt(int receipt, int messageID, MessageActionPtr msg);
|
||||
|
||||
private:
|
||||
|
@ -111,6 +119,7 @@ private:
|
|||
QString secondsToDHMS(quint32 duration);
|
||||
QHash<int, int> receipts;
|
||||
QMap<int, MessageActionPtr> undeliveredMsgs;
|
||||
CallConfirmWidget *callConfirm;
|
||||
};
|
||||
|
||||
#endif // CHATFORM_H
|
||||
|
|
|
@ -679,6 +679,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
connect(newfriend->getChatForm(), SIGNAL(sendFile(int32_t, QString, QString, long long)), core, SLOT(sendFile(int32_t, QString, QString, long long)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(hangupCall(int)), core, SLOT(hangupCall(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(rejectCall(int)), core, SLOT(rejectCall(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(startCall(int)), core, SLOT(startCall(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(startVideoCall(int,bool)), core, SLOT(startCall(int,bool)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(cancelCall(int,int)), core, SLOT(cancelCall(int,int)));
|
||||
|
|
Loading…
Reference in New Issue
Block a user