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

On add friend clicked pastes Tox Id from clipboard if there is one

This commit is contained in:
Rohil Surana 2015-03-27 22:13:25 +05:30
parent 41efb1491b
commit b98af21456
2 changed files with 13 additions and 0 deletions

View File

@ -19,6 +19,7 @@
#include <QFont>
#include <QMessageBox>
#include <QErrorMessage>
#include <QClipboard>
#include <tox/tox.h>
#include "ui_mainwindow.h"
#include "src/nexus.h"
@ -67,6 +68,7 @@ void AddFriendForm::show(Ui::MainWindow &ui)
ui.mainHead->layout()->addWidget(head);
main->show();
head->show();
setIdFromClipboard();
}
QString AddFriendForm::getMessage() const
@ -115,3 +117,13 @@ Ignore the proxy and connect to the Internet directly?"), QMessageBox::Yes|QMess
this->message.clear();
}
}
void AddFriendForm::setIdFromClipboard()
{
QClipboard* clipboard = QApplication::clipboard();
QString id = clipboard->text().trimmed();
if (Core::getInstance()->isReady() && !id.isEmpty() && ToxID::isToxId(id)) {
if (!ToxID::fromString(id).isMine())
toxId.setText(id);
}
}

View File

@ -45,6 +45,7 @@ private slots:
void onSendTriggered();
private:
void setIdFromClipboard();
QLabel headLabel, toxIdLabel, messageLabel;
QPushButton sendButton;
QLineEdit toxId;