mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix: Don't even try to add ourselves as a friend in the Tox URI handler
This commit is contained in:
parent
c75ee8a661
commit
bfda028a2a
@ -79,9 +79,10 @@ bool handleToxURI(const QString &toxURI)
|
|||||||
toxId = Toxme::lookup(toxaddr);
|
toxId = Toxme::lookup(toxaddr);
|
||||||
if (!toxId.isValid())
|
if (!toxId.isValid())
|
||||||
{
|
{
|
||||||
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning, "qTox",
|
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
|
||||||
QMessageBox::tr("%1 is not a valid Toxme address.")
|
QMessageBox::tr("Couldn't add friend"),
|
||||||
.arg(toxaddr), QMessageBox::Ok, nullptr);
|
QMessageBox::tr("%1 is not a valid Toxme address.")
|
||||||
|
.arg(toxaddr), QMessageBox::Ok, nullptr);
|
||||||
messageBox->setButtonText(QMessageBox::Ok, QMessageBox::tr("Ok"));
|
messageBox->setButtonText(QMessageBox::Ok, QMessageBox::tr("Ok"));
|
||||||
QObject::connect(messageBox, &QMessageBox::finished, messageBox, &QMessageBox::deleteLater);
|
QObject::connect(messageBox, &QMessageBox::finished, messageBox, &QMessageBox::deleteLater);
|
||||||
messageBox->show();
|
messageBox->show();
|
||||||
@ -89,6 +90,19 @@ bool handleToxURI(const QString &toxURI)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toxId == core->getSelfId())
|
||||||
|
{
|
||||||
|
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
|
||||||
|
QMessageBox::tr("Couldn't add friend"),
|
||||||
|
QMessageBox::tr("You can't add yourself as a friend!",
|
||||||
|
"When trying to add your own Tox ID as friend"),
|
||||||
|
QMessageBox::Ok, nullptr);
|
||||||
|
messageBox->setButtonText(QMessageBox::Ok, QMessageBox::tr("Ok"));
|
||||||
|
QObject::connect(messageBox, &QMessageBox::finished, messageBox, &QMessageBox::deleteLater);
|
||||||
|
messageBox->show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ToxURIDialog *dialog = new ToxURIDialog(0, toxaddr, QObject::tr("%1 here! Tox me maybe?",
|
ToxURIDialog *dialog = new ToxURIDialog(0, toxaddr, QObject::tr("%1 here! Tox me maybe?",
|
||||||
"Default message in Tox URI friend requests. Write something appropriate!")
|
"Default message in Tox URI friend requests. Write something appropriate!")
|
||||||
.arg(Nexus::getCore()->getUsername()));
|
.arg(Nexus::getCore()->getUsername()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user