diff --git a/cdata.cpp b/cdata.cpp new file mode 100644 index 000000000..120b7bca6 --- /dev/null +++ b/cdata.cpp @@ -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(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(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); +} diff --git a/cdata.h b/cdata.h new file mode 100644 index 000000000..17427e22d --- /dev/null +++ b/cdata.h @@ -0,0 +1,51 @@ +#ifndef CDATA_H +#define CDATA_H + +#include +#include +#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 diff --git a/core.cpp b/core.cpp index f9d4fc36d..c385866d7 100644 --- a/core.cpp +++ b/core.cpp @@ -15,6 +15,8 @@ */ #include "core.h" +#include "cdata.h" +#include "cstring.h" #include #include @@ -31,6 +33,7 @@ #define TOX_SAVE_INTERVAL 30*1000 #define TOX_FILE_INTERVAL 20 #define TOX_BOOTSTRAP_INTERVAL 10*1000 +#define TOXAV_MAX_CALLS 32 const QString Core::CONFIG_FILE_NAME = "tox_save"; QList Core::fileSendQueue; @@ -58,10 +61,62 @@ Core::~Core() { if (tox) { saveConfiguration(); + toxav_kill(toxav); 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() { 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 { 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); } -// 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(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(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(cString), cStringSize); -} - -uint16_t Core::CString::fromString(const QString& string, uint8_t* cString) -{ - QByteArray byteArray = QByteArray(string.toUtf8()); - memcpy(cString, reinterpret_cast(byteArray.data()), byteArray.size()); - return byteArray.size(); -} - void Core::quitGroupChat(int groupId) const { tox_del_groupchat(tox, groupId); diff --git a/core.h b/core.h index bc077d116..2ac62191c 100644 --- a/core.h +++ b/core.h @@ -20,6 +20,7 @@ #include "status.h" #include +#include #include #include @@ -76,108 +77,6 @@ public: explicit 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 dhtServerList; - int dhtServerId; - static QList 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; QString getGroupPeerName(int groupId, int peerId) const; QList getGroupPeerNames(int groupId) const; @@ -266,6 +165,46 @@ signals: void fileTransferFinished(ToxFile file); void fileTransferPaused(int FriendId, int FileNum, 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 dhtServerList; + int dhtServerId; + static QList fileSendQueue, fileRecvQueue; + + static const QString CONFIG_FILE_NAME; }; #endif // CORE_HPP diff --git a/cstring.cpp b/cstring.cpp new file mode 100644 index 000000000..9e2d0efaf --- /dev/null +++ b/cstring.cpp @@ -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(cString), cStringSize); +} + +uint16_t CString::fromString(const QString& string, uint8_t* cString) +{ + QByteArray byteArray = QByteArray(string.toUtf8()); + memcpy(cString, reinterpret_cast(byteArray.data()), byteArray.size()); + return byteArray.size(); +} diff --git a/cstring.h b/cstring.h new file mode 100644 index 000000000..cb15e1305 --- /dev/null +++ b/cstring.h @@ -0,0 +1,26 @@ +#ifndef CSTRING_H +#define CSTRING_H + +#include +#include + +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 diff --git a/friend.cpp b/friend.cpp index 40536ba81..bdb97249d 100644 --- a/friend.cpp +++ b/friend.cpp @@ -1,6 +1,6 @@ #include "friend.h" #include "friendlist.h" -#include "friendwidget.h" +#include "widget/friendwidget.h" Friend::Friend(int FriendId, QString UserId) : friendId(FriendId), userId(UserId) diff --git a/friend.h b/friend.h index dcc636137..d991cd832 100644 --- a/friend.h +++ b/friend.h @@ -2,7 +2,7 @@ #define FRIEND_H #include -#include "chatform.h" +#include "widget/form/chatform.h" class FriendWidget; diff --git a/group.cpp b/group.cpp index 5ac97aef8..1661db9fd 100644 --- a/group.cpp +++ b/group.cpp @@ -1,9 +1,9 @@ #include "group.h" -#include "groupwidget.h" -#include "groupchatform.h" +#include "widget/groupwidget.h" +#include "widget/form/groupchatform.h" #include "friendlist.h" #include "friend.h" -#include "widget.h" +#include "widget/widget.h" #include "core.h" #include diff --git a/toxgui.pro b/toxgui.pro index c4ed196aa..3911304db 100644 --- a/toxgui.pro +++ b/toxgui.pro @@ -11,51 +11,29 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = toxgui TEMPLATE = app - -SOURCES += main.cpp\ - widget.cpp \ - core.cpp \ - status.cpp \ - settings.cpp \ - addfriendform.cpp \ - settingsform.cpp \ - editablelabelwidget.cpp \ - copyableelidelabel.cpp \ - elidelabel.cpp \ - esclineedit.cpp \ - friendlist.cpp \ - friend.cpp \ - 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 \ +HEADERS += widget/form/addfriendform.h \ + widget/form/chatform.h \ + widget/form/groupchatform.h \ + widget/form/settingsform.h \ + widget/tool/chattextedit.h \ + widget/tool/copyableelidelabel.h \ + widget/tool/editablelabelwidget.h \ + widget/tool/elidelabel.h \ + widget/tool/esclineedit.h \ + widget/tool/friendrequestdialog.h \ + widget/filetransfertwidget.h \ + widget/friendwidget.h \ + widget/groupwidget.h \ + widget/widget.h \ friend.h \ - chatform.h \ - chattextedit.h \ - friendrequestdialog.h \ - friendwidget.h \ - groupwidget.h \ group.h \ grouplist.h \ - groupchatform.h \ - filetransfertwidget.h + settings.h \ + status.h \ + core.h \ + friendlist.h \ + cdata.h \ + cstring.h FORMS += widget.ui @@ -64,4 +42,30 @@ CONFIG += c++11 RESOURCES += \ 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 diff --git a/filetransfertwidget.cpp b/widget/filetransfertwidget.cpp similarity index 100% rename from filetransfertwidget.cpp rename to widget/filetransfertwidget.cpp diff --git a/filetransfertwidget.h b/widget/filetransfertwidget.h similarity index 100% rename from filetransfertwidget.h rename to widget/filetransfertwidget.h diff --git a/addfriendform.cpp b/widget/form/addfriendform.cpp similarity index 100% rename from addfriendform.cpp rename to widget/form/addfriendform.cpp diff --git a/addfriendform.h b/widget/form/addfriendform.h similarity index 100% rename from addfriendform.h rename to widget/form/addfriendform.h diff --git a/chatform.cpp b/widget/form/chatform.cpp similarity index 94% rename from chatform.cpp rename to widget/form/chatform.cpp index 7ffcf53a7..5bc81dabd 100644 --- a/chatform.cpp +++ b/widget/form/chatform.cpp @@ -1,8 +1,8 @@ #include "chatform.h" #include "friend.h" -#include "friendwidget.h" -#include "widget.h" -#include "filetransfertwidget.h" +#include "widget/friendwidget.h" +#include "widget/widget.h" +#include "widget/filetransfertwidget.h" #include #include #include @@ -17,7 +17,7 @@ ChatForm::ChatForm(Friend* chatFriend) headTextLayout = new QVBoxLayout(), mainLayout = new QVBoxLayout(); mainChatLayout = new QGridLayout(); msgEdit = new ChatTextEdit(); - sendButton = new QPushButton(), fileButton = new QPushButton(); + sendButton = new QPushButton(), fileButton = new QPushButton(), callButton = new QPushButton(); chatArea = new QScrollArea(); QFont bold; @@ -48,6 +48,12 @@ ChatForm::ChatForm(Friend* chatFriend) fileButton->setAutoFillBackground(true); fileButton->setIconSize(QSize(20,20)); 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); mainLayout->addWidget(chatArea); @@ -61,6 +67,7 @@ ChatForm::ChatForm(Friend* chatFriend) headLayout->addWidget(avatar); headLayout->addLayout(headTextLayout); headLayout->addStretch(); + headLayout->addWidget(callButton); headLayout->addWidget(fileButton); 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::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished); } + +void ChatForm::onCallReceived() +{ + +} + +void ChatForm::onCallTriggered() +{ + +} diff --git a/chatform.h b/widget/form/chatform.h similarity index 85% rename from chatform.h rename to widget/form/chatform.h index 17fec1f63..5e6ac25f9 100644 --- a/chatform.h +++ b/widget/form/chatform.h @@ -10,7 +10,7 @@ #include #include -#include "chattextedit.h" +#include "widget/tool/chattextedit.h" #include "ui_widget.h" #include "core.h" @@ -34,16 +34,19 @@ public: signals: void sendMessage(int, QString); - void sendFile(int32_t, QString, QByteArray); + void sendFile(int32_t friendId, QString, QByteArray); + void startCall(int friendId); public slots: void startFileSend(ToxFile file); void onFileRecvRequest(ToxFile file); + void onCallReceived(); private slots: void onSendTriggered(); void onAttachClicked(); void onSliderRangeChanged(); + void onCallTriggered(); private: Friend* f; @@ -52,7 +55,7 @@ private: QGridLayout *mainChatLayout; QLabel *avatar, *name, *statusMessage; ChatTextEdit *msgEdit; - QPushButton *sendButton, *fileButton; + QPushButton *sendButton, *fileButton, *callButton; QScrollArea *chatArea; QWidget *main, *head, *chatAreaWidget; QString previousName; diff --git a/groupchatform.cpp b/widget/form/groupchatform.cpp similarity index 98% rename from groupchatform.cpp rename to widget/form/groupchatform.cpp index 4904ae077..fa37d5bcc 100644 --- a/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -1,7 +1,7 @@ #include "groupchatform.h" #include "group.h" -#include "groupwidget.h" -#include "widget.h" +#include "widget/groupwidget.h" +#include "widget/widget.h" #include "friend.h" #include "friendlist.h" #include diff --git a/groupchatform.h b/widget/form/groupchatform.h similarity index 97% rename from groupchatform.h rename to widget/form/groupchatform.h index 68faac959..b309ddf10 100644 --- a/groupchatform.h +++ b/widget/form/groupchatform.h @@ -10,7 +10,7 @@ #include #include -#include "chattextedit.h" +#include "widget/tool/chattextedit.h" #include "ui_widget.h" // Spacing in px inserted when the author of the last message changes diff --git a/settingsform.cpp b/widget/form/settingsform.cpp similarity index 100% rename from settingsform.cpp rename to widget/form/settingsform.cpp diff --git a/settingsform.h b/widget/form/settingsform.h similarity index 100% rename from settingsform.h rename to widget/form/settingsform.h diff --git a/friendwidget.cpp b/widget/friendwidget.cpp similarity index 100% rename from friendwidget.cpp rename to widget/friendwidget.cpp diff --git a/friendwidget.h b/widget/friendwidget.h similarity index 100% rename from friendwidget.h rename to widget/friendwidget.h diff --git a/groupwidget.cpp b/widget/groupwidget.cpp similarity index 100% rename from groupwidget.cpp rename to widget/groupwidget.cpp diff --git a/groupwidget.h b/widget/groupwidget.h similarity index 100% rename from groupwidget.h rename to widget/groupwidget.h diff --git a/chattextedit.cpp b/widget/tool/chattextedit.cpp similarity index 100% rename from chattextedit.cpp rename to widget/tool/chattextedit.cpp diff --git a/chattextedit.h b/widget/tool/chattextedit.h similarity index 100% rename from chattextedit.h rename to widget/tool/chattextedit.h diff --git a/copyableelidelabel.cpp b/widget/tool/copyableelidelabel.cpp similarity index 100% rename from copyableelidelabel.cpp rename to widget/tool/copyableelidelabel.cpp diff --git a/copyableelidelabel.h b/widget/tool/copyableelidelabel.h similarity index 100% rename from copyableelidelabel.h rename to widget/tool/copyableelidelabel.h diff --git a/editablelabelwidget.cpp b/widget/tool/editablelabelwidget.cpp similarity index 100% rename from editablelabelwidget.cpp rename to widget/tool/editablelabelwidget.cpp diff --git a/editablelabelwidget.h b/widget/tool/editablelabelwidget.h similarity index 100% rename from editablelabelwidget.h rename to widget/tool/editablelabelwidget.h diff --git a/elidelabel.cpp b/widget/tool/elidelabel.cpp similarity index 100% rename from elidelabel.cpp rename to widget/tool/elidelabel.cpp diff --git a/elidelabel.h b/widget/tool/elidelabel.h similarity index 100% rename from elidelabel.h rename to widget/tool/elidelabel.h diff --git a/esclineedit.cpp b/widget/tool/esclineedit.cpp similarity index 100% rename from esclineedit.cpp rename to widget/tool/esclineedit.cpp diff --git a/esclineedit.h b/widget/tool/esclineedit.h similarity index 100% rename from esclineedit.h rename to widget/tool/esclineedit.h diff --git a/friendrequestdialog.cpp b/widget/tool/friendrequestdialog.cpp similarity index 100% rename from friendrequestdialog.cpp rename to widget/tool/friendrequestdialog.cpp diff --git a/friendrequestdialog.h b/widget/tool/friendrequestdialog.h similarity index 100% rename from friendrequestdialog.h rename to widget/tool/friendrequestdialog.h diff --git a/widget.cpp b/widget/widget.cpp similarity index 98% rename from widget.cpp rename to widget/widget.cpp index 1981b9d73..fa7d12d54 100644 --- a/widget.cpp +++ b/widget/widget.cpp @@ -3,12 +3,12 @@ #include "settings.h" #include "friend.h" #include "friendlist.h" -#include "friendrequestdialog.h" -#include "friendwidget.h" +#include "widget/tool/friendrequestdialog.h" +#include "widget/friendwidget.h" #include "grouplist.h" #include "group.h" -#include "groupwidget.h" -#include "groupchatform.h" +#include "widget/groupwidget.h" +#include "widget/form/groupchatform.h" #include #include diff --git a/widget.h b/widget/widget.h similarity index 97% rename from widget.h rename to widget/widget.h index 868365636..18e66b228 100644 --- a/widget.h +++ b/widget/widget.h @@ -5,8 +5,8 @@ #include #include #include "core.h" -#include "addfriendform.h" -#include "settingsform.h" +#include "widget/form/addfriendform.h" +#include "widget/form/settingsform.h" namespace Ui { class Widget;