summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-19 08:48:05 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-19 21:29:44 (GMT)
commitb1836ffb49bd7740dbd7c32bfad04d077e81ecb5 (patch)
tree9d0d9b3fad9c2bbd0192696d59e08477b8c22c10 /Swift/QtUI
parent2f6c2299c28c9bb03ee1437058a4c7071ff2ac3f (diff)
downloadswift-contrib-b1836ffb49bd7740dbd7c32bfad04d077e81ecb5.zip
swift-contrib-b1836ffb49bd7740dbd7c32bfad04d077e81ecb5.tar.bz2
Make Swift translatable.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/ChatList/ChatListModel.cpp2
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.cpp8
-rw-r--r--Swift/QtUI/EventViewer/QtEvent.cpp10
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp2
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp6
-rw-r--r--Swift/QtUI/QtAboutWidget.cpp8
-rw-r--r--Swift/QtUI/QtAvatarWidget.cpp6
-rw-r--r--Swift/QtUI/QtBookmarkDetailWindow.cpp2
-rw-r--r--Swift/QtUI/QtChatView.cpp6
-rw-r--r--Swift/QtUI/QtChatWindow.cpp6
-rw-r--r--Swift/QtUI/QtContactEditWidget.cpp6
-rw-r--r--Swift/QtUI/QtContactEditWindow.cpp12
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp32
-rw-r--r--Swift/QtUI/QtMainWindow.cpp20
-rw-r--r--Swift/QtUI/QtNameWidget.cpp6
-rw-r--r--Swift/QtUI/QtProfileWindow.cpp6
-rw-r--r--Swift/QtUI/QtStatusWidget.cpp15
-rw-r--r--Swift/QtUI/QtStatusWidget.h1
-rw-r--r--Swift/QtUI/QtSubscriptionRequestWindow.cpp12
-rw-r--r--Swift/QtUI/QtSwift.cpp3
-rw-r--r--Swift/QtUI/QtTranslator.h21
-rw-r--r--Swift/QtUI/QtWebView.cpp4
-rw-r--r--Swift/QtUI/QtXMLConsoleWidget.cpp12
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp6
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.h6
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.h11
-rw-r--r--Swift/QtUI/Roster/RosterModel.cpp3
-rw-r--r--Swift/QtUI/SConscript33
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.cpp17
-rw-r--r--Swift/QtUI/main.cpp35
-rw-r--r--Swift/QtUI/tmp/QtContextMenu.cpp14
-rw-r--r--Swift/QtUI/tmp/QtContextMenu.h17
-rw-r--r--Swift/QtUI/tmp/QtRosterContextMenu.cpp108
-rw-r--r--Swift/QtUI/tmp/QtRosterContextMenu.h32
34 files changed, 194 insertions, 294 deletions
diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp
index 39b6a3c..ba7b766 100644
--- a/Swift/QtUI/ChatList/ChatListModel.cpp
+++ b/Swift/QtUI/ChatList/ChatListModel.cpp
@@ -12,7 +12,7 @@ namespace Swift {
ChatListModel::ChatListModel() {
root_ = new ChatListGroupItem("", NULL);
- mucBookmarks_ = new ChatListGroupItem("Bookmarked Rooms", root_);
+ mucBookmarks_ = new ChatListGroupItem(tr("Bookmarked Rooms"), root_);
root_->addItem(mucBookmarks_);
}
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp
index 48ccf7f..b532cdb 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.cpp
+++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp
@@ -59,11 +59,11 @@ void QtChatListWindow::handleClicked(const QModelIndex& index) {
void QtChatListWindow::setupContextMenus() {
mucMenu_ = new QMenu();
- mucMenu_->addAction("Add New Bookmark", this, SLOT(handleAddBookmark()));
- mucMenu_->addAction("Edit Bookmark", this, SLOT(handleEditBookmark()));
- mucMenu_->addAction("Remove Bookmark", this, SLOT(handleRemoveBookmark()));
+ mucMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark()));
+ mucMenu_->addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark()));
+ mucMenu_->addAction(tr("Remove Bookmark"), this, SLOT(handleRemoveBookmark()));
emptyMenu_ = new QMenu();
- emptyMenu_->addAction("Add New Bookmark", this, SLOT(handleAddBookmark()));
+ emptyMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark()));
}
diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp
index f0bc276..05080d8 100644
--- a/Swift/QtUI/EventViewer/QtEvent.cpp
+++ b/Swift/QtUI/EventViewer/QtEvent.cpp
@@ -58,8 +58,14 @@ QString QtEvent::text() {
boost::shared_ptr<SubscriptionRequestEvent> subscriptionRequestEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event_);
if (subscriptionRequestEvent) {
std::string reason = subscriptionRequestEvent->getReason();
- std::string message = subscriptionRequestEvent->getJID().toBare().toString() + " would like to add you to their roster" + (reason.empty() ? "." : ", saying '" + reason + "'.");
- return P2QSTRING(message);
+ QString message;
+ if (reason.empty()) {
+ message = QString("%1 would like to add you to their roster.").arg(subscriptionRequestEvent->getJID().toBare().toString().c_str());
+ }
+ else {
+ message = QString("%1 would like to add you to their roster, saying '%2'").arg(subscriptionRequestEvent->getJID().toBare().toString().c_str()).arg(reason.c_str());
+ }
+ return message;
}
boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event_);
if (errorEvent) {
diff --git a/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp b/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp
index b1b4175..f392859 100644
--- a/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp
+++ b/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp
@@ -22,7 +22,7 @@ MUCSearchServiceItem* MUCSearchEmptyItem::getParent() {
QVariant MUCSearchEmptyItem::data(int role) {
switch (role) {
case Qt::DisplayRole:
- return QVariant("No rooms found");
+ return QVariant(QObject::tr("No rooms found"));
case Qt::FontRole: {
QFont font;
font.setItalic(true);
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
index 1e624b3..618ed65 100644
--- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
@@ -27,7 +27,7 @@ QtMUCSearchWindow::QtMUCSearchWindow() {
setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
setModal(true);
- setWindowTitle("Search Room");
+ setWindowTitle(tr("Search Room"));
ui_.filter_->hide();
model_ = new MUCSearchModel();
delegate_ = new MUCSearchDelegate();
@@ -47,9 +47,9 @@ QtMUCSearchWindow::QtMUCSearchWindow() {
ui_.okButton->setEnabled(false);
connect(ui_.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
- throbber_ = new QLabel("Searching", ui_.results_);
+ throbber_ = new QLabel(tr("Searching"), ui_.results_);
throbber_->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), throbber_));
- throbber_->setToolTip("Searching");
+ throbber_->setToolTip(tr("Searching"));
hasHadScrollBars_ = false;
updateThrobberPosition();
diff --git a/Swift/QtUI/QtAboutWidget.cpp b/Swift/QtUI/QtAboutWidget.cpp
index 38a4a8c..2f68769 100644
--- a/Swift/QtUI/QtAboutWidget.cpp
+++ b/Swift/QtUI/QtAboutWidget.cpp
@@ -20,7 +20,7 @@ namespace Swift {
QtAboutWidget::QtAboutWidget() : QDialog() {
#ifndef Q_WS_MAC
- setWindowTitle("About Swift");
+ setWindowTitle(QString(tr("About %1")).arg("Swift"));
#endif
setWindowIcon(QIcon(":/logo-icon-16.png"));
@@ -39,13 +39,13 @@ QtAboutWidget::QtAboutWidget() : QDialog() {
QLabel* versionLabel = new QLabel(QString("<center><font size='-1'>Version ") + QCoreApplication::applicationVersion() + "</font></center>", this);
mainLayout->addWidget(versionLabel);
- QString buildString = QString("<center><font size='-1'>Built with: Qt version ") + QT_VERSION_STR;
- buildString += QString("<br/>Running with Qt version ") + qVersion();
+ QString buildString = QString("<center><font size='-1'>") + QString(tr("Built with: Qt version %1")).arg(QT_VERSION_STR);
+ buildString += QString("<br/>") + QString(tr("Running with Qt version ")).arg(qVersion());
buildString += "</font></center>";
QLabel* buildLabel = new QLabel(buildString, this);
mainLayout->addWidget(buildLabel);
- QPushButton* licenseButton = new QPushButton("View License", this);
+ QPushButton* licenseButton = new QPushButton(tr("View License"), this);
mainLayout->addWidget(licenseButton);
connect(licenseButton, SIGNAL(clicked()), this, SLOT(handleLicenseClicked()));
diff --git a/Swift/QtUI/QtAvatarWidget.cpp b/Swift/QtUI/QtAvatarWidget.cpp
index 0879d46..ebdf1a6 100644
--- a/Swift/QtUI/QtAvatarWidget.cpp
+++ b/Swift/QtUI/QtAvatarWidget.cpp
@@ -70,10 +70,10 @@ void QtAvatarWidget::setAvatar(const ByteArray& data, const std::string& type) {
void QtAvatarWidget::mousePressEvent(QMouseEvent* event) {
QMenu menu;
- QAction* selectPicture = new QAction("Select picture ...", this);
+ QAction* selectPicture = new QAction(tr("Select picture ..."), this);
menu.addAction(selectPicture);
- QAction* clearPicture = new QAction("Clear picture", this);
+ QAction* clearPicture = new QAction(tr("Clear picture"), this);
menu.addAction(clearPicture);
QAction* result = menu.exec(event->globalPos());
@@ -92,7 +92,7 @@ void QtAvatarWidget::mousePressEvent(QMouseEvent* event) {
setAvatar(data, Q2PSTRING(type));
}
else {
- QMessageBox::critical(this, "Error", "The selected picture is in an unrecognized format");
+ QMessageBox::critical(this, tr("Error"), tr("The selected picture is in an unrecognized format"));
}
}
}
diff --git a/Swift/QtUI/QtBookmarkDetailWindow.cpp b/Swift/QtUI/QtBookmarkDetailWindow.cpp
index c0f04e2..fb04e03 100644
--- a/Swift/QtUI/QtBookmarkDetailWindow.cpp
+++ b/Swift/QtUI/QtBookmarkDetailWindow.cpp
@@ -28,7 +28,7 @@ boost::optional<MUCBookmark> QtBookmarkDetailWindow::createBookmarkFromForm() {
//check bookmarkName
JID room(Q2PSTRING(room_->text()));
if (!room.isValid() || room.getNode().empty() || !room.getResource().empty()) {
- QMessageBox::warning(this, "Bookmark not valid", "You must specify a valid room address (e.g. myroom@chats.example.com).");
+ QMessageBox::warning(this, tr("Bookmark not valid"), tr("You must specify a valid room address (e.g. myroom@chats.example.com)."));
return boost::optional<MUCBookmark>();
}
std::string name(Q2PSTRING(name_->text()));
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 0f25d76..521b072 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -58,9 +58,9 @@ QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent) : QWidget(parent) {
void QtChatView::handleClearRequested() {
QMessageBox messageBox(this);
- messageBox.setWindowTitle("Clear log");
- messageBox.setText("You are about to clear the contents of your chat log.");
- messageBox.setInformativeText("Are you sure?");
+ messageBox.setWindowTitle(tr("Clear log"));
+ messageBox.setText(tr("You are about to clear the contents of your chat log."));
+ messageBox.setInformativeText(tr("Are you sure?"));
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
messageBox.setDefaultButton(QMessageBox::Yes);
int button = messageBox.exec();
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index dac9e93..4b67ef0 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -287,9 +287,9 @@ void QtChatWindow::flash() {
void QtChatWindow::setAckState(std::string const& id, ChatWindow::AckState state) {
QString xml;
switch (state) {
- case ChatWindow::Pending: xml = "<img src='qrc:/icons/throbber.gif' alt='This message has not been received by your server yet.'/>"; break;
+ case ChatWindow::Pending: xml = "<img src='qrc:/icons/throbber.gif' alt='" + tr("This message has not been received by your server yet.") + "'/>"; break;
case ChatWindow::Received: xml = ""; break;
- case ChatWindow::Failed: xml = "<img src='qrc:/icons/error.png' alt='This message may not have been transmitted.'/>"; break;
+ case ChatWindow::Failed: xml = "<img src='qrc:/icons/error.png' alt='" + tr("This message may not have been transmitted.'") + "/>"; break;
}
messageLog_->setAckXML(P2QSTRING(id), xml);
}
@@ -309,7 +309,7 @@ void QtChatWindow::addErrorMessage(const std::string& errorMessage) {
QString errorMessageHTML(Qt::escape(P2QSTRING(errorMessage)));
errorMessageHTML.replace("\n","<br/>");
- messageLog_->addMessage(boost::shared_ptr<ChatSnippet>(new SystemMessageSnippet(QString("<span class=\"error\">Couldn't send message: %1</span>").arg(errorMessageHTML), QDateTime::currentDateTime(), false, theme_)));
+ messageLog_->addMessage(boost::shared_ptr<ChatSnippet>(new SystemMessageSnippet(QString("<span class=\"error\">" + tr("Couldn't send message: %1") + "</span>").arg(errorMessageHTML), QDateTime::currentDateTime(), false, theme_)));
previousMessageWasSelf_ = false;
previousMessageWasSystem_ = true;
diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp
index e8fe24a..fbc9685 100644
--- a/Swift/QtUI/QtContactEditWidget.cpp
+++ b/Swift/QtUI/QtContactEditWidget.cpp
@@ -25,13 +25,13 @@ QtContactEditWidget::QtContactEditWidget(const std::set<std::string>& allGroups,
QHBoxLayout* nameLayout = new QHBoxLayout();
- QLabel* label = new QLabel("Name:", this);
+ QLabel* label = new QLabel(tr("Name:"), this);
nameLayout->addWidget(label);
name_ = new QLineEdit(this);
nameLayout->addWidget(name_);
layout->addLayout(nameLayout);
- layout->addWidget(new QLabel("Groups:", this));
+ layout->addWidget(new QLabel(tr("Groups:"), this));
QScrollArea* groupsArea = new QScrollArea(this);
layout->addWidget(groupsArea);
@@ -53,7 +53,7 @@ QtContactEditWidget::QtContactEditWidget(const std::set<std::string>& allGroups,
QHBoxLayout* newGroupLayout = new QHBoxLayout();
newGroup_ = new QCheckBox(groups);
- newGroup_->setText("New Group:");
+ newGroup_->setText(tr("New Group:"));
newGroup_->setCheckState(Qt::Unchecked);
newGroupLayout->addWidget(newGroup_);
newGroupName_ = new QLineEdit(groups);
diff --git a/Swift/QtUI/QtContactEditWindow.cpp b/Swift/QtUI/QtContactEditWindow.cpp
index 97b8f95..543d39a 100644
--- a/Swift/QtUI/QtContactEditWindow.cpp
+++ b/Swift/QtUI/QtContactEditWindow.cpp
@@ -23,7 +23,7 @@ namespace Swift {
QtContactEditWindow::QtContactEditWindow() : contactEditWidget_(NULL) {
resize(300,300);
- setWindowTitle("Edit contact");
+ setWindowTitle(tr("Edit contact"));
setContentsMargins(0,0,0,0);
QBoxLayout* layout = new QVBoxLayout(this);
@@ -38,10 +38,10 @@ QtContactEditWindow::QtContactEditWindow() : contactEditWidget_(NULL) {
QHBoxLayout* buttonLayout = new QHBoxLayout();
layout->addLayout(buttonLayout);
- QPushButton* removeButton = new QPushButton("Remove contact", this);
+ QPushButton* removeButton = new QPushButton(tr("Remove contact"), this);
connect(removeButton, SIGNAL(clicked()), this, SLOT(handleRemoveContact()));
buttonLayout->addWidget(removeButton);
- QPushButton* okButton = new QPushButton("Ok", this);
+ QPushButton* okButton = new QPushButton(tr("Ok"), this);
connect(okButton, SIGNAL(clicked()), this, SLOT(handleUpdateContact()));
buttonLayout->addStretch();
buttonLayout->addWidget(okButton);
@@ -73,9 +73,9 @@ void QtContactEditWindow::hide() {
void QtContactEditWindow::handleRemoveContact() {
QMessageBox msgBox;
- msgBox.setWindowTitle("Confirm contact deletion");
- msgBox.setText("Are you sure you want to delete this contact?");
- msgBox.setInformativeText(QString("This will remove the contact '%1' from all groups they may be in.").arg(P2QSTRING(jid_.toString())));
+ msgBox.setWindowTitle(tr("Confirm contact deletion"));
+ msgBox.setText(tr("Are you sure you want to delete this contact?"));
+ msgBox.setInformativeText(QString(tr("This will remove the contact '%1' from all groups they may be in.")).arg(P2QSTRING(jid_.toString())));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index aae11d1..24e6d76 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -78,23 +78,23 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() {
layout->addStretch(2);
QLabel* jidLabel = new QLabel(this);
- jidLabel->setText("<font size='-1'>User address:</font>");
+ jidLabel->setText("<font size='-1'>" + tr("User address:") + "</font>");
layout->addWidget(jidLabel);
username_ = new QComboBox(this);
username_->setEditable(true);
- username_->setWhatsThis("User address - looks like someuser@someserver.com");
- username_->setToolTip("User address - looks like someuser@someserver.com");
+ username_->setWhatsThis(tr("User address - looks like someuser@someserver.com"));
+ username_->setToolTip(tr("User address - looks like someuser@someserver.com"));
username_->view()->installEventFilter(this);
layout->addWidget(username_);
QLabel* jidHintLabel = new QLabel(this);
- jidHintLabel->setText("<font size='-1' color='grey' >Example: alice@wonderland.lit</font>");
+ jidHintLabel->setText("<font size='-1' color='grey' >" + tr("Example: alice@wonderland.lit") + "</font>");
jidHintLabel->setAlignment(Qt::AlignRight);
layout->addWidget(jidHintLabel);
QLabel* passwordLabel = new QLabel();
- passwordLabel->setText("<font size='-1'>Password:</font>");
+ passwordLabel->setText("<font size='-1'>" + tr("Password:") + "</font>");
layout->addWidget(passwordLabel);
@@ -115,8 +115,8 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() {
certificateButton_ = new QToolButton(this);
certificateButton_->setCheckable(true);
certificateButton_->setIcon(QIcon(":/icons/certificate.png"));
- certificateButton_->setToolTip("Click if you have a personal certificate used for login to the service.");
- certificateButton_->setWhatsThis("Click if you have a personal certificate used for login to the service.");
+ certificateButton_->setToolTip(tr("Click if you have a personal certificate used for login to the service."));
+ certificateButton_->setWhatsThis(tr("Click if you have a personal certificate used for login to the service."));
credentialsLayout->addWidget(certificateButton_);
connect(certificateButton_, SIGNAL(clicked(bool)), SLOT(handleCertficateChecked(bool)));
@@ -154,7 +154,7 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() {
generalMenu_ = swiftMenu_;
#endif
- QAction* aboutAction = new QAction("&About Swift", this);
+ QAction* aboutAction = new QAction(QString(tr("&About %1")).arg("Swift"), this);
connect(aboutAction, SIGNAL(triggered()), SLOT(handleAbout()));
swiftMenu_->addAction(aboutAction);
@@ -180,7 +180,7 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() {
swiftMenu_->addSeparator();
#endif
- QAction* quitAction = new QAction("&Quit", this);
+ QAction* quitAction = new QAction(tr("&Quit"), this);
connect(quitAction, SIGNAL(triggered()), SLOT(handleQuit()));
swiftMenu_->addAction(quitAction);
@@ -194,7 +194,7 @@ bool QtLoginWindow::eventFilter(QObject *obj, QEvent *event) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Delete || keyEvent->key() == Qt::Key_Backspace) {
QString jid(username_->view()->currentIndex().data().toString());
- int result = QMessageBox::question(this, "Remove profile", "Remove the profile '" + jid + "'?", QMessageBox::Yes | QMessageBox::No);
+ int result = QMessageBox::question(this, tr("Remove profile"), tr("Remove the profile '%1'?").arg(jid), QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
onPurgeSavedLoginRequest(Q2PSTRING(jid));
}
@@ -288,7 +288,7 @@ void QtLoginWindow::loggedOut() {
void QtLoginWindow::setIsLoggingIn(bool loggingIn) {
/* Change the for loop as well if you add to this.*/
QWidget* widgets[5] = {username_, password_, remember_, loginAutomatically_, certificateButton_};
- loginButton_->setText(loggingIn ? "Cancel" : "Connect");
+ loginButton_->setText(loggingIn ? tr("Cancel") : tr("Connect"));
for (int i = 0; i < 5; i++) {
widgets[i]->setEnabled(!loggingIn);
}
@@ -309,7 +309,7 @@ void QtLoginWindow::setLoginAutomatically(bool loginAutomatically) {
void QtLoginWindow::handleCertficateChecked(bool checked) {
if (checked) {
- certificateFile_ = QFileDialog::getOpenFileName(this, "Select an authentication certificate", QString(), QString("*.cert"));
+ certificateFile_ = QFileDialog::getOpenFileName(this, tr("Select an authentication certificate"), QString(), QString("*.cert"));
if (certificateFile_.isEmpty()) {
certificateButton_->setChecked(false);
}
@@ -409,11 +409,11 @@ void QtLoginWindow::moveEvent(QMoveEvent*) {
bool QtLoginWindow::askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref certificate) {
QMessageBox dialog(this);
- dialog.setText("The certificate presented by the server is not valid.");
- dialog.setInformativeText(P2QSTRING(message) + "\n\nWould you like to permanently trust this certificate? This must only be done if you know it is correct.");
+ dialog.setText(tr("The certificate presented by the server is not valid."));
+ dialog.setInformativeText(P2QSTRING(message) + "\n\n" + tr("Would you like to permanently trust this certificate? This must only be done if you know it is correct."));
- QString detailedText = "Subject: " + P2QSTRING(certificate->getSubjectName()) + "\n";
- detailedText += "SHA-1 Fingerprint: " + P2QSTRING(certificate->getSHA1Fingerprint());
+ QString detailedText = tr("Subject: %1").arg(P2QSTRING(certificate->getSubjectName())) + "\n";
+ detailedText += tr("SHA-1 Fingerprint: %1").arg(P2QSTRING(certificate->getSHA1Fingerprint()));
dialog.setDetailedText(detailedText);
dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index 6ebd8aa..0f43f7e 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -60,21 +60,21 @@ QtMainWindow::QtMainWindow(QtSettingsProvider* settings, UIEventStream* uiEventS
treeWidget_ = new QtTreeWidget(uiEventStream_);
contactTabLayout->addWidget(treeWidget_);
- tabs_->addTab(contactsTabWidget_, "&Contacts");
+ tabs_->addTab(contactsTabWidget_, tr("&Contacts"));
eventWindow_ = new QtEventWindow(uiEventStream_);
connect(eventWindow_, SIGNAL(onNewEventCountUpdated(int)), this, SLOT(handleEventCountUpdated(int)));
chatListWindow_ = new QtChatListWindow(uiEventStream_);
- tabs_->addTab(eventWindow_, "&Notices");
- tabs_->addTab(chatListWindow_, "C&hats");
+ tabs_->addTab(eventWindow_, tr("&Notices"));
+ tabs_->addTab(chatListWindow_, tr("C&hats"));
this->setLayout(mainLayout);
QMenu* viewMenu = new QMenu(tr("&View"), this);
menus_.push_back(viewMenu);
- showOfflineAction_ = new QAction("Show offline contacts", this);
+ showOfflineAction_ = new QAction(tr("Show offline contacts"), this);
showOfflineAction_->setCheckable(true);
showOfflineAction_->setChecked(false);
connect(showOfflineAction_, SIGNAL(toggled(bool)), SLOT(handleShowOfflineToggled(bool)));
@@ -82,20 +82,20 @@ QtMainWindow::QtMainWindow(QtSettingsProvider* settings, UIEventStream* uiEventS
QMenu* actionsMenu = new QMenu(tr("&Actions"), this);
menus_.push_back(actionsMenu);
- QAction* editProfileAction = new QAction("Edit Profile", this);
+ QAction* editProfileAction = new QAction(tr("Edit Profile"), this);
connect(editProfileAction, SIGNAL(triggered()), SLOT(handleEditProfileAction()));
actionsMenu->addAction(editProfileAction);
- QAction* joinMUCAction = new QAction("&Join Room", this);
+ QAction* joinMUCAction = new QAction(tr("&Join Room"), this);
connect(joinMUCAction, SIGNAL(triggered()), SLOT(handleJoinMUCAction()));
actionsMenu->addAction(joinMUCAction);
- addUserAction_ = new QAction("&Add Contact", this);
+ addUserAction_ = new QAction(tr("&Add Contact"), this);
connect(addUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleAddUserActionTriggered(bool)));
actionsMenu->addAction(addUserAction_);
- chatUserAction_ = new QAction("Start &Chat", this);
+ chatUserAction_ = new QAction(tr("Start &Chat"), this);
connect(chatUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleChatUserActionTriggered(bool)));
actionsMenu->addAction(chatUserAction_);
actionsMenu->addSeparator();
- QAction* signOutAction = new QAction("&Sign Out", this);
+ QAction* signOutAction = new QAction(tr("&Sign Out"), this);
connect(signOutAction, SIGNAL(triggered()), SLOT(handleSignOutAction()));
actionsMenu->addAction(signOutAction);
@@ -127,7 +127,7 @@ void QtMainWindow::handleEventCountUpdated(int count) {
QColor eventTabColor = (count == 0) ? QColor() : QColor(255, 0, 0); // invalid resets to default
int eventIndex = 1;
tabs_->tabBar()->setTabTextColor(eventIndex, eventTabColor);
- QString text = "Notices";
+ QString text = tr("Notices");
if (count > 0) {
text += QString(" (%1)").arg(count);
}
diff --git a/Swift/QtUI/QtNameWidget.cpp b/Swift/QtUI/QtNameWidget.cpp
index 412665d..6124c65 100644
--- a/Swift/QtUI/QtNameWidget.cpp
+++ b/Swift/QtUI/QtNameWidget.cpp
@@ -44,7 +44,7 @@ void QtNameWidget::mousePressEvent(QMouseEvent* event) {
QMenu menu;
bool hasNick = !nick.isEmpty();
- QAction* showAsNick = new QAction(hasNick ? "Show nickname" : "(No Nickname Set)", this);
+ QAction* showAsNick = new QAction(hasNick ? tr("Show nickname") : tr("(No Nickname Set)"), this);
showAsNick->setCheckable(true);
showAsNick->setEnabled(hasNick);
if (mode == ShowNick && hasNick) {
@@ -52,14 +52,14 @@ void QtNameWidget::mousePressEvent(QMouseEvent* event) {
}
menu.addAction(showAsNick);
- QAction* showAsJID = new QAction("Show ID", this);
+ QAction* showAsJID = new QAction(tr("Show ID"), this);
showAsJID->setCheckable(true);
if (mode == ShowJID || !hasNick) {
showAsJID->setChecked(true);
}
menu.addAction(showAsJID);
- QAction* editProfile = new QAction("Edit Profile", this);
+ QAction* editProfile = new QAction(tr("Edit Profile"), this);
menu.addAction(editProfile);
QAction* result = menu.exec(event->globalPos());
diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp
index c4fe400..2b723be 100644
--- a/Swift/QtUI/QtProfileWindow.cpp
+++ b/Swift/QtUI/QtProfileWindow.cpp
@@ -21,7 +21,7 @@
namespace Swift {
QtProfileWindow::QtProfileWindow() {
- setWindowTitle("Edit Profile");
+ setWindowTitle(tr("Edit Profile"));
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
sizePolicy.setHorizontalStretch(0);
@@ -40,7 +40,7 @@ QtProfileWindow::QtProfileWindow() {
QVBoxLayout* fieldsLayout = new QVBoxLayout();
QHBoxLayout* horizontalLayout_2 = new QHBoxLayout();
- nicknameLabel = new QLabel("Nickname: ", this);
+ nicknameLabel = new QLabel(tr("Nickname:"), this);
horizontalLayout_2->addWidget(nicknameLabel);
nickname = new QLineEdit(this);
horizontalLayout_2->addWidget(nickname);
@@ -64,7 +64,7 @@ QtProfileWindow::QtProfileWindow() {
throbberLabel->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), this));
horizontalLayout->addWidget(throbberLabel);
- saveButton = new QPushButton("Save", this);
+ saveButton = new QPushButton(tr("Save"), this);
connect(saveButton, SIGNAL(clicked()), SLOT(handleSave()));
horizontalLayout->addWidget(saveButton);
diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp
index db6d6c5..78bbb03 100644
--- a/Swift/QtUI/QtStatusWidget.cpp
+++ b/Swift/QtUI/QtStatusWidget.cpp
@@ -22,11 +22,12 @@
#include "Swift/QtUI/QtElidingLabel.h"
#include "Swift/QtUI/QtLineEdit.h"
#include "Swift/QtUI/QtSwiftUtil.h"
-
-const QString NO_MESSAGE = QString("(No message)");
+#include <Swift/Controllers/StatusUtil.h>
namespace Swift {
+const QString QtStatusWidget::NO_MESSAGE = QString(QT_TRANSLATE_NOOP("QtStatusWidget", "(No message)"));
+
QtStatusWidget::QtStatusWidget(QWidget *parent) : QWidget(parent), editCursor_(Qt::IBeamCursor), viewCursor_(Qt::PointingHandCursor) {
isClicking_ = false;
connecting_ = false;
@@ -131,12 +132,12 @@ void QtStatusWidget::generateList() {
foreach (StatusShow::Type type, icons_.keys()) {
QListWidgetItem* item = new QListWidgetItem(text == "" ? NO_MESSAGE : text, menu_);
item->setIcon(icons_[type]);
- item->setToolTip(P2QSTRING(StatusShow::typeToFriendlyName(type)) + ": " + item->text());
+ item->setToolTip(P2QSTRING(statusShowTypeToFriendlyName(type)) + ": " + item->text());
item->setStatusTip(item->toolTip());
item->setData(Qt::UserRole, QVariant(type));
}
foreach (StatusShow::Type type, icons_.keys()) {
- QListWidgetItem* item = new QListWidgetItem(P2QSTRING(StatusShow::typeToFriendlyName(type)), menu_);
+ QListWidgetItem* item = new QListWidgetItem(P2QSTRING(statusShowTypeToFriendlyName(type)), menu_);
item->setIcon(icons_[type]);
item->setToolTip(item->text());
item->setStatusTip(item->toolTip());
@@ -168,7 +169,7 @@ void QtStatusWidget::handleClicked() {
types.push_back(StatusShow::DND);
types.push_back(StatusShow::None);
foreach (StatusShow::Type type, types) {
- if (statusEdit_->text() == P2QSTRING(StatusShow::typeToFriendlyName(type))) {
+ if (statusEdit_->text() == P2QSTRING(statusShowTypeToFriendlyName(type))) {
statusEdit_->setText("");
}
}
@@ -229,9 +230,9 @@ void QtStatusWidget::handleItemClicked(QListWidgetItem* item) {
void QtStatusWidget::setNewToolTip() {
if (connecting_) {
- statusTextLabel_->setToolTip("Connecting");
+ statusTextLabel_->setToolTip(tr("Connecting"));
} else {
- statusTextLabel_->setToolTip(P2QSTRING(StatusShow::typeToFriendlyName(selectedStatusType_)) + ": " + statusTextLabel_->text());
+ statusTextLabel_->setToolTip(P2QSTRING(statusShowTypeToFriendlyName(selectedStatusType_)) + ": " + statusTextLabel_->text());
}
}
diff --git a/Swift/QtUI/QtStatusWidget.h b/Swift/QtUI/QtStatusWidget.h
index dcff433..f302c64 100644
--- a/Swift/QtUI/QtStatusWidget.h
+++ b/Swift/QtUI/QtStatusWidget.h
@@ -62,6 +62,7 @@ namespace Swift {
bool editing_;
QMovie* connectingMovie_;
bool connecting_;
+ static const QString NO_MESSAGE;
};
}
diff --git a/Swift/QtUI/QtSubscriptionRequestWindow.cpp b/Swift/QtUI/QtSubscriptionRequestWindow.cpp
index e201808..c38f421 100644
--- a/Swift/QtUI/QtSubscriptionRequestWindow.cpp
+++ b/Swift/QtUI/QtSubscriptionRequestWindow.cpp
@@ -15,23 +15,23 @@
namespace Swift {
QtSubscriptionRequestWindow::QtSubscriptionRequestWindow(boost::shared_ptr<SubscriptionRequestEvent> event, QWidget* parent) : QDialog(parent), event_(event) {
- QString text = P2QSTRING(event->getJID().toString()) + " would like to add you to their roster.\n Would you like to add them to your roster and share your status when you're online? \n\nIf you choose to defer this choice, you'll be asked again when you next login.";
+ QString text = QString("%1 would like to add you to their roster.\n Would you like to add them to your roster and share your status when you're online? \n\nIf you choose to defer this choice, you'll be asked again when you next login.").arg(event->getJID().toString().c_str());
QVBoxLayout* layout = new QVBoxLayout();
QLabel* label = new QLabel(text, this);
layout->addWidget(label);
if (event_->getConcluded()) {
- QLabel* doneLabel = new QLabel("You have already replied to this request");
- QPushButton* okButton = new QPushButton("OK", this);
+ QLabel* doneLabel = new QLabel(tr("You have already replied to this request"));
+ QPushButton* okButton = new QPushButton(tr("Ok"), this);
connect(okButton, SIGNAL(clicked()), this, SLOT(handleDefer()));
layout->addWidget(doneLabel);
layout->addWidget(okButton);
} else {
- QPushButton* yesButton = new QPushButton("Yes", this);
+ QPushButton* yesButton = new QPushButton(tr("Yes"), this);
connect(yesButton, SIGNAL(clicked()), this, SLOT(handleYes()));
- QPushButton* noButton = new QPushButton("No", this);
+ QPushButton* noButton = new QPushButton(tr("No"), this);
connect(noButton, SIGNAL(clicked()), this, SLOT(handleNo()));
- QPushButton* deferButton = new QPushButton("Defer", this);
+ QPushButton* deferButton = new QPushButton(tr("Defer"), this);
connect(deferButton, SIGNAL(clicked()), this, SLOT(handleDefer()));
QHBoxLayout* buttonLayout = new QHBoxLayout();
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index bb40da8..d4c306f 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -8,7 +8,6 @@
#include <string>
#include <QSplitter>
-#include <QTextCodec>
#include <boost/bind.hpp>
#include "QtLoginWindow.h"
@@ -72,8 +71,6 @@ po::options_description QtSwift::getOptionsDescription() {
QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL) {
- QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
-
if (options.count("netbook-mode")) {
splitter_ = new QSplitter();
} else {
diff --git a/Swift/QtUI/QtTranslator.h b/Swift/QtUI/QtTranslator.h
new file mode 100644
index 0000000..fdafaf0
--- /dev/null
+++ b/Swift/QtUI/QtTranslator.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2011 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <QCoreApplication>
+
+#include <Swift/Controllers/Translator.h>
+
+class QtTranslator : public Swift::Translator {
+ public:
+ QtTranslator() {
+ }
+
+ virtual std::string translate(const std::string& text, const std::string& context) {
+ return std::string(QCoreApplication::translate(context.c_str(), text.c_str(), 0, QCoreApplication::UnicodeUTF8).toUtf8());
+ }
+};
diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp
index 3aab88b..9d12010 100644
--- a/Swift/QtUI/QtWebView.cpp
+++ b/Swift/QtUI/QtWebView.cpp
@@ -5,7 +5,7 @@
*/
-#include "Swift/QtUI/QtWebView.h"
+#include "QtWebView.h"
#include <QKeyEvent>
#include <QFocusEvent>
@@ -58,7 +58,7 @@ void QtWebView::contextMenuEvent(QContextMenuEvent* ev) {
}
// Add our own custom actions
- menu->addAction("Clear", this, SIGNAL(clearRequested()));
+ menu->addAction(tr("Clear"), this, SIGNAL(clearRequested()));
menu->exec(ev->globalPos());
delete menu;
diff --git a/Swift/QtUI/QtXMLConsoleWidget.cpp b/Swift/QtUI/QtXMLConsoleWidget.cpp
index 42c8a8f..c1b1d0d 100644
--- a/Swift/QtUI/QtXMLConsoleWidget.cpp
+++ b/Swift/QtUI/QtXMLConsoleWidget.cpp
@@ -19,7 +19,7 @@
namespace Swift {
QtXMLConsoleWidget::QtXMLConsoleWidget() {
- setWindowTitle("Console");
+ setWindowTitle(tr("Console"));
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setSpacing(0);
@@ -37,17 +37,17 @@ QtXMLConsoleWidget::QtXMLConsoleWidget() {
buttonLayout->setContentsMargins(10,0,20,0);
buttonLayout->setSpacing(0);
- enabled = new QCheckBox("Trace input/output", bottom);
+ enabled = new QCheckBox(tr("Trace input/output"), bottom);
enabled->setChecked(true);
buttonLayout->addWidget(enabled);
buttonLayout->addStretch();
- QPushButton* clearButton = new QPushButton("Clear", bottom);
+ QPushButton* clearButton = new QPushButton(tr("Clear"), bottom);
connect(clearButton, SIGNAL(clicked()), textEdit, SLOT(clear()));
buttonLayout->addWidget(clearButton);
- setWindowTitle("Debug Console");
+ setWindowTitle(tr("Debug Console"));
emit titleUpdated();
}
@@ -72,11 +72,11 @@ void QtXMLConsoleWidget::closeEvent(QCloseEvent* event) {
}
void QtXMLConsoleWidget::handleDataRead(const std::string& data) {
- appendTextIfEnabled("<!-- IN -->\n" + data + "\n", QColor(33,98,33));
+ appendTextIfEnabled(std::string(tr("<!-- IN -->").toUtf8()) + "\n" + data + "\n", QColor(33,98,33));
}
void QtXMLConsoleWidget::handleDataWritten(const std::string& data) {
- appendTextIfEnabled("<!-- OUT -->\n" + data + "\n", QColor(155,1,0));
+ appendTextIfEnabled(std::string(tr("<!-- OUT -->").toUtf8()) + "\n" + data + "\n", QColor(155,1,0));
}
void QtXMLConsoleWidget::appendTextIfEnabled(const std::string& data, const QColor& color) {
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index 90084c4..963ce72 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -83,18 +83,18 @@ void QtTreeWidget::contextMenuEvent(QContextMenuEvent* event) {
RosterItem* item = static_cast<RosterItem*>(index.internalPointer());
QMenu contextMenu;
if (ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item)) {
- QAction* editContact = contextMenu.addAction("Edit");
+ QAction* editContact = contextMenu.addAction(tr("Edit"));
QAction* result = contextMenu.exec(event->globalPos());
if (result == editContact) {
eventStream_->send(boost::make_shared<RequestContactEditorUIEvent>(contact->getJID()));
}
}
else if (GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item)) {
- QAction* renameGroup = contextMenu.addAction("Rename");
+ QAction* renameGroup = contextMenu.addAction(tr("Rename"));
QAction* result = contextMenu.exec(event->globalPos());
if (result == renameGroup) {
bool ok;
- QString newName = QInputDialog::getText(NULL, "Rename group", "New name for " + P2QSTRING(group->getDisplayName()), QLineEdit::Normal, P2QSTRING(group->getDisplayName()), &ok);
+ QString newName = QInputDialog::getText(NULL, tr("Rename group"), tr("New name for %1").arg(P2QSTRING(group->getDisplayName())), QLineEdit::Normal, P2QSTRING(group->getDisplayName()), &ok);
if (ok) {
eventStream_->send(boost::make_shared<RenameGroupUIEvent>(group->getDisplayName(), Q2PSTRING(newName)));
}
diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h
index ff11567..3430f7e 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.h
+++ b/Swift/QtUI/Roster/QtTreeWidget.h
@@ -4,12 +4,10 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFT_QtTreeWidget_H
-#define SWIFT_QtTreeWidget_H
+#pragma once
#include <QTreeView>
#include <QModelIndex>
-#include "Swift/QtUI/Roster/QtTreeWidget.h"
#include "Swift/QtUI/Roster/RosterModel.h"
#include "Swift/QtUI/Roster/RosterDelegate.h"
@@ -44,5 +42,3 @@ class QtTreeWidget : public QTreeView{
};
}
-#endif
-
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h
index a2d0cdd..6855989 100644
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.h
+++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h
@@ -4,22 +4,17 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFT_QtTreeWidgetItem_H
-#define SWIFT_QtTreeWidgetItem_H
+#pragma once
#include <QColor>
#include <QVariant>
-
#include <string>
+
#include "Swiften/Roster/TreeWidgetFactory.h"
#include "Swiften/Roster/TreeWidget.h"
#include "Swiften/Roster/TreeWidgetItem.h"
-#include "Swift/QtUI/Roster/QtTreeWidgetItem.h"
-
-
#include "Swift/QtUI/QtSwiftUtil.h"
-
namespace Swift {
enum RosterRoles {
StatusTextRole = Qt::UserRole,
@@ -89,5 +84,3 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem {
bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right);
}
-#endif
-
diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp
index 306b76f..2399a21 100644
--- a/Swift/QtUI/Roster/RosterModel.cpp
+++ b/Swift/QtUI/Roster/RosterModel.cpp
@@ -15,6 +15,7 @@
#include "Swiften/Elements/StatusShow.h"
#include "Swift/Controllers/Roster/ContactRosterItem.h"
#include "Swift/Controllers/Roster/GroupRosterItem.h"
+#include <Swift/Controllers/StatusUtil.h>
#include "QtSwiftUtil.h"
#include "Swift/QtUI/Roster/QtTreeWidget.h"
@@ -126,7 +127,7 @@ QString RosterModel::getToolTip(RosterItem* item) const {
if (contact->getDisplayJID().isValid()) {
tip += "\n" + P2QSTRING(contact->getDisplayJID().toBare().toString());
}
- tip += "\n " + P2QSTRING(StatusShow::typeToFriendlyName(contact->getStatusShow()));
+ tip += "\n " + P2QSTRING(statusShowTypeToFriendlyName(contact->getStatusShow()));
if (!getStatusText(item).isEmpty()) {
tip += ": " + getStatusText(item);
}
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 6238693..e52d76a 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -155,7 +155,24 @@ myenv.Uic4("QtJoinMUCWindow.ui")
myenv.Qrc("DefaultTheme.qrc")
myenv.Qrc("Swift.qrc")
-commonResources = ["../resources/sounds"]
+# Resources
+commonResources = {
+ "": ["../resources/sounds"]
+}
+
+# Translation
+translation_sources = [env.File("../Translations/Swift.ts").abspath]
+for file in os.listdir(Dir("../Translations").abspath) :
+ if file.startswith("Swift_") and file.endswith(".ts") :
+ lang = file[6:-3]
+ translation_resource = "../resources/translations/Swift_" + lang + ".qm"
+ translation_source = "../Translations/Swift_" + lang + ".ts"
+ translation_sources.append(env.File(translation_source).abspath)
+ myenv.Qm(translation_resource, translation_source)
+ commonResources["translations"] = commonResources.get("translations", []) + [translation_resource]
+if ARGUMENTS.get("update_translations", False) :
+ t = myenv.Command(translation_sources, [], [myenv.Action("$QT4_LUPDATE -I " + env.Dir("#").abspath + " -silent -codecfortr utf-8 -recursive Swift -ts " + " ".join(translation_sources), cmdstr = "$QT4_LUPDATECOMSTR")])
+ myenv.AlwaysBuild(t)
if env["PLATFORM"] == "darwin" :
frameworks = []
@@ -163,7 +180,8 @@ if env["PLATFORM"] == "darwin" :
frameworks.append(env["SPARKLE_FRAMEWORK"])
if env["HAVE_GROWL"] :
frameworks.append(env["GROWL_FRAMEWORK"])
- app = myenv.AppBundle("Swift", version = myenv["SWIFT_VERSION"], resources = ["../resources/MacOSX/Swift.icns"] + commonResources, frameworks = frameworks)
+ commonResources[""] = commonResources.get("", []) + ["../resources/MacOSX/Swift.icns"]
+ app = myenv.AppBundle("Swift", version = myenv["SWIFT_VERSION"], resources = commonResources, frameworks = frameworks)
if env["DIST"] :
myenv.Command(["Swift-${SWIFT_VERSION}.dmg"], [app], ["Swift/Packaging/MacOSX/package.sh " + app.path + " Swift/Packaging/MacOSX/Swift.dmg.gz $TARGET $QTDIR"])
@@ -171,15 +189,18 @@ if env.get("SWIFT_INSTALLDIR", "") :
env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "bin"), swiftProgram)
env.InstallAs(os.path.join(env["SWIFT_INSTALLDIR"], "share", "pixmaps", "swift.xpm"), "../resources/logo/logo-icon-32.xpm")
env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "applications"), "../resources/swift.desktop")
- for resource in commonResources :
- env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "swift"), resource)
+ for dir, resource in commonResources.items() :
+ env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "swift", dir), resource)
if env["PLATFORM"] == "win32" :
if env["DIST"] :
- myenv.WindowsBundle("Swift", resources = [
+ commonResources[""] = commonResources.get("", []) + [
os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll"),
os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll"),
- ] + commonResources + ["../resources/images"],
+ "../resources/images",
+ ]
+ myenv.WindowsBundle("Swift",
+ resources = commonResources,
qtimageformats = ["gif", "ico", "jpeg", "mng", "svg", "tiff"],
qtlibs = ["QtCore4", "QtGui4", "QtNetwork4", "QtWebKit4", "QtXMLPatterns4", "phonon4"])
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index c6fb004..a384f5d 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -23,7 +23,7 @@ namespace Swift {
QtUserSearchFirstPage::QtUserSearchFirstPage(UserSearchWindow::Type type, const QString& title) {
setupUi(this);
setTitle(title);
- setSubTitle(QString("%1. If you know their JID you can enter it directly, or you can search for them.").arg(type == UserSearchWindow::AddContact ? "Add another user to your roster" : "Chat to another user"));
+ setSubTitle(QString(tr("%1. If you know their JID you can enter it directly, or you can search for them.")).arg(type == UserSearchWindow::AddContact ? tr("Add another user to your roster") : tr("Chat to another user")));
connect(jid_, SIGNAL(textChanged(const QString&)), this, SLOT(emitCompletenessCheck()));
connect(service_->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(emitCompletenessCheck()));
}
@@ -82,7 +82,7 @@ QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWin
setupUi(this);
model_ = new UserSearchModel();
delegate_ = new UserSearchDelegate();
- QString title(type == UserSearchWindow::AddContact ? "Add Contact" : "Chat to User");
+ QString title(type == UserSearchWindow::AddContact ? tr("Add Contact") : tr("Chat to User"));
setWindowTitle(title);
firstPage_ = new QtUserSearchFirstPage(type, title);
connect(firstPage_->byJID_, SIGNAL(toggled(bool)), this, SLOT(handleFirstPageRadioChange()));
@@ -289,7 +289,14 @@ void QtUserSearchWindow::clearForm() {
void QtUserSearchWindow::clear() {
firstPage_->errorLabel_->setVisible(false);
- firstPage_->howLabel_->setText(QString("How would you like to find the user to %1?").arg(type_ == AddContact ? "add" : "chat to"));
+ QString howText;
+ if (type_ == AddContact) {
+ howText = QString("How would you like to find the user to add?");
+ }
+ else {
+ howText = QString("How would you like to find the user to chat to?");
+ }
+ firstPage_->howLabel_->setText(howText);
firstPage_->byJID_->setChecked(true);
clearForm();
model_->clear();
@@ -311,13 +318,13 @@ void QtUserSearchWindow::setError(const QString& error) {
void QtUserSearchWindow::setSearchError(bool error) {
if (error) {
- setError("Error while searching");
+ setError(tr("Error while searching"));
}
}
void QtUserSearchWindow::setServerSupportsSearch(bool support) {
if (!support) {
- setError("This server doesn't support searching for users.");
+ setError(tr("This server doesn't support searching for users."));
}
}
diff --git a/Swift/QtUI/main.cpp b/Swift/QtUI/main.cpp
index c5f744a..3cbb170 100644
--- a/Swift/QtUI/main.cpp
+++ b/Swift/QtUI/main.cpp
@@ -8,14 +8,37 @@
#include <boost/program_options/variables_map.hpp>
#include <boost/program_options.hpp>
#include <boost/version.hpp>
-
#include <iostream>
-
#include <QApplication>
+#include <QTextCodec>
+#include <QTranslator>
+#include <QLocale>
+
+#include <Swift/Controllers/Translator.h>
+#include <Swift/Controllers/ApplicationInfo.h>
+#include <SwifTools/Application/PlatformApplicationPathProvider.h>
#include "QtSwift.h"
+#include "QtTranslator.h"
int main(int argc, char* argv[]) {
+ QApplication app(argc, argv);
+
+ QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+
+ // Translation
+ QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
+ boost::filesystem::path someTranslationPath = Swift::PlatformApplicationPathProvider(SWIFT_APPLICATION_NAME).getResourcePath("/translations/Swift_nl.qm");
+ QTranslator qtTranslator;
+ if (!someTranslationPath.empty()) {
+ //std::cout << "Loading " << std::string(QLocale::system().name().toUtf8()) << std::endl;
+ qtTranslator.load("Swift_" + QLocale::system().name(), someTranslationPath.parent_path().string().c_str());
+ }
+ app.installTranslator(&qtTranslator);
+ QtTranslator swiftTranslator;
+ Swift::Translator::setInstance(&swiftTranslator);
+
+ // Parse program options
boost::program_options::options_description desc = Swift::QtSwift::getOptionsDescription();
boost::program_options::variables_map vm;
try {
@@ -32,7 +55,11 @@ int main(int argc, char* argv[]) {
std::cout << desc << "\n";
return 1;
}
- QApplication app(argc, argv);
+
Swift::QtSwift swift(vm);
- return app.exec();
+ int result = app.exec();
+
+ Swift::Translator::setInstance(NULL);
+
+ return result;
}
diff --git a/Swift/QtUI/tmp/QtContextMenu.cpp b/Swift/QtUI/tmp/QtContextMenu.cpp
deleted file mode 100644
index c74fb31..0000000
--- a/Swift/QtUI/tmp/QtContextMenu.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "ContextMenus/QtContextMenu.h"
-
-namespace Swift {
-
-QtContextMenu::~QtContextMenu() {
-}
-
-}
diff --git a/Swift/QtUI/tmp/QtContextMenu.h b/Swift/QtUI/tmp/QtContextMenu.h
deleted file mode 100644
index 9e73ef9..0000000
--- a/Swift/QtUI/tmp/QtContextMenu.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-namespace Swift {
- class RosterItem;
- class QtContextMenu {
- public:
- virtual ~QtContextMenu();
-
- virtual void show(RosterItem* item) = 0;
- };
-}
diff --git a/Swift/QtUI/tmp/QtRosterContextMenu.cpp b/Swift/QtUI/tmp/QtRosterContextMenu.cpp
deleted file mode 100644
index c8375ba..0000000
--- a/Swift/QtUI/tmp/QtRosterContextMenu.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swift/QtUI/ContextMenus/QtRosterContextMenu.h"
-
-#include <QInputDialog>
-#include <QLineEdit>
-#include <QMenu>
-#include <QDebug>
-#include <QDialog>
-#include <QMessageBox>
-
-#include <boost/shared_ptr.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-#include "Swiften/Roster/ContactRosterItem.h"
-#include "Swiften/Roster/GroupRosterItem.h"
-#include <string>
-#include "Swiften/Roster/Roster.h"
-#include "Swift/Controllers/UIEvents/UIEvent.h"
-#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h"
-#include "Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h"
-#include "Swift/QtUI/QtSwiftUtil.h"
-#include "Swift/QtUI/QtEditContactDialog.h"
-
-
-namespace Swift {
-
-QtRosterContextMenu::QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidget* treeWidget) : eventStream_(eventStream), treeWidget_(treeWidget), item_(NULL) {
-}
-
-void QtRosterContextMenu::show(RosterItem* item) {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
- item_ = item;
- QMenu contextMenu;
- if (contact) {
- contextMenu.addAction("Edit", this, SLOT(handleEditContact()));
- }
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item);
- if (group) {
- contextMenu.addAction("Rename", this, SLOT(handleRenameGroup()));
- }
- contextMenu.exec(QCursor::pos());
-}
-
-void QtRosterContextMenu::handleEditContact() {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item_);
- assert(contact);
-
- // Figure out all the groups the contact is in
- QList<QString> allGroups;
- foreach (RosterItem* item, treeWidget_->getRoster()->getRoot()->getChildren()) {
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item);
- if (group) {
- allGroups.push_back(P2QSTRING(group->getDisplayName()));
- }
- }
-
- QtEditContactDialog editDialog(contact, allGroups, eventStream_);
-
- if (groupDialog.exec() == QDialog::Accepted) {
- eventStream_->send(groupDialog.getRegroupEvent());
- }
-
- /* ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item_);
- QMessageBox msgBox;
- msgBox.setWindowTitle("Confirm contact deletion");
- msgBox.setText("Are you sure you want to delete this contact?");
- msgBox.setInformativeText(QString("This will remove the contact '%1' from all groups they may be in.").arg(P2QSTRING(contact->getJID().toString())));
- msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- msgBox.setDefaultButton(QMessageBox::Yes);
- int ret = msgBox.exec();
- if (ret == QMessageBox::Yes) {
- eventStream_->send(boost::shared_ptr<UIEvent>(new RemoveRosterItemUIEvent(contact->getJID())));
- }*/
-
-
-/* bool ok;
- QString newName = QInputDialog::getText(NULL, "Rename contact", "New name for " + P2QSTRING(item_->getDisplayName()), QLineEdit::Normal, P2QSTRING(item_->getDisplayName()), &ok);
- if (ok) {
- eventStream_->send(boost::shared_ptr<UIEvent>(new RenameRosterItemUIEvent(contact->getJID(), Q2PSTRING(newName))));
- }*/
-}
-
-void QtRosterContextMenu::handleRenameGroup() {
- /*
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item_);
- assert(group);
- bool ok;
- QString newName = QInputDialog::getText(NULL, "Rename group", "New name for " + P2QSTRING(item_->getDisplayName()), QLineEdit::Normal, P2QSTRING(item_->getDisplayName()), &ok);
- if (ok) {
- std::vector<std::string> addedGroups;
- std::vector<std::string> removedGroups;
- addedGroups.push_back(Q2PSTRING(newName));
- removedGroups.push_back(group->getDisplayName());
- foreach (RosterItem* child, group->getChildren()) {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(child);
- assert(contact);
- eventStream_->send(boost::make_shared<RegroupRosterItemUIEvent>(contact->getJID(), addedGroups, removedGroups));
- }
- }
- */
-}
-
-}
diff --git a/Swift/QtUI/tmp/QtRosterContextMenu.h b/Swift/QtUI/tmp/QtRosterContextMenu.h
deleted file mode 100644
index 2357735..0000000
--- a/Swift/QtUI/tmp/QtRosterContextMenu.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include <QObject>
-
-#include "Swift/QtUI/ContextMenus/QtContextMenu.h"
-#include "Swift/QtUI/Roster/QtTreeWidget.h"
-#include "Swift/Controllers/UIEvents/UIEventStream.h"
-
-namespace Swift {
- class RosterItem;
- class QtRosterContextMenu : public QObject, public QtContextMenu {
- Q_OBJECT
- public:
- QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidget* treeWidget);
- void show(RosterItem* item);
-
- private slots:
- void handleRenameGroup();
- void handleEditContact();
-
- private:
- UIEventStream* eventStream_;
- QtTreeWidget* treeWidget_;
- RosterItem* item_;
- };
-}