mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'newcallmockup'
This commit is contained in:
commit
2c6b457caf
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
|
||||
|
|
2
res.qrc
2
res.qrc
|
@ -227,5 +227,7 @@
|
|||
<file>ui/window/applicationIcon.png</file>
|
||||
<file>ui/window/statusPanel.css</file>
|
||||
<file>ui/window/window.css</file>
|
||||
<file>ui/acceptCall/acceptCall.png</file>
|
||||
<file>ui/rejectCall/rejectCall.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -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)
|
||||
|
|
92
src/widget/callconfirmwidget.cpp
Normal file
92
src/widget/callconfirmwidget.cpp
Normal file
|
@ -0,0 +1,92 @@
|
|||
#include "callconfirmwidget.h"
|
||||
#include "widget.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QRect>
|
||||
#include <QPalette>
|
||||
|
||||
CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor) :
|
||||
QWidget(Widget::getInstance()), anchor(Anchor),
|
||||
rectW{120}, rectH{85},
|
||||
spikeW{30}, spikeH{15},
|
||||
roundedFactor{15}
|
||||
{
|
||||
setWindowFlags(Qt::SubWindow);
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
setPalette(palette);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
QLabel *callLabel = new QLabel(tr("Incoming call..."), this);
|
||||
callLabel->setAlignment(Qt::AlignHCenter);
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
||||
QPushButton *accept = new QPushButton(this), *reject = new QPushButton(this);
|
||||
accept->setFlat(true);
|
||||
reject->setFlat(true);
|
||||
accept->setStyleSheet("QPushButton{border:none;}");
|
||||
reject->setStyleSheet("QPushButton{border:none;}");
|
||||
accept->setIcon(QIcon(":/ui/acceptCall/acceptCall.png"));
|
||||
reject->setIcon(QIcon(":/ui/rejectCall/rejectCall.png"));
|
||||
accept->setIconSize(accept->size());
|
||||
reject->setIconSize(reject->size());
|
||||
|
||||
buttonBox->addButton(accept, QDialogButtonBox::AcceptRole);
|
||||
buttonBox->addButton(reject, QDialogButtonBox::RejectRole);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &CallConfirmWidget::accepted);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &CallConfirmWidget::rejected);
|
||||
|
||||
connect(Widget::getInstance(), &Widget::resized, this, &CallConfirmWidget::reposition);
|
||||
|
||||
layout->setMargin(12);
|
||||
layout->addSpacing(spikeH);
|
||||
layout->addWidget(callLabel);
|
||||
layout->addWidget(buttonBox);
|
||||
|
||||
setFixedSize(rectW,rectH+spikeH);
|
||||
reposition();
|
||||
}
|
||||
|
||||
void CallConfirmWidget::reposition()
|
||||
{
|
||||
Widget* w = Widget::getInstance();
|
||||
QPoint pos = anchor->mapToGlobal({(anchor->width()-rectW)/2,anchor->height()})-w->mapToGlobal({0,0});
|
||||
|
||||
// We don't want the widget to overflow past the right of the screen
|
||||
int xOverflow=0;
|
||||
if (pos.x() + rectW > w->width())
|
||||
xOverflow = pos.x() + rectW - w->width();
|
||||
pos.rx() -= xOverflow;
|
||||
|
||||
mainRect = {0,spikeH,rectW,rectH};
|
||||
brush = QBrush(QColor(65,65,65));
|
||||
spikePoly = QPolygon({{(rectW-spikeW)/2+xOverflow,spikeH},
|
||||
{rectW/2+xOverflow,0},
|
||||
{(rectW+spikeW)/2+xOverflow,spikeH}});
|
||||
|
||||
move(pos);
|
||||
update();
|
||||
}
|
||||
|
||||
void CallConfirmWidget::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setBrush(brush);
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
painter.drawRoundRect(mainRect, roundedFactor, roundedFactor);
|
||||
painter.drawPolygon(spikePoly);
|
||||
}
|
||||
|
||||
void CallConfirmWidget::showEvent(QShowEvent*)
|
||||
{
|
||||
reposition();
|
||||
update();
|
||||
}
|
44
src/widget/callconfirmwidget.h
Normal file
44
src/widget/callconfirmwidget.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef CALLCONFIRMWIDGET_H
|
||||
#define CALLCONFIRMWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QRect>
|
||||
#include <QPolygon>
|
||||
#include <QBrush>
|
||||
|
||||
class QPaintEvent;
|
||||
class QShowEvent;
|
||||
|
||||
/// This is a widget with dialog buttons to accept/reject a call
|
||||
/// It tracks the position of another widget called the anchor
|
||||
/// and looks like a bubble at the bottom of that widget.
|
||||
class CallConfirmWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CallConfirmWidget(const QWidget *Anchor);
|
||||
|
||||
signals:
|
||||
void accepted();
|
||||
void rejected();
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event) override;
|
||||
virtual void showEvent(QShowEvent * event) override;
|
||||
|
||||
protected slots:
|
||||
void reposition(); ///< Recalculate our positions to track the anchor
|
||||
|
||||
private:
|
||||
const QWidget* anchor; ///< The widget we're going to be tracking
|
||||
|
||||
QRect mainRect;
|
||||
QPolygon spikePoly;
|
||||
QBrush brush;
|
||||
|
||||
const int rectW, rectH;
|
||||
const int spikeW, spikeH;
|
||||
const int roundedFactor; ///< By how much are the corners of the main rect rounded
|
||||
};
|
||||
|
||||
#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)
|
||||
|
@ -266,6 +270,12 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
|
|||
videoButton->disconnect();
|
||||
if (video)
|
||||
{
|
||||
callConfirm = new CallConfirmWidget(videoButton);
|
||||
if (isVisible())
|
||||
callConfirm->show();
|
||||
connect(callConfirm, SIGNAL(accepted()), this, SLOT(onAnswerCallTriggered()));
|
||||
connect(callConfirm, SIGNAL(rejected()), this, SLOT(onRejectCallTriggered()));
|
||||
|
||||
callButton->setObjectName("grey");
|
||||
callButton->style()->polish(callButton);
|
||||
videoButton->setObjectName("yellow");
|
||||
|
@ -274,6 +284,12 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
|
|||
}
|
||||
else
|
||||
{
|
||||
callConfirm = new CallConfirmWidget(callButton);
|
||||
if (isVisible())
|
||||
callConfirm->show();
|
||||
connect(callConfirm, SIGNAL(accepted()), this, SLOT(onAnswerCallTriggered()));
|
||||
connect(callConfirm, SIGNAL(rejected()), this, SLOT(onRejectCallTriggered()));
|
||||
|
||||
callButton->setObjectName("yellow");
|
||||
callButton->style()->polish(callButton);
|
||||
videoButton->setObjectName("grey");
|
||||
|
@ -329,12 +345,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 +382,9 @@ void ChatForm::onAvEnd(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvEnd";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -452,6 +473,9 @@ void ChatForm::onAvEnding(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvEnding";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -481,6 +505,9 @@ void ChatForm::onAvRequestTimeout(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvRequestTimeout";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -508,6 +535,9 @@ void ChatForm::onAvPeerTimeout(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvPeerTimeout";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -535,6 +565,9 @@ void ChatForm::onAvRejected(int FriendId, int)
|
|||
|
||||
qDebug() << "onAvRejected";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
micButton->setObjectName("green");
|
||||
|
@ -577,7 +610,13 @@ void ChatForm::onAvMediaChange(int FriendId, int CallId, bool video)
|
|||
void ChatForm::onAnswerCallTriggered()
|
||||
{
|
||||
qDebug() << "onAnswerCallTriggered";
|
||||
|
||||
|
||||
if (callConfirm)
|
||||
{
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
}
|
||||
|
||||
audioInputFlag = true;
|
||||
audioOutputFlag = true;
|
||||
emit answerCall(callId);
|
||||
|
@ -596,10 +635,29 @@ 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";
|
||||
|
||||
|
||||
audioInputFlag = true;
|
||||
audioOutputFlag = true;
|
||||
callButton->disconnect();
|
||||
|
@ -610,7 +668,7 @@ void ChatForm::onCallTriggered()
|
|||
void ChatForm::onVideoCallTriggered()
|
||||
{
|
||||
qDebug() << "onVideoCallTriggered";
|
||||
|
||||
|
||||
audioInputFlag = true;
|
||||
audioOutputFlag = true;
|
||||
callButton->disconnect();
|
||||
|
@ -625,6 +683,9 @@ void ChatForm::onAvCallFailed(int FriendId)
|
|||
|
||||
qDebug() << "onAvCallFailed";
|
||||
|
||||
delete callConfirm;
|
||||
callConfirm = nullptr;
|
||||
|
||||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
callButton->disconnect();
|
||||
|
@ -947,3 +1008,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
|
||||
|
|
|
@ -377,6 +377,8 @@ void Widget::resizeEvent(QResizeEvent *event)
|
|||
{
|
||||
Q_UNUSED(event);
|
||||
saveWindowGeometry();
|
||||
|
||||
emit resized();
|
||||
}
|
||||
|
||||
QString Widget::detectProfile()
|
||||
|
@ -679,6 +681,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)));
|
||||
|
|
|
@ -90,6 +90,7 @@ signals:
|
|||
void usernameChanged(const QString& username);
|
||||
void statusMessageChanged(const QString& statusMessage);
|
||||
void changeProfile(const QString& profile);
|
||||
void resized();
|
||||
|
||||
private slots:
|
||||
void onConnected();
|
||||
|
|
BIN
ui/acceptCall/acceptCall.png
Normal file
BIN
ui/acceptCall/acceptCall.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
ui/rejectCall/rejectCall.png
Normal file
BIN
ui/rejectCall/rejectCall.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in New Issue
Block a user