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

refactor: Use extra comment to make code cleaner

This commit is contained in:
Diadlo 2017-08-20 17:42:44 +03:00
parent 15987ece3d
commit 1ac97c4734
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -196,8 +196,8 @@ void AddFriendForm::addFriend(const QString& idText)
deleteFriendRequest(friendId); deleteFriendRequest(friendId);
if (friendId == Core::getInstance()->getSelfId()) { if (friendId == Core::getInstance()->getSelfId()) {
GUI::showWarning(tr("Couldn't add friend"), GUI::showWarning(tr("Couldn't add friend"),
tr("You can't add yourself as a friend!", //: When trying to add your own Tox ID as friend
"When trying to add your own Tox ID as friend")); tr("You can't add yourself as a friend!"));
} else { } else {
emit friendRequested(friendId, getMessage()); emit friendRequested(friendId, getMessage());
} }
@ -239,8 +239,8 @@ void AddFriendForm::onImportOpenClicked()
QFile contactFile(path); QFile contactFile(path);
if (!contactFile.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!contactFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
GUI::showWarning(tr("Couldn't open file"), GUI::showWarning(tr("Couldn't open file"),
tr("Couldn't open the contact file", //: Error message when trying to open a contact list file to import
"Error message when trying to open a contact list file to import")); tr("Couldn't open the contact file"));
return; return;
} }
@ -271,10 +271,10 @@ void AddFriendForm::onIdChanged(const QString& id)
const QString tId = id.trimmed(); const QString tId = id.trimmed();
const bool isValidId = tId.isEmpty() || checkIsValidId(tId); const bool isValidId = tId.isEmpty() || checkIsValidId(tId);
const QString toxIdText(tr("Tox ID", //: Tox ID of the person you're sending a friend request to
"Tox ID of the person you're sending a friend request to")); const QString toxIdText(tr("Tox ID"));
const QString toxIdComment(tr("either 76 hexadecimal characters or name@example.com", //: Tox ID format description
"Tox ID format description")); const QString toxIdComment(tr("either 76 hexadecimal characters or name@example.com"));
const QString labelText = isValidId ? QStringLiteral("%1 (%2)") const QString labelText = isValidId ? QStringLiteral("%1 (%2)")
: QStringLiteral("%1 <font color='red'>(%2)</font>"); : QStringLiteral("%1 <font color='red'>(%2)</font>");
@ -345,26 +345,23 @@ void AddFriendForm::onCurrentChanged(int index)
void AddFriendForm::retranslateUi() void AddFriendForm::retranslateUi()
{ {
headLabel.setText(tr("Add Friends")); headLabel.setText(tr("Add Friends"));
static const QString messageLabelText = tr("Message", //: The message you send in friend requests
"The message you send in friend requests"); static const QString messageLabelText = tr("Message");
messageLabel.setText(messageLabelText); messageLabel.setText(messageLabelText);
importMessageLabel.setText(messageLabelText); importMessageLabel.setText(messageLabelText);
importFileButton.setText(tr("Open", "Button to choose a file with a list of contacts to import")); //: Button to choose a file with a list of contacts to import
importFileButton.setText(tr("Open"));
importSendButton.setText(tr("Send friend requests")); importSendButton.setText(tr("Send friend requests"));
sendButton.setText(tr("Send friend request")); sendButton.setText(tr("Send friend request"));
message.setPlaceholderText(tr("%1 here! Tox me maybe?", "Default message in friend requests if " //: Default message in friend requests if the field is left blank. Write something appropriate!
"the field is left blank. Write " message.setPlaceholderText(tr("%1 here! Tox me maybe?").arg(lastUsername));
"something appropriate!")
.arg(lastUsername));
importMessage.setPlaceholderText(message.placeholderText()); importMessage.setPlaceholderText(message.placeholderText());
if (contactsToImport.isEmpty()) { importFileLabel.setText(contactsToImport.isEmpty()
importFileLabel.setText(tr("Import a list of contacts, one Tox ID per line")); ? tr("Import a list of contacts, one Tox ID per line")
} else { //: Shows the number of contacts we're about to import from a file (at least one)
importFileLabel.setText(tr("Ready to import %n contact(s), click send to confirm", : tr("Ready to import %n contact(s), click send to confirm", "",
"Shows the number of contacts we're about to import from a file" contactsToImport.size()));
" (at least one)", contactsToImport.size()));
}
onIdChanged(toxId.text()); onIdChanged(toxId.text());