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

Preparation for audio calls, refactoring

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-06-27 00:42:45 +02:00
parent fc8d3c6624
commit 17cca2e3cd
38 changed files with 359 additions and 307 deletions

64
cdata.cpp Normal file
View File

@ -0,0 +1,64 @@
#include "cdata.h"
// CData
CData::CData(const QString &data, uint16_t byteSize)
{
cData = new uint8_t[byteSize];
cDataSize = fromString(data, cData);
}
CData::~CData()
{
delete[] cData;
}
uint8_t* CData::data()
{
return cData;
}
uint16_t CData::size()
{
return cDataSize;
}
QString CData::toString(const uint8_t *cData, const uint16_t cDataSize)
{
return QString(QByteArray(reinterpret_cast<const char*>(cData), cDataSize).toHex()).toUpper();
}
uint16_t CData::fromString(const QString& data, uint8_t* cData)
{
QByteArray arr = QByteArray::fromHex(data.toLower().toLatin1());
memcpy(cData, reinterpret_cast<uint8_t*>(arr.data()), arr.size());
return arr.size();
}
// CUserId
CUserId::CUserId(const QString &userId) :
CData(userId, SIZE)
{
// intentionally left empty
}
QString CUserId::toString(const uint8_t* cUserId)
{
return CData::toString(cUserId, SIZE);
}
// CFriendAddress
CFriendAddress::CFriendAddress(const QString &friendAddress) :
CData(friendAddress, SIZE)
{
// intentionally left empty
}
QString CFriendAddress::toString(const uint8_t *cFriendAddress)
{
return CData::toString(cFriendAddress, SIZE);
}

51
cdata.h Normal file
View File

@ -0,0 +1,51 @@
#ifndef CDATA_H
#define CDATA_H
#include <cstdint>
#include <QString>
#include "tox/tox.h"
class CData
{
public:
uint8_t* data();
uint16_t size();
protected:
explicit CData(const QString& data, uint16_t byteSize);
virtual ~CData();
static QString toString(const uint8_t* cData, const uint16_t cDataSize);
private:
uint8_t* cData;
uint16_t cDataSize;
static uint16_t fromString(const QString& userId, uint8_t* cData);
};
class CUserId : public CData
{
public:
explicit CUserId(const QString& userId);
static QString toString(const uint8_t *cUserId);
private:
static const uint16_t SIZE = TOX_CLIENT_ID_SIZE;
};
class CFriendAddress : public CData
{
public:
explicit CFriendAddress(const QString& friendAddress);
static QString toString(const uint8_t* cFriendAddress);
private:
static const uint16_t SIZE = TOX_FRIEND_ADDRESS_SIZE;
};
#endif // CDATA_H

196
core.cpp
View File

@ -15,6 +15,8 @@
*/ */
#include "core.h" #include "core.h"
#include "cdata.h"
#include "cstring.h"
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
@ -31,6 +33,7 @@
#define TOX_SAVE_INTERVAL 30*1000 #define TOX_SAVE_INTERVAL 30*1000
#define TOX_FILE_INTERVAL 20 #define TOX_FILE_INTERVAL 20
#define TOX_BOOTSTRAP_INTERVAL 10*1000 #define TOX_BOOTSTRAP_INTERVAL 10*1000
#define TOXAV_MAX_CALLS 32
const QString Core::CONFIG_FILE_NAME = "tox_save"; const QString Core::CONFIG_FILE_NAME = "tox_save";
QList<ToxFile> Core::fileSendQueue; QList<ToxFile> Core::fileSendQueue;
@ -58,10 +61,62 @@ Core::~Core()
{ {
if (tox) { if (tox) {
saveConfiguration(); saveConfiguration();
toxav_kill(toxav);
tox_kill(tox); tox_kill(tox);
} }
} }
void Core::start()
{
tox = tox_new(1);
if (tox == nullptr)
{
qCritical() << "Tox core failed to start";
emit failedToStart();
return;
}
toxav = toxav_new(tox, TOXAV_MAX_CALLS);
if (toxav == nullptr)
{
qCritical() << "Toxav core failed to start";
emit failedToStart();
return;
}
loadConfiguration();
tox_callback_friend_request(tox, onFriendRequest, this);
tox_callback_friend_message(tox, onFriendMessage, this);
tox_callback_friend_action(tox, onAction, this);
tox_callback_name_change(tox, onFriendNameChange, this);
tox_callback_typing_change(tox, onFriendTypingChange, this);
tox_callback_status_message(tox, onStatusMessageChanged, this);
tox_callback_user_status(tox, onUserStatusChanged, this);
tox_callback_connection_status(tox, onConnectionStatusChanged, this);
tox_callback_group_invite(tox, onGroupInvite, this);
tox_callback_group_message(tox, onGroupMessage, this);
tox_callback_group_namelist_change(tox, onGroupNamelistChange, this);
tox_callback_file_send_request(tox, onFileSendRequestCallback, this);
tox_callback_file_control(tox, onFileControlCallback, this);
tox_callback_file_data(tox, onFileDataCallback, this);
uint8_t friendAddress[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(tox, friendAddress);
emit friendAddressGenerated(CFriendAddress::toString(friendAddress));
CString cUsername(Settings::getInstance().getUsername());
tox_set_name(tox, cUsername.data(), cUsername.size());
CString cStatusMessage(Settings::getInstance().getStatusMessage());
tox_set_status_message(tox, cStatusMessage.data(), cStatusMessage.size());
bootstrapDht();
toxTimer->start(tox_do_interval(tox));
}
void Core::onBootstrapTimer() void Core::onBootstrapTimer()
{ {
if(!tox_isconnected(tox)) if(!tox_isconnected(tox))
@ -680,48 +735,6 @@ void Core::checkLastOnline(int friendId) {
} }
} }
void Core::start()
{
tox = tox_new(1);
if (tox == nullptr) {
qCritical() << "Core failed to start";
emit failedToStart();
return;
}
loadConfiguration();
tox_callback_friend_request(tox, onFriendRequest, this);
tox_callback_friend_message(tox, onFriendMessage, this);
tox_callback_friend_action(tox, onAction, this);
tox_callback_name_change(tox, onFriendNameChange, this);
tox_callback_typing_change(tox, onFriendTypingChange, this);
tox_callback_status_message(tox, onStatusMessageChanged, this);
tox_callback_user_status(tox, onUserStatusChanged, this);
tox_callback_connection_status(tox, onConnectionStatusChanged, this);
tox_callback_group_invite(tox, onGroupInvite, this);
tox_callback_group_message(tox, onGroupMessage, this);
tox_callback_group_namelist_change(tox, onGroupNamelistChange, this);
tox_callback_file_send_request(tox, onFileSendRequestCallback, this);
tox_callback_file_control(tox, onFileControlCallback, this);
tox_callback_file_data(tox, onFileDataCallback, this);
uint8_t friendAddress[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(tox, friendAddress);
emit friendAddressGenerated(CFriendAddress::toString(friendAddress));
CString cUsername(Settings::getInstance().getUsername());
tox_set_name(tox, cUsername.data(), cUsername.size());
CString cStatusMessage(Settings::getInstance().getStatusMessage());
tox_set_status_message(tox, cStatusMessage.data(), cStatusMessage.size());
bootstrapDht();
toxTimer->start(tox_do_interval(tox));
}
int Core::getGroupNumberPeers(int groupId) const int Core::getGroupNumberPeers(int groupId) const
{ {
return tox_group_number_peers(tox, groupId); return tox_group_number_peers(tox, groupId);
@ -768,105 +781,6 @@ int Core::joinGroupchat(int32_t friendnumber, uint8_t* friend_group_public_key)
return tox_join_groupchat(tox, friendnumber, friend_group_public_key); return tox_join_groupchat(tox, friendnumber, friend_group_public_key);
} }
// CData
Core::CData::CData(const QString &data, uint16_t byteSize)
{
cData = new uint8_t[byteSize];
cDataSize = fromString(data, cData);
}
Core::CData::~CData()
{
delete[] cData;
}
uint8_t* Core::CData::data()
{
return cData;
}
uint16_t Core::CData::size()
{
return cDataSize;
}
QString Core::CData::toString(const uint8_t *cData, const uint16_t cDataSize)
{
return QString(QByteArray(reinterpret_cast<const char*>(cData), cDataSize).toHex()).toUpper();
}
uint16_t Core::CData::fromString(const QString& data, uint8_t* cData)
{
QByteArray arr = QByteArray::fromHex(data.toLower().toLatin1());
memcpy(cData, reinterpret_cast<uint8_t*>(arr.data()), arr.size());
return arr.size();
}
// CUserId
Core::CUserId::CUserId(const QString &userId) :
CData(userId, SIZE)
{
// intentionally left empty
}
QString Core::CUserId::toString(const uint8_t* cUserId)
{
return CData::toString(cUserId, SIZE);
}
// CFriendAddress
Core::CFriendAddress::CFriendAddress(const QString &friendAddress) :
CData(friendAddress, SIZE)
{
// intentionally left empty
}
QString Core::CFriendAddress::toString(const uint8_t *cFriendAddress)
{
return CData::toString(cFriendAddress, SIZE);
}
// CString
Core::CString::CString(const QString& string)
{
cString = new uint8_t[string.length() * MAX_SIZE_OF_UTF8_ENCODED_CHARACTER]();
cStringSize = fromString(string, cString);
}
Core::CString::~CString()
{
delete[] cString;
}
uint8_t* Core::CString::data()
{
return cString;
}
uint16_t Core::CString::size()
{
return cStringSize;
}
QString Core::CString::toString(const uint8_t* cString, uint16_t cStringSize)
{
return QString::fromUtf8(reinterpret_cast<const char*>(cString), cStringSize);
}
uint16_t Core::CString::fromString(const QString& string, uint8_t* cString)
{
QByteArray byteArray = QByteArray(string.toUtf8());
memcpy(cString, reinterpret_cast<uint8_t*>(byteArray.data()), byteArray.size());
return byteArray.size();
}
void Core::quitGroupChat(int groupId) const void Core::quitGroupChat(int groupId) const
{ {
tox_del_groupchat(tox, groupId); tox_del_groupchat(tox, groupId);

143
core.h
View File

@ -20,6 +20,7 @@
#include "status.h" #include "status.h"
#include <tox/tox.h> #include <tox/tox.h>
#include <tox/toxav.h>
#include <cstdint> #include <cstdint>
#include <QDateTime> #include <QDateTime>
@ -76,108 +77,6 @@ public:
explicit Core(); explicit Core();
~Core(); ~Core();
private:
static void onFriendRequest(Tox* tox, const uint8_t* cUserId, const uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onFriendMessage(Tox* tox, int friendId, uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onFriendNameChange(Tox* tox, int friendId, uint8_t* cName, uint16_t cNameSize, void* core);
static void onFriendTypingChange(Tox* tox, int friendId, uint8_t isTyping, void* core);
static void onStatusMessageChanged(Tox* tox, int friendId, uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onUserStatusChanged(Tox* tox, int friendId, uint8_t userstatus, void* core);
static void onConnectionStatusChanged(Tox* tox, int friendId, uint8_t status, void* core);
static void onAction(Tox* tox, int friendId, uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onGroupInvite(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata);
static void onGroupMessage(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata);
static void onGroupNamelistChange(Tox *tox, int groupnumber, int peernumber, uint8_t change, void *userdata);
static void onFileSendRequestCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize,
uint8_t *filename, uint16_t filename_length, void *userdata);
static void onFileControlCallback(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
uint8_t control_type, uint8_t *data, uint16_t length, void *core);
static void onFileDataCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata);
void checkConnection();
void onBootstrapTimer();
void loadConfiguration();
void saveConfiguration();
void loadFriends();
static void sendAllFileData(Core* core, ToxFile* file);
static void removeFileFromQueue(bool sendQueue, int friendId, int fileId);
void checkLastOnline(int friendId);
Tox* tox;
QTimer *toxTimer, *saveTimer, *fileTimer, *bootstrapTimer;
QList<DhtServer> dhtServerList;
int dhtServerId;
static QList<ToxFile> fileSendQueue, fileRecvQueue;
static const QString CONFIG_FILE_NAME;
class CData
{
public:
uint8_t* data();
uint16_t size();
protected:
explicit CData(const QString& data, uint16_t byteSize);
virtual ~CData();
static QString toString(const uint8_t* cData, const uint16_t cDataSize);
private:
uint8_t* cData;
uint16_t cDataSize;
static uint16_t fromString(const QString& userId, uint8_t* cData);
};
class CUserId : public CData
{
public:
explicit CUserId(const QString& userId);
static QString toString(const uint8_t *cUserId);
private:
static const uint16_t SIZE = TOX_CLIENT_ID_SIZE;
};
class CFriendAddress : public CData
{
public:
explicit CFriendAddress(const QString& friendAddress);
static QString toString(const uint8_t* cFriendAddress);
private:
static const uint16_t SIZE = TOX_FRIEND_ADDRESS_SIZE;
};
class CString
{
public:
explicit CString(const QString& string);
~CString();
uint8_t* data();
uint16_t size();
static QString toString(const uint8_t* cMessage, const uint16_t cMessageSize);
private:
const static int MAX_SIZE_OF_UTF8_ENCODED_CHARACTER = 4;
uint8_t* cString;
uint16_t cStringSize;
static uint16_t fromString(const QString& message, uint8_t* cMessage);
};
public:
int getGroupNumberPeers(int groupId) const; int getGroupNumberPeers(int groupId) const;
QString getGroupPeerName(int groupId, int peerId) const; QString getGroupPeerName(int groupId, int peerId) const;
QList<QString> getGroupPeerNames(int groupId) const; QList<QString> getGroupPeerNames(int groupId) const;
@ -266,6 +165,46 @@ signals:
void fileTransferFinished(ToxFile file); void fileTransferFinished(ToxFile file);
void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction); void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction);
void fileTransferInfo(int FriendId, int FileNum, int Filesize, int BytesSent, ToxFile::FileDirection direction); void fileTransferInfo(int FriendId, int FileNum, int Filesize, int BytesSent, ToxFile::FileDirection direction);
private:
static void onFriendRequest(Tox* tox, const uint8_t* cUserId, const uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onFriendMessage(Tox* tox, int friendId, uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onFriendNameChange(Tox* tox, int friendId, uint8_t* cName, uint16_t cNameSize, void* core);
static void onFriendTypingChange(Tox* tox, int friendId, uint8_t isTyping, void* core);
static void onStatusMessageChanged(Tox* tox, int friendId, uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onUserStatusChanged(Tox* tox, int friendId, uint8_t userstatus, void* core);
static void onConnectionStatusChanged(Tox* tox, int friendId, uint8_t status, void* core);
static void onAction(Tox* tox, int friendId, uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onGroupInvite(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata);
static void onGroupMessage(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata);
static void onGroupNamelistChange(Tox *tox, int groupnumber, int peernumber, uint8_t change, void *userdata);
static void onFileSendRequestCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize,
uint8_t *filename, uint16_t filename_length, void *userdata);
static void onFileControlCallback(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
uint8_t control_type, uint8_t *data, uint16_t length, void *core);
static void onFileDataCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata);
void checkConnection();
void onBootstrapTimer();
void loadConfiguration();
void saveConfiguration();
void loadFriends();
static void sendAllFileData(Core* core, ToxFile* file);
static void removeFileFromQueue(bool sendQueue, int friendId, int fileId);
void checkLastOnline(int friendId);
private:
Tox* tox;
ToxAv* toxav;
QTimer *toxTimer, *saveTimer, *fileTimer, *bootstrapTimer;
QList<DhtServer> dhtServerList;
int dhtServerId;
static QList<ToxFile> fileSendQueue, fileRecvQueue;
static const QString CONFIG_FILE_NAME;
}; };
#endif // CORE_HPP #endif // CORE_HPP

34
cstring.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "cstring.h"
CString::CString(const QString& string)
{
cString = new uint8_t[string.length() * MAX_SIZE_OF_UTF8_ENCODED_CHARACTER]();
cStringSize = fromString(string, cString);
}
CString::~CString()
{
delete[] cString;
}
uint8_t* CString::data()
{
return cString;
}
uint16_t CString::size()
{
return cStringSize;
}
QString CString::toString(const uint8_t* cString, uint16_t cStringSize)
{
return QString::fromUtf8(reinterpret_cast<const char*>(cString), cStringSize);
}
uint16_t CString::fromString(const QString& string, uint8_t* cString)
{
QByteArray byteArray = QByteArray(string.toUtf8());
memcpy(cString, reinterpret_cast<uint8_t*>(byteArray.data()), byteArray.size());
return byteArray.size();
}

26
cstring.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef CSTRING_H
#define CSTRING_H
#include <cstdint>
#include <QString>
class CString
{
public:
explicit CString(const QString& string);
~CString();
uint8_t* data();
uint16_t size();
static QString toString(const uint8_t* cMessage, const uint16_t cMessageSize);
private:
const static int MAX_SIZE_OF_UTF8_ENCODED_CHARACTER = 4;
uint8_t* cString;
uint16_t cStringSize;
static uint16_t fromString(const QString& message, uint8_t* cMessage);
};
#endif // CSTRING_H

View File

@ -1,6 +1,6 @@
#include "friend.h" #include "friend.h"
#include "friendlist.h" #include "friendlist.h"
#include "friendwidget.h" #include "widget/friendwidget.h"
Friend::Friend(int FriendId, QString UserId) Friend::Friend(int FriendId, QString UserId)
: friendId(FriendId), userId(UserId) : friendId(FriendId), userId(UserId)

View File

@ -2,7 +2,7 @@
#define FRIEND_H #define FRIEND_H
#include <QString> #include <QString>
#include "chatform.h" #include "widget/form/chatform.h"
class FriendWidget; class FriendWidget;

View File

@ -1,9 +1,9 @@
#include "group.h" #include "group.h"
#include "groupwidget.h" #include "widget/groupwidget.h"
#include "groupchatform.h" #include "widget/form/groupchatform.h"
#include "friendlist.h" #include "friendlist.h"
#include "friend.h" #include "friend.h"
#include "widget.h" #include "widget/widget.h"
#include "core.h" #include "core.h"
#include <QDebug> #include <QDebug>

View File

@ -11,51 +11,29 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = toxgui TARGET = toxgui
TEMPLATE = app TEMPLATE = app
HEADERS += widget/form/addfriendform.h \
SOURCES += main.cpp\ widget/form/chatform.h \
widget.cpp \ widget/form/groupchatform.h \
core.cpp \ widget/form/settingsform.h \
status.cpp \ widget/tool/chattextedit.h \
settings.cpp \ widget/tool/copyableelidelabel.h \
addfriendform.cpp \ widget/tool/editablelabelwidget.h \
settingsform.cpp \ widget/tool/elidelabel.h \
editablelabelwidget.cpp \ widget/tool/esclineedit.h \
copyableelidelabel.cpp \ widget/tool/friendrequestdialog.h \
elidelabel.cpp \ widget/filetransfertwidget.h \
esclineedit.cpp \ widget/friendwidget.h \
friendlist.cpp \ widget/groupwidget.h \
friend.cpp \ widget/widget.h \
chatform.cpp \
chattextedit.cpp \
friendrequestdialog.cpp \
friendwidget.cpp \
groupwidget.cpp \
group.cpp \
grouplist.cpp \
groupchatform.cpp \
filetransfertwidget.cpp
HEADERS += widget.h \
core.h \
status.h \
settings.h \
addfriendform.h \
settingsform.h \
editablelabelwidget.h \
elidelabel.h \
copyableelidelabel.h \
esclineedit.h \
friendlist.h \
friend.h \ friend.h \
chatform.h \
chattextedit.h \
friendrequestdialog.h \
friendwidget.h \
groupwidget.h \
group.h \ group.h \
grouplist.h \ grouplist.h \
groupchatform.h \ settings.h \
filetransfertwidget.h status.h \
core.h \
friendlist.h \
cdata.h \
cstring.h
FORMS += widget.ui FORMS += widget.ui
@ -64,4 +42,30 @@ CONFIG += c++11
RESOURCES += \ RESOURCES += \
res.qrc res.qrc
LIBS += -ltoxcore -lsodium LIBS += -ltoxcore -ltoxav -lsodium
SOURCES += \
widget/form/addfriendform.cpp \
widget/form/chatform.cpp \
widget/form/groupchatform.cpp \
widget/form/settingsform.cpp \
widget/tool/chattextedit.cpp \
widget/tool/copyableelidelabel.cpp \
widget/tool/editablelabelwidget.cpp \
widget/tool/elidelabel.cpp \
widget/tool/esclineedit.cpp \
widget/tool/friendrequestdialog.cpp \
widget/filetransfertwidget.cpp \
widget/friendwidget.cpp \
widget/groupwidget.cpp \
widget/widget.cpp \
core.cpp \
friend.cpp \
friendlist.cpp \
group.cpp \
grouplist.cpp \
main.cpp \
settings.cpp \
status.cpp \
cdata.cpp \
cstring.cpp

View File

@ -1,8 +1,8 @@
#include "chatform.h" #include "chatform.h"
#include "friend.h" #include "friend.h"
#include "friendwidget.h" #include "widget/friendwidget.h"
#include "widget.h" #include "widget/widget.h"
#include "filetransfertwidget.h" #include "widget/filetransfertwidget.h"
#include <QFont> #include <QFont>
#include <QTime> #include <QTime>
#include <QScrollBar> #include <QScrollBar>
@ -17,7 +17,7 @@ ChatForm::ChatForm(Friend* chatFriend)
headTextLayout = new QVBoxLayout(), mainLayout = new QVBoxLayout(); headTextLayout = new QVBoxLayout(), mainLayout = new QVBoxLayout();
mainChatLayout = new QGridLayout(); mainChatLayout = new QGridLayout();
msgEdit = new ChatTextEdit(); msgEdit = new ChatTextEdit();
sendButton = new QPushButton(), fileButton = new QPushButton(); sendButton = new QPushButton(), fileButton = new QPushButton(), callButton = new QPushButton();
chatArea = new QScrollArea(); chatArea = new QScrollArea();
QFont bold; QFont bold;
@ -48,6 +48,12 @@ ChatForm::ChatForm(Friend* chatFriend)
fileButton->setAutoFillBackground(true); fileButton->setAutoFillBackground(true);
fileButton->setIconSize(QSize(20,20)); fileButton->setIconSize(QSize(20,20));
fileButton->setFixedSize(50,40); fileButton->setFixedSize(50,40);
callButton->setIcon(QIcon("img/button icons/call_2x.png"));
callButton->setFlat(true);
callButton->setPalette(toxgreen);
callButton->setAutoFillBackground(true);
callButton->setIconSize(QSize(20,20));
callButton->setFixedSize(50,40);
main->setLayout(mainLayout); main->setLayout(mainLayout);
mainLayout->addWidget(chatArea); mainLayout->addWidget(chatArea);
@ -61,6 +67,7 @@ ChatForm::ChatForm(Friend* chatFriend)
headLayout->addWidget(avatar); headLayout->addWidget(avatar);
headLayout->addLayout(headTextLayout); headLayout->addLayout(headTextLayout);
headLayout->addStretch(); headLayout->addStretch();
headLayout->addWidget(callButton);
headLayout->addWidget(fileButton); headLayout->addWidget(fileButton);
headTextLayout->addStretch(); headTextLayout->addStretch();
@ -248,3 +255,13 @@ void ChatForm::onFileRecvRequest(ToxFile file)
connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransfertWidget::onFileTransferCancelled); connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransfertWidget::onFileTransferCancelled);
connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished); connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished);
} }
void ChatForm::onCallReceived()
{
}
void ChatForm::onCallTriggered()
{
}

View File

@ -10,7 +10,7 @@
#include <QScrollArea> #include <QScrollArea>
#include <QTime> #include <QTime>
#include "chattextedit.h" #include "widget/tool/chattextedit.h"
#include "ui_widget.h" #include "ui_widget.h"
#include "core.h" #include "core.h"
@ -34,16 +34,19 @@ public:
signals: signals:
void sendMessage(int, QString); void sendMessage(int, QString);
void sendFile(int32_t, QString, QByteArray); void sendFile(int32_t friendId, QString, QByteArray);
void startCall(int friendId);
public slots: public slots:
void startFileSend(ToxFile file); void startFileSend(ToxFile file);
void onFileRecvRequest(ToxFile file); void onFileRecvRequest(ToxFile file);
void onCallReceived();
private slots: private slots:
void onSendTriggered(); void onSendTriggered();
void onAttachClicked(); void onAttachClicked();
void onSliderRangeChanged(); void onSliderRangeChanged();
void onCallTriggered();
private: private:
Friend* f; Friend* f;
@ -52,7 +55,7 @@ private:
QGridLayout *mainChatLayout; QGridLayout *mainChatLayout;
QLabel *avatar, *name, *statusMessage; QLabel *avatar, *name, *statusMessage;
ChatTextEdit *msgEdit; ChatTextEdit *msgEdit;
QPushButton *sendButton, *fileButton; QPushButton *sendButton, *fileButton, *callButton;
QScrollArea *chatArea; QScrollArea *chatArea;
QWidget *main, *head, *chatAreaWidget; QWidget *main, *head, *chatAreaWidget;
QString previousName; QString previousName;

View File

@ -1,7 +1,7 @@
#include "groupchatform.h" #include "groupchatform.h"
#include "group.h" #include "group.h"
#include "groupwidget.h" #include "widget/groupwidget.h"
#include "widget.h" #include "widget/widget.h"
#include "friend.h" #include "friend.h"
#include "friendlist.h" #include "friendlist.h"
#include <QFont> #include <QFont>

View File

@ -10,7 +10,7 @@
#include <QScrollArea> #include <QScrollArea>
#include <QTime> #include <QTime>
#include "chattextedit.h" #include "widget/tool/chattextedit.h"
#include "ui_widget.h" #include "ui_widget.h"
// Spacing in px inserted when the author of the last message changes // Spacing in px inserted when the author of the last message changes

View File

@ -3,12 +3,12 @@
#include "settings.h" #include "settings.h"
#include "friend.h" #include "friend.h"
#include "friendlist.h" #include "friendlist.h"
#include "friendrequestdialog.h" #include "widget/tool/friendrequestdialog.h"
#include "friendwidget.h" #include "widget/friendwidget.h"
#include "grouplist.h" #include "grouplist.h"
#include "group.h" #include "group.h"
#include "groupwidget.h" #include "widget/groupwidget.h"
#include "groupchatform.h" #include "widget/form/groupchatform.h"
#include <QMessageBox> #include <QMessageBox>
#include <QDebug> #include <QDebug>

View File

@ -5,8 +5,8 @@
#include <QWidget> #include <QWidget>
#include <QString> #include <QString>
#include "core.h" #include "core.h"
#include "addfriendform.h" #include "widget/form/addfriendform.h"
#include "settingsform.h" #include "widget/form/settingsform.h"
namespace Ui { namespace Ui {
class Widget; class Widget;