mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix #205
This commit is contained in:
parent
5198dd1404
commit
e91846e821
8
core.cpp
8
core.cpp
|
@ -701,6 +701,14 @@ void Core::setUsername(const QString& username)
|
|||
}
|
||||
}
|
||||
|
||||
QString Core::getSelfId()
|
||||
{
|
||||
uint8_t friendAddress[TOX_FRIEND_ADDRESS_SIZE];
|
||||
tox_get_address(tox, friendAddress);
|
||||
|
||||
return CFriendAddress::toString(friendAddress);
|
||||
}
|
||||
|
||||
QString Core::getStatusMessage()
|
||||
{
|
||||
int size = tox_get_self_status_message_size(tox);
|
||||
|
|
1
core.h
1
core.h
|
@ -127,6 +127,7 @@ public:
|
|||
|
||||
QString getUsername();
|
||||
QString getStatusMessage();
|
||||
QString getSelfId();
|
||||
|
||||
void increaseVideoBusyness();
|
||||
void decreaseVideoBusyness();
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <QFont>
|
||||
#include <QMessageBox>
|
||||
#include <tox/tox.h>
|
||||
#include "widget/widget.h"
|
||||
#include "core.h"
|
||||
|
||||
#define TOX_ID_LENGTH 2*TOX_FRIEND_ADDRESS_SIZE
|
||||
|
||||
|
@ -74,6 +76,7 @@ bool AddFriendForm::isToxId(const QString &value) const
|
|||
void AddFriendForm::showWarning(const QString &message) const
|
||||
{
|
||||
QMessageBox warning(main);
|
||||
warning.setWindowTitle("Tox");
|
||||
warning.setText(message);
|
||||
warning.setIcon(QMessageBox::Warning);
|
||||
warning.exec();
|
||||
|
@ -92,6 +95,9 @@ void AddFriendForm::onSendTriggered()
|
|||
if (id.isEmpty()) {
|
||||
showWarning(tr("Please fill in a valid Tox ID","Tox ID of the friend you're sending a friend request to"));
|
||||
} else if (isToxId(id)) {
|
||||
if (id.toUpper() == Widget::getInstance()->getCore()->getSelfId().toUpper())
|
||||
showWarning(tr("You can't add yourself as a friend !","When trying to add your own Tox ID as friend"));
|
||||
else
|
||||
emit friendRequested(id, getMessage());
|
||||
this->toxId.setText("");
|
||||
this->message.setText("");
|
||||
|
|
|
@ -404,7 +404,8 @@ void Widget::setStatusMessage(const QString &statusMessage)
|
|||
|
||||
void Widget::addFriend(int friendId, const QString &userId)
|
||||
{
|
||||
qDebug() << "Adding friend with id "+userId;
|
||||
|
||||
qDebug() << "Widget: Adding friend with id "+userId;
|
||||
Friend* newfriend = FriendList::addFriend(friendId, userId);
|
||||
QLayout* layout = contactListWidget->getFriendLayout(Status::Offline);
|
||||
layout->addWidget(newfriend->widget);
|
||||
|
|
Loading…
Reference in New Issue
Block a user