24 #include <QCoreApplication>
25 #include <QDialogButtonBox>
28 #include <QMessageBox>
29 #include <QPlainTextEdit>
30 #include <QPushButton>
33 #include <QVBoxLayout>
43 QString toxaddr = toxURI.mid(4);
46 QString error = QString();
48 error = QMessageBox::tr(
"%1 is not a valid Tox address.").arg(toxaddr);
50 error = QMessageBox::tr(
"You can't add yourself as a friend!",
51 "When trying to add your own Tox ID as friend");
54 if (!error.isEmpty()) {
62 if (result == QDialog::Accepted) {
71 friendsLabel->setText(tr(
"Do you want to add %1 as a friend?").arg(userId));
79 const QString defaultMessage =
80 QObject::tr(
"%1 here! Tox me maybe?",
81 "Default message in Tox URI friend requests. Write something appropriate!");
82 const QString username = core.getUsername();
83 const QString
message = defaultMessage.arg(username);
85 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
86 setWindowTitle(tr(
"Add a friend",
"Title of the window to add a friend through Tox URI"));
88 friendsLabel =
new QLabel(
"",
this);
89 userIdEdit =
new QLineEdit(
"",
this);
90 userIdEdit->setCursorPosition(0);
91 userIdEdit->setReadOnly(
true);
93 QLabel* userIdLabel =
new QLabel(tr(
"User ID:"),
this);
94 QLabel* messageLabel =
new QLabel(tr(
"Friend request message:"),
this);
95 messageEdit =
new QPlainTextEdit(message,
this);
97 QDialogButtonBox* buttonBox =
new QDialogButtonBox(Qt::Horizontal,
this);
99 buttonBox->addButton(tr(
"Send",
"Send a friend request"), QDialogButtonBox::AcceptRole);
100 buttonBox->addButton(tr(
"Cancel",
"Don't send a friend request"), QDialogButtonBox::RejectRole);
102 connect(buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept);
103 connect(buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
105 QVBoxLayout* layout =
new QVBoxLayout(
this);
107 layout->addWidget(friendsLabel);
108 layout->addSpacing(12);
109 layout->addWidget(userIdLabel);
110 layout->addWidget(userIdEdit);
111 layout->addWidget(messageLabel);
112 layout->addWidget(messageEdit);
113 layout->addWidget(buttonBox);