From 537d55bd7fea22537497ee7618a4fd5bb18a8164 Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Thu, 3 Jul 2014 21:42:23 +0200 Subject: [PATCH] Makes toxgui translatable --- widget/camera.cpp | 4 ++-- widget/filetransfertwidget.cpp | 2 +- widget/form/addfriendform.cpp | 24 ++++++++++++------------ widget/form/chatform.cpp | 6 +++--- widget/form/groupchatform.cpp | 8 ++++---- widget/form/settingsform.cpp | 10 +++++----- widget/friendwidget.cpp | 6 +++--- widget/groupwidget.cpp | 10 +++++----- widget/selfcamview.cpp | 2 +- widget/tool/friendrequestdialog.cpp | 12 ++++++------ widget/widget.cpp | 6 +++--- 11 files changed, 45 insertions(+), 45 deletions(-) diff --git a/widget/camera.cpp b/widget/camera.cpp index 1a9b782cc..0c35e333b 100644 --- a/widget/camera.cpp +++ b/widget/camera.cpp @@ -142,8 +142,8 @@ bool Camera::isFormatSupported(const QVideoSurfaceFormat& format) const } else { - QMessageBox::warning(0, "Camera eror", - QString("Camera format %1 not supported, can't use the camera") + QMessageBox::warning(0, tr("Camera eror"), + tr("Camera format %1 not supported, can't use the camera") .arg(format.pixelFormat())); return false; } diff --git a/widget/filetransfertwidget.cpp b/widget/filetransfertwidget.cpp index 0eec0a23c..9d1543423 100644 --- a/widget/filetransfertwidget.cpp +++ b/widget/filetransfertwidget.cpp @@ -228,7 +228,7 @@ void FileTransfertWidget::rejectRecvRequest() void FileTransfertWidget::acceptRecvRequest() { - QString path = QFileDialog::getSaveFileName(0,"Save a file",QDir::currentPath()+'/'+filename->text()); + QString path = QFileDialog::getSaveFileName(0,tr("Save a file","Title of the file saving dialog"),QDir::currentPath()+'/'+filename->text()); if (path.isEmpty()) return; diff --git a/widget/form/addfriendform.cpp b/widget/form/addfriendform.cpp index ae38d2f92..2ff1e3985 100644 --- a/widget/form/addfriendform.cpp +++ b/widget/form/addfriendform.cpp @@ -12,12 +12,12 @@ AddFriendForm::AddFriendForm() : dns(this) main = new QWidget(), head = new QWidget(); QFont bold; bold.setBold(true); - headLabel.setText("Add Friends"); + headLabel.setText(tr("Add Friends")); headLabel.setFont(bold); - toxIdLabel.setText("Tox ID"); - messageLabel.setText("Message"); - sendButton.setText("Send friend request"); + toxIdLabel.setText(tr("Tox ID","Tox ID of the person you're sending a friend request to")); + messageLabel.setText(tr("Message","The message you send in friend requests")); + sendButton.setText(tr("Send friend request")); main->setLayout(&layout); layout.addWidget(&toxIdLabel); @@ -64,7 +64,7 @@ void AddFriendForm::showWarning(const QString &message) const QString AddFriendForm::getMessage() const { const QString msg = message.toPlainText(); - return !msg.isEmpty() ? msg : "Tox me maybe?"; + return !msg.isEmpty() ? msg : tr("Tox me maybe?","Default message in friend requests if the field is left blank. Write something appropriate!"); } void AddFriendForm::onSendTriggered() @@ -72,7 +72,7 @@ void AddFriendForm::onSendTriggered() QString id = toxId.text().trimmed(); if (id.isEmpty()) { - showWarning("Please fill in a valid Tox ID"); + 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)) { emit friendRequested(id, getMessage()); } else { @@ -87,38 +87,38 @@ void AddFriendForm::handleDnsLookup() const QString idKeyWord("id="); if (dns.error() != QDnsLookup::NoError) { - showWarning("Error while looking up DNS"); + showWarning(tr("Error while looking up DNS","The DNS gives the Tox ID associated to toxme.se addresses")); return; } const QList textRecords = dns.textRecords(); if (textRecords.length() != 1) { - showWarning("Unexpected number of text records"); + showWarning(tr("Unexpected number of text records", "Error with the DNS")); return; } const QList textRecordValues = textRecords.first().values(); if (textRecordValues.length() != 1) { - showWarning("Unexpected number of values in text record"); + showWarning(tr("Unexpected number of values in text record", "Error with the DNS")); return; } const QString entry(textRecordValues.first()); int idx = entry.indexOf(idKeyWord); if (idx < 0) { - showWarning("The DNS lookup does not contain any Tox ID"); + showWarning(tr("The DNS lookup does not contain any Tox ID", "Error with the DNS")); return; } idx += idKeyWord.length(); if (entry.length() < idx + static_cast(TOX_ID_SIZE)) { - showWarning("The DNS lookup does not contain a valid Tox ID"); + showWarning(tr("The DNS lookup does not contain a valid Tox ID", "Error with the DNS")); return; } const QString friendAdress = entry.mid(idx, TOX_ID_SIZE); if (!isToxId(friendAdress)) { - showWarning("The DNS lookup does not contain a valid Tox ID"); + showWarning(tr("The DNS lookup does not contain a valid Tox ID", "Error with the DNS")); return; } diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 4090119aa..6e1737444 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -258,7 +258,7 @@ void ChatForm::addMessage(QLabel* author, QLabel* message, QLabel* date) void ChatForm::onAttachClicked() { - QString path = QFileDialog::getOpenFileName(0,"Send a file"); + QString path = QFileDialog::getOpenFileName(0,tr("Send a file")); if (path.isEmpty()) return; @@ -583,13 +583,13 @@ void ChatForm::onChatContextMenuRequested(QPoint pos) QWidget* sender = (QWidget*)QObject::sender(); pos = sender->mapToGlobal(pos); QMenu menu; - menu.addAction("Save chat log", this, SLOT(onSaveLogClicked())); + menu.addAction(tr("Save chat log"), this, SLOT(onSaveLogClicked())); menu.exec(pos); } void ChatForm::onSaveLogClicked() { - QString path = QFileDialog::getSaveFileName(0,"Save chat log"); + QString path = QFileDialog::getSaveFileName(0,tr("Save chat log")); if (path.isEmpty()) return; diff --git a/widget/form/groupchatform.cpp b/widget/form/groupchatform.cpp index 7116ae7f1..95bf4df2c 100644 --- a/widget/form/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -29,7 +29,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup) name->setText(group->widget->name.text()); name->setFont(bold); nusers->setFont(small); - nusers->setText(QString("%1 users in chat").arg(group->peers.size())); + nusers->setText(tr("%1 users in chat").arg(group->peers.size())); avatar->setPixmap(QPixmap(":/img/group.png")); QString names; for (QString& s : group->peers) @@ -152,7 +152,7 @@ void GroupChatForm::addGroupMessage(QString message, int peerId) if (group->peers.contains(peerId)) msgAuthor = new QLabel(group->peers[peerId]); else - msgAuthor = new QLabel(""); + msgAuthor = new QLabel(tr("")); QLabel *msgText = new QLabel(message); QLabel *msgDate = new QLabel(QTime::currentTime().toString("hh:mm")); @@ -217,7 +217,7 @@ void GroupChatForm::onSliderRangeChanged() void GroupChatForm::onUserListChanged() { - nusers->setText(QString("%1 users in chat").arg(group->nPeers)); + nusers->setText(tr("%1 users in chat").arg(group->nPeers)); QString names; for (QString& s : group->peers) names.append(s+", "); @@ -236,7 +236,7 @@ void GroupChatForm::onChatContextMenuRequested(QPoint pos) void GroupChatForm::onSaveLogClicked() { - QString path = QFileDialog::getSaveFileName(0,"Save chat log"); + QString path = QFileDialog::getSaveFileName(0,tr("Save chat log")); if (path.isEmpty()) return; diff --git a/widget/form/settingsform.cpp b/widget/form/settingsform.cpp index 4e000848a..38c9846ef 100644 --- a/widget/form/settingsform.cpp +++ b/widget/form/settingsform.cpp @@ -10,17 +10,17 @@ SettingsForm::SettingsForm() QFont bold, small; bold.setBold(true); small.setPixelSize(7); - headLabel.setText("User Settings"); + headLabel.setText(tr("User Settings","\"Headline\" of the window")); headLabel.setFont(bold); - nameLabel.setText("Name"); - statusTextLabel.setText("Status"); + nameLabel.setText(tr("Name","Username/nick")); + statusTextLabel.setText(tr("Status","Status message")); idLabel.setText("Tox ID"); id.setFont(small); id.setTextInteractionFlags(Qt::TextSelectableByMouse); - videoTest.setText("Test video"); - enableIPv6.setText("Enable IPv6 (recommended)"); + videoTest.setText(tr("Test video","Text on a button to test the video/webcam")); + enableIPv6.setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6")); enableIPv6.setChecked(Settings::getInstance().getEnableIPv6()); main->setLayout(&layout); diff --git a/widget/friendwidget.cpp b/widget/friendwidget.cpp index cc1118536..364980ce2 100644 --- a/widget/friendwidget.cpp +++ b/widget/friendwidget.cpp @@ -62,8 +62,8 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) { QPoint pos = event->globalPos(); QMenu menu; - menu.addAction("Copy friend ID"); - QMenu* inviteMenu = menu.addMenu("Invite in group"); + menu.addAction(tr("Copy friend ID","Menu to copy the Tox ID of that friend")); + QMenu* inviteMenu = menu.addMenu(tr("Invite in group","Menu to invite a friend in a groupchat")); QMap groupActions; for (Group* group : GroupList::groupList) { @@ -73,7 +73,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) if (groupActions.isEmpty()) inviteMenu->setEnabled(false); menu.addSeparator(); - menu.addAction("Remove friend"); + menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist")); QAction* selectedItem = menu.exec(pos); if (selectedItem) diff --git a/widget/groupwidget.cpp b/widget/groupwidget.cpp index 9932f0162..0e70ee3ed 100644 --- a/widget/groupwidget.cpp +++ b/widget/groupwidget.cpp @@ -35,9 +35,9 @@ GroupWidget::GroupWidget(int GroupId, QString Name) this->setPalette(pal3); Group* g = GroupList::findGroup(groupId); if (g) - nusers.setText(QString("%1 users in chat").arg(g->peers.size())); + nusers.setText(QString(tr("%1 users in chat")).arg(g->peers.size())); else - nusers.setText("0 users in chat"); + nusers.setText(tr("0 users in chat")); textLayout.addStretch(); textLayout.addWidget(&name); @@ -65,7 +65,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent * event) { QPoint pos = event->globalPos(); QMenu menu; - menu.addAction("Quit group"); + menu.addAction(tr("Quit group","Menu to quit a groupchat")); QAction* selectedItem = menu.exec(pos); if (selectedItem) @@ -123,9 +123,9 @@ void GroupWidget::onUserListChanged() { Group* g = GroupList::findGroup(groupId); if (g) - nusers.setText(QString("%1 users in chat").arg(g->nPeers)); + nusers.setText(tr("%1 users in chat").arg(g->nPeers)); else - nusers.setText("0 users in chat"); + nusers.setText(tr("0 users in chat")); } void GroupWidget::setAsActiveChatroom() diff --git a/widget/selfcamview.cpp b/widget/selfcamview.cpp index 52b4766c1..bef9e50b8 100644 --- a/widget/selfcamview.cpp +++ b/widget/selfcamview.cpp @@ -13,7 +13,7 @@ SelfCamView::SelfCamView(Camera* Cam, QWidget* parent) mainLayout{new QHBoxLayout()}, cam(Cam) { setLayout(mainLayout); - setWindowTitle("Tox video test"); + setWindowTitle(tr("Tox video test","Title of the window to test the video/webcam")); setMinimumSize(320,240); updateDisplayTimer.setInterval(5); diff --git a/widget/tool/friendrequestdialog.cpp b/widget/tool/friendrequestdialog.cpp index 1c7e66139..cb7868e4b 100644 --- a/widget/tool/friendrequestdialog.cpp +++ b/widget/tool/friendrequestdialog.cpp @@ -27,22 +27,22 @@ FriendRequestDialog::FriendRequestDialog(QWidget *parent, const QString &userId, QDialog(parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - setWindowTitle("Friend request"); + setWindowTitle(tr("Friend request","Title of the window to aceept/deny a friend request")); - QLabel *friendsLabel = new QLabel("Someone wants to make friends with you.", this); - QLabel *userIdLabel = new QLabel("User ID:", this); + QLabel *friendsLabel = new QLabel(tr("Someone wants to make friends with you"), this); + QLabel *userIdLabel = new QLabel(tr("User ID:"), this); QLineEdit *userIdEdit = new QLineEdit(userId, this); userIdEdit->setCursorPosition(0); userIdEdit->setReadOnly(true); - QLabel *messageLabel = new QLabel("Friend request message:", this); + QLabel *messageLabel = new QLabel(tr("Friend request message:"), this); QPlainTextEdit *messageEdit = new QPlainTextEdit(message, this); messageEdit->setReadOnly(true); QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this); - buttonBox->addButton("Accept", QDialogButtonBox::AcceptRole); - buttonBox->addButton("Reject", QDialogButtonBox::RejectRole); + buttonBox->addButton(tr("Accept","Accept a friend request"), QDialogButtonBox::AcceptRole); + buttonBox->addButton(tr("Reject","Reject a friend request"), QDialogButtonBox::RejectRole); connect(buttonBox, &QDialogButtonBox::accepted, this, &FriendRequestDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &FriendRequestDialog::reject); diff --git a/widget/widget.cpp b/widget/widget.cpp index 956638e75..fb8493ab5 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -1109,9 +1109,9 @@ void Widget::minimizeBtnClicked() void Widget::onStatusImgClicked() { QMenu menu; - menu.addAction("Online"); - menu.addAction("Away"); - menu.addAction("Busy"); + menu.addAction(tr("Online","Button to set your status to 'Online'")); + menu.addAction(tr("Away","Button to set your status to 'Away'")); + menu.addAction(tr("Busy","Button to set your status to 'Busy'")); QPoint pos = QCursor::pos(); QAction* selectedItem = menu.exec(pos);