diff options
author | Saturneric <[email protected]> | 2021-12-01 17:25:46 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-12-01 17:53:09 +0000 |
commit | 1ae8663decb3163b92d32b80cefb46eb678a5af6 (patch) | |
tree | 8e8cb58cacfe12827438b0524917cb0926f926cb /src/ui | |
parent | Add & Modified (diff) | |
download | GpgFrontend-1ae8663decb3163b92d32b80cefb46eb678a5af6.tar.gz GpgFrontend-1ae8663decb3163b92d32b80cefb46eb678a5af6.zip |
Add i18n Support
1. Remove Qt Linguist.
2. Add GNU gettext libraries.
3. Modified source codes to meet with i18n support.
Diffstat (limited to 'src/ui')
90 files changed, 1234 insertions, 1167 deletions
diff --git a/src/ui/FileEncryptionDialog.cpp b/src/ui/FileEncryptionDialog.cpp index d141df1e..cad0dcb1 100755 --- a/src/ui/FileEncryptionDialog.cpp +++ b/src/ui/FileEncryptionDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -29,17 +29,16 @@ namespace GpgFrontend::UI { FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, - DialogAction action, - QWidget* parent) + DialogAction action, QWidget* parent) : QDialog(parent), mAction(action) { if (mAction == Decrypt) { - setWindowTitle(tr("Decrypt File")); + setWindowTitle(_("Decrypt File")); } else if (mAction == Encrypt) { - setWindowTitle(tr("Encrypt File")); + setWindowTitle(_("Encrypt File")); } else if (mAction == Sign) { - setWindowTitle(tr("Sign File")); + setWindowTitle(_("Sign File")); } else if (mAction == Verify) { - setWindowTitle(tr("Verify File")); + setWindowTitle(_("Verify File")); } setModal(true); @@ -49,19 +48,19 @@ FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotExecuteAction())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - auto* groupBox1 = new QGroupBox(tr("Input Parameters")); + auto* groupBox1 = new QGroupBox(_("Input Parameters")); /* Setup input & Outputfileselection*/ inputFileEdit = new QLineEdit(); auto* fb1 = new QPushButton("Select"); connect(fb1, SIGNAL(clicked()), this, SLOT(slotSelectInputFile())); - auto* fl1 = new QLabel(tr("Target File")); + auto* fl1 = new QLabel(_("Target File")); fl1->setBuddy(inputFileEdit); outputFileEdit = new QLineEdit(); auto* fb2 = new QPushButton("Select"); connect(fb2, SIGNAL(clicked()), this, SLOT(slotSelectOutputFile())); - auto* fl2 = new QLabel(tr("Output File")); + auto* fl2 = new QLabel(_("Output File")); fl2->setBuddy(outputFileEdit); auto* gLayout = new QGridLayout(); @@ -77,7 +76,7 @@ FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, } else { auto* sfb1 = new QPushButton("Select"); connect(sfb1, SIGNAL(clicked()), this, SLOT(slotSelectSignFile())); - auto* sfl1 = new QLabel(tr("Signature File(.sig) Path")); + auto* sfl1 = new QLabel(_("Signature File(.sig) Path")); sfl1->setBuddy(signFileEdit); gLayout->addWidget(sfl1, 1, 0); @@ -114,8 +113,7 @@ FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, return true; }); - if (mAction == Decrypt) - mKeyList->setDisabled(true); + if (mAction == Decrypt) mKeyList->setDisabled(true); mKeyList->slotRefresh(); mKeyList->setChecked(keyList); @@ -136,15 +134,14 @@ FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, } void FileEncryptionDialog::slotSelectInputFile() { - QString path = ""; + QString path; if (inputFileEdit->text().size() > 0) { path = QFileInfo(inputFileEdit->text()).absolutePath(); } - // QString infileName = QFileDialog::getOpenFileName(this, tr("Open File"), - // path, tr("Files") + tr("All Files (*)")); - QString infileName = - QFileDialog::getOpenFileName(this, tr("Open File"), path); + // QString infileName = QFileDialog::getOpenFileName(this, _("Open File"), + // path, _("Files") + _("All Files (*)")); + QString infileName = QFileDialog::getOpenFileName(this, _("Open File"), path); inputFileEdit->setText(infileName); // try to find a matching output-filename, if not yet done @@ -169,26 +166,26 @@ void FileEncryptionDialog::slotSelectInputFile() { } void FileEncryptionDialog::slotSelectOutputFile() { - QString path = ""; + QString path; if (outputFileEdit->text().size() > 0) { path = QFileInfo(outputFileEdit->text()).absolutePath(); } QString outfileName = - QFileDialog::getSaveFileName(this, tr("Save File"), path, nullptr, - nullptr, QFileDialog::DontConfirmOverwrite); + QFileDialog::getSaveFileName(this, _("Save File"), path, nullptr, nullptr, + QFileDialog::DontConfirmOverwrite); outputFileEdit->setText(outfileName); } void FileEncryptionDialog::slotSelectSignFile() { - QString path = ""; + QString path; if (signFileEdit->text().size() > 0) { path = QFileInfo(signFileEdit->text()).absolutePath(); } QString signfileName = - QFileDialog::getSaveFileName(this, tr("Open File"), path, nullptr, - nullptr, QFileDialog::DontConfirmOverwrite); + QFileDialog::getSaveFileName(this, _("Open File"), path, nullptr, nullptr, + QFileDialog::DontConfirmOverwrite); signFileEdit->setText(signfileName); if (inputFileEdit->text().size() == 0 && @@ -203,7 +200,7 @@ void FileEncryptionDialog::slotExecuteAction() { QFile infile; infile.setFileName(inputFileEdit->text()); if (!infile.open(QIODevice::ReadOnly)) { - statusLabel->setText(tr("Couldn't open file")); + statusLabel->setText(_("Couldn't open file")); inputFileEdit->setStyleSheet("QLineEdit { background: yellow }"); return; } @@ -223,8 +220,8 @@ void FileEncryptionDialog::slotExecuteAction() { if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) { qDebug() << "Error" << gpgme_strerror(err); - QMessageBox::warning(this, tr("Error"), - tr("Error Occurred During Encryption")); + QMessageBox::warning(this, _("Error"), + _("Error Occurred During Encryption")); return; } } @@ -236,8 +233,8 @@ void FileEncryptionDialog::slotExecuteAction() { BasicOperator::GetInstance().Decrypt(in_data, out_data, result); if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) { qDebug() << "Error" << gpgme_strerror(err); - QMessageBox::warning(this, tr("Error"), - tr("Error Occurred During Decryption")); + QMessageBox::warning(this, _("Error"), + _("Error Occurred During Decryption")); return; } } @@ -249,8 +246,8 @@ void FileEncryptionDialog::slotExecuteAction() { std::move(keys), in_data, out_data, GPGME_SIG_MODE_DETACH, result); if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) { qDebug() << "Error" << gpgme_strerror(err); - QMessageBox::warning(this, tr("Error"), - tr("Error Occurred During Signature")); + QMessageBox::warning(this, _("Error"), + _("Error Occurred During Signature")); return; } } @@ -270,12 +267,8 @@ void FileEncryptionDialog::slotExecuteAction() { accept(); } -void FileEncryptionDialog::slotShowKeyList() { - mKeyList->show(); -} +void FileEncryptionDialog::slotShowKeyList() { mKeyList->show(); } -void FileEncryptionDialog::slotHideKeyList() { - mKeyList->hide(); -} +void FileEncryptionDialog::slotHideKeyList() { mKeyList->hide(); } } // namespace GpgFrontend::UI diff --git a/src/ui/FileEncryptionDialog.h b/src/ui/FileEncryptionDialog.h index a3e56564..613f84e7 100755 --- a/src/ui/FileEncryptionDialog.h +++ b/src/ui/FileEncryptionDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -51,8 +51,7 @@ class FileEncryptionDialog : public QDialog { * @param keyList * @param parent */ - FileEncryptionDialog(KeyIdArgsListPtr keyList, - DialogAction action, + FileEncryptionDialog(KeyIdArgsListPtr keyList, DialogAction action, QWidget* parent = nullptr); public slots: diff --git a/src/ui/FindWidget.cpp b/src/ui/FindWidget.cpp index f9b92685..6326b119 100644 --- a/src/ui/FindWidget.cpp +++ b/src/ui/FindWidget.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -30,13 +30,14 @@ FindWidget::FindWidget(QWidget* parent, QTextEdit* edit) : QWidget(parent) { mTextpage = edit; findEdit = new QLineEdit(this); auto* closeButton = new QPushButton( - this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), "", this); - auto* nextButton = new QPushButton(QIcon(":button_next.png"), ""); + this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), QString(), + this); + auto* nextButton = new QPushButton(QIcon(":button_next.png"), QString()); auto* previousButton = new QPushButton(QIcon(":button_previous.png"), ""); auto* notificationWidgetLayout = new QHBoxLayout(this); notificationWidgetLayout->setContentsMargins(10, 0, 0, 0); - notificationWidgetLayout->addWidget(new QLabel(tr("Find:"))); + notificationWidgetLayout->addWidget(new QLabel(QString(_("Find")) + ": ")); notificationWidgetLayout->addWidget(findEdit, 2); notificationWidgetLayout->addWidget(nextButton); notificationWidgetLayout->addWidget(previousButton); diff --git a/src/ui/FindWidget.h b/src/ui/FindWidget.h index f57f95a6..e4cbdaab 100644 --- a/src/ui/FindWidget.h +++ b/src/ui/FindWidget.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/GpgFrontendUI.h b/src/ui/GpgFrontendUI.h index 593ed872..c5d80d01 100644 --- a/src/ui/GpgFrontendUI.h +++ b/src/ui/GpgFrontendUI.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -26,11 +26,24 @@ #define GPGFRONTEND_GPGFRONTENDUI_H #include <GpgFrontend.h> -#include <easyloggingpp/easylogging++.h> #include <QtCore> #include <QtNetwork> #include <QtPrintSupport> #include <QtWidgets> +/** + * Resources File(s) Path Vars + */ +#if defined(MACOS) && defined(RELEASE) +#define RESOURCE_DIR(appDir) (appDir + "/../Resources/") +#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir / ".." / "Resources") +#elif defined(LINUX) && defined(RELEASE) +#define RESOURCE_DIR(appDir) (appDir + "/../share/") +#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir / ".." / "share") +#else +#define RESOURCE_DIR(appDir) (appDir) +#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir) +#endif + #endif // GPGFRONTEND_GPGFRONTENDUI_H diff --git a/src/ui/KeyImportDetailDialog.cpp b/src/ui/KeyImportDetailDialog.cpp index 92c73f0e..321de3a6 100644 --- a/src/ui/KeyImportDetailDialog.cpp +++ b/src/ui/KeyImportDetailDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -33,11 +33,11 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, // If no key for import found, just show a message if (mResult.considered == 0) { if (automatic) - QMessageBox::information(nullptr, tr("Key Update Details"), - tr("No keys found")); + QMessageBox::information(nullptr, _("Key Update Details"), + _("No keys found")); else - QMessageBox::information(nullptr, tr("Key Import Details"), - tr("No keys found to import")); + QMessageBox::information(nullptr, _("Key Import Details"), + _("No keys found to import")); return; } @@ -54,9 +54,9 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, this->setLayout(mvbox); if (automatic) - this->setWindowTitle(tr("Key Update Details")); + this->setWindowTitle(_("Key Update Details")); else - this->setWindowTitle(tr("Key Import Details")); + this->setWindowTitle(_("Key Import Details")); this->resize(QSize(600, 300)); this->setModal(true); @@ -65,48 +65,52 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, void KeyImportDetailDialog::createGeneralInfoBox() { // GridBox for general import information - generalInfoBox = new QGroupBox(tr("General key info")); + generalInfoBox = new QGroupBox(_("General key info")); auto* generalInfoBoxLayout = new QGridLayout(generalInfoBox); - generalInfoBoxLayout->addWidget(new QLabel(tr("Considered:")), 1, 0); + generalInfoBoxLayout->addWidget(new QLabel(QString(_("Considered")) + ": "), + 1, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.considered)), 1, 1); int row = 2; if (mResult.unchanged != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Public unchanged:")), row, - 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Public unchanged")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.unchanged)), row, 1); row++; } if (mResult.imported != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Imported:")), row, 0); + generalInfoBoxLayout->addWidget(new QLabel(QString(_("Imported")) + ": "), + row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.imported)), row, 1); row++; } if (mResult.not_imported != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Not imported:")), row, 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Not Imported")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.not_imported)), row, 1); row++; } if (mResult.secret_read != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Private read:")), row, 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Private Read")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.secret_read)), row, 1); row++; } if (mResult.secret_imported != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Private imported:")), row, - 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Private Imported")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.secret_imported)), row, 1); row++; } if (mResult.secret_unchanged != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Private unchanged:")), row, - 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Private Unchanged")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.secret_unchanged)), row, 1); row++; @@ -115,7 +119,7 @@ void KeyImportDetailDialog::createGeneralInfoBox() { void KeyImportDetailDialog::createKeysTable() { LOG(INFO) << "KeyImportDetailDialog::createKeysTable() Called"; - + keysTable = new QTableWidget(this); keysTable->setRowCount(0); keysTable->setColumnCount(4); @@ -124,8 +128,7 @@ void KeyImportDetailDialog::createKeysTable() { keysTable->setSelectionMode(QAbstractItemView::NoSelection); QStringList headerLabels; - headerLabels << tr("Name") << tr("Email") << tr("Status") - << tr("Fingerprint"); + headerLabels << _("Name") << _("Email") << _("Status") << _("Fingerprint"); keysTable->verticalHeader()->hide(); keysTable->setHorizontalHeaderLabels(headerLabels); @@ -154,27 +157,27 @@ QString KeyImportDetailDialog::getStatusString(int keyStatus) { QString statusString; // keystatus is greater than 15, if key is private if (keyStatus > 15) { - statusString.append(tr("private")); + statusString.append(_("Private")); keyStatus = keyStatus - 16; } else { - statusString.append(tr("public")); + statusString.append(_("Public")); } if (keyStatus == 0) { - statusString.append(", " + tr("unchanged")); + statusString.append(", " + QString(_("Unchanged"))); } else { if (keyStatus == 1) { - statusString.append(", " + tr("new key")); + statusString.append(", " + QString(_("New Key"))); } else { if (keyStatus > 7) { - statusString.append(", " + tr("new subkey")); + statusString.append(", " + QString(_("New Subkey"))); keyStatus = keyStatus - 8; } if (keyStatus > 3) { - statusString.append(", " + tr("new signature")); + statusString.append(", " + QString(_("New Signature"))); keyStatus = keyStatus - 4; } if (keyStatus > 1) { - statusString.append(", " + tr("new uid")); + statusString.append(", " + QString(_("New UID"))); keyStatus = keyStatus - 2; } } diff --git a/src/ui/KeyImportDetailDialog.h b/src/ui/KeyImportDetailDialog.h index e3137503..0c7d6807 100644 --- a/src/ui/KeyImportDetailDialog.h +++ b/src/ui/KeyImportDetailDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -26,6 +26,7 @@ #define __KEYIMPORTDETAILSDIALOG_H__ #include <gpg/function/GpgKeyImportExportor.h> + #include "gpg/GpgContext.h" #include "ui/GpgFrontendUI.h" @@ -34,8 +35,7 @@ class KeyImportDetailDialog : public QDialog { Q_OBJECT public: - KeyImportDetailDialog(GpgImportInformation result, - bool automatic, + KeyImportDetailDialog(GpgImportInformation result, bool automatic, QWidget* parent = nullptr); private: diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp index df476fc9..0c3d6a14 100755 --- a/src/ui/KeyMgmt.cpp +++ b/src/ui/KeyMgmt.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -88,7 +88,7 @@ KeyMgmt::KeyMgmt(QWidget* parent) this->settings.setValue("keymgmt/setWindowSize", true); } - setWindowTitle(tr("Key Pair Management")); + setWindowTitle(_("Key Pair Management")); mKeyList->addMenuAction(deleteSelectedKeysAct); mKeyList->addMenuAction(showKeyDetailsAct); @@ -97,91 +97,90 @@ KeyMgmt::KeyMgmt(QWidget* parent) } void KeyMgmt::createActions() { - openKeyFileAct = new QAction(tr("&Open"), this); - openKeyFileAct->setShortcut(tr("Ctrl+O")); - openKeyFileAct->setToolTip(tr("Open Key File")); + openKeyFileAct = new QAction(_("Open"), this); + openKeyFileAct->setShortcut(QKeySequence(_("Ctrl+O"))); + openKeyFileAct->setToolTip(_("Open Key File")); connect(openKeyFileAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromFile())); - closeAct = new QAction(tr("&Close"), this); - closeAct->setShortcut(tr("Ctrl+Q")); + closeAct = new QAction(_("Close"), this); + closeAct->setShortcut(QKeySequence(_("Ctrl+Q"))); closeAct->setIcon(QIcon(":exit.png")); - closeAct->setToolTip(tr("Close")); + closeAct->setToolTip(_("Close")); connect(closeAct, SIGNAL(triggered()), this, SLOT(close())); - generateKeyPairAct = new QAction(tr("New Keypair"), this); - generateKeyPairAct->setShortcut(tr("Ctrl+N")); + generateKeyPairAct = new QAction(_("New Keypair"), this); + generateKeyPairAct->setShortcut(QKeySequence(_("Ctrl+N"))); generateKeyPairAct->setIcon(QIcon(":key_generate.png")); - generateKeyPairAct->setToolTip(tr("Generate KeyPair")); + generateKeyPairAct->setToolTip(_("Generate KeyPair")); connect(generateKeyPairAct, SIGNAL(triggered()), this, SLOT(slotGenerateKeyDialog())); - generateSubKeyAct = new QAction(tr("New Subkey"), this); - generateSubKeyAct->setShortcut(tr("Ctrl+Shift+N")); + generateSubKeyAct = new QAction(_("New Subkey"), this); + generateSubKeyAct->setShortcut(QKeySequence(_("Ctrl+Shift+N"))); generateSubKeyAct->setIcon(QIcon(":key_generate.png")); - generateSubKeyAct->setToolTip(tr("Generate Subkey For Selected KeyPair")); + generateSubKeyAct->setToolTip(_("Generate Subkey For Selected KeyPair")); connect(generateSubKeyAct, SIGNAL(triggered()), this, SLOT(slotGenerateSubKey())); - importKeyFromFileAct = new QAction(tr("&File"), this); + importKeyFromFileAct = new QAction(_("File"), this); importKeyFromFileAct->setIcon(QIcon(":import_key_from_file.png")); - importKeyFromFileAct->setToolTip(tr("Import New Key From File")); + importKeyFromFileAct->setToolTip(_("Import New Key From File")); connect(importKeyFromFileAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromFile())); - importKeyFromClipboardAct = new QAction(tr("&Clipboard"), this); + importKeyFromClipboardAct = new QAction(_("Clipboard"), this); importKeyFromClipboardAct->setIcon(QIcon(":import_key_from_clipboard.png")); - importKeyFromClipboardAct->setToolTip(tr("Import New Key From Clipboard")); + importKeyFromClipboardAct->setToolTip(_("Import New Key From Clipboard")); connect(importKeyFromClipboardAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromClipboard())); - importKeyFromKeyServerAct = new QAction(tr("&Keyserver"), this); + importKeyFromKeyServerAct = new QAction(_("Keyserver"), this); importKeyFromKeyServerAct->setIcon(QIcon(":import_key_from_server.png")); - importKeyFromKeyServerAct->setToolTip(tr("Import New Key From Keyserver")); + importKeyFromKeyServerAct->setToolTip(_("Import New Key From Keyserver")); connect(importKeyFromKeyServerAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromKeyServer())); - exportKeyToClipboardAct = new QAction(tr("Export To &Clipboard"), this); + exportKeyToClipboardAct = new QAction(_("Export To Clipboard"), this); exportKeyToClipboardAct->setIcon(QIcon(":export_key_to_clipboard.png")); - exportKeyToClipboardAct->setToolTip( - tr("Export Selected Key(s) To Clipboard")); + exportKeyToClipboardAct->setToolTip(_("Export Selected Key(s) To Clipboard")); connect(exportKeyToClipboardAct, SIGNAL(triggered()), this, SLOT(slotExportKeyToClipboard())); - exportKeyToFileAct = new QAction(tr("Export To &File"), this); + exportKeyToFileAct = new QAction(_("Export To File"), this); exportKeyToFileAct->setIcon(QIcon(":export_key_to_file.png")); - exportKeyToFileAct->setToolTip(tr("Export Selected Key(s) To File")); + exportKeyToFileAct->setToolTip(_("Export Selected Key(s) To File")); connect(exportKeyToFileAct, SIGNAL(triggered()), this, SLOT(slotExportKeyToFile())); - deleteSelectedKeysAct = new QAction(tr("Delete Selected Key(s)"), this); - deleteSelectedKeysAct->setToolTip(tr("Delete the Selected keys")); + deleteSelectedKeysAct = new QAction(_("Delete Selected Key(s)"), this); + deleteSelectedKeysAct->setToolTip(_("Delete the Selected keys")); connect(deleteSelectedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteSelectedKeys())); - deleteCheckedKeysAct = new QAction(tr("Delete Checked Key(s)"), this); - deleteCheckedKeysAct->setToolTip(tr("Delete the Checked keys")); + deleteCheckedKeysAct = new QAction(_("Delete Checked Key(s)"), this); + deleteCheckedKeysAct->setToolTip(_("Delete the Checked keys")); deleteCheckedKeysAct->setIcon(QIcon(":button_delete.png")); connect(deleteCheckedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteCheckedKeys())); - showKeyDetailsAct = new QAction(tr("Show Key Details"), this); - showKeyDetailsAct->setToolTip(tr("Show Details for this Key")); + showKeyDetailsAct = new QAction(_("Show Key Details"), this); + showKeyDetailsAct->setToolTip(_("Show Details for this Key")); connect(showKeyDetailsAct, SIGNAL(triggered()), this, SLOT(slotShowKeyDetails())); } void KeyMgmt::createMenus() { - fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu = menuBar()->addMenu(_("File")); fileMenu->addAction(openKeyFileAct); fileMenu->addAction(closeAct); - keyMenu = menuBar()->addMenu(tr("&Key")); - generateKeyMenu = keyMenu->addMenu(tr("&Generate Key")); + keyMenu = menuBar()->addMenu(_("Key")); + generateKeyMenu = keyMenu->addMenu(_("Generate Key")); generateKeyMenu->addAction(generateKeyPairAct); generateKeyMenu->addAction(generateSubKeyAct); - importKeyMenu = keyMenu->addMenu(tr("&Import Key")); + importKeyMenu = keyMenu->addMenu(_("Import Key")); importKeyMenu->addAction(importKeyFromFileAct); importKeyMenu->addAction(importKeyFromClipboardAct); importKeyMenu->addAction(importKeyFromKeyServerAct); @@ -192,7 +191,7 @@ void KeyMgmt::createMenus() { } void KeyMgmt::createToolBars() { - QToolBar* keyToolBar = addToolBar(tr("Key")); + QToolBar* keyToolBar = addToolBar(_("Key")); keyToolBar->setObjectName("keytoolbar"); // add button with popup menu for import @@ -200,8 +199,8 @@ void KeyMgmt::createToolBars() { generateToolButton->setMenu(generateKeyMenu); generateToolButton->setPopupMode(QToolButton::InstantPopup); generateToolButton->setIcon(QIcon(":key_generate.png")); - generateToolButton->setText(tr("Generate")); - generateToolButton->setToolTip(tr("Generate A New Keypair or Subkey")); + generateToolButton->setText(_("Generate")); + generateToolButton->setToolTip(_("Generate A New Keypair or Subkey")); generateToolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); keyToolBar->addWidget(generateToolButton); @@ -210,8 +209,8 @@ void KeyMgmt::createToolBars() { toolButton->setMenu(importKeyMenu); toolButton->setPopupMode(QToolButton::InstantPopup); toolButton->setIcon(QIcon(":key_import.png")); - toolButton->setToolTip(tr("Import key")); - toolButton->setText(tr("Import Key")); + toolButton->setToolTip(_("Import key")); + toolButton->setText(_("Import Key")); toolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); keyToolBar->addWidget(toolButton); @@ -231,8 +230,8 @@ void KeyMgmt::slotImportKeys(const std::string& in_buffer) { void KeyMgmt::slotImportKeyFromFile() { QString file_name = QFileDialog::getOpenFileName( - this, tr("Open Key"), "", - tr("Key Files") + " (*.asc *.txt);;" + tr("Keyring files") + + this, _("Open Key"), QString(), + QString(_("Key Files")) + " (*.asc *.txt);;" + _("Keyring files") + " (*.gpg);;All Files (*)"); if (!file_name.isNull()) { slotImportKeys(read_all_data_in_file(file_name.toStdString())); @@ -277,10 +276,12 @@ void KeyMgmt::deleteKeysWithWarning(KeyIdArgsListPtr key_ids) { } int ret = QMessageBox::warning( - this, tr("Deleting Keys"), - "<b>" + tr("Are you sure that you want to delete the following keys?") + + this, _("Deleting Keys"), + "<b>" + + QString( + _("Are you sure that you want to delete the following keys?")) + "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { @@ -296,7 +297,7 @@ void KeyMgmt::slotShowKeyDetails() { auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front()); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } @@ -313,19 +314,19 @@ void KeyMgmt::slotExportKeyToFile() { auto key = GpgKeyGetter::GetInstance().GetKey(mKeyList->getSelected()->front()); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } QString fileString = QString::fromStdString(key.name() + " " + key.email() + "(" + key.id() + ")_pub.asc"); QString file_name = QFileDialog::getSaveFileName( - this, tr("Export Key To File"), fileString, - tr("Key Files") + " (*.asc *.txt);;All Files (*)"); + this, _("Export Key To File"), fileString, + QString(_("Key Files")) + " (*.asc *.txt);;All Files (*)"); write_buffer_to_file(file_name.toStdString(), *key_export_data); - emit signalStatusBarChanged(QString(tr("key(s) exported"))); + emit signalStatusBarChanged(QString(_("key(s) exported"))); } void KeyMgmt::slotExportKeyToClipboard() { @@ -349,19 +350,19 @@ void KeyMgmt::slotGenerateSubKey() { auto keys_selected = mKeyList->getSelected(); if (keys_selected->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one KeyPair before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one KeyPair before doing this operation.")); return; } const auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front()); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } if (!key.is_private_key()) { - QMessageBox::critical(nullptr, tr("Invalid Operation"), - tr("If a key pair does not have a private key then " - "it will not be able to generate sub-keys.")); + QMessageBox::critical(nullptr, _("Invalid Operation"), + _("If a key pair does not have a private key then " + "it will not be able to generate sub-keys.")); return; } diff --git a/src/ui/KeyMgmt.h b/src/ui/KeyMgmt.h index f96fbf38..1bf350f7 100755 --- a/src/ui/KeyMgmt.h +++ b/src/ui/KeyMgmt.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp index 866e378a..b529637f 100644 --- a/src/ui/KeyServerImportDialog.cpp +++ b/src/ui/KeyServerImportDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -44,17 +44,17 @@ KeyServerImportDialog::KeyServerImportDialog(KeyList* keyList, bool automatic, } // Buttons - closeButton = createButton(tr("&Close"), SLOT(close())); - importButton = createButton(tr("&Import ALL"), SLOT(slotImport())); + closeButton = createButton(_("Close"), SLOT(close())); + importButton = createButton(_("Import ALL"), SLOT(slotImport())); importButton->setDisabled(true); - searchButton = createButton(tr("&Search"), SLOT(slotSearch())); + searchButton = createButton(_("Search"), SLOT(slotSearch())); // Line edit for search string - searchLabel = new QLabel(tr("Search String:")); + searchLabel = new QLabel(QString(_("Search String")) + _(": ")); searchLineEdit = new QLineEdit(); // combobox for keyserverlist - keyServerLabel = new QLabel(tr("Key Server:")); + keyServerLabel = new QLabel(QString(_("Key Server")) + _(": ")); keyServerComboBox = createComboBox(); // table containing the keys found @@ -101,9 +101,9 @@ KeyServerImportDialog::KeyServerImportDialog(KeyList* keyList, bool automatic, this->setLayout(mainLayout); if (automatic) - this->setWindowTitle(tr("Update Keys from Keyserver")); + this->setWindowTitle(_("Update Keys from Keyserver")); else - this->setWindowTitle(tr("Import Keys from Keyserver")); + this->setWindowTitle(_("Import Keys from Keyserver")); if (automatic) { this->setFixedSize(240, 42); @@ -168,7 +168,7 @@ void KeyServerImportDialog::createKeysTable() { keysTable->setSelectionMode(QAbstractItemView::SingleSelection); QStringList labels; - labels << tr("UID") << tr("Creation date") << tr("KeyID") << tr("Tag"); + labels << _("UID") << _("Creation date") << _("KeyID") << _("Tag"); keysTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::ResizeToContents); keysTable->setHorizontalHeaderLabels(labels); @@ -190,7 +190,7 @@ void KeyServerImportDialog::setMessage(const QString& text, bool error) { void KeyServerImportDialog::slotSearch() { if (searchLineEdit->text().isEmpty()) { - setMessage("<h4>" + tr("Text is empty.") + "</h4>", false); + setMessage("<h4>" + QString(_("Text is empty.")) + "</h4>", false); return; } @@ -233,16 +233,16 @@ void KeyServerImportDialog::slotSearchFinished() { qDebug() << "Error From Reply" << reply->errorString(); switch (error) { case QNetworkReply::ContentNotFoundError: - setMessage(tr("Not Key Found"), true); + setMessage(_("Not Key Found"), true); break; case QNetworkReply::TimeoutError: - setMessage(tr("Timeout"), true); + setMessage(_("Timeout"), true); break; case QNetworkReply::HostNotFoundError: - setMessage(tr("Key Server Not Found"), true); + setMessage(_("Key Server Not Found"), true); break; default: - setMessage(tr("Connection Error"), true); + setMessage(_("Connection Error"), true); } return; } @@ -250,32 +250,35 @@ void KeyServerImportDialog::slotSearchFinished() { if (first_line.contains("Error")) { QString text = QString(reply->readLine(1024)); if (text.contains("Too many responses")) { - setMessage("<h4>" + tr("Too many responses from keyserver!") + "</h4>", - true); + setMessage( + "<h4>" + QString(_("Too many responses from keyserver!")) + "</h4>", + true); return; } else if (text.contains("No keys found")) { // if string looks like hex string, search again with 0x prepended QRegExp rx("[0-9A-Fa-f]*"); QString query = searchLineEdit->text(); if (rx.exactMatch(query)) { - setMessage("<h4>" + - tr("No keys found, input may be kexId, retrying search " - "with 0x.") + - "</h4>", - true); + setMessage( + "<h4>" + + QString(_("No keys found, input may be kexId, retrying search " + "with 0x.")) + + "</h4>", + true); searchLineEdit->setText(query.prepend("0x")); this->slotSearch(); return; } else { - setMessage("<h4>" + tr("No keys found containing the search string!") + - "</h4>", - true); + setMessage( + "<h4>" + QString(_("No keys found containing the search string!")) + + "</h4>", + true); return; } } else if (text.contains("Insufficiently specific words")) { - setMessage( - "<h4>" + tr("Insufficiently specific search string!") + "</h4>", - true); + setMessage("<h4>" + QString(_("Insufficiently specific search string!")) + + "</h4>", + true); return; } else { setMessage(text, true); @@ -306,11 +309,11 @@ void KeyServerImportDialog::slotSearchFinished() { } if (flags.contains("r")) { keysTable->setItem(row, 3, - new QTableWidgetItem(QString(tr("revoked")))); + new QTableWidgetItem(QString(_("revoked")))); } if (flags.contains("d")) { keysTable->setItem(row, 3, - new QTableWidgetItem(QString(tr("disabled")))); + new QTableWidgetItem(QString(_("disabled")))); } } @@ -350,9 +353,12 @@ void KeyServerImportDialog::slotSearchFinished() { } } } - setMessage(tr("<h4>%1 keys found. Double click a key to import it.</h4>") - .arg(row), - false); + setMessage( + QString("<h4>") + + QString(_("%1 keys found. Double click a key to import it.")) + .arg(row) + + "</h4>", + false); } keysTable->resizeColumnsToContents(); importButton->setDisabled(keysTable->size().isEmpty()); @@ -424,16 +430,16 @@ void KeyServerImportDialog::slotImportFinished() { qDebug() << "Error From Reply" << reply->errorString(); switch (error) { case QNetworkReply::ContentNotFoundError: - setMessage(tr("Key Not Found"), true); + setMessage(_("Key Not Found"), true); break; case QNetworkReply::TimeoutError: - setMessage(tr("Timeout"), true); + setMessage(_("Timeout"), true); break; case QNetworkReply::HostNotFoundError: - setMessage(tr("Key Server Not Found"), true); + setMessage(_("Key Server Not Found"), true); break; default: - setMessage(tr("Connection Error"), true); + setMessage(_("Connection Error"), true); } if (mAutomatic) { setWindowFlags(Qt::Window | Qt::WindowTitleHint | @@ -454,9 +460,9 @@ void KeyServerImportDialog::slotImportFinished() { this->importKeys(std::make_unique<ByteArray>(key.constData(), key.length())); if (mAutomatic) { - setMessage(tr("<h4>Key Updated</h4>"), false); + setMessage(QString("<h4>") + _("Key Updated") + "</h4>", false); } else { - setMessage(tr("<h4>Key Imported</h4>"), false); + setMessage(QString("<h4>") + _("Key Imported") + "</h4>", false); } } @@ -518,7 +524,7 @@ KeyServerImportDialog::KeyServerImportDialog(QWidget* parent) mainLayout->addLayout(messageLayout, 0, 0, 1, 3); this->setLayout(mainLayout); - this->setWindowTitle(tr("Upload Keys from Keyserver")); + this->setWindowTitle(_("Upload Keys from Keyserver")); this->setFixedSize(200, 42); this->setModal(true); } diff --git a/src/ui/KeyServerImportDialog.h b/src/ui/KeyServerImportDialog.h index f768afa7..0fb7dbf1 100644 --- a/src/ui/KeyServerImportDialog.h +++ b/src/ui/KeyServerImportDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/KeyUploadDialog.cpp index da905e8e..e8c37c5b 100644 --- a/src/ui/KeyUploadDialog.cpp +++ b/src/ui/KeyUploadDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -50,7 +50,7 @@ KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids, this->setLayout(layout); this->setModal(true); - this->setWindowTitle(tr("Uploading Public Key")); + this->setWindowTitle(_("Uploading Public Key")); this->setFixedSize(240, 42); } @@ -116,16 +116,16 @@ void KeyUploadDialog::slotUploadFinished() { QString message; switch (error) { case QNetworkReply::ContentNotFoundError: - message = tr("Key Not Found"); + message = _("Key Not Found"); break; case QNetworkReply::TimeoutError: - message = tr("Timeout"); + message = _("Timeout"); break; case QNetworkReply::HostNotFoundError: - message = tr("Key Server Not Found"); + message = _("Key Server Not Found"); break; default: - message = tr("Connection Error"); + message = _("Connection Error"); } QMessageBox::critical(this, "Upload Failed", message); return; diff --git a/src/ui/KeyUploadDialog.h b/src/ui/KeyUploadDialog.h index bf7533cb..b607c321 100644 --- a/src/ui/KeyUploadDialog.h +++ b/src/ui/KeyUploadDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index b986782b..cc04f246 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -32,7 +32,7 @@ namespace GpgFrontend::UI { MainWindow::MainWindow() { networkAccessManager = new QNetworkAccessManager(this); - auto waitingDialog = new WaitingDialog(tr("Loading Gnupg"), this); + auto waitingDialog = new WaitingDialog(_("Loading Gnupg"), this); QString baseUrl = "https://api.github.com/repos/saturneric/gpgfrontend/releases/latest"; @@ -57,9 +57,9 @@ MainWindow::MainWindow() { // Check Context Status if (!GpgContext::GetInstance().good()) { QMessageBox::critical( - nullptr, tr("ENV Loading Failed"), - tr("Gnupg is not installed correctly, please follow the ReadME " - "instructions to install gnupg and then open GPGFrontend.")); + nullptr, _("ENV Loading Failed"), + _("Gnupg is not installed correctly, please follow the ReadME " + "instructions to install gnupg and then open GpgFrontend.")); QCoreApplication::quit(); exit(0); } diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 095bc974..82acee63 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -230,11 +230,11 @@ class MainWindow : public QMainWindow { */ void slotOpenSettingsDialog(); -// /** -// * @details Show a warn message in status bar, if there are files in -// * attachment folder. -// */ -// void slotCheckAttachmentFolder(); + // /** + // * @details Show a warn message in status bar, if there are files in + // * attachment folder. + // */ + // void slotCheckAttachmentFolder(); /** * @details Replace double linebreaks by single linebreaks in currently active diff --git a/src/ui/QuitDialog.cpp b/src/ui/QuitDialog.cpp index f6b3f196..a5ed7c3f 100755 --- a/src/ui/QuitDialog.cpp +++ b/src/ui/QuitDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -24,11 +24,13 @@ #include "ui/QuitDialog.h" +#include <boost/format.hpp> + namespace GpgFrontend::UI { QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) : QDialog(parent) { - setWindowTitle(tr("Unsaved Files")); + setWindowTitle(_("Unsaved Files")); setModal(true); discarded = false; @@ -75,10 +77,12 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) pixmap = pixmap.scaled(50, 50, Qt::KeepAspectRatio, Qt::SmoothTransformation); auto* warn_icon = new QLabel(); warn_icon->setPixmap(pixmap); - auto* warn_label = - new QLabel(tr("%1 files contain unsaved information.<br/>Save the " - "changes before closing?") - .arg(row)); + + const auto info = + boost::format(_("%1% files contain unsaved information.<br/>Save the " + "changes before closing?")) % + std::to_string(row); + auto* warn_label = new QLabel(QString::fromStdString(info.str())); auto* warnBoxLayout = new QHBoxLayout(); warnBoxLayout->addWidget(warn_icon); warnBoxLayout->addWidget(warn_label); @@ -89,10 +93,10 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) /* * Two labels on top and under the filelist */ - auto* checkLabel = new QLabel(tr("Check the files you want to save:")); - auto* note_label = - new QLabel(tr("<b>Note:</b> If you don't save these files, all changes " - "are lost.<br/>")); + auto* checkLabel = new QLabel(_("Check the files you want to save:")); + auto* note_label = new QLabel( + "<b>" + QString(_("Note")) + ":</b>" + + _("If you don't save these files, all changes are lost.") + "<br/>"); /* * Buttonbox @@ -122,9 +126,7 @@ void QuitDialog::slotMyDiscard() { reject(); } -bool QuitDialog::isDiscarded() const { - return discarded; -} +bool QuitDialog::isDiscarded() const { return discarded; } QList<int> QuitDialog::getTabIdsToSave() { QList<int> tabIdsToSave; diff --git a/src/ui/QuitDialog.h b/src/ui/QuitDialog.h index 86616667..2b1dd37f 100755 --- a/src/ui/QuitDialog.h +++ b/src/ui/QuitDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/ShowCopyDialog.cpp b/src/ui/ShowCopyDialog.cpp index 98a1df3c..0503e079 100644 --- a/src/ui/ShowCopyDialog.cpp +++ b/src/ui/ShowCopyDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -26,8 +26,7 @@ namespace GpgFrontend::UI { -ShowCopyDialog::ShowCopyDialog(const QString& text, - const QString& info, +ShowCopyDialog::ShowCopyDialog(const QString& text, const QString& info, QWidget* parent) : QDialog(parent) { textEdit = new QTextEdit(); diff --git a/src/ui/ShowCopyDialog.h b/src/ui/ShowCopyDialog.h index 82deedee..fefef7ab 100644 --- a/src/ui/ShowCopyDialog.h +++ b/src/ui/ShowCopyDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -32,8 +32,7 @@ namespace GpgFrontend::UI { class ShowCopyDialog : public QDialog { Q_OBJECT public: - explicit ShowCopyDialog(const QString& text, - const QString& info = "", + explicit ShowCopyDialog(const QString& text, const QString& info = "", QWidget* parent = nullptr); private slots: diff --git a/src/ui/SignalStation.cpp b/src/ui/SignalStation.cpp index ad5c0b53..fff2971a 100644 --- a/src/ui/SignalStation.cpp +++ b/src/ui/SignalStation.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/SignalStation.h b/src/ui/SignalStation.h index 92211aa2..38e55d9f 100644 --- a/src/ui/SignalStation.h +++ b/src/ui/SignalStation.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index 4dd571a1..f8658a78 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -53,7 +53,6 @@ void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board, void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board, const ResultAnalyse& result_analyse_a, const ResultAnalyse& result_analyse_b) { - LOG(INFO) << "process_result_analyse Started"; info_board->associateTabWidget(edit->tabWidget); diff --git a/src/ui/UserInterfaceUtils.h b/src/ui/UserInterfaceUtils.h index 979cebe6..ec439461 100644 --- a/src/ui/UserInterfaceUtils.h +++ b/src/ui/UserInterfaceUtils.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/VerifyDetailsDialog.cpp b/src/ui/VerifyDetailsDialog.cpp index f06c31a4..1ad9d996 100644 --- a/src/ui/VerifyDetailsDialog.cpp +++ b/src/ui/VerifyDetailsDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -24,17 +24,17 @@ #include "ui/VerifyDetailsDialog.h" +#include <boost/format.hpp> + namespace GpgFrontend::UI { -VerifyDetailsDialog::VerifyDetailsDialog(QWidget* parent, - KeyList* keyList, - GpgError error, - GpgVerifyResult result) +VerifyDetailsDialog::VerifyDetailsDialog(QWidget* parent, KeyList* keyList, + GpgError error, GpgVerifyResult result) : QDialog(parent), mKeyList(keyList), mResult(std::move(result)), error(error) { - this->setWindowTitle(tr("Signature Details")); + this->setWindowTitle(_("Signature Details")); mainLayout = new QHBoxLayout(); this->setLayout(mainLayout); @@ -53,12 +53,13 @@ void VerifyDetailsDialog::slotRefresh() { buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); - mVboxLayout->addWidget(new QLabel(tr("Status: ") + gpgme_strerror(error))); + mVboxLayout->addWidget(new QLabel(QString::fromStdString( + std::string(_("Status")) + ": " + gpgme_strerror(error)))); auto sign = mResult->signatures; if (sign == nullptr) { - mVboxLayout->addWidget(new QLabel(tr("No valid input found"))); + mVboxLayout->addWidget(new QLabel(_("No valid input found"))); mVboxLayout->addWidget(buttonBox); return; } @@ -69,15 +70,19 @@ void VerifyDetailsDialog::slotRefresh() { // Set the title widget depending on sign status if (gpg_err_code(sign->status) == GPG_ERR_BAD_SIGNATURE) { - mVboxLayout->addWidget(new QLabel(tr("Error Validating signature"))); + mVboxLayout->addWidget(new QLabel(_("Error Validating signature"))); } else if (mInputSignature != nullptr) { - mVboxLayout->addWidget( - new QLabel(tr("File was signed on %1 <br/> It Contains:<br/><br/>") - .arg(QLocale::system().toString(timestamp)))); + const auto info = (boost::format(_("File was signed on %1%")) % + QLocale::system().toString(timestamp).toStdString()) + .str() + + "<br/>" + _("It Contains") + ": " + "<br/><br/>"; + mVboxLayout->addWidget(new QLabel(info.c_str())); } else { - mVboxLayout->addWidget( - new QLabel(tr("Signed on %1 <br/> It Contains:<br /><br/>") - .arg(QLocale::system().toString(timestamp)))); + const auto info = (boost::format(_("Signed on %1%")) % + QLocale::system().toString(timestamp).toStdString()) + .str() + + "<br/>" + _("It Contains") + ": " + "<br/><br/>"; + mVboxLayout->addWidget(new QLabel(info.c_str())); } // Add information box for every single key while (sign) { diff --git a/src/ui/VerifyDetailsDialog.h b/src/ui/VerifyDetailsDialog.h index 3d201194..3de4a56f 100644 --- a/src/ui/VerifyDetailsDialog.h +++ b/src/ui/VerifyDetailsDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -34,10 +34,8 @@ namespace GpgFrontend::UI { class VerifyDetailsDialog : public QDialog { Q_OBJECT public: - explicit VerifyDetailsDialog(QWidget* parent, - KeyList* keyList, - GpgError error, - GpgVerifyResult result); + explicit VerifyDetailsDialog(QWidget* parent, KeyList* keyList, + GpgError error, GpgVerifyResult result); private slots: diff --git a/src/ui/WaitingDialog.cpp b/src/ui/WaitingDialog.cpp index 44727193..d9aab23b 100644 --- a/src/ui/WaitingDialog.cpp +++ b/src/ui/WaitingDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/WaitingDialog.h b/src/ui/WaitingDialog.h index 342360fd..798c2a3c 100644 --- a/src/ui/WaitingDialog.h +++ b/src/ui/WaitingDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp index 2f050e80..c2733f0c 100644 --- a/src/ui/Wizard.cpp +++ b/src/ui/Wizard.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -40,7 +40,7 @@ Wizard::Wizard(KeyMgmt* keyMgmt, QWidget* parent) #ifndef Q_WS_MAC setWizardStyle(ModernStyle); #endif - setWindowTitle(tr("First Start Wizard")); + setWindowTitle(_("First Start Wizard")); // http://www.flickr.com/photos/laureenp/6141822934/ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/keys2.jpg")); @@ -67,19 +67,19 @@ IntroPage::IntroPage(QWidget* parent) appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { - setTitle(tr("Getting Started...")); - setSubTitle(tr("... with GPGFrontend")); + setTitle(_("Getting Started...")); + setSubTitle(_("... with GpgFrontend")); auto* topLabel = new QLabel( - tr("Welcome to use GPGFrontend for decrypting and signing text or " - "file!") + + QString(_("Welcome to use GpgFrontend for decrypting and signing text or " + "file!")) + " <br><br><a href='https://gpgfrontend.pub'>GpgFrontend</a> " + - tr("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and " - "Installation-Free OpenPGP Crypto Tool.") + - tr("For brief information have a look at the") + + _("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and " + "Installation-Free OpenPGP Crypto Tool.") + + _("For brief information have a look at the") + " <a href='https://gpgfrontend.pub/index.html#/overview'>" + - tr("Overview") + "</a> (" + - tr("by clicking the link, the page will open in the web browser") + + _("Overview") + "</a> (" + + _("by clicking the link, the page will open in the web browser") + "). <br>"); topLabel->setTextFormat(Qt::RichText); topLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); @@ -87,7 +87,7 @@ IntroPage::IntroPage(QWidget* parent) topLabel->setWordWrap(true); // QComboBox for language selection - auto* langLabel = new QLabel(tr("Choose a Language")); + auto* langLabel = new QLabel(_("Choose a Language")); langLabel->setWordWrap(true); languages = SettingsDialog::listLanguages(); @@ -99,7 +99,7 @@ IntroPage::IntroPage(QWidget* parent) // selected entry from config QString langKey = settings.value("int/lang").toString(); QString langValue = languages.value(langKey); - if (langKey != "") { + if (!langKey.isEmpty()) { langSelectBox->setCurrentIndex(langSelectBox->findText(langValue)); } @@ -120,35 +120,35 @@ void IntroPage::slotLangChange(const QString& lang) { qApp->exit(RESTART_CODE); } -int IntroPage::nextId() const { - return Wizard::Page_Choose; -} +int IntroPage::nextId() const { return Wizard::Page_Choose; } ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { - setTitle(tr("Choose your action...")); - setSubTitle(tr("...by clicking on the appropriate link.")); + setTitle(_("Choose your action...")); + setSubTitle(_("...by clicking on the appropriate link.")); auto* keygenLabel = new QLabel( - tr("If you have never used GPGFrontend before and also don't own a gpg " - "key yet you " - "may possibly want to read how to") + + QString(_( + "If you have never used GpgFrontend before and also don't own a gpg " + "key yet you " + "may possibly want to read how to")) + " <a href=\"https://gpgfrontend.pub/index.html#/manual/generate-key\">" + - tr("Generate Key") + "</a><hr>"); + _("Generate Key") + "</a><hr>"); keygenLabel->setTextFormat(Qt::RichText); keygenLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); keygenLabel->setOpenExternalLinks(true); keygenLabel->setWordWrap(true); auto* encrDecyTextLabel = new QLabel( - tr("If you want to learn how to encrypt, decrypt, sign and verify text, " - "you can read ") + + QString(_( + "If you want to learn how to encrypt, decrypt, sign and verify text, " + "you can read ")) + "<a " "href=\"https://gpgfrontend.pub/index.html#/manual/" "encrypt-decrypt-text\">" + - tr("Encrypt & Decrypt Text") + "</a> " + tr("or") + + _("Encrypt & Decrypt Text") + "</a> " + _("or") + " <a " "href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-text\">" + - tr("Sign & Verify Text") + "</a><hr>"); + _("Sign & Verify Text") + "</a><hr>"); encrDecyTextLabel->setTextFormat(Qt::RichText); encrDecyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); @@ -156,14 +156,14 @@ ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { encrDecyTextLabel->setWordWrap(true); auto* signVerifyTextLabel = new QLabel( - tr("If you want to operate file, you can read ") + + QString(_("If you want to operate file, you can read ")) + "<a " "href=\"https://gpgfrontend.pub/index.html#/manual/" "encrypt-decrypt-file\">" + - tr("Encrypt & Sign File") + "</a> " + tr("or") + + _("Encrypt & Sign File") + "</a> " + _("or") + " <a " "href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-file\">" + - tr("Sign & Verify File") + "</a><hr>"); + _("Sign & Verify File") + "</a><hr>"); signVerifyTextLabel->setTextFormat(Qt::RichText); signVerifyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); signVerifyTextLabel->setOpenExternalLinks(true); @@ -177,9 +177,7 @@ ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { nextPage = Wizard::Page_Conclusion; } -int ChoosePage::nextId() const { - return nextPage; -} +int ChoosePage::nextId() const { return nextPage; } void ChoosePage::slotJumpPage(const QString& page) { QMetaObject qmo = Wizard::staticMetaObject; @@ -191,22 +189,22 @@ void ChoosePage::slotJumpPage(const QString& page) { } KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { - setTitle(tr("Create a keypair...")); - setSubTitle(tr("...for decrypting and signing messages")); + setTitle(_("Create a keypair...")); + setSubTitle(_("...for decrypting and signing messages")); auto* topLabel = new QLabel( - tr("You should create a new keypair." - "The pair consists of a public and a private key.<br>" - "Other users can use the public key to encrypt messages for you " - "and verify messages signed by you." - "You can use the private key to decrypt and sign messages.<br>" - "For more information have a look at the offline tutorial (which then " - "is shown in the main window):")); + _("You should create a new keypair." + "The pair consists of a public and a private key.<br>" + "Other users can use the public key to encrypt messages for you " + "and verify messages signed by you." + "You can use the private key to decrypt and sign messages.<br>" + "For more information have a look at the offline tutorial (which then " + "is shown in the main window):")); topLabel->setWordWrap(true); auto* linkLabel = new QLabel( "<a href=" "docu_keygen.html#content" ">" + - tr("Offline tutorial") + "</a>"); + QString(_("Offline tutorial")) + "</a>"); // linkLabel->setOpenExternalLinks(true); // connect(linkLabel, SIGNAL(linkActivated(QString)), @@ -214,7 +212,7 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { auto* createKeyButtonBox = new QWidget(this); auto* createKeyButtonBoxLayout = new QHBoxLayout(createKeyButtonBox); - auto* createKeyButton = new QPushButton(tr("Create New Key")); + auto* createKeyButton = new QPushButton(_("Create New Key")); createKeyButtonBoxLayout->addWidget(createKeyButton); createKeyButtonBoxLayout->addStretch(1); auto* layout = new QVBoxLayout(); @@ -227,9 +225,7 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { setLayout(layout); } -int KeyGenPage::nextId() const { - return Wizard::Page_Conclusion; -} +int KeyGenPage::nextId() const { return Wizard::Page_Conclusion; } void KeyGenPage::slotGenerateKeyDialog() { qDebug() << "Try Opening KeyGenDialog"; @@ -238,27 +234,28 @@ void KeyGenPage::slotGenerateKeyDialog() { } ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { - setTitle(tr("Ready.")); - setSubTitle(tr("Have fun with GPGFrontend!")); + setTitle(_("Ready.")); + setSubTitle(_("Have fun with GpgFrontend!")); auto* bottomLabel = - new QLabel(tr("You are ready to use GPGFrontend now.<br><br>") + + new QLabel(QString(_("You are ready to use GpgFrontend now.<br><br>")) + "<a " "href=\"https://saturneric.github.io/GpgFrontend/index.html#/" "overview\">" + - tr("The Online Document") + "</a>" + - tr(" will get you started with GPGFrontend. It will open in " - "the main window.<br>")); + _("The Online Document") + "</a>" + + _(" will get you started with GpgFrontend. It will open in " + "the main window.") + + "<br>"); bottomLabel->setTextFormat(Qt::RichText); bottomLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); bottomLabel->setOpenExternalLinks(true); bottomLabel->setWordWrap(true); - openHelpCheckBox = new QCheckBox(tr("Open offline help.")); + openHelpCheckBox = new QCheckBox(_("Open offline help.")); openHelpCheckBox->setChecked(Qt::Checked); - dontShowWizardCheckBox = new QCheckBox(tr("Dont show the wizard again.")); + dontShowWizardCheckBox = new QCheckBox(_("Dont show the wizard again.")); dontShowWizardCheckBox->setChecked(Qt::Checked); registerField("showWizard", dontShowWizardCheckBox); @@ -272,8 +269,6 @@ ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { setVisible(true); } -int ConclusionPage::nextId() const { - return -1; -} +int ConclusionPage::nextId() const { return -1; } } // namespace GpgFrontend::UI diff --git a/src/ui/Wizard.h b/src/ui/Wizard.h index 41b1a745..e1e9092d 100644 --- a/src/ui/Wizard.h +++ b/src/ui/Wizard.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/help/AboutDialog.cpp index 4c6c2348..cd0010a6 100644 --- a/src/ui/help/AboutDialog.cpp +++ b/src/ui/help/AboutDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -23,8 +23,8 @@ */ #include "ui/help/AboutDialog.h" -#include "GpgFrontendBuildInfo.h" +#include "GpgFrontendBuildInfo.h" #include "rapidjson/document.h" #include "rapidjson/writer.h" @@ -33,16 +33,16 @@ using namespace rapidjson; namespace GpgFrontend::UI { AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) : QDialog(parent) { - this->setWindowTitle(tr("About ") + qApp->applicationName()); + this->setWindowTitle(QString(_("About")) + " " + qApp->applicationName()); auto* tabWidget = new QTabWidget; auto* infoTab = new InfoTab(); auto* translatorsTab = new TranslatorsTab(); updateTab = new UpdateTab(); - tabWidget->addTab(infoTab, tr("General")); - tabWidget->addTab(translatorsTab, tr("Translators")); - tabWidget->addTab(updateTab, tr("Update")); + tabWidget->addTab(infoTab, _("General")); + tabWidget->addTab(translatorsTab, _("Translators")); + tabWidget->addTab(updateTab, _("Update")); connect(tabWidget, &QTabWidget::currentChanged, this, [&](int index) { qDebug() << "Current Index" << index; }); @@ -73,20 +73,21 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { "<center><h2>" + qApp->applicationName() + "</h2></center>" + "<center><b>" + qApp->applicationVersion() + "</b></center>" + "<center>" + GIT_VERSION + "</center>" + - tr("<br><center>GPGFrontend is an easy-to-use, compact, cross-platform, " - "<br>" - "and installation-free gpg front-end tool.<br>" - "It visualizes most of the common operations of gpg commands.<br>" - "It's licensed under the GPL v3<br><br>" - "<b>Developer:</b><br>" - "Saturneric<br><br>" - "If you have any questions or suggestions, raise an issue<br/>" - "at <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> " - "or send a mail to my mailing list at <a " - "href=\"mailto:[email protected]\">[email protected]</a>.") + - tr("<br><br> Built with Qt ") + qVersion() + tr(" and GPGME ") + - GpgFrontend::GpgContext::getGpgmeVersion().c_str() + tr("<br>Built at ") + - BUILD_TIMESTAMP + "</center>"); + _("<br><center>GpgFrontend is an easy-to-use, compact, cross-platform, " + "<br>" + "and installation-free gpg front-end tool.<br>" + "It visualizes most of the common operations of gpg commands.<br>" + "It's licensed under the GPL v3<br><br>" + "<b>Developer:</b><br>" + "Saturneric<br><br>" + "If you have any questions or suggestions, raise an issue<br/>" + "at <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> " + "or send a mail to my mailing list at <a " + "href=\"mailto:[email protected]\">[email protected]</a>.") + + "<br><br> " + _("Built with Qt") + " " + qVersion() + " " + + _("and GPGME") + " " + + GpgFrontend::GpgContext::getGpgmeVersion().c_str() + "<br>" + + _("Built at") + " " + BUILD_TIMESTAMP + "</center>"); auto* layout = new QGridLayout(); auto* pixmapLabel = new QLabel(); @@ -128,18 +129,20 @@ UpdateTab::UpdateTab(QWidget* parent) { QString::number(VERSION_PATCH); auto tipsLabel = new QLabel(); - tipsLabel->setText("<center>" + - tr("It is recommended that you always check the version " - "of GpgFrontend and upgrade to the latest version.") + - "</center><br><center>" + - tr("New versions not only represent new features, but " - "also often represent functional and security fixes.") + - "</center>"); + tipsLabel->setText( + "<center>" + + QString(_("It is recommended that you always check the version " + "of GpgFrontend and upgrade to the latest version.")) + + "</center><br><center>" + + _("New versions not only represent new features, but " + "also often represent functional and security fixes.") + + "</center>"); tipsLabel->setWordWrap(true); currentVersionLabel = new QLabel(); - currentVersionLabel->setText("<center>" + tr("Current Version: ") + "<b>" + - currentVersion + "</b></center>"); + currentVersionLabel->setText("<center>" + QString(_("Current Version")) + + _(": ") + "<b>" + currentVersion + + "</b></center>"); currentVersionLabel->setWordWrap(true); latestVersionLabel = new QLabel(); @@ -148,13 +151,13 @@ UpdateTab::UpdateTab(QWidget* parent) { upgradeLabel = new QLabel(); upgradeLabel->setText( "<center>" + - tr("The current version is inconsistent with the latest version on " - "github.") + - "</center><br><center>" + - tr("Please click <a " - "href=\"https://github.com/saturneric/GpgFrontend/releases\">here</a> " - "to download the latest version.") + - "</center>"); + QString( + _("The current version is inconsistent with the latest version on " + "github.")) + + "</center><br><center>" + _("Please click") + + " <a " + "href=\"https://github.com/saturneric/GpgFrontend/releases\">here</a> " + + _("to download the latest version.") + "</center>"); upgradeLabel->setWordWrap(true); upgradeLabel->setOpenExternalLinks(true); upgradeLabel->setHidden(true); @@ -192,8 +195,7 @@ void UpdateTab::getLatestVersion() { request.setUrl(QUrl(baseUrl)); QNetworkReply* replay = manager->get(request); auto thread = QThread::create([replay, this]() { - while (replay->isRunning()) - QApplication::processEvents(); + while (replay->isRunning()) QApplication::processEvents(); emit replyFromUpdateServer(replay->readAll()); }); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); @@ -209,8 +211,8 @@ void UpdateTab::processReplyDataFromUpdateServer(const QByteArray& data) { if (d.Parse(data.constData()).HasParseError() || !d.IsObject()) { qDebug() << "VersionCheckThread Found Network Error"; auto latestVersion = "Unknown"; - latestVersionLabel->setText("<center><b>" + - tr("Latest Version From Github: ") + + latestVersionLabel->setText(QString("<center><b>") + + _("Latest Version From Github") + ": " + latestVersion + "</b></center>"); return; } @@ -228,11 +230,10 @@ void UpdateTab::processReplyDataFromUpdateServer(const QByteArray& data) { latestVersion = "Unknown"; latestVersionLabel->setText("<center><b>" + - tr("Latest Version From Github: ") + + QString(_("Latest Version From Github")) + ": " + latestVersion + "</b></center>"); - if (latestVersion > currentVersion) - upgradeLabel->setHidden(false); + if (latestVersion > currentVersion) upgradeLabel->setHidden(false); } } // namespace GpgFrontend::UI diff --git a/src/ui/help/AboutDialog.h b/src/ui/help/AboutDialog.h index 3b7d42c8..a7d7099b 100644 --- a/src/ui/help/AboutDialog.h +++ b/src/ui/help/AboutDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/help/VersionCheckThread.cpp b/src/ui/help/VersionCheckThread.cpp index 3204dadf..a35583f4 100644 --- a/src/ui/help/VersionCheckThread.cpp +++ b/src/ui/help/VersionCheckThread.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -23,6 +23,7 @@ */ #include "ui/help/VersionCheckThread.h" + #include "GpgFrontendBuildInfo.h" #include "rapidjson/document.h" diff --git a/src/ui/help/VersionCheckThread.h b/src/ui/help/VersionCheckThread.h index eedbfa5b..181ee947 100644 --- a/src/ui/help/VersionCheckThread.h +++ b/src/ui/help/VersionCheckThread.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/keygen/KeygenDialog.cpp index a8bc6935..382be5cb 100644 --- a/src/ui/keygen/KeygenDialog.cpp +++ b/src/ui/keygen/KeygenDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -34,7 +34,7 @@ KeyGenDialog::KeyGenDialog(QWidget* parent) : QDialog(parent) { buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - this->setWindowTitle(tr("Generate Key")); + this->setWindowTitle(_("Generate Key")); this->setModal(true); connect(this, SIGNAL(KeyGenerated()), SignalStation::GetInstance(), @@ -66,16 +66,17 @@ void KeyGenDialog::generateKeyDialog() { } void KeyGenDialog::slotKeyGenAccept() { - QString errorString = ""; + std::stringstream error_stream; /** * check for errors in keygen dialog input */ if ((nameEdit->text()).size() < 5) { - errorString.append(tr(" Name must contain at least five characters. \n")); + error_stream << " " << _("Name must contain at least five characters.") + << std::endl; } if (emailEdit->text().isEmpty() || !check_email_address(emailEdit->text())) { - errorString.append(tr(" Please give a email address. \n")); + error_stream << " " << _("Please give a email address.") << std::endl; } /** @@ -83,10 +84,13 @@ void KeyGenDialog::slotKeyGenAccept() { * in the future) */ if (dateEdit->dateTime() > QDateTime::currentDateTime().addYears(2)) { - errorString.append(tr(" Expiration time no more than 2 years. \n")); + error_stream << " " << _("Expiration time no more than 2 years.") + << std::endl; } - if (errorString.isEmpty()) { + auto err_string = error_stream.str(); + + if (err_string.empty()) { /** * create the string for key generation */ @@ -124,15 +128,15 @@ void KeyGenDialog::slotKeyGenAccept() { auto* msg_box = new QMessageBox(nullptr); msg_box->setAttribute(Qt::WA_DeleteOnClose); msg_box->setStandardButtons(QMessageBox::Ok); - msg_box->setWindowTitle(tr("Success")); - msg_box->setText(tr("The new key pair has been generated.")); + msg_box->setWindowTitle(_("Success")); + msg_box->setText(_("The new key pair has been generated.")); msg_box->setModal(false); msg_box->open(); emit KeyGenerated(); this->close(); } else { - QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(error))); + QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(error))); } } else { @@ -143,7 +147,7 @@ void KeyGenDialog::slotKeyGenAccept() { QPalette error = errorLabel->palette(); error.setColor(QPalette::Window, "#ff8080"); errorLabel->setPalette(error); - errorLabel->setText(errorString); + errorLabel->setText(err_string.c_str()); this->show(); } @@ -161,18 +165,18 @@ QGroupBox* KeyGenDialog::create_key_usage_group_box() { auto* groupBox = new QGroupBox(this); auto* grid = new QGridLayout(this); - groupBox->setTitle(tr("Key Usage")); + groupBox->setTitle(_("Key Usage")); - auto* encrypt = new QCheckBox(tr("Encryption"), groupBox); + auto* encrypt = new QCheckBox(_("Encryption"), groupBox); encrypt->setTristate(false); - auto* sign = new QCheckBox(tr("Signing"), groupBox); + auto* sign = new QCheckBox(_("Signing"), groupBox); sign->setTristate(false); - auto* cert = new QCheckBox(tr("Certification"), groupBox); + auto* cert = new QCheckBox(_("Certification"), groupBox); cert->setTristate(false); - auto* auth = new QCheckBox(tr("Authentication"), groupBox); + auto* auth = new QCheckBox(_("Authentication"), groupBox); auth->setTristate(false); keyUsageCheckBoxes.push_back(encrypt); @@ -317,7 +321,7 @@ bool KeyGenDialog::check_email_address(const QString& str) { } QGroupBox* KeyGenDialog::create_basic_info_group_box() { - errorLabel = new QLabel(tr("")); + errorLabel = new QLabel(); nameEdit = new QLineEdit(this); emailEdit = new QLineEdit(this); commentEdit = new QLineEdit(this); @@ -348,14 +352,14 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() { auto* vbox1 = new QGridLayout; - vbox1->addWidget(new QLabel(tr("Name:")), 0, 0); - vbox1->addWidget(new QLabel(tr("Email Address:")), 1, 0); - vbox1->addWidget(new QLabel(tr("Comment:")), 2, 0); - vbox1->addWidget(new QLabel(tr("Expiration Date:")), 3, 0); - vbox1->addWidget(new QLabel(tr("Never Expire")), 3, 3); - vbox1->addWidget(new QLabel(tr("KeySize (in Bit):")), 4, 0); - vbox1->addWidget(new QLabel(tr("Key Type:")), 5, 0); - vbox1->addWidget(new QLabel(tr("Non Pass Phrase")), 6, 0); + vbox1->addWidget(new QLabel(QString(_("Name")) + ": "), 0, 0); + vbox1->addWidget(new QLabel(QString(_("Email Address")) + ": "), 1, 0); + vbox1->addWidget(new QLabel(QString(_("Comment")) + ": "), 2, 0); + vbox1->addWidget(new QLabel(QString(_("Expiration Date")) + ": "), 3, 0); + vbox1->addWidget(new QLabel(QString(_("Never Expire")) + ": "), 3, 3); + vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 4, 0); + vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 5, 0); + vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase")) + ": "), 6, 0); vbox1->addWidget(nameEdit, 0, 1, 1, 3); vbox1->addWidget(emailEdit, 1, 1, 1, 3); @@ -368,7 +372,7 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() { auto basicInfoGroupBox = new QGroupBox(); basicInfoGroupBox->setLayout(vbox1); - basicInfoGroupBox->setTitle(tr("Basic Information")); + basicInfoGroupBox->setTitle(_("Basic Information")); return basicInfoGroupBox; } diff --git a/src/ui/keygen/KeygenDialog.h b/src/ui/keygen/KeygenDialog.h index 60a34a90..c16a2e76 100644 --- a/src/ui/keygen/KeygenDialog.h +++ b/src/ui/keygen/KeygenDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -44,8 +44,8 @@ class KeyGenDialog : public QDialog { */ explicit KeyGenDialog(QWidget* parent = nullptr); - signals: - void KeyGenerated(); + signals: + void KeyGenerated(); private: QGroupBox* create_key_usage_group_box(); @@ -54,7 +54,7 @@ class KeyGenDialog : public QDialog { QRegularExpression re_email{ R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"}; - + QStringList errorMessages; /** List of errors occuring when checking entries of lineedits */ std::unique_ptr<GenKeyInfo> genKeyInfo = std::make_unique<GenKeyInfo>(); diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/keygen/SubkeyGenerateDialog.cpp index 41bc36c9..593b1cae 100644 --- a/src/ui/keygen/SubkeyGenerateDialog.cpp +++ b/src/ui/keygen/SubkeyGenerateDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -50,7 +50,7 @@ SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent) vbox2->addWidget(errorLabel); vbox2->addWidget(buttonBox); - this->setWindowTitle(tr("Generate New Subkey")); + this->setWindowTitle(_("Generate New Subkey")); this->setLayout(vbox2); this->setModal(true); @@ -67,16 +67,16 @@ QGroupBox* SubkeyGenerateDialog::create_key_usage_group_box() { groupBox->setTitle("Key Usage"); - auto* encrypt = new QCheckBox(tr("Encryption"), groupBox); + auto* encrypt = new QCheckBox(_("Encryption"), groupBox); encrypt->setTristate(false); - auto* sign = new QCheckBox(tr("Signing"), groupBox); + auto* sign = new QCheckBox(_("Signing"), groupBox); sign->setTristate(false); - auto* cert = new QCheckBox(tr("Certification"), groupBox); + auto* cert = new QCheckBox(_("Certification"), groupBox); cert->setTristate(false); - auto* auth = new QCheckBox(tr("Authentication"), groupBox); + auto* auth = new QCheckBox(_("Authentication"), groupBox); auth->setTristate(false); keyUsageCheckBoxes.push_back(encrypt); @@ -95,7 +95,7 @@ QGroupBox* SubkeyGenerateDialog::create_key_usage_group_box() { } QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() { - errorLabel = new QLabel(tr("")); + errorLabel = new QLabel(); keySizeSpinBox = new QSpinBox(this); keyTypeComboBox = new QComboBox(this); @@ -120,10 +120,10 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() { auto* vbox1 = new QGridLayout; - vbox1->addWidget(new QLabel(tr("Expiration Date:")), 2, 0); - vbox1->addWidget(new QLabel(tr("Never Expire")), 2, 3); - vbox1->addWidget(new QLabel(tr("KeySize (in Bit):")), 1, 0); - vbox1->addWidget(new QLabel(tr("Key Type:")), 0, 0); + vbox1->addWidget(new QLabel(QString(_("Expiration Date")) + ": "), 2, 0); + vbox1->addWidget(new QLabel(QString(_("Never Expire")) + ": "), 2, 3); + vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 1, 0); + vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 0, 0); vbox1->addWidget(dateEdit, 2, 1); vbox1->addWidget(expireCheckBox, 2, 2); @@ -132,7 +132,7 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() { auto basicInfoGroupBox = new QGroupBox(); basicInfoGroupBox->setLayout(vbox1); - basicInfoGroupBox->setTitle(tr("Basic Information")); + basicInfoGroupBox->setTitle(_("Basic Information")); return basicInfoGroupBox; } @@ -215,17 +215,19 @@ void SubkeyGenerateDialog::refresh_widgets_state() { } void SubkeyGenerateDialog::slotKeyGenAccept() { - QString errorString = ""; + std::stringstream err_stream; /** * primary keys should have a reasonable expiration date (no more than 2 years * in the future) */ if (dateEdit->dateTime() > QDateTime::currentDateTime().addYears(2)) { - errorString.append(tr(" Expiration time no more than 2 years. ")); + err_stream << " " << _("Expiration time no more than 2 years.") << " "; } - if (errorString.isEmpty()) { + auto err_string = err_stream.str(); + + if (err_string.empty()) { genKeyInfo->setKeySize(keySizeSpinBox->value()); if (expireCheckBox->checkState()) { @@ -255,15 +257,15 @@ void SubkeyGenerateDialog::slotKeyGenAccept() { auto* msg_box = new QMessageBox(nullptr); msg_box->setAttribute(Qt::WA_DeleteOnClose); msg_box->setStandardButtons(QMessageBox::Ok); - msg_box->setWindowTitle(tr("Success")); - msg_box->setText(tr("The new subkey has been generated.")); + msg_box->setWindowTitle(_("Success")); + msg_box->setText(_("The new subkey has been generated.")); msg_box->setModal(false); msg_box->open(); emit SubKeyGenerated(); this->close(); } else - QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(error))); + QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(error))); } else { /** @@ -273,7 +275,7 @@ void SubkeyGenerateDialog::slotKeyGenAccept() { QPalette error = errorLabel->palette(); error.setColor(QPalette::Window, "#ff8080"); errorLabel->setPalette(error); - errorLabel->setText(errorString); + errorLabel->setText(err_string.c_str()); this->show(); } diff --git a/src/ui/keygen/SubkeyGenerateDialog.h b/src/ui/keygen/SubkeyGenerateDialog.h index 12f608d0..ec7c9fb1 100644 --- a/src/ui/keygen/SubkeyGenerateDialog.h +++ b/src/ui/keygen/SubkeyGenerateDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/keypair_details/EditSubKeyDialog.cpp b/src/ui/keypair_details/EditSubKeyDialog.cpp index e44c987f..6c2e0ce1 100644 --- a/src/ui/keypair_details/EditSubKeyDialog.cpp +++ b/src/ui/keypair_details/EditSubKeyDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/keypair_details/EditSubKeyDialog.h b/src/ui/keypair_details/EditSubKeyDialog.h index 6577d382..51842405 100644 --- a/src/ui/keypair_details/EditSubKeyDialog.h +++ b/src/ui/keypair_details/EditSubKeyDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -25,10 +25,6 @@ #ifndef GPGFRONTEND_EDITSUBKEY_H #define GPGFRONTEND_EDITSUBKEY_H +class EditSubKeyDialog {}; -class EditSubKeyDialog { - -}; - - -#endif //GPGFRONTEND_EDITSUBKEY_H +#endif // GPGFRONTEND_EDITSUBKEY_H diff --git a/src/ui/keypair_details/KeyDetailsDialog.cpp b/src/ui/keypair_details/KeyDetailsDialog.cpp index 54bc6286..f3cab771 100644 --- a/src/ui/keypair_details/KeyDetailsDialog.cpp +++ b/src/ui/keypair_details/KeyDetailsDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -28,16 +28,16 @@ namespace GpgFrontend::UI { KeyDetailsDialog::KeyDetailsDialog(const GpgKey& key, QWidget* parent) : QDialog(parent) { tabWidget = new QTabWidget(); - tabWidget->addTab(new KeyPairDetailTab(key.id(), tabWidget), tr("KeyPair")); - tabWidget->addTab(new KeyPairUIDTab(key.id(), tabWidget), tr("UIDs")); - tabWidget->addTab(new KeyPairSubkeyTab(key.id(), tabWidget), tr("Subkeys")); + tabWidget->addTab(new KeyPairDetailTab(key.id(), tabWidget), _("KeyPair")); + tabWidget->addTab(new KeyPairUIDTab(key.id(), tabWidget), _("UIDs")); + tabWidget->addTab(new KeyPairSubkeyTab(key.id(), tabWidget), _("Subkeys")); auto* mainLayout = new QVBoxLayout; mainLayout->addWidget(tabWidget); this->setAttribute(Qt::WA_DeleteOnClose, true); this->setLayout(mainLayout); - this->setWindowTitle(tr("Key Details")); + this->setWindowTitle(_("Key Details")); this->setModal(true); this->setMinimumSize(380, 620); this->show(); diff --git a/src/ui/keypair_details/KeyDetailsDialog.h b/src/ui/keypair_details/KeyDetailsDialog.h index 0f7342aa..51fc01cf 100644 --- a/src/ui/keypair_details/KeyDetailsDialog.h +++ b/src/ui/keypair_details/KeyDetailsDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/keypair_details/KeyNewUIDDialog.cpp index 00401231..809a05f8 100644 --- a/src/ui/keypair_details/KeyNewUIDDialog.cpp +++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -41,9 +41,9 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) errorLabel = new QLabel(); auto gridLayout = new QGridLayout(); - gridLayout->addWidget(new QLabel(tr("Name")), 0, 0); - gridLayout->addWidget(new QLabel(tr("Email")), 1, 0); - gridLayout->addWidget(new QLabel(tr("Comment")), 2, 0); + gridLayout->addWidget(new QLabel(_("Name")), 0, 0); + gridLayout->addWidget(new QLabel(_("Email")), 1, 0); + gridLayout->addWidget(new QLabel(_("Comment")), 2, 0); gridLayout->addWidget(name, 0, 1); gridLayout->addWidget(email, 1, 1); @@ -51,14 +51,14 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) gridLayout->addWidget(createButton, 3, 0, 1, 2); gridLayout->addWidget( - new QLabel(tr("Notice: The New UID Created will be set as Primary.")), 4, + new QLabel(_("Notice: The New UID Created will be set as Primary.")), 4, 0, 1, 2); gridLayout->addWidget(errorLabel, 5, 0, 1, 2); connect(createButton, SIGNAL(clicked(bool)), this, SLOT(slotCreateNewUID())); this->setLayout(gridLayout); - this->setWindowTitle(tr("Create New UID")); + this->setWindowTitle(_("Create New UID")); this->setAttribute(Qt::WA_DeleteOnClose, true); this->setModal(true); @@ -67,19 +67,20 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) } void KeyNewUIDDialog::slotCreateNewUID() { - QString errorString = ""; + std::stringstream error_stream; /** * check for errors in keygen dialog input */ if ((name->text()).size() < 5) { - errorString.append(tr(" Name must contain at least five characters. \n")); + error_stream << " " << _("Name must contain at least five characters.") + << std::endl; } if (email->text().isEmpty() || !check_email_address(email->text())) { - errorString.append(tr(" Please give a email address. \n")); + error_stream << " " << _("Please give a email address.") << std::endl; } - - if (errorString.isEmpty()) { + auto error_string = error_stream.str(); + if (error_string.empty()) { if (UidOperator::GetInstance().addUID(mKey, name->text().toStdString(), comment->text().toStdString(), email->text().toStdString())) { @@ -96,7 +97,7 @@ void KeyNewUIDDialog::slotCreateNewUID() { QPalette error = errorLabel->palette(); error.setColor(QPalette::Window, "#ff8080"); errorLabel->setPalette(error); - errorLabel->setText(errorString); + errorLabel->setText(error_string.c_str()); this->show(); } diff --git a/src/ui/keypair_details/KeyNewUIDDialog.h b/src/ui/keypair_details/KeyNewUIDDialog.h index 73c4aa7b..2e38a7f4 100644 --- a/src/ui/keypair_details/KeyNewUIDDialog.h +++ b/src/ui/keypair_details/KeyNewUIDDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -35,8 +35,8 @@ class KeyNewUIDDialog : public QDialog { public: KeyNewUIDDialog(const KeyId& key, QWidget* parent = nullptr); - signals: - void signalUIDCreated(); + signals: + void signalUIDCreated(); private slots: diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp index 34639cbb..a7d082d1 100644 --- a/src/ui/keypair_details/KeyPairDetailTab.cpp +++ b/src/ui/keypair_details/KeyPairDetailTab.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -34,10 +34,10 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) : QWidget(parent), mKey(GpgKeyGetter::GetInstance().GetKey(key_id)) { keyid = mKey.id(); - ownerBox = new QGroupBox(tr("Owner")); - keyBox = new QGroupBox(tr("Master Key")); - fingerprintBox = new QGroupBox(tr("Fingerprint")); - additionalUidBox = new QGroupBox(tr("Additional UIDs")); + ownerBox = new QGroupBox(_("Owner")); + keyBox = new QGroupBox(_("Master Key")); + fingerprintBox = new QGroupBox(_("Fingerprint")); + additionalUidBox = new QGroupBox(_("Additional UIDs")); nameVarLabel = new QLabel(); nameVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); @@ -59,7 +59,7 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) // Show the situation that master key not exists. masterKeyExistVarLabel = - new QLabel(mKey.has_master_key() ? tr("Exists") : tr("Not Exists")); + new QLabel(mKey.has_master_key() ? _("Exists") : _("Not Exists")); if (!mKey.has_master_key()) { auto paletteExpired = masterKeyExistVarLabel->palette(); paletteExpired.setColor(masterKeyExistVarLabel->foregroundRole(), Qt::red); @@ -85,21 +85,22 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) auto* vboxKD = new QGridLayout(); auto* vboxOD = new QGridLayout(); - vboxOD->addWidget(new QLabel(tr("Name:")), 0, 0); - vboxOD->addWidget(new QLabel(tr("Email Address:")), 1, 0); - vboxOD->addWidget(new QLabel(tr("Comment:")), 2, 0); + vboxOD->addWidget(new QLabel(QString(_("Name")) + ": "), 0, 0); + vboxOD->addWidget(new QLabel(QString(_("Email Address")) + ": "), 1, 0); + vboxOD->addWidget(new QLabel(QString(_("Comment")) + ": "), 2, 0); vboxOD->addWidget(nameVarLabel, 0, 1); vboxOD->addWidget(emailVarLabel, 1, 1); vboxOD->addWidget(commentVarLabel, 2, 1); - vboxKD->addWidget(new QLabel(tr("Key ID: ")), 0, 0); - vboxKD->addWidget(new QLabel(tr("Algorithm: ")), 1, 0); - vboxKD->addWidget(new QLabel(tr("Key Size:")), 2, 0); - vboxKD->addWidget(new QLabel(tr("Nominal Usage: ")), 3, 0); - vboxKD->addWidget(new QLabel(tr("Actual Usage: ")), 4, 0); - vboxKD->addWidget(new QLabel(tr("Expires on: ")), 5, 0); - vboxKD->addWidget(new QLabel(tr("Last Update: ")), 6, 0); - vboxKD->addWidget(new QLabel(tr("Secret Key Existence: ")), 7, 0); + vboxKD->addWidget(new QLabel(QString(_("Key ID")) + ": "), 0, 0); + vboxKD->addWidget(new QLabel(QString(_("Algorithm")) + ": "), 1, 0); + vboxKD->addWidget(new QLabel(QString(_("Key Size")) + ": "), 2, 0); + vboxKD->addWidget(new QLabel(QString(_("Nominal Usage")) + ": "), 3, 0); + vboxKD->addWidget(new QLabel(QString(_("Actual Usage")) + ": "), 4, 0); + vboxKD->addWidget(new QLabel(QString(_("Expires on")) + ": "), 5, 0); + vboxKD->addWidget(new QLabel(QString(_("Last Update")) + ": "), 6, 0); + vboxKD->addWidget(new QLabel(QString(_("Secret Key Existence")) + ": "), 7, + 0); vboxKD->addWidget(keySizeVarLabel, 2, 1); vboxKD->addWidget(expireVarLabel, 5, 1); @@ -123,9 +124,9 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) hboxFP->addWidget(fingerPrintVarLabel); - auto* copyFingerprintButton = new QPushButton(tr("Copy")); + auto* copyFingerprintButton = new QPushButton(_("Copy")); copyFingerprintButton->setFlat(true); - copyFingerprintButton->setToolTip(tr("copy fingerprint to clipboard")); + copyFingerprintButton->setToolTip(_("copy fingerprint to clipboard")); connect(copyFingerprintButton, SIGNAL(clicked()), this, SLOT(slotCopyFingerprint())); @@ -136,29 +137,29 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) mvbox->addStretch(); if (mKey.is_private_key()) { - auto* privKeyBox = new QGroupBox(tr("Operations")); + auto* privKeyBox = new QGroupBox(_("Operations")); auto* vboxPK = new QVBoxLayout(); auto* exportButton = - new QPushButton(tr("Export Private Key (Include Subkey)")); + new QPushButton(_("Export Private Key (Include Subkey)")); vboxPK->addWidget(exportButton); connect(exportButton, SIGNAL(clicked()), this, SLOT(slotExportPrivateKey())); if (mKey.has_master_key()) { auto* editExpiresButton = - new QPushButton(tr("Modify Expiration Datetime (Master Key)")); + new QPushButton(_("Modify Expiration Datetime (Master Key)")); vboxPK->addWidget(editExpiresButton); connect(editExpiresButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime())); auto hBoxLayout = new QHBoxLayout(); auto* keyServerOperaButton = - new QPushButton(tr("Key Server Operation (Pubkey)")); + new QPushButton(_("Key Server Operation (Pubkey)")); keyServerOperaButton->setStyleSheet("text-align:center;"); auto* revokeCertGenButton = - new QPushButton(tr("Generate Revoke Certificate")); + new QPushButton(_("Generate Revoke Certificate")); connect(revokeCertGenButton, SIGNAL(clicked()), this, SLOT(slotGenRevokeCert())); @@ -185,10 +186,10 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) auto* expLabel = new QLabel(); auto* iconLabel = new QLabel(); if (mKey.expired()) { - expLabel->setText(tr("Warning: The Master Key has expired.")); + expLabel->setText(_("Warning: The Master Key has expired.")); } if (mKey.revoked()) { - expLabel->setText(tr("Warning: The Master Key has been revoked")); + expLabel->setText(_("Warning: The Master Key has been revoked")); } iconLabel->setPixmap(pixmap.scaled(24, 24, Qt::KeepAspectRatio)); @@ -215,11 +216,11 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) void KeyPairDetailTab::slotExportPrivateKey() { // Show a information box with explanation about private key int ret = QMessageBox::information( - this, tr("Exporting private Key"), - "<h3>" + tr("You are about to export your") + "<font color=\"red\">" + - tr(" PRIVATE KEY ") + "</font>!</h3>\n" + - tr("This is NOT your Public Key, so DON'T give it away.") + "<br />" + - tr("Do you REALLY want to export your PRIVATE KEY?"), + this, _("Exporting private Key"), + "<h3>" + QString(_("You are about to export your")) + + "<font color=\"red\">" + _(" PRIVATE KEY ") + "</font>!</h3>\n" + + _("This is NOT your Public Key, so DON'T give it away.") + "<br />" + + _("Do you REALLY want to export your PRIVATE KEY?"), QMessageBox::Cancel | QMessageBox::Ok); // export key, if ok was clicked @@ -234,21 +235,21 @@ void KeyPairDetailTab::slotExportPrivateKey() { auto key = GpgKeyGetter::GetInstance().GetKey(keyid); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } auto fileString = key.name() + " " + key.email() + "(" + key.id() + ")_secret.asc"; auto fileName = QFileDialog::getSaveFileName( - this, tr("Export Key To File"), QString::fromStdString(fileString), - tr("Key Files") + " (*.asc *.txt);;All Files (*)") + this, _("Export Key To File"), QString::fromStdString(fileString), + QString(_("Key Files")) + " (*.asc *.txt);;All Files (*)") .toStdString(); if (!write_buffer_to_file(fileName, *keyArray)) { - QMessageBox::critical(nullptr, tr("Export Error"), - tr("Couldn't open %1 for writing") - .arg(QString::fromStdString(fileName))); + QMessageBox::critical( + nullptr, _("Export Error"), + QString(_("Couldn't open %1 for writing")).arg(fileName.c_str())); return; } } @@ -263,7 +264,7 @@ QString KeyPairDetailTab::beautifyFingerprint(QString fingerprint) { } void KeyPairDetailTab::slotCopyFingerprint() { - QString fpr = fingerPrintVarLabel->text().trimmed().replace(" ", ""); + QString fpr = fingerPrintVarLabel->text().trimmed().replace(" ", QString()); QClipboard* cb = QApplication::clipboard(); cb->setText(fpr); } @@ -305,7 +306,7 @@ void KeyPairDetailTab::slotRefreshKeyInfo() { keySizeVal = QString::number(mKey.length()); if (to_time_t(boost::posix_time::ptime(mKey.expires())) == 0) { - keyExpireVal = tr("Never Expire"); + keyExpireVal = _("Never Expire"); } else { keyExpireVal = QString::fromStdString(boost::gregorian::to_iso_string(mKey.expires())); @@ -327,10 +328,10 @@ void KeyPairDetailTab::slotRefreshKeyInfo() { void KeyPairDetailTab::createKeyServerOperaMenu() { keyServerOperaMenu = new QMenu(this); - auto* uploadKeyPair = new QAction(tr("Upload Key Pair to Key Server"), this); + auto* uploadKeyPair = new QAction(_("Upload Key Pair to Key Server"), this); connect(uploadKeyPair, SIGNAL(triggered()), this, SLOT(slotUploadKeyToServer())); - auto* updateKeyPair = new QAction(tr("Update Key Pair"), this); + auto* updateKeyPair = new QAction(_("Update Key Pair"), this); connect(updateKeyPair, SIGNAL(triggered()), this, SLOT(slotUpdateKeyToServer())); @@ -356,8 +357,8 @@ void KeyPairDetailTab::slotUpdateKeyToServer() { void KeyPairDetailTab::slotGenRevokeCert() { auto mOutputFileName = QFileDialog::getSaveFileName( - this, tr("Generate revocation certificate"), QString(), - QStringLiteral("%1 (*.rev)").arg(tr("Revocation Certificates"))); + this, _("Generate revocation certificate"), QString(), + QStringLiteral("%1 (*.rev)").arg(_("Revocation Certificates"))); // if (!mOutputFileName.isEmpty()) // mCtx->generateRevokeCert(mKey, mOutputFileName); diff --git a/src/ui/keypair_details/KeyPairDetailTab.h b/src/ui/keypair_details/KeyPairDetailTab.h index 5f6e93fe..782696ac 100644 --- a/src/ui/keypair_details/KeyPairDetailTab.h +++ b/src/ui/keypair_details/KeyPairDetailTab.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/keypair_details/KeyPairSubkeyTab.cpp index 61007b37..7b239bf1 100644 --- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp +++ b/src/ui/keypair_details/KeyPairSubkeyTab.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -39,7 +39,7 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent) auto uidButtonsLayout = new QGridLayout(); - auto addSubkeyButton = new QPushButton(tr("Generate A New Subkey")); + auto addSubkeyButton = new QPushButton(_("Generate A New Subkey")); if (!mKey.is_private_key() || !mKey.has_master_key()) { addSubkeyButton->setDisabled(true); setHidden(addSubkeyButton); @@ -56,14 +56,20 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent) auto* subkeyDetailLayout = new QGridLayout(); - subkeyDetailLayout->addWidget(new QLabel(tr("Key ID: ")), 0, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Algorithm: ")), 1, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Key Size:")), 2, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Usage: ")), 3, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Expires On ")), 4, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Last Update: ")), 5, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Existence: ")), 6, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Fingerprint: ")), 7, 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Key ID")) + ": "), 0, 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Algorithm")) + ": "), 1, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Key Size")) + ": "), 2, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Usage")) + ": "), 3, 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Expires On")) + ": "), 4, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Last Update")) + ": "), 5, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Existence")) + ": "), 6, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Fingerprint")) + ": "), 7, + 0); keyidVarLabel = new QLabel(); keySizeVarLabel = new QLabel(); @@ -128,8 +134,8 @@ void KeyPairSubkeyTab::createSubkeyList() { subkeyList->setAlternatingRowColors(true); QStringList labels; - labels << tr("Subkey ID") << tr("Key Size") << tr("Algo") << tr("Create Date") - << tr("Expire Date"); + labels << _("Subkey ID") << _("Key Size") << _("Algo") << _("Create Date") + << _("Expire Date"); subkeyList->setHorizontalHeaderLabels(labels); subkeyList->horizontalHeader()->setStretchLastSection(false); @@ -172,7 +178,7 @@ void KeyPairSubkeyTab::slotRefreshSubkeyList() { auto* tmp4 = new QTableWidgetItem( boost::posix_time::to_time_t( boost::posix_time::ptime(subkeys.expires())) == 0 - ? tr("Never Expire") + ? _("Never Expire") : QString::fromStdString(to_iso_string(subkeys.expires()))); tmp4->setTextAlignment(Qt::AlignCenter); subkeyList->setItem(row, 4, tmp4); @@ -207,7 +213,7 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() { expireVarLabel->setText( subkey_time_t == 0 - ? tr("Never Expires") + ? _("Never Expires") : QString::fromStdString(to_iso_string(subkey.expires()))); if (subkey_time_t != 0 && subkey.expires() < boost::posix_time::second_clock::local_time().date()) { @@ -227,15 +233,16 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() { QString usage; QTextStream usage_steam(&usage); - if (subkey.can_certify()) usage_steam << "Cert "; - if (subkey.can_encrypt()) usage_steam << "Encr "; - if (subkey.can_sign()) usage_steam << "Sign "; - if (subkey.can_authenticate()) usage_steam << "Auth "; + if (subkey.can_certify()) usage_steam << _("Cert") << " "; + if (subkey.can_encrypt()) usage_steam << _("Encr") << " "; + if (subkey.can_sign()) usage_steam << _("Sign") << " "; + if (subkey.can_authenticate()) usage_steam << _("Auth") << " "; usageVarLabel->setText(usage); // Show the situation that master key not exists. - masterKeyExistVarLabel->setText(subkey.secret() ? "Exists" : "Not Exists"); + masterKeyExistVarLabel->setText(subkey.secret() ? _("Exists") + : _("Not Exists")); if (!subkey.secret()) { auto paletteExpired = masterKeyExistVarLabel->palette(); paletteExpired.setColor(masterKeyExistVarLabel->foregroundRole(), Qt::red); @@ -252,8 +259,8 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() { void KeyPairSubkeyTab::createSubkeyOperaMenu() { subkeyOperaMenu = new QMenu(this); - // auto *revokeSubkeyAct = new QAction(tr("Revoke Subkey")); - auto* editSubkeyAct = new QAction(tr("Edit Expire Date")); + // auto *revokeSubkeyAct = new QAction(_("Revoke Subkey")); + auto* editSubkeyAct = new QAction(_("Edit Expire Date")); connect(editSubkeyAct, SIGNAL(triggered(bool)), this, SLOT(slotEditSubkey())); // subkeyOperaMenu->addAction(revokeSubkeyAct); diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.h b/src/ui/keypair_details/KeyPairSubkeyTab.h index 6466d8b4..018f6ddc 100644 --- a/src/ui/keypair_details/KeyPairSubkeyTab.h +++ b/src/ui/keypair_details/KeyPairSubkeyTab.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -25,10 +25,9 @@ #ifndef GPGFRONTEND_KEYPAIRSUBKEYTAB_H #define GPGFRONTEND_KEYPAIRSUBKEYTAB_H -#include "ui/GpgFrontendUI.h" - #include "KeySetExpireDateDialog.h" #include "gpg/GpgContext.h" +#include "ui/GpgFrontendUI.h" #include "ui/keygen/SubkeyGenerateDialog.h" namespace GpgFrontend::UI { diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp index f787bebd..7358c20a 100644 --- a/src/ui/keypair_details/KeyPairUIDTab.cpp +++ b/src/ui/keypair_details/KeyPairUIDTab.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -41,8 +41,8 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent) auto uidButtonsLayout = new QGridLayout(); - auto addUIDButton = new QPushButton(tr("New UID")); - auto manageUIDButton = new QPushButton(tr("UID Management")); + auto addUIDButton = new QPushButton(_("New UID")); + auto manageUIDButton = new QPushButton(_("UID Management")); if (mKey.has_master_key()) { manageUIDButton->setMenu(manageSelectedUIDMenu); @@ -61,7 +61,7 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent) auto uidGroupBox = new QGroupBox(); uidGroupBox->setLayout(gridLayout); - uidGroupBox->setTitle(tr("UIDs")); + uidGroupBox->setTitle(_("UIDs")); auto signGridLayout = new QGridLayout(); signGridLayout->addWidget(sigList, 0, 0); @@ -69,7 +69,7 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent) auto signGroupBox = new QGroupBox(); signGroupBox->setLayout(signGridLayout); - signGroupBox->setTitle(tr("Signature of Selected UID")); + signGroupBox->setTitle(_("Signature of Selected UID")); auto vboxLayout = new QVBoxLayout(); vboxLayout->addWidget(uidGroupBox); @@ -112,7 +112,7 @@ void KeyPairUIDTab::createUIDList() { uidList->setAlternatingRowColors(true); QStringList labels; - labels << tr("Select") << tr("Name") << tr("Email") << tr("Comment"); + labels << _("Select") << _("Name") << _("Email") << _("Comment"); uidList->setHorizontalHeaderLabels(labels); uidList->horizontalHeader()->setStretchLastSection(true); } @@ -135,8 +135,8 @@ void KeyPairUIDTab::createSignList() { sigList->setAlternatingRowColors(true); QStringList labels; - labels << tr("Key ID") << tr("Name") << tr("Email") << tr("Create Date") - << tr("Expired Date"); + labels << _("Key ID") << _("Name") << _("Email") << _("Create Date") + << _("Expired Date"); sigList->setHorizontalHeaderLabels(labels); sigList->horizontalHeader()->setStretchLastSection(false); } @@ -235,7 +235,7 @@ void KeyPairUIDTab::slotRefreshSigList() { auto* tmp5 = new QTableWidgetItem( boost::posix_time::to_time_t( boost::posix_time::ptime(sig.expire_time())) == 0 - ? tr("Never Expires") + ? _("Never Expires") : QString::fromStdString( boost::gregorian::to_iso_string(sig.expire_time()))); tmp5->setTextAlignment(Qt::AlignCenter); @@ -253,8 +253,8 @@ void KeyPairUIDTab::slotAddSign() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one or more UIDs before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one or more UIDs before doing this operation.")); return; } @@ -275,9 +275,9 @@ UIDArgsListPtr KeyPairUIDTab::getUIDChecked() { void KeyPairUIDTab::createManageUIDMenu() { manageSelectedUIDMenu = new QMenu(this); - auto* signUIDAct = new QAction(tr("Sign Selected UID(s)"), this); + auto* signUIDAct = new QAction(_("Sign Selected UID(s)"), this); connect(signUIDAct, SIGNAL(triggered()), this, SLOT(slotAddSign())); - auto* delUIDAct = new QAction(tr("Delete Selected UID(s)"), this); + auto* delUIDAct = new QAction(_("Delete Selected UID(s)"), this); connect(delUIDAct, SIGNAL(triggered()), this, SLOT(slotDelUID())); if (mKey.has_master_key()) { @@ -297,11 +297,11 @@ void KeyPairUIDTab::slotAddUID() { void KeyPairUIDTab::slotAddUIDResult(int result) { if (result == 1) { - QMessageBox::information(nullptr, tr("Successful Operation"), - tr("Successfully added a new UID.")); + QMessageBox::information(nullptr, _("Successful Operation"), + _("Successfully added a new UID.")); } else if (result == -1) { - QMessageBox::critical(nullptr, tr("Operation Failed"), - tr("An error occurred during the operation.")); + QMessageBox::critical(nullptr, _("Operation Failed"), + _("An error occurred during the operation.")); } } @@ -310,8 +310,8 @@ void KeyPairUIDTab::slotDelUID() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one or more UIDs before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one or more UIDs before doing this operation.")); return; } @@ -322,10 +322,12 @@ void KeyPairUIDTab::slotDelUID() { } int ret = QMessageBox::warning( - this, tr("Deleting UIDs"), - "<b>" + tr("Are you sure that you want to delete the following uids?") + + this, _("Deleting UIDs"), + "<b>" + + QString( + _("Are you sure that you want to delete the following UIDs?")) + "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); bool if_all_success = true; @@ -340,8 +342,8 @@ void KeyPairUIDTab::slotDelUID() { if (!if_all_success) { QMessageBox::critical( - nullptr, tr("Operation Failed"), - tr("At least an error occurred during the operation.")); + nullptr, _("Operation Failed"), + _("At least an error occurred during the operation.")); } emit signalUpdateUIDInfo(); } @@ -363,17 +365,18 @@ void KeyPairUIDTab::slotSetPrimaryUID() { keynames.append("<br/>"); int ret = QMessageBox::warning( - this, tr("Set Primary UID"), - "<b>" + tr("Are you sure that you want to set the Primary UID to?") + + this, _("Set Primary UID"), + "<b>" + + QString(_("Are you sure that you want to set the Primary UID to?")) + "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { if (!UidOperator::GetInstance().setPrimaryUID(mKey, selected_uids->front())) { - QMessageBox::critical(nullptr, tr("Operation Failed"), - tr("An error occurred during the operation.")); + QMessageBox::critical(nullptr, _("Operation Failed"), + _("An error occurred during the operation.")); } else { emit signalUpdateUIDInfo(); } @@ -404,12 +407,12 @@ SignIdArgsListPtr KeyPairUIDTab::getSignSelected() { void KeyPairUIDTab::createUIDPopupMenu() { uidPopupMenu = new QMenu(this); - auto* serPrimaryUIDAct = new QAction(tr("Set As Primary"), this); + auto* serPrimaryUIDAct = new QAction(_("Set As Primary"), this); connect(serPrimaryUIDAct, SIGNAL(triggered()), this, SLOT(slotSetPrimaryUID())); - auto* signUIDAct = new QAction(tr("Sign UID"), this); + auto* signUIDAct = new QAction(_("Sign UID"), this); connect(signUIDAct, SIGNAL(triggered()), this, SLOT(slotAddSignSingle())); - auto* delUIDAct = new QAction(tr("Delete UID"), this); + auto* delUIDAct = new QAction(_("Delete UID"), this); connect(delUIDAct, SIGNAL(triggered()), this, SLOT(slotDelUIDSingle())); if (mKey.has_master_key()) { @@ -435,8 +438,8 @@ void KeyPairUIDTab::slotAddSignSingle() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one UID before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one UID before doing this operation.")); return; } @@ -449,8 +452,8 @@ void KeyPairUIDTab::slotDelUIDSingle() { auto selected_uids = getUIDSelected(); if (selected_uids->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one UID before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one UID before doing this operation.")); return; } @@ -460,16 +463,18 @@ void KeyPairUIDTab::slotDelUIDSingle() { keynames.append("<br/>"); int ret = QMessageBox::warning( - this, tr("Deleting UID"), - "<b>" + tr("Are you sure that you want to delete the following uid?") + + this, _("Deleting UID"), + "<b>" + + QString( + _("Are you sure that you want to delete the following uid?")) + "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { if (!UidOperator::GetInstance().revUID(mKey, selected_uids->front())) { - QMessageBox::critical(nullptr, tr("Operation Failed"), - tr("An error occurred during the operation.")); + QMessageBox::critical(nullptr, _("Operation Failed"), + _("An error occurred during the operation.")); } else { emit signalUpdateUIDInfo(); } @@ -479,7 +484,7 @@ void KeyPairUIDTab::slotDelUIDSingle() { void KeyPairUIDTab::createSignPopupMenu() { signPopupMenu = new QMenu(this); - auto* delSignAct = new QAction(tr("Delete(Revoke) Key Signature"), this); + auto* delSignAct = new QAction(_("Delete(Revoke) Key Signature"), this); connect(delSignAct, SIGNAL(triggered()), this, SLOT(slotDelSign())); signPopupMenu->addAction(delSignAct); @@ -489,8 +494,8 @@ void KeyPairUIDTab::slotDelSign() { auto selected_signs = getSignSelected(); if (selected_signs->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one Key Signature before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one Key Signature before doing this operation.")); return; } @@ -498,9 +503,9 @@ void KeyPairUIDTab::slotDelSign() { .GetKey(selected_signs->front().first) .good()) { QMessageBox::critical( - nullptr, tr("Invalid Operation"), - tr("To delete the signature, you need to have its corresponding public " - "key in the local database.")); + nullptr, _("Invalid Operation"), + _("To delete the signature, you need to have its corresponding public " + "key in the local database.")); return; } @@ -509,18 +514,19 @@ void KeyPairUIDTab::slotDelSign() { keynames.append(QString::fromStdString(selected_signs->front().second)); keynames.append("<br/>"); - int ret = QMessageBox::warning( - this, tr("Deleting Key Signature"), - "<b>" + - tr("Are you sure that you want to delete the following signature?") + - "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), - QMessageBox::No | QMessageBox::Yes); + int ret = + QMessageBox::warning(this, _("Deleting Key Signature"), + "<b>" + + QString(_("Are you sure that you want to delete " + "the following signature?")) + + "</b><br/><br/>" + keynames + +"<br/>" + + _("The action can not be undone."), + QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { if (!GpgKeyManager::GetInstance().revSign(mKey, selected_signs)) { - QMessageBox::critical(nullptr, tr("Operation Failed"), - tr("An error occurred during the operation.")); + QMessageBox::critical(nullptr, _("Operation Failed"), + _("An error occurred during the operation.")); } } } diff --git a/src/ui/keypair_details/KeyPairUIDTab.h b/src/ui/keypair_details/KeyPairUIDTab.h index 1f88e7b7..6dece8d5 100644 --- a/src/ui/keypair_details/KeyPairUIDTab.h +++ b/src/ui/keypair_details/KeyPairUIDTab.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/keypair_details/KeySetExpireDateDialog.cpp index 2c5b837f..d197a76b 100644 --- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp +++ b/src/ui/keypair_details/KeySetExpireDateDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -69,15 +69,15 @@ void KeySetExpireDateDialog::slotConfirm() { auto* msg_box = new QMessageBox(nullptr); msg_box->setAttribute(Qt::WA_DeleteOnClose); msg_box->setStandardButtons(QMessageBox::Ok); - msg_box->setWindowTitle(tr("Success")); - msg_box->setText(tr("The expire date of the key pair has been updated.")); + msg_box->setWindowTitle(_("Success")); + msg_box->setText(_("The expire date of the key pair has been updated.")); msg_box->setModal(false); msg_box->open(); emit signalKeyExpireDateUpdated(); } else { - QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(err))); + QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(err))); } this->close(); @@ -90,12 +90,12 @@ void KeySetExpireDateDialog::init() { dateTimeEdit->setMaximumDateTime(maxDateTime); nonExpiredCheck = new QCheckBox(); nonExpiredCheck->setTristate(false); - confirmButton = new QPushButton(tr("Confirm")); + confirmButton = new QPushButton(_("Confirm")); auto* gridLayout = new QGridLayout(); gridLayout->addWidget(dateTimeEdit, 0, 0, 1, 2); gridLayout->addWidget(nonExpiredCheck, 0, 2, 1, 1, Qt::AlignRight); - gridLayout->addWidget(new QLabel(tr("Never Expire")), 0, 3); + gridLayout->addWidget(new QLabel(_("Never Expire")), 0, 3); gridLayout->addWidget(confirmButton, 1, 3); connect(nonExpiredCheck, SIGNAL(stateChanged(int)), this, diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.h b/src/ui/keypair_details/KeySetExpireDateDialog.h index f9779005..37a7f7e4 100644 --- a/src/ui/keypair_details/KeySetExpireDateDialog.h +++ b/src/ui/keypair_details/KeySetExpireDateDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/keypair_details/KeyUIDSignDialog.cpp b/src/ui/keypair_details/KeyUIDSignDialog.cpp index 0614024f..6cce116b 100644 --- a/src/ui/keypair_details/KeyUIDSignDialog.cpp +++ b/src/ui/keypair_details/KeyUIDSignDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -78,7 +78,7 @@ KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid, layout->addWidget(mKeyList, 0, 0); layout->addWidget(signKeyButton, 2, 0, Qt::AlignRight); - timeLayout->addWidget(new QLabel(tr("Expire Date")), 0, 0); + timeLayout->addWidget(new QLabel(_("Expire Date")), 0, 0); timeLayout->addWidget(expiresEdit, 0, 1); timeLayout->addWidget(nonExpireCheck, 0, 2); layout->addLayout(timeLayout, 1, 0); @@ -87,7 +87,7 @@ KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid, this->setLayout(layout); this->setModal(true); - this->setWindowTitle(tr("Sign For Key's UID(s)")); + this->setWindowTitle(_("Sign For Key's UID(s)")); this->adjustSize(); setAttribute(Qt::WA_DeleteOnClose, true); @@ -114,15 +114,13 @@ void KeyUIDSignDialog::slotSignKey(bool clicked) { // Sign For mKey if (!GpgKeyManager::GetInstance().signKey(mKey, *keys, uid, expires)) { QMessageBox::critical( - nullptr, tr("Unsuccessful Operation"), - QString(tr("Signature operation failed for UID ") + "%1") - .arg(uid.c_str())); + nullptr, _("Unsuccessful Operation"), + QString(_("Signature operation failed for UID %1")).arg(uid.c_str())); } } - QMessageBox::information( - nullptr, tr("Operation Complete"), - tr("The signature operation of the UID is complete")); + QMessageBox::information(nullptr, _("Operation Complete"), + _("The signature operation of the UID is complete")); this->close(); emit signalKeyUIDSignUpdate(); } diff --git a/src/ui/keypair_details/KeyUIDSignDialog.h b/src/ui/keypair_details/KeyUIDSignDialog.h index 1bd68416..8a83977a 100644 --- a/src/ui/keypair_details/KeyUIDSignDialog.h +++ b/src/ui/keypair_details/KeyUIDSignDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp index 2edac85d..32fae92e 100644 --- a/src/ui/main_window/MainWindowFileSlotFunction.cpp +++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -33,18 +33,18 @@ bool file_pre_check(QWidget* parent, const QString& path) { QFileInfo file_info(path); QFileInfo path_info(file_info.absolutePath()); if (!file_info.isFile()) { - QMessageBox::critical(parent, QApplication::tr("Error"), - QApplication::tr("Select a file before doing it.")); + QMessageBox::critical(parent, _("Error"), + _("Select a file before doing it.")); return false; } if (!file_info.isReadable()) { - QMessageBox::critical(parent, QApplication::tr("Error"), - QApplication::tr("No permission to read this file.")); + QMessageBox::critical(parent, _("Error"), + _("No permission to read this file.")); return false; } if (!path_info.isWritable()) { - QMessageBox::critical(parent, QApplication::tr("Error"), - QApplication::tr("No permission to create file.")); + QMessageBox::critical(parent, _("Error"), + _("No permission to create file.")); return false; } return true; @@ -58,8 +58,8 @@ void MainWindow::slotFileEncrypt() { if (QFile::exists(path + ".asc")) { auto ret = QMessageBox::warning( - this, tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), + this, _("Warning"), + _("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -68,17 +68,18 @@ void MainWindow::slotFileEncrypt() { auto key_ids = mKeyList->getChecked(); auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids); if (keys->empty()) { - QMessageBox::critical(this, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected")); return; } for (const auto& key : *keys) { if (!key.CanEncrActual()) { QMessageBox::information( - this, tr("Invalid Operation"), - tr("The selected key contains a key that does not actually have a " - "encrypt usage.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + this, _("Invalid Operation"), + QString( + _("The selected key contains a key that does not actually have a " + "encrypt usage.")) + + "<br/><br/>" + _("For example the Following Key:") + " <br/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -87,7 +88,7 @@ void MainWindow::slotFileEncrypt() { GpgEncrResult result = nullptr; GpgError error; bool if_error = false; - process_operation(this, tr("Encrypting").toStdString(), [&]() { + process_operation(this, _("Encrypting"), [&]() { try { error = GpgFileOpera::EncryptFile(std::move(*keys), path.toStdString(), result); @@ -102,8 +103,8 @@ void MainWindow::slotFileEncrypt() { process_result_analyse(edit, infoBoard, resultAnalyse); fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } @@ -125,8 +126,8 @@ void MainWindow::slotFileDecrypt() { if (QFile::exists(outFileName)) { auto ret = QMessageBox::warning( - this, tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), + this, _("Warning"), + _("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -135,7 +136,7 @@ void MainWindow::slotFileDecrypt() { GpgDecrResult result = nullptr; gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Decrypting").toStdString(), [&]() { + process_operation(this, _("Decrypting"), [&]() { try { error = GpgFileOpera::DecryptFile(path.toStdString(), result); } catch (const std::runtime_error& e) { @@ -150,8 +151,8 @@ void MainWindow::slotFileDecrypt() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } @@ -164,8 +165,8 @@ void MainWindow::slotFileSign() { if (QFile::exists(path + ".sig")) { auto ret = QMessageBox::warning( - this, tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), + this, _("Warning"), + _("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -175,17 +176,17 @@ void MainWindow::slotFileSign() { auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids); if (keys->empty()) { - QMessageBox::critical(this, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected")); return; } for (const auto& key : *keys) { if (!key.CanSignActual()) { QMessageBox::information( - this, tr("Invalid Operation"), - tr("The selected key contains a key that does not actually have a " - "sign usage.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + this, _("Invalid Operation"), + QString(_("The selected key contains a key that does not actually " + "have a sign usage.")) + + "<br/><br/>" + _("for example the Following Key:") + " <br/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -195,7 +196,7 @@ void MainWindow::slotFileSign() { gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Signing").toStdString(), [&]() { + process_operation(this, _("Signing"), [&]() { try { error = GpgFileOpera::SignFile(std::move(*keys), path.toStdString(), result); @@ -212,8 +213,8 @@ void MainWindow::slotFileSign() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } @@ -244,26 +245,26 @@ void MainWindow::slotFileVerify() { if (!dataFileInfo.isFile() || !signFileInfo.isFile()) { QMessageBox::critical( - this, tr("Error"), - tr("Please select the appropriate target file or signature file. " - "Ensure that both are in this directory.")); + this, _("Error"), + _("Please select the appropriate target file or signature file. " + "Ensure that both are in this directory.")); return; } if (!dataFileInfo.isReadable()) { - QMessageBox::critical(this, tr("Error"), - tr("No permission to read target file.")); + QMessageBox::critical(this, _("Error"), + _("No permission to read target file.")); return; } if (!fileInfo.isReadable()) { - QMessageBox::critical(this, tr("Error"), - tr("No permission to read signature file.")); + QMessageBox::critical(this, _("Error"), + _("No permission to read signature file.")); return; } GpgVerifyResult result = nullptr; gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Verifying").toStdString(), [&]() { + process_operation(this, _("Verifying"), [&]() { try { error = GpgFileOpera::VerifyFile(dataFilePath.toStdString(), result); } catch (const std::runtime_error& e) { @@ -286,8 +287,8 @@ void MainWindow::slotFileVerify() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } @@ -300,8 +301,8 @@ void MainWindow::slotFileEncryptSign() { if (QFile::exists(path + ".gpg")) { auto ret = QMessageBox::warning( - this, tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), + this, _("Warning"), + _("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -311,7 +312,7 @@ void MainWindow::slotFileEncryptSign() { auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids); if (keys->empty()) { - QMessageBox::critical(this, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected")); return; } @@ -323,10 +324,11 @@ void MainWindow::slotFileEncryptSign() { if (!key_can_sign && !key_can_encr) { QMessageBox::critical( - nullptr, tr("Invalid KeyPair"), - tr("The selected keypair cannot be used for signing and encryption " - "at the same time.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + nullptr, _("Invalid KeyPair"), + QString(_( + "The selected keypair cannot be used for signing and encryption " + "at the same time.")) + + "<br/><br/>" + _("For example the Following Key:") + " <br/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -336,16 +338,16 @@ void MainWindow::slotFileEncryptSign() { } if (!can_encr) { - QMessageBox::critical(nullptr, tr("Incomplete Operation"), - tr("None of the selected key pairs can provide the " - "encryption function.")); + QMessageBox::critical(nullptr, _("Incomplete Operation"), + _("None of the selected key pairs can provide the " + "encryption function.")); return; } if (!can_sign) { - QMessageBox::warning(nullptr, tr("Incomplete Operation"), - tr("None of the selected key pairs can provide the " - "signature function.")); + QMessageBox::warning(nullptr, _("Incomplete Operation"), + _("None of the selected key pairs can provide the " + "signature function.")); } GpgEncrResult encr_result = nullptr; @@ -354,7 +356,7 @@ void MainWindow::slotFileEncryptSign() { gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Encrypting and Signing").toStdString(), [&]() { + process_operation(this, _("Encrypting and Signing"), [&]() { try { error = GpgFileOpera::EncryptSignFile( std::move(*keys), path.toStdString(), encr_result, sign_result); @@ -373,8 +375,8 @@ void MainWindow::slotFileEncryptSign() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } @@ -398,7 +400,7 @@ void MainWindow::slotFileDecryptVerify() { GpgVerifyResult v_result = nullptr; gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Decrypting and Verifying").toStdString(), [&]() { + process_operation(this, _("Decrypting and Verifying"), [&]() { try { error = GpgFileOpera::DecryptVerifyFile(path.toStdString(), d_result, v_result); @@ -426,8 +428,8 @@ void MainWindow::slotFileDecryptVerify() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } diff --git a/src/ui/main_window/MainWindowServerSlotFunction.cpp b/src/ui/main_window/MainWindowServerSlotFunction.cpp index 6266efda..17491db7 100644 --- a/src/ui/main_window/MainWindowServerSlotFunction.cpp +++ b/src/ui/main_window/MainWindowServerSlotFunction.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -45,10 +45,10 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { GpgKey key = mCtx->getKeyRefById(ownKeyId); if (!key.good) { - QMessageBox::critical(this, tr("Invalid Own Key"), - tr("Own Key can not be use to do any operation. " - "Please go to the setting interface to select an " - "OwnKey and get a ServiceToken.")); + QMessageBox::critical(this, _("Invalid Own Key"), + _("Own Key can not be use to do any operation. " + "Please go to the setting interface to select an " + "OwnKey and get a ServiceToken.")); return {}; } @@ -57,8 +57,8 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { QString serviceToken = settings.value("general/serviceToken").toString(); if (serviceToken.isEmpty() || !utils->checkServiceTokenFormat(serviceToken)) { QMessageBox::critical( - this, tr("Error"), - tr("Please obtain a Service Token from the server in the settings.")); + this, _("Error"), + _("Please obtain a Service Token from the server in the settings.")); return {}; } @@ -95,11 +95,10 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { QNetworkReply* reply = utils->getNetworkManager().post(request, postData); - auto dialog = new WaitingDialog(tr("Getting Cpt From Server"), this); + auto dialog = new WaitingDialog(_("Getting Cpt From Server"), this); dialog->show(); - while (reply->isRunning()) - QApplication::processEvents(); + while (reply->isRunning()) QApplication::processEvents(); dialog->close(); @@ -117,9 +116,9 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { if (!utils->checkDataValueStr("cryptoText") || !utils->checkDataValueStr("sha") || !utils->checkDataValueStr("serviceToken")) { - QMessageBox::critical(this, tr("Error"), - tr("The communication content with the server does " - "not meet the requirements")); + QMessageBox::critical(this, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); return {}; } @@ -134,7 +133,7 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { serviceToken == serviceTokenFromServer) { return cryptoText; } else - QMessageBox::critical(this, tr("Error"), tr("Invalid short ciphertext")); + QMessageBox::critical(this, _("Error"), _("Invalid short ciphertext")); return {}; } @@ -156,8 +155,8 @@ void MainWindow::shortenCryptText() { if (serviceToken.isEmpty() || !utils->checkServiceTokenFormat(serviceToken)) { QMessageBox::critical( - this, tr("Invalid Service Token"), - tr("Please go to the setting interface to get a ServiceToken.")); + this, _("Invalid Service Token"), + _("Please go to the setting interface to get a ServiceToken.")); return; } @@ -167,8 +166,8 @@ void MainWindow::shortenCryptText() { GpgKey key = mCtx->getKeyRefById(ownKeyId); if (!key.good) { - QMessageBox::critical(this, tr("Invalid Own Key"), - tr("Own Key can not be use to do any operation.")); + QMessageBox::critical(this, _("Invalid Own Key"), + _("Own Key can not be use to do any operation.")); return; } @@ -217,10 +216,9 @@ void MainWindow::shortenCryptText() { QNetworkReply* reply = networkAccessManager->post(request, postData); - auto* dialog = new WaitingDialog(tr("Getting Scpt From Server"), this); + auto* dialog = new WaitingDialog(_("Getting Scpt From Server"), this); dialog->show(); - while (reply->isRunning()) - QApplication::processEvents(); + while (reply->isRunning()) QApplication::processEvents(); dialog->close(); if (utils->checkServerReply(reply->readAll().constData())) { @@ -233,9 +231,9 @@ void MainWindow::shortenCryptText() { if (!utils->checkDataValueStr("shortenText") || !utils->checkDataValueStr("md5")) { - QMessageBox::critical(this, tr("Error"), - tr("The communication content with the server does " - "not meet the requirements")); + QMessageBox::critical(this, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); return; } @@ -246,14 +244,14 @@ void MainWindow::shortenCryptText() { if (md5_generator.result().toHex() == utils->getDataValueStr("md5")) { auto* dialog = new ShowCopyDialog(shortenText, - tr("Notice: Use Decrypt & Verify operation to " - "decrypt this short crypto text."), + _("Notice: Use Decrypt & Verify operation to " + "decrypt this short crypto text."), this); dialog->show(); } else { QMessageBox::critical( - this, tr("Error"), - tr("There is a problem with the communication with the server")); + this, _("Error"), + _("There is a problem with the communication with the server")); return; } } diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp index 37150160..0f7bdb26 100644 --- a/src/ui/main_window/MainWindowSlotFunction.cpp +++ b/src/ui/main_window/MainWindowSlotFunction.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -52,8 +52,8 @@ void MainWindow::slotEncrypt() { auto key_ids = mKeyList->getChecked(); if (key_ids->empty()) { - QMessageBox::critical(nullptr, tr("No Key Selected"), - tr("No Key Selected")); + QMessageBox::critical(nullptr, _("No Key Selected"), + _("No Key Selected")); return; } @@ -62,10 +62,11 @@ void MainWindow::slotEncrypt() { for (const auto& key : *keys) { if (!key.CanEncrActual()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("The selected key contains a key that does not actually have a " - "encrypt usage.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + nullptr, _("Invalid Operation"), + QString(_( + "The selected key contains a key that does not actually have a " + "encrypt usage.")) + + "<br/><br/>" + _("For example the Following Key:") + " <br/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -76,7 +77,7 @@ void MainWindow::slotEncrypt() { GpgEncrResult result = nullptr; GpgError error; bool if_error = false; - process_operation(this, tr("Encrypting").toStdString(), [&]() { + process_operation(this, _("Encrypting"), [&]() { try { auto buffer = edit->curTextPage()->toPlainText().toUtf8().toStdString(); error = GpgFrontend::BasicOperator::GetInstance().Encrypt( @@ -100,17 +101,17 @@ void MainWindow::slotEncrypt() { if (settings.value("sendMail/enable", false).toBool()) new SendMailDialog(edit->curTextPage()->toPlainText(), this); else { - QMessageBox::warning(nullptr, tr("Function Disabled"), - tr("Please go to the settings interface to " - "enable and configure this function.")); + QMessageBox::warning(nullptr, _("Function Disabled"), + _("Please go to the settings interface to " + "enable and configure this function.")); } }); } #endif } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } @@ -126,7 +127,7 @@ void MainWindow::slotSign() { auto key_ids = mKeyList->getPrivateChecked(); if (key_ids->empty()) { - QMessageBox::critical(this, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected")); return; } @@ -134,11 +135,12 @@ void MainWindow::slotSign() { for (const auto& key : *keys) { if (!key.CanSignActual()) { QMessageBox::information( - this, tr("Invalid Operation"), - tr("The selected key contains a key that does not actually have a " - "signature usage.<br/>") + - tr("<br/>For example the Following Key: <br/>") + - QString::fromStdString(key.uids()->front().uid())); + this, _("Invalid Operation"), + QString(_( + "The selected key contains a key that does not actually have a " + "signature usage.")) + + "<br/><br/>" + _("For example the Following Key:") + "<br/>" + + key.uids()->front().uid().c_str()); return; } } @@ -149,7 +151,7 @@ void MainWindow::slotSign() { gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Signing").toStdString(), [&]() { + process_operation(this, _("Signing"), [&]() { try { auto buffer = edit->curTextPage()->toPlainText().toUtf8().toStdString(); error = GpgFrontend::BasicOperator::GetInstance().Sign( @@ -165,8 +167,8 @@ void MainWindow::slotSign() { process_result_analyse(edit, infoBoard, resultAnalyse); edit->slotFillTextEditWithText(QString::fromStdString(*tmp)); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } else if (edit->slotCurPageFileTreeView() != nullptr) { @@ -184,15 +186,15 @@ void MainWindow::slotDecrypt() { if (text.trimmed().startsWith( GpgConstants::GPG_FRONTEND_SHORT_CRYPTO_HEAD)) { QMessageBox::critical( - this, tr("Notice"), - tr("Short Crypto Text only supports Decrypt & Verify.")); + this, _("Notice"), + _("Short Crypto Text only supports Decrypt & Verify.")); return; } GpgDecrResult result = nullptr; gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Decrypting").toStdString(), [&]() { + process_operation(this, _("Decrypting"), [&]() { try { auto buffer = text.toStdString(); error = GpgFrontend::BasicOperator::GetInstance().Decrypt( @@ -210,8 +212,8 @@ void MainWindow::slotDecrypt() { if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) edit->slotFillTextEditWithText(QString::fromStdString(*decrypted)); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } else if (edit->slotCurPageFileTreeView() != nullptr) { @@ -244,7 +246,7 @@ void MainWindow::slotVerify() { GpgVerifyResult result = nullptr; GpgError error; bool if_error = false; - process_operation(this, tr("Verifying").toStdString(), [&]() { + process_operation(this, _("Verifying"), [&]() { try { auto buffer = text.toStdString(); error = GpgFrontend::BasicOperator::GetInstance().Verify( @@ -268,8 +270,8 @@ void MainWindow::slotVerify() { // } } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } else if (edit->slotCurPageFileTreeView() != nullptr) { @@ -284,8 +286,8 @@ void MainWindow::slotEncryptSign() { auto key_ids = mKeyList->getChecked(); if (key_ids->empty()) { - QMessageBox::critical(nullptr, tr("No Key Selected"), - tr("No Key Selected")); + QMessageBox::critical(nullptr, _("No Key Selected"), + _("No Key Selected")); return; } @@ -296,9 +298,9 @@ void MainWindow::slotEncryptSign() { if (!key_can_encrypt) { QMessageBox::critical( - nullptr, tr("Invalid KeyPair"), - tr("The selected keypair cannot be used for encryption.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + nullptr, _("Invalid KeyPair"), + QString(_("The selected keypair cannot be used for encryption.")) + + "<br/><br/>" + _("For example the Following Key:") + " <br/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -326,7 +328,7 @@ void MainWindow::slotEncryptSign() { bool if_error = false; auto tmp = std::make_unique<ByteArray>(); - process_operation(this, tr("Encrypting and Signing").toStdString(), [&]() { + process_operation(this, _("Encrypting and Signing"), [&]() { try { auto buffer = edit->curTextPage()->toPlainText().toUtf8().toStdString(); error = GpgFrontend::BasicOperator::GetInstance().EncryptSign( @@ -344,11 +346,11 @@ void MainWindow::slotEncryptSign() { pubkeyUploader.start(); if (!pubkeyUploader.result()) { QMessageBox::warning( - nullptr, tr("Automatic Key Exchange Warning"), - tr("Part of the automatic key exchange failed, " - "which may be related to your key.") + - tr("If possible, try to use the RSA algorithm " - "compatible with the server for signing.")); + nullptr, _("Automatic Key Exchange Warning"), + _("Part of the automatic key exchange failed, " + "which may be related to your key.") + + _("If possible, try to use the RSA algorithm " + "compatible with the server for signing.")); } } #endif @@ -366,9 +368,9 @@ void MainWindow::slotEncryptSign() { if (settings.value("sendMail/enable", false).toBool()) new SendMailDialog(edit->curTextPage()->toPlainText(), this); else { - QMessageBox::warning(nullptr, tr("Function Disabled"), - tr("Please go to the settings interface to " - "enable and configure this function.")); + QMessageBox::warning(nullptr, _("Function Disabled"), + _("Please go to the settings interface to " + "enable and configure this function.")); } }); #endif @@ -376,9 +378,9 @@ void MainWindow::slotEncryptSign() { #ifdef ADVANCE_SUPPORT infoBoard->addOptionalAction("Shorten Ciphertext", [this]() { if (settings.value("general/serviceToken").toString().isEmpty()) - QMessageBox::warning(nullptr, tr("Service Token Empty"), - tr("Please go to the settings interface to set " - "Own Key and get Service Token.")); + QMessageBox::warning(nullptr, _("Service Token Empty"), + _("Please go to the settings interface to set " + "Own Key and get Service Token.")); else { shortenCryptText(); } @@ -386,8 +388,8 @@ void MainWindow::slotEncryptSign() { #endif } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } else if (edit->slotCurPageFileTreeView() != nullptr) { @@ -432,16 +434,15 @@ void MainWindow::slotDecryptVerify() { } #endif auto decrypted = std::make_unique<ByteArray>(); - process_operation(this, tr("Decrypting and Verifying").toStdString(), - [&]() { - try { - auto buffer = text.toStdString(); - error = BasicOperator::GetInstance().DecryptVerify( - buffer, decrypted, d_result, v_result); - } catch (const std::runtime_error& e) { - if_error = true; - } - }); + process_operation(this, _("Decrypting and Verifying"), [&]() { + try { + auto buffer = text.toStdString(); + error = BasicOperator::GetInstance().DecryptVerify(buffer, decrypted, + d_result, v_result); + } catch (const std::runtime_error& e) { + if_error = true; + } + }); if (!if_error) { infoBoard->associateFileTreeView(edit->curFilePage()); @@ -463,8 +464,8 @@ void MainWindow::slotDecryptVerify() { // }); // } } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } @@ -494,7 +495,7 @@ void MainWindow::slotCopyMailAddressToClipboard() { auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } QClipboard* cb = QApplication::clipboard(); @@ -509,7 +510,7 @@ void MainWindow::slotShowKeyDetails() { if (key.good()) { new KeyDetailsDialog(key, this); } else { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); } } @@ -534,21 +535,24 @@ void MainWindow::slotOpenFile(QString& path) { edit->slotOpenFile(path); } void MainWindow::slotVersionUpgrade(const QString& currentVersion, const QString& latestVersion) { if (currentVersion < latestVersion) { - QMessageBox::warning(this, tr("Outdated Version"), - tr("This version(%1) is out of date, please update " - "the latest version in time. ") - .arg(currentVersion) + - tr("You can download the latest version(%1) on " - "Github Releases Page.<br/>") - .arg(latestVersion)); + QMessageBox::warning( + this, _("Outdated Version"), + QString(_("This version(%1) is out of date, please update " + "the latest version in time. ")) + .arg(currentVersion) + + QString(_("You can download the latest version(%1) on " + "Github Releases Page.<br/>")) + .arg(latestVersion)); } else if (currentVersion > latestVersion) { QMessageBox::warning( - this, tr("Unreleased Version"), - tr("This version(%1) has not been officially released and is not " - "recommended for use in a production environment. <br/>") + this, _("Unreleased Version"), + QString( + _("This version(%1) has not been officially released and is not " + "recommended for use in a production environment. <br/>")) .arg(currentVersion) + - tr("You can download the latest version(%1) on Github Releases " - "Page.<br/>") + QString( + _("You can download the latest version(%1) on Github Releases " + "Page.<br/>")) .arg(latestVersion)); } } diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index 7310bd1c..312364e2 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -53,10 +53,10 @@ void MainWindow::slotStartWizard() { // if (filenum > 0) { // QString statusText; // if (filenum == 1) { -// statusText = tr("There is one unencrypted file in attachment folder"); +// statusText = _("There is one unencrypted file in attachment folder"); // } else { -// statusText = tr("There are ") + QString::number(filenum) + -// tr(" unencrypted files in attachment folder"); +// statusText = _("There are ") + QString::number(filenum) + +// _(" unencrypted files in attachment folder"); // } // statusBarIcon->setStatusTip(statusText); // statusBarIcon->show(); diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp index cf5d1172..08a9e215 100644 --- a/src/ui/main_window/MainWindowUI.cpp +++ b/src/ui/main_window/MainWindowUI.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -29,256 +29,255 @@ namespace GpgFrontend::UI { void MainWindow::createActions() { /* Main Menu */ - newTabAct = new QAction(tr("&New"), this); + newTabAct = new QAction(_("New"), this); newTabAct->setIcon(QIcon(":misc_doc.png")); QList<QKeySequence> newTabActShortcutList; newTabActShortcutList.append(QKeySequence(Qt::CTRL + Qt::Key_N)); newTabActShortcutList.append(QKeySequence(Qt::CTRL + Qt::Key_T)); newTabAct->setShortcuts(newTabActShortcutList); - newTabAct->setToolTip(tr("Open a new file")); + newTabAct->setToolTip(_("Open a new file")); connect(newTabAct, SIGNAL(triggered()), edit, SLOT(slotNewTab())); - openAct = new QAction(tr("&Open..."), this); + openAct = new QAction(_("Open..."), this); openAct->setIcon(QIcon(":fileopen.png")); openAct->setShortcut(QKeySequence::Open); - openAct->setToolTip(tr("Open an existing file")); + openAct->setToolTip(_("Open an existing file")); connect(openAct, SIGNAL(triggered()), edit, SLOT(slotOpen())); - browserAct = new QAction(tr("&Browser"), this); + browserAct = new QAction(_("Browser"), this); browserAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); - browserAct->setToolTip(tr("Open a file browser")); + browserAct->setToolTip(_("Open a file browser")); connect(browserAct, SIGNAL(triggered()), this, SLOT(slotOpenFileTab())); - saveAct = new QAction(tr("&Save"), this); + saveAct = new QAction(_("Save"), this); saveAct->setIcon(QIcon(":filesave.png")); saveAct->setShortcut(QKeySequence::Save); - saveAct->setToolTip(tr("Save the current File")); + saveAct->setToolTip(_("Save the current File")); connect(saveAct, SIGNAL(triggered()), edit, SLOT(slotSave())); - saveAsAct = new QAction(tr("Save &As") + "...", this); + saveAsAct = new QAction(QString(_("Save As")) + "...", this); saveAsAct->setIcon(QIcon(":filesaveas.png")); saveAsAct->setShortcut(QKeySequence::SaveAs); - saveAsAct->setToolTip(tr("Save the current File as...")); + saveAsAct->setToolTip(_("Save the current File as...")); connect(saveAsAct, SIGNAL(triggered()), edit, SLOT(slotSaveAs())); - printAct = new QAction(tr("&Print"), this); + printAct = new QAction(_("Print"), this); printAct->setIcon(QIcon(":fileprint.png")); printAct->setShortcut(QKeySequence::Print); - printAct->setToolTip(tr("Print Document")); + printAct->setToolTip(_("Print Document")); connect(printAct, SIGNAL(triggered()), edit, SLOT(slotPrint())); - closeTabAct = new QAction(tr("&Close"), this); + closeTabAct = new QAction(_("Close"), this); closeTabAct->setShortcut(QKeySequence::Close); - closeTabAct->setToolTip(tr("Close file")); + closeTabAct->setToolTip(_("Close file")); connect(closeTabAct, SIGNAL(triggered()), edit, SLOT(slotCloseTab())); - quitAct = new QAction(tr("&Quit"), this); + quitAct = new QAction(_("Quit"), this); quitAct->setShortcut(QKeySequence::Quit); quitAct->setIcon(QIcon(":exit.png")); - quitAct->setToolTip(tr("Quit Program")); + quitAct->setToolTip(_("Quit Program")); connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); /* Edit Menu */ - undoAct = new QAction(tr("&Undo"), this); + undoAct = new QAction(_("Undo"), this); undoAct->setShortcut(QKeySequence::Undo); - undoAct->setToolTip(tr("Undo Last Edit Action")); + undoAct->setToolTip(_("Undo Last Edit Action")); connect(undoAct, SIGNAL(triggered()), edit, SLOT(slotUndo())); - redoAct = new QAction(tr("&Redo"), this); + redoAct = new QAction(_("Redo"), this); redoAct->setShortcut(QKeySequence::Redo); - redoAct->setToolTip(tr("Redo Last Edit Action")); + redoAct->setToolTip(_("Redo Last Edit Action")); connect(redoAct, SIGNAL(triggered()), edit, SLOT(slotRedo())); - zoomInAct = new QAction(tr("Zoom In"), this); + zoomInAct = new QAction(_("Zoom In"), this); zoomInAct->setShortcut(QKeySequence::ZoomIn); connect(zoomInAct, SIGNAL(triggered()), edit, SLOT(slotZoomIn())); - zoomOutAct = new QAction(tr("Zoom Out"), this); + zoomOutAct = new QAction(_("Zoom Out"), this); zoomOutAct->setShortcut(QKeySequence::ZoomOut); connect(zoomOutAct, SIGNAL(triggered()), edit, SLOT(slotZoomOut())); - pasteAct = new QAction(tr("&Paste"), this); + pasteAct = new QAction(_("Paste"), this); pasteAct->setIcon(QIcon(":button_paste.png")); pasteAct->setShortcut(QKeySequence::Paste); - pasteAct->setToolTip(tr("Paste Text From Clipboard")); + pasteAct->setToolTip(_("Paste Text From Clipboard")); connect(pasteAct, SIGNAL(triggered()), edit, SLOT(slotPaste())); - cutAct = new QAction(tr("Cu&t"), this); + cutAct = new QAction(_("Cut"), this); cutAct->setIcon(QIcon(":button_cut.png")); cutAct->setShortcut(QKeySequence::Cut); cutAct->setToolTip( - tr("Cut the current selection's contents to the " - "clipboard")); + _("Cut the current selection's contents to the " + "clipboard")); connect(cutAct, SIGNAL(triggered()), edit, SLOT(slotCut())); - copyAct = new QAction(tr("&Copy"), this); + copyAct = new QAction(_("Copy"), this); copyAct->setIcon(QIcon(":button_copy.png")); copyAct->setShortcut(QKeySequence::Copy); copyAct->setToolTip( - tr("Copy the current selection's contents to the " - "clipboard")); + _("Copy the current selection's contents to the " + "clipboard")); connect(copyAct, SIGNAL(triggered()), edit, SLOT(slotCopy())); - quoteAct = new QAction(tr("&Quote"), this); + quoteAct = new QAction(_("Quote"), this); quoteAct->setIcon(QIcon(":quote.png")); - quoteAct->setToolTip(tr("Quote whole text")); + quoteAct->setToolTip(_("Quote whole text")); connect(quoteAct, SIGNAL(triggered()), edit, SLOT(slotQuote())); - selectAllAct = new QAction(tr("Select &All"), this); + selectAllAct = new QAction(_("Select All"), this); selectAllAct->setIcon(QIcon(":edit.png")); selectAllAct->setShortcut(QKeySequence::SelectAll); - selectAllAct->setToolTip(tr("Select the whole text")); + selectAllAct->setToolTip(_("Select the whole text")); connect(selectAllAct, SIGNAL(triggered()), edit, SLOT(slotSelectAll())); - findAct = new QAction(tr("&Find"), this); + findAct = new QAction(_("Find"), this); findAct->setShortcut(QKeySequence::Find); - findAct->setToolTip(tr("Find a word")); + findAct->setToolTip(_("Find a word")); connect(findAct, SIGNAL(triggered()), this, SLOT(slotFind())); - cleanDoubleLinebreaksAct = new QAction(tr("Remove &spacing"), this); + cleanDoubleLinebreaksAct = new QAction(_("Remove spacing"), this); cleanDoubleLinebreaksAct->setIcon(QIcon(":format-line-spacing-triple.png")); // cleanDoubleLineBreaksAct->setShortcut(QKeySequence::SelectAll); cleanDoubleLinebreaksAct->setToolTip( - tr("Remove double linebreaks, e.g. in pasted text from webmailer")); + _("Remove double linebreaks, e.g. in pasted text from Web Mailer")); connect(cleanDoubleLinebreaksAct, SIGNAL(triggered()), this, SLOT(slotCleanDoubleLinebreaks())); - openSettingsAct = new QAction(tr("Se&ttings"), this); - openSettingsAct->setToolTip(tr("Open settings dialog")); + openSettingsAct = new QAction(_("Settings"), this); + openSettingsAct->setToolTip(_("Open settings dialog")); openSettingsAct->setShortcut(QKeySequence::Preferences); connect(openSettingsAct, SIGNAL(triggered()), this, SLOT(slotOpenSettingsDialog())); /* Crypt Menu */ - encryptAct = new QAction(tr("&Encrypt"), this); + encryptAct = new QAction(_("Encrypt"), this); encryptAct->setIcon(QIcon(":encrypted.png")); encryptAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E)); - encryptAct->setToolTip(tr("Encrypt Message")); + encryptAct->setToolTip(_("Encrypt Message")); connect(encryptAct, SIGNAL(triggered()), this, SLOT(slotEncrypt())); - encryptSignAct = new QAction(tr("&Encrypt &Sign"), this); + encryptSignAct = new QAction(_("Encrypt Sign"), this); encryptSignAct->setIcon(QIcon(":encrypted_signed.png")); encryptSignAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E)); - encryptSignAct->setToolTip(tr("Encrypt and Sign Message")); + encryptSignAct->setToolTip(_("Encrypt and Sign Message")); connect(encryptSignAct, SIGNAL(triggered()), this, SLOT(slotEncryptSign())); - decryptAct = new QAction(tr("&Decrypt"), this); + decryptAct = new QAction(_("Decrypt"), this); decryptAct->setIcon(QIcon(":decrypted.png")); decryptAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); - decryptAct->setToolTip(tr("Decrypt Message")); + decryptAct->setToolTip(_("Decrypt Message")); connect(decryptAct, SIGNAL(triggered()), this, SLOT(slotDecrypt())); - decryptVerifyAct = new QAction(tr("&Decrypt &Verify"), this); + decryptVerifyAct = new QAction(_("Decrypt Verify"), this); decryptVerifyAct->setIcon(QIcon(":decrypted_verified.png")); decryptVerifyAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D)); - decryptVerifyAct->setToolTip(tr("Decrypt and Verify Message")); + decryptVerifyAct->setToolTip(_("Decrypt and Verify Message")); connect(decryptVerifyAct, SIGNAL(triggered()), this, SLOT(slotDecryptVerify())); /* * File encryption submenu */ - fileEncryptAct = new QAction(tr("&Encrypt File"), this); - fileEncryptAct->setToolTip(tr("Encrypt File")); + fileEncryptAct = new QAction(_("Encrypt File"), this); + fileEncryptAct->setToolTip(_("Encrypt File")); connect(fileEncryptAct, SIGNAL(triggered()), this, SLOT(slotFileEncryptCustom())); - fileDecryptAct = new QAction(tr("&Decrypt File"), this); - fileDecryptAct->setToolTip(tr("Decrypt File")); + fileDecryptAct = new QAction(_("Decrypt File"), this); + fileDecryptAct->setToolTip(_("Decrypt File")); connect(fileDecryptAct, SIGNAL(triggered()), this, SLOT(slotFileDecryptCustom())); - fileSignAct = new QAction(tr("&Sign File"), this); - fileSignAct->setToolTip(tr("Sign File")); + fileSignAct = new QAction(_("Sign File"), this); + fileSignAct->setToolTip(_("Sign File")); connect(fileSignAct, SIGNAL(triggered()), this, SLOT(slotFileSignCustom())); - fileVerifyAct = new QAction(tr("&Verify File"), this); - fileVerifyAct->setToolTip(tr("Verify File")); + fileVerifyAct = new QAction(_("Verify File"), this); + fileVerifyAct->setToolTip(_("Verify File")); connect(fileVerifyAct, SIGNAL(triggered()), this, SLOT(slotFileVerifyCustom())); - signAct = new QAction(tr("&Sign"), this); + signAct = new QAction(_("Sign"), this); signAct->setIcon(QIcon(":signature.png")); signAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I)); - signAct->setToolTip(tr("Sign Message")); + signAct->setToolTip(_("Sign Message")); connect(signAct, SIGNAL(triggered()), this, SLOT(slotSign())); - verifyAct = new QAction(tr("&Verify"), this); + verifyAct = new QAction(_("Verify"), this); verifyAct->setIcon(QIcon(":verify.png")); verifyAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V)); - verifyAct->setToolTip(tr("Verify Message")); + verifyAct->setToolTip(_("Verify Message")); connect(verifyAct, SIGNAL(triggered()), this, SLOT(slotVerify())); /* Key Menu */ - importKeyFromEditAct = new QAction(tr("&Editor"), this); + importKeyFromEditAct = new QAction(_("Editor"), this); importKeyFromEditAct->setIcon(QIcon(":txt.png")); - importKeyFromEditAct->setToolTip(tr("Import New Key From Editor")); + importKeyFromEditAct->setToolTip(_("Import New Key From Editor")); connect(importKeyFromEditAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromEdit())); - openKeyManagementAct = new QAction(tr("Manage &Keys"), this); + openKeyManagementAct = new QAction(_("Manage Keys"), this); openKeyManagementAct->setIcon(QIcon(":keymgmt.png")); - openKeyManagementAct->setToolTip(tr("Open Keymanagement")); + openKeyManagementAct->setToolTip(_("Open Key Management")); connect(openKeyManagementAct, SIGNAL(triggered()), this, SLOT(slotOpenKeyManagement())); /* * About Menu */ - aboutAct = new QAction(tr("&About"), this); + aboutAct = new QAction(_("About"), this); aboutAct->setIcon(QIcon(":help.png")); - aboutAct->setToolTip(tr("Show the application's About box")); + aboutAct->setToolTip(_("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(slotAbout())); /* * Check Update Menu */ - checkUpdateAct = new QAction(tr("&Check for Updates"), this); + checkUpdateAct = new QAction(_("Check for Updates"), this); checkUpdateAct->setIcon(QIcon(":help.png")); - checkUpdateAct->setToolTip(tr("Check for updates")); + checkUpdateAct->setToolTip(_("Check for updates")); connect(checkUpdateAct, SIGNAL(triggered()), this, SLOT(slotCheckUpdate())); - startWizardAct = new QAction(tr("Open &Wizard"), this); - startWizardAct->setToolTip(tr("Open the wizard")); + startWizardAct = new QAction(_("Open Wizard"), this); + startWizardAct->setToolTip(_("Open the wizard")); connect(startWizardAct, SIGNAL(triggered()), this, SLOT(slotStartWizard())); /* Popup-Menu-Action for KeyList */ appendSelectedKeysAct = - new QAction(tr("Append Selected Key(s) To Text"), this); + new QAction(_("Append Selected Key(s) To Text"), this); appendSelectedKeysAct->setToolTip( - tr("Append The Selected Keys To Text in Editor")); + _("Append The Selected Keys To Text in Editor")); connect(appendSelectedKeysAct, SIGNAL(triggered()), this, SLOT(slotAppendSelectedKeys())); - copyMailAddressToClipboardAct = new QAction(tr("Copy Email"), this); + copyMailAddressToClipboardAct = new QAction(_("Copy Email"), this); copyMailAddressToClipboardAct->setToolTip( - tr("Copy selected Email to clipboard")); + _("Copy selected Email to clipboard")); connect(copyMailAddressToClipboardAct, SIGNAL(triggered()), this, SLOT(slotCopyMailAddressToClipboard())); // TODO: find central place for shared actions, to avoid code-duplication with // keymgmt.cpp - showKeyDetailsAct = new QAction(tr("Show Key Details"), this); - showKeyDetailsAct->setToolTip(tr("Show Details for this Key")); + showKeyDetailsAct = new QAction(_("Show Key Details"), this); + showKeyDetailsAct->setToolTip(_("Show Details for this Key")); connect(showKeyDetailsAct, SIGNAL(triggered()), this, SLOT(slotShowKeyDetails())); refreshKeysFromKeyserverAct = - new QAction(tr("Refresh Key From Key Server"), this); + new QAction(_("Refresh Key From Key Server"), this); refreshKeysFromKeyserverAct->setToolTip( - tr("Refresh key from default key server")); + _("Refresh key from default key server")); connect(refreshKeysFromKeyserverAct, SIGNAL(triggered()), this, SLOT(refreshKeysFromKeyserver())); - uploadKeyToServerAct = - new QAction(tr("Upload Public Key(s) To Server"), this); + uploadKeyToServerAct = new QAction(_("Upload Public Key(s) To Server"), this); uploadKeyToServerAct->setToolTip( - tr("Upload The Selected Public Keys To Server")); + _("Upload The Selected Public Keys To Server")); connect(uploadKeyToServerAct, SIGNAL(triggered()), this, SLOT(uploadKeyToServer())); @@ -295,15 +294,15 @@ void MainWindow::createActions() { SLOT(slotSwitchTabDown())); this->addAction(switchTabDownAct); - cutPgpHeaderAct = new QAction(tr("Remove PGP Header"), this); + cutPgpHeaderAct = new QAction(_("Remove PGP Header"), this); connect(cutPgpHeaderAct, SIGNAL(triggered()), this, SLOT(slotCutPgpHeader())); - addPgpHeaderAct = new QAction(tr("Add PGP Header"), this); + addPgpHeaderAct = new QAction(_("Add PGP Header"), this); connect(addPgpHeaderAct, SIGNAL(triggered()), this, SLOT(slotAddPgpHeader())); } void MainWindow::createMenus() { - fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu = menuBar()->addMenu(_("File")); fileMenu->addAction(newTabAct); fileMenu->addAction(browserAct); fileMenu->addAction(openAct); @@ -316,7 +315,7 @@ void MainWindow::createMenus() { fileMenu->addAction(closeTabAct); fileMenu->addAction(quitAct); - editMenu = menuBar()->addMenu(tr("&Edit")); + editMenu = menuBar()->addMenu(_("Edit")); editMenu->addAction(undoAct); editMenu->addAction(redoAct); editMenu->addSeparator(); @@ -334,13 +333,13 @@ void MainWindow::createMenus() { editMenu->addSeparator(); editMenu->addAction(openSettingsAct); - fileEncMenu = new QMenu(tr("&File...")); + fileEncMenu = new QMenu(_("File...")); fileEncMenu->addAction(fileEncryptAct); fileEncMenu->addAction(fileDecryptAct); fileEncMenu->addAction(fileSignAct); fileEncMenu->addAction(fileVerifyAct); - cryptMenu = menuBar()->addMenu(tr("&Crypt")); + cryptMenu = menuBar()->addMenu(_("Crypt")); cryptMenu->addAction(encryptAct); cryptMenu->addAction(encryptSignAct); cryptMenu->addAction(decryptAct); @@ -351,8 +350,8 @@ void MainWindow::createMenus() { cryptMenu->addSeparator(); cryptMenu->addMenu(fileEncMenu); - keyMenu = menuBar()->addMenu(tr("&Keys")); - importKeyMenu = keyMenu->addMenu(tr("&Import Key")); + keyMenu = menuBar()->addMenu(_("Keys")); + importKeyMenu = keyMenu->addMenu(_("Import Key")); importKeyMenu->setIcon(QIcon(":key_import.png")); importKeyMenu->addAction(keyMgmt->importKeyFromFileAct); importKeyMenu->addAction(importKeyFromEditAct); @@ -361,7 +360,7 @@ void MainWindow::createMenus() { importKeyMenu->addAction(keyMgmt->importKeyFromKeyServerAct); keyMenu->addAction(openKeyManagementAct); - steganoMenu = menuBar()->addMenu(tr("&Steganography")); + steganoMenu = menuBar()->addMenu(_("Steganography")); steganoMenu->addAction(cutPgpHeaderAct); steganoMenu->addAction(addPgpHeaderAct); @@ -372,9 +371,9 @@ void MainWindow::createMenus() { } #endif - viewMenu = menuBar()->addMenu(tr("&View")); + viewMenu = menuBar()->addMenu(_("View")); - helpMenu = menuBar()->addMenu(tr("&Help")); + helpMenu = menuBar()->addMenu(_("Help")); helpMenu->addAction(startWizardAct); helpMenu->addSeparator(); helpMenu->addAction(checkUpdateAct); @@ -382,7 +381,7 @@ void MainWindow::createMenus() { } void MainWindow::createToolBars() { - fileToolBar = addToolBar(tr("File")); + fileToolBar = addToolBar(_("File")); fileToolBar->setObjectName("fileToolBar"); fileToolBar->addAction(newTabAct); fileToolBar->addAction(openAct); @@ -390,7 +389,7 @@ void MainWindow::createToolBars() { fileToolBar->hide(); viewMenu->addAction(fileToolBar->toggleViewAction()); - cryptToolBar = addToolBar(tr("Crypt")); + cryptToolBar = addToolBar(_("Crypt")); cryptToolBar->setObjectName("cryptToolBar"); cryptToolBar->addAction(encryptAct); cryptToolBar->addAction(encryptSignAct); @@ -400,19 +399,19 @@ void MainWindow::createToolBars() { cryptToolBar->addAction(verifyAct); viewMenu->addAction(cryptToolBar->toggleViewAction()); - keyToolBar = addToolBar(tr("Key")); + keyToolBar = addToolBar(_("Key")); keyToolBar->setObjectName("keyToolBar"); keyToolBar->addAction(openKeyManagementAct); viewMenu->addAction(keyToolBar->toggleViewAction()); - editToolBar = addToolBar(tr("Edit")); + editToolBar = addToolBar(_("Edit")); editToolBar->setObjectName("editToolBar"); editToolBar->addAction(copyAct); editToolBar->addAction(pasteAct); editToolBar->addAction(selectAllAct); viewMenu->addAction(editToolBar->toggleViewAction()); - specialEditToolBar = addToolBar(tr("Special Edit")); + specialEditToolBar = addToolBar(_("Special Edit")); specialEditToolBar->setObjectName("specialEditToolBar"); specialEditToolBar->addAction(quoteAct); specialEditToolBar->addAction(cleanDoubleLinebreaksAct); @@ -424,8 +423,8 @@ void MainWindow::createToolBars() { importButton->setMenu(importKeyMenu); importButton->setPopupMode(QToolButton::InstantPopup); importButton->setIcon(QIcon(":key_import.png")); - importButton->setToolTip(tr("Import key from...")); - importButton->setText(tr("Import key")); + importButton->setToolTip(_("Import key from...")); + importButton->setText(_("Import key")); keyToolBar->addWidget(importButton); // Add dropdown menu for file encryption/decryption to crypttoolbar @@ -433,8 +432,8 @@ void MainWindow::createToolBars() { connect(fileEncButton, SIGNAL(clicked(bool)), this, SLOT(slotOpenFileTab())); fileEncButton->setPopupMode(QToolButton::InstantPopup); fileEncButton->setIcon(QIcon(":fileencryption.png")); - fileEncButton->setToolTip(tr("Browser to view and operate file")); - fileEncButton->setText(tr("Browser")); + fileEncButton->setToolTip(_("Browser to view and operate file")); + fileEncButton->setText(_("Browser")); fileToolBar->addWidget(fileEncButton); } @@ -451,14 +450,14 @@ void MainWindow::createStatusBar() { statusBarIcon->setPixmap(*pixmap); statusBar()->insertPermanentWidget(0, statusBarIcon, 0); statusBarIcon->hide(); - statusBar()->showMessage(tr("Ready"), 2000); + statusBar()->showMessage(_("Ready"), 2000); statusBarBox->setLayout(statusBarBoxLayout); } void MainWindow::createDockWindows() { /* KeyList-Dockwindow */ - keyListDock = new QDockWidget(tr("Key ToolBox"), this); + keyListDock = new QDockWidget(_("Key ToolBox"), this); keyListDock->setObjectName("EncryptDock"); keyListDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -467,7 +466,7 @@ void MainWindow::createDockWindows() { keyListDock->setWidget(mKeyList); viewMenu->addAction(keyListDock->toggleViewAction()); - infoBoardDock = new QDockWidget(tr("Information Board"), this); + infoBoardDock = new QDockWidget(_("Information Board"), this); infoBoardDock->setObjectName("Information Board"); infoBoardDock->setAllowedAreas(Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, infoBoardDock); diff --git a/src/ui/settings/GlobalSettingStation.cpp b/src/ui/settings/GlobalSettingStation.cpp index 5d292446..3e229091 100644 --- a/src/ui/settings/GlobalSettingStation.cpp +++ b/src/ui/settings/GlobalSettingStation.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -37,11 +37,11 @@ void GlobalSettingStation::Sync() noexcept { using namespace libconfig; try { ui_cfg.writeFile(ui_config_path.c_str()); - LOG(INFO) << "Updated ui configuration successfully written to: " + LOG(INFO) << _("Updated ui configuration successfully written to") << ui_config_path; } catch (const FileIOException& fioex) { - LOG(ERROR) << "I/O error while writing ui configuration file: " + LOG(ERROR) << _("I/O error while writing ui configuration file") << ui_config_path; } } @@ -50,9 +50,13 @@ GlobalSettingStation::GlobalSettingStation() noexcept { using namespace boost::filesystem; using namespace libconfig; - LOG(INFO) << "App Configure Path" << app_configure_path; - LOG(INFO) << "App Data Path" << app_data_path; - LOG(INFO) << "App Log Path" << app_log_path; + el::Loggers::addFlag(el::LoggingFlag::AutoSpacing); + + LOG(INFO) << _("App Path") << app_path; + LOG(INFO) << _("App Configure Path") << app_configure_path; + LOG(INFO) << _("App Data Path") << app_data_path; + LOG(INFO) << _("App Log Path") << app_log_path; + LOG(INFO) << _("App Locale Path") << app_locale_path; if (!is_directory(app_configure_path)) create_directory(app_configure_path); @@ -65,23 +69,24 @@ GlobalSettingStation::GlobalSettingStation() noexcept { if (!exists(ui_config_path)) { try { this->ui_cfg.writeFile(ui_config_path.c_str()); - LOG(INFO) << "UserInterface configuration successfully written to: " + LOG(INFO) << _("UserInterface configuration successfully written to") << ui_config_path; } catch (const FileIOException& fioex) { - LOG(ERROR) << "I/O error while writing UserInterface configuration file: " - << ui_config_path; + LOG(ERROR) + << _("I/O error while writing UserInterface configuration file") + << ui_config_path; } } else { try { this->ui_cfg.readFile(ui_config_path.c_str()); - LOG(INFO) << "UserInterface configuration successfully read from: " + LOG(INFO) << _("UserInterface configuration successfully read from") << ui_config_path; } catch (const FileIOException& fioex) { - LOG(ERROR) << "I/O error while reading UserInterface configure file"; + LOG(ERROR) << _("I/O error while reading UserInterface configure file"); } catch (const ParseException& pex) { - LOG(ERROR) << "Parse error at " << pex.getFile() << ":" << pex.getLine() - << " - " << pex.getError(); + LOG(ERROR) << _("Parse error at ") << pex.getFile() << ":" + << pex.getLine() << " - " << pex.getError(); } } } diff --git a/src/ui/settings/GlobalSettingStation.h b/src/ui/settings/GlobalSettingStation.h index 03a362ba..b5a86865 100644 --- a/src/ui/settings/GlobalSettingStation.h +++ b/src/ui/settings/GlobalSettingStation.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -33,8 +33,6 @@ class GlobalSettingStation : public QObject { Q_OBJECT - static std::unique_ptr<GlobalSettingStation> _instance; - public: static GlobalSettingStation& GetInstance(); @@ -48,6 +46,10 @@ class GlobalSettingStation : public QObject { return app_log_path; } + [[nodiscard]] boost::filesystem::path GetLocaleDir() const { + return app_locale_path; + } + void Sync() noexcept; private: @@ -62,6 +64,10 @@ class GlobalSettingStation : public QObject { // Program Data Location boost::filesystem::path app_log_path = app_data_path / "logs"; + // Program Data Location + boost::filesystem::path app_locale_path = + RESOURCE_DIR_BOOST_PATH(app_path) / "locales"; + // Program Configure Location boost::filesystem::path app_configure_path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) @@ -75,6 +81,8 @@ class GlobalSettingStation : public QObject { boost::filesystem::path ui_config_path = ui_config_dir_path / "ui.cfg"; libconfig::Config ui_cfg; + + static std::unique_ptr<GlobalSettingStation> _instance; }; #endif // GPGFRONTEND_GLOBALSETTINGSTATION_H diff --git a/src/ui/settings/SettingsAdvanced.cpp b/src/ui/settings/SettingsAdvanced.cpp index 048cbe2d..b64ec8e9 100644 --- a/src/ui/settings/SettingsAdvanced.cpp +++ b/src/ui/settings/SettingsAdvanced.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -34,15 +34,15 @@ AdvancedTab::AdvancedTab(QWidget* parent) /***************************************** * Steganography Box *****************************************/ - auto* steganoBox = new QGroupBox(tr("Show Steganography Options")); + auto* steganoBox = new QGroupBox(_("Show Steganography Options")); auto* steganoBoxLayout = new QHBoxLayout(); - steganoCheckBox = new QCheckBox(tr("Show Steganographic Options."), this); + steganoCheckBox = new QCheckBox(_("Show Steganographic Options."), this); steganoBoxLayout->addWidget(steganoCheckBox); steganoBox->setLayout(steganoBoxLayout); - auto* pubkeyExchangeBox = new QGroupBox(tr("Pubkey Exchange")); + auto* pubkeyExchangeBox = new QGroupBox(_("Pubkey Exchange")); auto* pubkeyExchangeBoxLayout = new QHBoxLayout(); - autoPubkeyExchangeCheckBox = new QCheckBox(tr("Auto Pubkey Exchange"), this); + autoPubkeyExchangeCheckBox = new QCheckBox(_("Auto Pubkey Exchange"), this); pubkeyExchangeBoxLayout->addWidget(autoPubkeyExchangeCheckBox); pubkeyExchangeBox->setLayout(pubkeyExchangeBoxLayout); diff --git a/src/ui/settings/SettingsAdvanced.h b/src/ui/settings/SettingsAdvanced.h index 197fa22d..d8ec8089 100644 --- a/src/ui/settings/SettingsAdvanced.h +++ b/src/ui/settings/SettingsAdvanced.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/settings/SettingsAppearance.cpp b/src/ui/settings/SettingsAppearance.cpp index 74ad6c2a..91bef9ef 100644 --- a/src/ui/settings/SettingsAppearance.cpp +++ b/src/ui/settings/SettingsAppearance.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -34,11 +34,11 @@ AppearanceTab::AppearanceTab(QWidget* parent) /***************************************** * Icon-Size-Box *****************************************/ - auto* iconSizeBox = new QGroupBox(tr("Iconsize")); + auto* iconSizeBox = new QGroupBox(_("Icon Size")); iconSizeGroup = new QButtonGroup(); - iconSizeSmall = new QRadioButton(tr("small")); - iconSizeMedium = new QRadioButton(tr("medium")); - iconSizeLarge = new QRadioButton(tr("large")); + iconSizeSmall = new QRadioButton(_("small")); + iconSizeMedium = new QRadioButton(_("medium")); + iconSizeLarge = new QRadioButton(_("large")); iconSizeGroup->addButton(iconSizeSmall, 1); iconSizeGroup->addButton(iconSizeMedium, 2); @@ -54,11 +54,11 @@ AppearanceTab::AppearanceTab(QWidget* parent) /***************************************** * Icon-Style-Box *****************************************/ - auto* iconStyleBox = new QGroupBox(tr("Iconstyle")); + auto* iconStyleBox = new QGroupBox(_("Icon Style")); iconStyleGroup = new QButtonGroup(); - iconTextButton = new QRadioButton(tr("just text")); - iconIconsButton = new QRadioButton(tr("just icons")); - iconAllButton = new QRadioButton(tr("text and icons")); + iconTextButton = new QRadioButton(_("just text")); + iconIconsButton = new QRadioButton(_("just icons")); + iconAllButton = new QRadioButton(_("text and icons")); iconStyleGroup->addButton(iconTextButton, 1); iconStyleGroup->addButton(iconIconsButton, 2); @@ -74,10 +74,10 @@ AppearanceTab::AppearanceTab(QWidget* parent) /***************************************** * Window-Size-Box *****************************************/ - auto* windowSizeBox = new QGroupBox(tr("Windowstate")); + auto* windowSizeBox = new QGroupBox(_("Window State")); auto* windowSizeBoxLayout = new QHBoxLayout(); windowSizeCheckBox = - new QCheckBox(tr("Save window size and position on exit."), this); + new QCheckBox(_("Save window size and position on exit."), this); windowSizeBoxLayout->addWidget(windowSizeCheckBox); windowSizeBox->setLayout(windowSizeBoxLayout); @@ -85,13 +85,13 @@ AppearanceTab::AppearanceTab(QWidget* parent) * Info-Board-Font-Size-Box *****************************************/ - auto* infoBoardBox = new QGroupBox(tr("Information Board")); + auto* infoBoardBox = new QGroupBox(_("Information Board")); auto* infoBoardLayout = new QHBoxLayout(); infoBoardFontSizeSpin = new QSpinBox(); infoBoardFontSizeSpin->setRange(9, 18); infoBoardFontSizeSpin->setValue(10); infoBoardFontSizeSpin->setSingleStep(1); - infoBoardLayout->addWidget(new QLabel(tr(" Front Size"))); + infoBoardLayout->addWidget(new QLabel(_("Front Size"))); infoBoardLayout->addWidget(infoBoardFontSizeSpin); infoBoardBox->setLayout(infoBoardLayout); diff --git a/src/ui/settings/SettingsAppearance.h b/src/ui/settings/SettingsAppearance.h index 163f3c93..284ecb1c 100644 --- a/src/ui/settings/SettingsAppearance.h +++ b/src/ui/settings/SettingsAppearance.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -60,6 +60,6 @@ class AppearanceTab : public QWidget { void signalRestartNeeded(bool needed); }; -} +} // namespace GpgFrontend::UI #endif // GPGFRONTEND_SETTINGSAPPEARANCE_H diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/settings/SettingsDialog.cpp index 553ce53e..4f959b68 100644 --- a/src/ui/settings/SettingsDialog.cpp +++ b/src/ui/settings/SettingsDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -46,14 +46,14 @@ SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) { advancedTab = new AdvancedTab; gpgPathsTab = new GpgPathsTab; - tabWidget->addTab(generalTab, tr("General")); - tabWidget->addTab(appearanceTab, tr("Appearance")); + tabWidget->addTab(generalTab, _("General")); + tabWidget->addTab(appearanceTab, _("Appearance")); #ifdef SMTP_SUPPORT - tabWidget->addTab(sendMailTab, tr("Send Mail")); + tabWidget->addTab(sendMailTab, _("Send Mail")); #endif - tabWidget->addTab(keyserverTab, tr("Key Server")); - // tabWidget->addTab(gpgPathsTab, tr("Gpg paths")); - tabWidget->addTab(advancedTab, tr("Advanced")); + tabWidget->addTab(keyserverTab, _("Key Server")); + // tabWidget->addTab(gpgPathsTab, _("Gpg paths")); + tabWidget->addTab(advancedTab, _("Advanced")); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -68,7 +68,7 @@ SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) { mainLayout->stretch(0); setLayout(mainLayout); - setWindowTitle(tr("Settings")); + setWindowTitle(_("Settings")); // slots for handling the restartneeded member this->slotSetRestartNeeded(false); @@ -118,7 +118,7 @@ void SettingsDialog::slotAccept() { QHash<QString, QString> SettingsDialog::listLanguages() { QHash<QString, QString> languages; - languages.insert("", tr("System Default")); + languages.insert(QString(), _("System Default")); QString appPath = qApp->applicationDirPath(); QDir qmDir = QDir(RESOURCE_DIR(appPath) + "/ts/"); @@ -153,26 +153,29 @@ GpgPathsTab::GpgPathsTab(QWidget* parent) /***************************************** * Keydb Box *****************************************/ - auto* keydbBox = new QGroupBox(tr("Relative path to keydb")); + auto* keydbBox = new QGroupBox(_("Relative path to Key Database")); auto* keydbBoxLayout = new QGridLayout(); // Label containing the current keydbpath relative to default keydb path keydbLabel = new QLabel(accKeydbPath, this); - auto* keydbButton = new QPushButton("Change keydb path", this); + auto* keydbButton = new QPushButton(_("Change Key Database path"), this); connect(keydbButton, SIGNAL(clicked()), this, SLOT(chooseKeydbDir())); - auto* keydbDefaultButton = new QPushButton("Set keydb to default path", this); + auto* keydbDefaultButton = + new QPushButton(_("Set Key Database to default path"), this); connect(keydbDefaultButton, SIGNAL(clicked()), this, SLOT(setKeydbPathToDefault())); keydbBox->setLayout(keydbBoxLayout); - keydbBoxLayout->addWidget(new QLabel(tr("Current keydb path: ")), 1, 1); + keydbBoxLayout->addWidget( + new QLabel(QString(_("Current Key Database path")) + ": "), 1, 1); keydbBoxLayout->addWidget(keydbLabel, 1, 2); keydbBoxLayout->addWidget(keydbButton, 1, 3); keydbBoxLayout->addWidget(keydbDefaultButton, 2, 3); keydbBoxLayout->addWidget( - new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you " - "change the keydb path!")), + new QLabel(QString("<b>") + _("NOTE") + ": </b> " + + _("GpgFrontend will restart automatically if you change the " + "Key Database path!")), 3, 1, 1, 3); auto* mainLayout = new QVBoxLayout; @@ -200,12 +203,12 @@ void GpgPathsTab::setKeydbPathToDefault() { QString GpgPathsTab::chooseKeydbDir() { QString dir = QFileDialog::getExistingDirectory( - this, tr("Choose keydb directory"), accKeydbPath, + this, _("Choose keydb directory"), accKeydbPath, QFileDialog::ShowDirsOnly); accKeydbPath = getRelativePath(defKeydbPath, dir); keydbLabel->setText(accKeydbPath); - return ""; + return {}; } void GpgPathsTab::setSettings() { diff --git a/src/ui/settings/SettingsDialog.h b/src/ui/settings/SettingsDialog.h index 0f89e266..9f670cfd 100755 --- a/src/ui/settings/SettingsDialog.h +++ b/src/ui/settings/SettingsDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/settings/SettingsGeneral.cpp index f5a98282..51e0649c 100644 --- a/src/ui/settings/SettingsGeneral.cpp +++ b/src/ui/settings/SettingsGeneral.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -45,12 +45,12 @@ GeneralTab::GeneralTab(QWidget* parent) /***************************************** * GpgFrontend Server *****************************************/ - auto* serverBox = new QGroupBox(tr("GpgFrontend Server")); + auto* serverBox = new QGroupBox(_("GpgFrontend Server")); auto* serverBoxLayout = new QVBoxLayout(); serverSelectBox = new QComboBox(); serverBoxLayout->addWidget(serverSelectBox); serverBoxLayout->addWidget(new QLabel( - tr("Server that provides short key and key exchange services"))); + _("Server that provides short key and key exchange services"))); serverBox->setLayout(serverBoxLayout); #endif @@ -58,10 +58,10 @@ GeneralTab::GeneralTab(QWidget* parent) /***************************************** * Save-Checked-Keys-Box *****************************************/ - auto* saveCheckedKeysBox = new QGroupBox(tr("Save Checked Keys")); + auto* saveCheckedKeysBox = new QGroupBox(_("Save Checked Keys")); auto* saveCheckedKeysBoxLayout = new QHBoxLayout(); saveCheckedKeysCheckBox = new QCheckBox( - tr("Save checked private keys on exit and restore them on next start."), + _("Save checked private keys on exit and restore them on next start."), this); saveCheckedKeysBoxLayout->addWidget(saveCheckedKeysCheckBox); saveCheckedKeysBox->setLayout(saveCheckedKeysBoxLayout); @@ -70,10 +70,10 @@ GeneralTab::GeneralTab(QWidget* parent) * Key-Impport-Confirmation Box *****************************************/ auto* importConfirmationBox = - new QGroupBox(tr("Confirm drag'n'drop key import")); + new QGroupBox(_("Confirm drag'n'drop key import")); auto* importConfirmationBoxLayout = new QHBoxLayout(); importConfirmationCheckBox = new QCheckBox( - tr("Import files dropped on the keylist without confirmation."), this); + _("Import files dropped on the Key List without confirmation."), this); importConfirmationBoxLayout->addWidget(importConfirmationCheckBox); importConfirmationBox->setLayout(importConfirmationBoxLayout); @@ -81,7 +81,7 @@ GeneralTab::GeneralTab(QWidget* parent) /***************************************** * Language Select Box *****************************************/ - auto* langBox = new QGroupBox(tr("Language")); + auto* langBox = new QGroupBox(_("Language")); auto* langBoxLayout = new QVBoxLayout(); langSelectBox = new QComboBox; lang = SettingsDialog::listLanguages(); @@ -91,9 +91,9 @@ GeneralTab::GeneralTab(QWidget* parent) } langBoxLayout->addWidget(langSelectBox); - langBoxLayout->addWidget( - new QLabel(tr("<b>NOTE: </b> GpgFrontend will restart automatically if " - "you change the language!"))); + langBoxLayout->addWidget(new QLabel( + "<b>" + QString(_("NOTE")) + _(": ") + "</b>" + + _("GpgFrontend will restart automatically if you change the language!"))); langBox->setLayout(langBoxLayout); connect(langSelectBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLanguageChanged())); @@ -103,12 +103,12 @@ GeneralTab::GeneralTab(QWidget* parent) /***************************************** * Own Key Select Box *****************************************/ - auto* ownKeyBox = new QGroupBox(tr("Own key")); + auto* ownKeyBox = new QGroupBox(_("Own key")); auto* ownKeyBoxLayout = new QVBoxLayout(); auto* ownKeyServiceTokenLayout = new QHBoxLayout(); ownKeySelectBox = new QComboBox; - getServiceTokenButton = new QPushButton(tr("Get Service Token")); - serviceTokenLabel = new QLabel(tr("No Service Token Found")); + getServiceTokenButton = new QPushButton(_("Get Service Token")); + serviceTokenLabel = new QLabel(_("No Service Token Found")); serviceTokenLabel->setAlignment(Qt::AlignCenter); ownKeyBox->setLayout(ownKeyBoxLayout); @@ -116,7 +116,7 @@ GeneralTab::GeneralTab(QWidget* parent) mKeyList = new KeyList(); // Fill the keyid hashmap - keyIds.insert({"", "<none>"}); + keyIds.insert({QString(), "<none>"}); auto private_keys = mKeyList->getAllPrivateKeys(); @@ -135,7 +135,7 @@ GeneralTab::GeneralTab(QWidget* parent) SLOT(slotGetServiceToken())); ownKeyBoxLayout->addWidget(new QLabel( - tr("Key pair for synchronization and identity authentication"))); + _("Key pair for synchronization and identity authentication"))); ownKeyBoxLayout->addWidget(ownKeySelectBox); ownKeyBoxLayout->addLayout(ownKeyServiceTokenLayout); ownKeyServiceTokenLayout->addWidget(getServiceTokenButton); @@ -204,7 +204,7 @@ void GeneralTab::setSettings() { // Language setting QString langKey = settings.value("int/lang").toString(); QString langValue = lang.value(langKey); - if (langKey != "") { + if (!langKey.isEmpty()) { langSelectBox->setCurrentIndex(langSelectBox->findText(langValue)); } @@ -277,7 +277,7 @@ void GeneralTab::slotLanguageChanged() { emit signalRestartNeeded(true); } #ifdef SERVER_SUPPORT void GeneralTab::slotOwnKeyIdChanged() { // Set ownKeyId to currently selected - this->serviceTokenLabel->setText(tr("No Service Token Found")); + this->serviceTokenLabel->setText(_("No Service Token Found")); serviceToken.clear(); } #endif @@ -296,8 +296,8 @@ void GeneralTab::slotGetServiceToken() { if (keyId.isEmpty()) { QMessageBox::critical( - this, tr("Invalid Operation"), - tr("Own Key can not be None while getting service token.")); + this, _("Invalid Operation"), + _("Own Key can not be None while getting service token.")); return; } @@ -309,7 +309,7 @@ void GeneralTab::slotGetServiceToken() { GpgKey key = mCtx->getKeyRefById(keyId); if (!key.good) { - QMessageBox::critical(this, tr("Error"), tr("Key Not Exists")); + QMessageBox::critical(this, _("Error"), _("Key Not Exists")); return; } @@ -380,9 +380,9 @@ void GeneralTab::slotGetServiceToken() { if (!utils->checkDataValueStr("serviceToken") || !utils->checkDataValueStr("fpr")) { - QMessageBox::critical(this, tr("Error"), - tr("The communication content with the server does " - "not meet the requirements")); + QMessageBox::critical(this, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); return; } @@ -395,12 +395,12 @@ void GeneralTab::slotGetServiceToken() { // Auto update settings settings.setValue("general/serviceToken", serviceToken); serviceTokenLabel->setText(serviceToken); - QMessageBox::information(this, tr("Notice"), - tr("Succeed in getting service token")); + QMessageBox::information(this, _("Notice"), + _("Succeed in getting service token")); } else { QMessageBox::critical( - this, tr("Error"), - tr("There is a problem with the communication with the server")); + this, _("Error"), + _("There is a problem with the communication with the server")); } } } diff --git a/src/ui/settings/SettingsGeneral.h b/src/ui/settings/SettingsGeneral.h index cc61d8bc..5816af9d 100644 --- a/src/ui/settings/SettingsGeneral.h +++ b/src/ui/settings/SettingsGeneral.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/settings/SettingsKeyServer.cpp b/src/ui/settings/SettingsKeyServer.cpp index d232a46e..dc77491b 100644 --- a/src/ui/settings/SettingsKeyServer.cpp +++ b/src/ui/settings/SettingsKeyServer.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -31,7 +31,7 @@ KeyserverTab::KeyserverTab(QWidget* parent) appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { - auto generalGroupBox = new QGroupBox(tr("General")); + auto generalGroupBox = new QGroupBox(_("General")); auto generalLayout = new QVBoxLayout(); keyServerTable = new QTableWidget(); @@ -53,11 +53,11 @@ KeyserverTab::KeyserverTab(QWidget* parent) keyServerTable->setAlternatingRowColors(true); QStringList labels; - labels << tr("No.") << tr("Address") << tr("Available"); + labels << _("No.") << _("Address") << _("Available"); keyServerTable->setHorizontalHeaderLabels(labels); auto* mainLayout = new QVBoxLayout(this); - auto* label = new QLabel(tr("Default Key Server for Import:")); + auto* label = new QLabel(QString(_("Default Key Server for Import")) + ": "); comboBox = new QComboBox; comboBox->setEditable(false); @@ -67,7 +67,7 @@ KeyserverTab::KeyserverTab(QWidget* parent) auto* addKeyServerLayout = new QHBoxLayout(addKeyServerBox); auto* http = new QLabel("URL: "); newKeyServerEdit = new QLineEdit(this); - auto* newKeyServerButton = new QPushButton(tr("Add"), this); + auto* newKeyServerButton = new QPushButton(_("Add"), this); connect(newKeyServerButton, SIGNAL(clicked()), this, SLOT(addKeyServer())); addKeyServerLayout->addWidget(http); addKeyServerLayout->addWidget(newKeyServerEdit); @@ -140,7 +140,7 @@ void KeyserverTab::refreshTable() { auto* tmp2 = new QTableWidgetItem(server); tmp2->setTextAlignment(Qt::AlignCenter); keyServerTable->setItem(index, 1, tmp2); - auto* tmp3 = new QTableWidgetItem(""); + auto* tmp3 = new QTableWidgetItem(); tmp3->setTextAlignment(Qt::AlignCenter); keyServerTable->setItem(index, 2, tmp3); index++; diff --git a/src/ui/settings/SettingsKeyServer.h b/src/ui/settings/SettingsKeyServer.h index ce7c5b2e..23186702 100644 --- a/src/ui/settings/SettingsKeyServer.h +++ b/src/ui/settings/SettingsKeyServer.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -56,6 +56,6 @@ class KeyserverTab : public QWidget { void signalRestartNeeded(bool needed); }; -} +} // namespace GpgFrontend::UI #endif // GPGFRONTEND_SETTINGSKEYSERVER_H diff --git a/src/ui/settings/SettingsSendMail.cpp b/src/ui/settings/SettingsSendMail.cpp index 9d48b2a0..2518991d 100644 --- a/src/ui/settings/SettingsSendMail.cpp +++ b/src/ui/settings/SettingsSendMail.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -35,7 +35,7 @@ SendMailTab::SendMailTab(QWidget* parent) appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { - enableCheckBox = new QCheckBox(tr("Enable")); + enableCheckBox = new QCheckBox(_("Enable")); enableCheckBox->setTristate(false); smtpAddress = new QLineEdit(); @@ -54,31 +54,31 @@ SendMailTab::SendMailTab(QWidget* parent) defaultSender = new QLineEdit(); ; - checkConnectionButton = new QPushButton(tr("Check Connection")); + checkConnectionButton = new QPushButton(_("Check Connection")); - auto generalGroupBox = new QGroupBox(tr("General")); - auto connectGroupBox = new QGroupBox(tr("Connection")); - auto preferenceGroupBox = new QGroupBox(tr("Preference")); + auto generalGroupBox = new QGroupBox(_("General")); + auto connectGroupBox = new QGroupBox(_("Connection")); + auto preferenceGroupBox = new QGroupBox(_("Preference")); auto generalLayout = new QGridLayout(); generalLayout->addWidget(enableCheckBox); auto connectLayout = new QGridLayout(); - connectLayout->addWidget(new QLabel(tr("SMTP Address")), 1, 0); + connectLayout->addWidget(new QLabel(_("SMTP Address")), 1, 0); connectLayout->addWidget(smtpAddress, 1, 1, 1, 4); - connectLayout->addWidget(new QLabel(tr("Username")), 2, 0); + connectLayout->addWidget(new QLabel(_("Username")), 2, 0); connectLayout->addWidget(username, 2, 1, 1, 4); - connectLayout->addWidget(new QLabel(tr("Password")), 3, 0); + connectLayout->addWidget(new QLabel(_("Password")), 3, 0); connectLayout->addWidget(password, 3, 1, 1, 4); - connectLayout->addWidget(new QLabel(tr("Port")), 4, 0); + connectLayout->addWidget(new QLabel(_("Port")), 4, 0); connectLayout->addWidget(portSpin, 4, 1, 1, 1); - connectLayout->addWidget(new QLabel(tr("Connection Security")), 5, 0); + connectLayout->addWidget(new QLabel(_("Connection Security")), 5, 0); connectLayout->addWidget(connectionTypeComboBox, 5, 1, 1, 1); connectLayout->addWidget(checkConnectionButton, 6, 0); auto preferenceLayout = new QGridLayout(); - preferenceLayout->addWidget(new QLabel(tr("Default Sender")), 0, 0); + preferenceLayout->addWidget(new QLabel(_("Default Sender")), 0, 0); preferenceLayout->addWidget(defaultSender, 0, 1, 1, 4); generalGroupBox->setLayout(generalLayout); @@ -164,17 +164,17 @@ void SendMailTab::slotCheckConnection() { bool if_success = true; if (!smtp.connectToHost()) { - QMessageBox::critical(this, tr("Fail"), tr("Fail to Connect SMTP Server")); + QMessageBox::critical(this, _("Fail"), _("Fail to Connect SMTP Server")); if_success = false; } if (if_success && !smtp.login()) { - QMessageBox::critical(this, tr("Fail"), tr("Fail to Login")); + QMessageBox::critical(this, _("Fail"), _("Fail to Login")); if_success = false; } if (if_success) - QMessageBox::information(this, tr("Success"), - tr("Succeed in connecting and login")); + QMessageBox::information(this, _("Success"), + _("Succeed in connecting and login")); } #endif diff --git a/src/ui/smtp/SendMailDialog.cpp b/src/ui/smtp/SendMailDialog.cpp index 51ece6c9..7c8933a0 100644 --- a/src/ui/smtp/SendMailDialog.cpp +++ b/src/ui/smtp/SendMailDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -40,9 +40,9 @@ SendMailDialog::SendMailDialog(QString text, QWidget* parent) mText(std::move(text)) { if (smtpAddress.isEmpty()) { QMessageBox::critical( - this, tr("Incomplete configuration"), - tr("The SMTP address is empty, please go to the setting interface to " - "complete the configuration.")); + this, _("Incomplete configuration"), + _("The SMTP address is empty, please go to the setting interface to " + "complete the configuration.")); deleteLater(); return; @@ -96,21 +96,23 @@ void SendMailDialog::slotConfirm() { QStringList rcptStringList = recipientEdit->toPlainText().split(';'); if (rcptStringList.isEmpty()) { - errString.append(tr(" Recipient cannot be empty \n")); + errString.append(QString(" ") + _("Recipient cannot be empty") + " \n"); } else { for (const auto& reci : rcptStringList) { qDebug() << "Receiver" << reci.trimmed(); if (!check_email_address(reci.trimmed())) { - errString.append( - tr(" One or more Recipient's Email Address is invalid \n")); + errString.append(QString(" ") + + _("One or more Recipient's Email Address is invalid") + + " \n"); break; } } } if (senderEdit->text().isEmpty()) { - errString.append(tr(" Sender cannot be empty \n")); + errString.append(QString(" ") + _("Sender cannot be empty") + " \n"); } else if (!check_email_address(senderEdit->text())) { - errString.append(tr(" Sender's Email Address is invalid \n")); + errString.append(QString(" ") + _("Sender's Email Address is invalid") + + " \n"); } if (!errString.isEmpty()) { @@ -166,26 +168,25 @@ void SendMailDialog::slotConfirm() { // Now we can send the mail if (!smtp.connectToHost()) { qDebug() << "Connect to SMTP Server Failed"; - QMessageBox::critical(this, tr("Fail"), tr("Fail to Connect SMTP Server")); + QMessageBox::critical(this, _("Fail"), _("Fail to Connect SMTP Server")); return; } if (!smtp.login()) { qDebug() << "Login to SMTP Server Failed"; - QMessageBox::critical(this, tr("Fail"), - tr("Fail to Login into SMTP Server")); + QMessageBox::critical(this, _("Fail"), _("Fail to Login into SMTP Server")); return; } if (!smtp.sendMail(message)) { qDebug() << "Send Mail to SMTP Server Failed"; - QMessageBox::critical(this, tr("Fail"), - tr("Fail to Send Mail to SMTP Server")); + QMessageBox::critical(this, _("Fail"), + _("Fail to Send Mail to SMTP Server")); return; } smtp.quit(); // Close after sending email - QMessageBox::information(this, tr("Success"), - tr("Succeed in Sending Mail to SMTP Server")); + QMessageBox::information(this, _("Success"), + _("Succeed in Sending Mail to SMTP Server")); deleteLater(); } diff --git a/src/ui/smtp/SendMailDialog.h b/src/ui/smtp/SendMailDialog.h index 6afdfe79..87dfd81f 100644 --- a/src/ui/smtp/SendMailDialog.h +++ b/src/ui/smtp/SendMailDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/EditorPage.cpp b/src/ui/widgets/EditorPage.cpp index 26976048..6fd72c20 100644 --- a/src/ui/widgets/EditorPage.cpp +++ b/src/ui/widgets/EditorPage.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -41,7 +41,7 @@ EditorPage::EditorPage(QString filePath, QWidget* parent) mainLayout->addWidget(textPage); mainLayout->setContentsMargins(0, 0, 0, 0); setLayout(mainLayout); - + textPage->setFocus(); // Front in same width diff --git a/src/ui/widgets/EditorPage.h b/src/ui/widgets/EditorPage.h index 0f637500..1e19a0de 100644 --- a/src/ui/widgets/EditorPage.h +++ b/src/ui/widgets/EditorPage.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index 2cb59ae1..4b88092b 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -167,17 +167,17 @@ void FilePage::slotGoPath() { void FilePage::createPopupMenu() { popUpMenu = new QMenu(); - auto openItemAct = new QAction(tr("Open"), this); + auto openItemAct = new QAction(_("Open"), this); connect(openItemAct, SIGNAL(triggered()), this, SLOT(slotOpenItem())); - auto deleteItemAct = new QAction(tr("Delete"), this); + auto deleteItemAct = new QAction(_("Delete"), this); connect(deleteItemAct, SIGNAL(triggered()), this, SLOT(slotDeleteItem())); - encryptItemAct = new QAction(tr("Encrypt and Sign"), this); + encryptItemAct = new QAction(_("Encrypt and Sign"), this); connect(encryptItemAct, SIGNAL(triggered()), this, SLOT(slotEncryptItem())); - decryptItemAct = new QAction(tr("Decrypt and Verify"), this); + decryptItemAct = new QAction(_("Decrypt and Verify"), this); connect(decryptItemAct, SIGNAL(triggered()), this, SLOT(slotDecryptItem())); - signItemAct = new QAction(tr("Only Sign"), this); + signItemAct = new QAction(_("Only Sign"), this); connect(signItemAct, SIGNAL(triggered()), this, SLOT(slotSignItem())); - verifyItemAct = new QAction(tr("Only Verify"), this); + verifyItemAct = new QAction(_("Only Verify"), this); connect(verifyItemAct, SIGNAL(triggered()), this, SLOT(slotVerifyItem())); popUpMenu->addAction(openItemAct); @@ -233,8 +233,8 @@ void FilePage::slotDeleteItem() { QModelIndex index = dirTreeView->currentIndex(); QVariant data = dirTreeView->model()->data(index); - auto ret = QMessageBox::warning(this, tr("Warning"), - tr("Are you sure you want to delete it?"), + auto ret = QMessageBox::warning(this, _("Warning"), + _("Are you sure you want to delete it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -242,8 +242,8 @@ void FilePage::slotDeleteItem() { qDebug() << "Delete Item" << data.toString(); if (!dirModel->remove(index)) { - QMessageBox::critical(this, tr("Error"), - tr("Unable to delete the file or folder.")); + QMessageBox::critical(this, _("Error"), + _("Unable to delete the file or folder.")); } } diff --git a/src/ui/widgets/FilePage.h b/src/ui/widgets/FilePage.h index 9fd4308e..31be81f3 100644 --- a/src/ui/widgets/FilePage.h +++ b/src/ui/widgets/FilePage.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/GroupKeyList.cpp b/src/ui/widgets/GroupKeyList.cpp index 404e8faf..efba4428 100644 --- a/src/ui/widgets/GroupKeyList.cpp +++ b/src/ui/widgets/GroupKeyList.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/GroupKeyList.h b/src/ui/widgets/GroupKeyList.h index f0c9e2c6..163c7126 100644 --- a/src/ui/widgets/GroupKeyList.h +++ b/src/ui/widgets/GroupKeyList.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/HelpPage.cpp b/src/ui/widgets/HelpPage.cpp index dfc24929..7b1e86c0 100644 --- a/src/ui/widgets/HelpPage.cpp +++ b/src/ui/widgets/HelpPage.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -77,8 +77,6 @@ QUrl HelpPage::localizedHelp(const QUrl& url) { } } -QTextBrowser* HelpPage::getBrowser() { - return browser; -} +QTextBrowser* HelpPage::getBrowser() { return browser; } } // namespace GpgFrontend::UI diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp index aac80514..7de99a2b 100644 --- a/src/ui/widgets/InfoBoardWidget.cpp +++ b/src/ui/widgets/InfoBoardWidget.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -39,7 +39,7 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent, KeyList* keyList) infoBoard->setContentsMargins(0, 0, 0, 0); importFromKeyserverAct = - new QAction(tr("Import missing key from Keyserver"), this); + new QAction(_("Import missing key from Keyserver"), this); connect(importFromKeyserverAct, SIGNAL(triggered()), this, SLOT(slotImportFromKeyserver())); @@ -57,7 +57,7 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent, KeyList* keyList) actionButtonLayout->setSpacing(0); actionButtonMenu->setLayout(actionButtonLayout); - auto label = new QLabel(tr("Optional Actions")); + auto label = new QLabel(_("Optional Actions")); label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); label->setContentsMargins(0, 0, 0, 0); diff --git a/src/ui/widgets/InfoBoardWidget.h b/src/ui/widgets/InfoBoardWidget.h index 5512a78a..858aa014 100644 --- a/src/ui/widgets/InfoBoardWidget.h +++ b/src/ui/widgets/InfoBoardWidget.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 4cb30acf..b3391c68 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -78,8 +78,8 @@ KeyList::KeyList(KeyListRow::KeyType selectType, } QStringList labels; - labels << tr("Select") << tr("Type") << tr("Name") << tr("Email Address") - << tr("Usage") << tr("Validity") << tr("Finger Print"); + labels << _("Select") << _("Type") << _("Name") << _("Email Address") + << _("Usage") << _("Validity") << _("Finger Print"); mKeyList->setHorizontalHeaderLabels(labels); mKeyList->horizontalHeader()->setStretchLastSection(false); @@ -103,7 +103,6 @@ KeyList::KeyList(KeyListRow::KeyType selectType, } void KeyList::slotRefresh() { - LOG(INFO) << "KeyList::slotRefresh Called"; auto keyList = getChecked(); @@ -302,14 +301,16 @@ void KeyList::addMenuAction(QAction* act) { popupMenu->addAction(act); } void KeyList::dropEvent(QDropEvent* event) { auto* dialog = new QDialog(); - dialog->setWindowTitle(tr("Import Keys")); + dialog->setWindowTitle(_("Import Keys")); QLabel* label; - label = new QLabel(tr("You've dropped something on the table.\n GpgFrontend " - "will now try to import key(s).") + - "\n"); + label = + new QLabel(QString(_("You've dropped something on the table.")) + "\n " + + _("GpgFrontend " + "will now try to import key(s).") + + "\n"); // "always import keys"-CheckBox - auto* checkBox = new QCheckBox(tr("Always import without bothering.")); + auto* checkBox = new QCheckBox(_("Always import without bothering.")); if (settings.value("general/confirmImportKeys").toBool()) checkBox->setCheckState(Qt::Unchecked); @@ -343,7 +344,8 @@ void KeyList::dropEvent(QDropEvent* event) { QFile file; file.setFileName(tmp.toLocalFile()); if (!file.open(QIODevice::ReadOnly)) { - qDebug() << tr("Couldn't Open File: ") + tmp.toString(); + LOG(INFO) << _("Couldn't Open File") << ":" + << tmp.toString().toStdString(); } QByteArray inBuffer = file.readAll(); this->importKeys(inBuffer); diff --git a/src/ui/widgets/KeyList.h b/src/ui/widgets/KeyList.h index c1c49c5c..524b2bd0 100644 --- a/src/ui/widgets/KeyList.h +++ b/src/ui/widgets/KeyList.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/SignersPicker.cpp b/src/ui/widgets/SignersPicker.cpp index 3c720b10..3131989b 100644 --- a/src/ui/widgets/SignersPicker.cpp +++ b/src/ui/widgets/SignersPicker.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -27,7 +27,7 @@ namespace GpgFrontend::UI { SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) { - auto confirmButton = new QPushButton(tr("Confirm")); + auto confirmButton = new QPushButton(_("Confirm")); connect(confirmButton, SIGNAL(clicked(bool)), this, SLOT(accept())); /*Setup KeyList*/ diff --git a/src/ui/widgets/SignersPicker.h b/src/ui/widgets/SignersPicker.h index 278e0142..055b6ef6 100644 --- a/src/ui/widgets/SignersPicker.h +++ b/src/ui/widgets/SignersPicker.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp index aaac98ee..efc2abbf 100644 --- a/src/ui/widgets/TextEdit.cpp +++ b/src/ui/widgets/TextEdit.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -24,6 +24,8 @@ #include "ui/widgets/TextEdit.h" +#include <boost/format.hpp> + namespace GpgFrontend::UI { TextEdit::TextEdit(QWidget* parent) : QWidget(parent) { @@ -46,7 +48,7 @@ TextEdit::TextEdit(QWidget* parent) : QWidget(parent) { } void TextEdit::slotNewTab() { - QString header = tr("untitled") + QString::number(++countPage) + ".txt"; + QString header = _("untitled") + QString::number(++countPage) + ".txt"; auto* page = new EditorPage(); tabWidget->addTab(page, header); @@ -83,9 +85,11 @@ void TextEdit::slotOpenFile(QString& path) { page->getTextPage()->setFocus(); page->readFile(); } else { - QMessageBox::warning( - this, tr("Warning"), - tr("Cannot read file %1:\n%2.").arg(path).arg(file.errorString())); + QMessageBox::warning(this, _("Warning"), + (boost::format(_("Cannot read file %1%:\n%2%.")) % + path.toStdString() % file.errorString().toStdString()) + .str() + .c_str()); } file.close(); @@ -93,7 +97,7 @@ void TextEdit::slotOpenFile(QString& path) { void TextEdit::slotOpen() { QStringList fileNames = - QFileDialog::getOpenFileNames(this, tr("Open file"), QDir::currentPath()); + QFileDialog::getOpenFileNames(this, _("Open file"), QDir::currentPath()); for (const auto& fileName : fileNames) { if (!fileName.isEmpty()) { QFile file(fileName); @@ -118,10 +122,12 @@ void TextEdit::slotOpen() { // enableAction(true) file.close(); } else { - QMessageBox::warning(this, tr("Warning"), - tr("Cannot read file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); + QMessageBox::warning( + this, _("Warning"), + (boost::format(_("Cannot read file %1%:\n%2%.")) % + fileName.toStdString() % file.errorString().toStdString()) + .str() + .c_str()); } } } @@ -164,13 +170,16 @@ bool TextEdit::saveFile(const QString& fileName) { int curIndex = tabWidget->currentIndex(); tabWidget->setTabText(curIndex, strippedName(fileName)); page->setFilePath(fileName); - // statusBar()->showMessage(tr("File saved"), 2000); + // statusBar()->showMessage(_("File saved"), 2000); file.close(); return true; } else { QMessageBox::warning( - this, tr("File"), - tr("Cannot write file %1:\n%2.").arg(fileName).arg(file.errorString())); + this, _("Warning"), + (boost::format(_("Cannot read file %1%:\n%2%.")) % + fileName.toStdString() % file.errorString().toStdString()) + .str() + .c_str()); return false; } } @@ -182,13 +191,13 @@ bool TextEdit::slotSaveAs() { EditorPage* page = slotCurPageTextEdit(); QString path; - if (page->getFilePath() != "") { + if (!page->getFilePath().isEmpty()) { path = page->getFilePath(); } else { path = tabWidget->tabText(tabWidget->currentIndex()).remove(0, 2); } - QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), path); + QString fileName = QFileDialog::getSaveFileName(this, _("Save file"), path); return saveFile(fileName); } @@ -250,16 +259,18 @@ bool TextEdit::maybeSaveCurrentTab(bool askToSave) { const QString& filePath = page->getFilePath(); if (askToSave) { result = QMessageBox::warning( - this, tr("Unsaved document"), - tr("The document \"%1\" has been modified. Do you want to " - "save your changes?<br/>") + this, _("Unsaved document"), + QString(_("The document \"%1\" has been modified. Do you want to " + "save your changes?")) .arg(docname) + - tr("<b>Note:</b> If you don't save these files, all changes are " - "lost.<br/>"), + "<br/><b>" + _("Note:") + "</b>" + + _("If you don't save these files, all changes are " + "lost.") + + "<br/>", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); } if ((result == QMessageBox::Save) || (!askToSave)) { - if (filePath == "") { + if (filePath.isEmpty()) { // QString docname = tabWidget->tabText(tabWidget->currentIndex()); // docname.remove(0,2); return slotSaveAs(); @@ -398,8 +409,11 @@ void TextEdit::loadFile(const QString& fileName) { QFile file(fileName); if (!file.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::warning( - this, tr("Application"), - tr("Cannot read file %1:\n%2.").arg(fileName).arg(file.errorString())); + this, _("Warning"), + (boost::format(_("Cannot read file %1%:\n%2%.")) % + fileName.toStdString() % file.errorString().toStdString()) + .str() + .c_str()); return; } QTextStream in(&file); @@ -409,7 +423,7 @@ void TextEdit::loadFile(const QString& fileName) { slotCurPageTextEdit()->setFilePath(fileName); tabWidget->setTabText(tabWidget->currentIndex(), strippedName(fileName)); file.close(); - // statusBar()->showMessage(tr("File loaded"), 2000); + // statusBar()->showMessage(_("File loaded"), 2000); } QString TextEdit::strippedName(const QString& fullFileName) { @@ -434,7 +448,7 @@ void TextEdit::slotPrint() { } document->print(&printer); - // statusBar()->showMessage(tr("Ready"), 2000); + // statusBar()->showMessage(_("Ready"), 2000); #endif } diff --git a/src/ui/widgets/TextEdit.h b/src/ui/widgets/TextEdit.h index beebc8c4..3cff74e7 100644 --- a/src/ui/widgets/TextEdit.h +++ b/src/ui/widgets/TextEdit.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp index 97f792b1..7c25d593 100644 --- a/src/ui/widgets/VerifyKeyDetailBox.cpp +++ b/src/ui/widgets/VerifyKeyDetailBox.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -36,17 +36,17 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(QWidget* parent, KeyList* keyList, switch (gpg_err_code(signature->status)) { case GPG_ERR_NO_PUBKEY: { this->setTitle("A Error Signature"); - auto* importButton = new QPushButton(tr("Import from keyserver")); + auto* importButton = new QPushButton(_("Import from keyserver")); connect(importButton, SIGNAL(clicked()), this, SLOT(slotImportFormKeyserver())); - this->setTitle(tr("Key not present with id 0x") + signature->fpr); + this->setTitle(QString(_("Key not present with id 0x")) + signature->fpr); auto grid = new QGridLayout(); - grid->addWidget(new QLabel(tr("Status:")), 0, 0); - // grid->addWidget(new QLabel(tr("Fingerprint:")), 1, 0); - grid->addWidget(new QLabel(tr("Key not present in keylist")), 0, 1); + grid->addWidget(new QLabel(QString(_("Status")) + _(":")), 0, 0); + // grid->addWidget(new QLabel(_("Fingerprint:")), 1, 0); + grid->addWidget(new QLabel(_("Key not present in key list")), 0, 1); // grid->addWidget(new QLabel(signature->fpr), 1, 1); grid->addWidget(importButton, 2, 0, 2, 1); @@ -54,91 +54,96 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(QWidget* parent, KeyList* keyList, break; } case GPG_ERR_NO_ERROR: { - this->setTitle("A Signature:"); + this->setTitle(QString(_("A Signature")) + ":"); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } case GPG_ERR_CERT_REVOKED: { this->setTitle("An Error Signature"); - vbox->addWidget(new QLabel(tr("Status: Cert Revoked"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("Cert Revoked"))); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } case GPG_ERR_SIG_EXPIRED: { this->setTitle("An Error Signature"); - vbox->addWidget(new QLabel(tr("Status: Signature Expired"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("Signature Expired"))); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } case GPG_ERR_KEY_EXPIRED: { this->setTitle("An Error Signature"); - vbox->addWidget(new QLabel(tr("Status: Signature Expired"))); - vbox->addWidget(new QLabel(tr("Status: Key Expired"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("Key Expired"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("Key Expired"))); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } case GPG_ERR_GENERAL: { this->setTitle("An Error Signature"); - vbox->addWidget(new QLabel(tr("Status: General Error"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("General Error"))); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } default: { this->setTitle("An Error Signature"); - this->setTitle(tr("Status: Unknown Error")); + this->setTitle(QString(_("Status")) + ":" + _("Unknown Error ")); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; @@ -168,48 +173,48 @@ QGridLayout* VerifyKeyDetailBox::createKeyInfoGrid( GpgKey key = GpgKeyGetter::GetInstance().GetKey(signature->fpr); if (!key.good()) return nullptr; - grid->addWidget(new QLabel(tr("Signer Name:")), 0, 0); - grid->addWidget(new QLabel(tr("Signer Email:")), 1, 0); - grid->addWidget(new QLabel(tr("Key's Fingerprint:")), 2, 0); - grid->addWidget(new QLabel(tr("Valid:")), 3, 0); - grid->addWidget(new QLabel(tr("Flags:")), 4, 0); + grid->addWidget(new QLabel(QString(_("Signer Name")) + ":"), 0, 0); + grid->addWidget(new QLabel(QString(_("Signer Email")) + ":"), 1, 0); + grid->addWidget(new QLabel(QString(_("Key's Fingerprint")) + ":"), 2, 0); + grid->addWidget(new QLabel(QString(_("Valid")) + ":"), 3, 0); + grid->addWidget(new QLabel(QString(_("Flags")) + ":"), 4, 0); grid->addWidget(new QLabel(QString::fromStdString(key.name())), 0, 1); grid->addWidget(new QLabel(QString::fromStdString(key.email())), 1, 1); grid->addWidget(new QLabel(beautifyFingerprint(signature->fpr)), 2, 1); if (signature->summary & GPGME_SIGSUM_VALID) { - grid->addWidget(new QLabel(tr("Fully Valid")), 3, 1); + grid->addWidget(new QLabel(_("Fully Valid")), 3, 1); } else { - grid->addWidget(new QLabel(tr("NOT Fully Valid")), 3, 1); + grid->addWidget(new QLabel(_("NOT Fully Valid")), 3, 1); } QString flags; QTextStream textStream(&flags); if (signature->summary & GPGME_SIGSUM_GREEN) { - textStream << tr("Good "); + textStream << _("Good") << " "; } if (signature->summary & GPGME_SIGSUM_RED) { - textStream << tr("Bad "); + textStream << _("Bad") << " "; } if (signature->summary & GPGME_SIGSUM_SIG_EXPIRED) { - textStream << tr("Expired "); + textStream << _("Expired") << " "; } if (signature->summary & GPGME_SIGSUM_KEY_MISSING) { - textStream << tr("Missing Key "); + textStream << _("Missing Key") << " "; } if (signature->summary & GPGME_SIGSUM_KEY_REVOKED) { - textStream << tr("Revoked Key "); + textStream << _("Revoked Key") << " "; } if (signature->summary & GPGME_SIGSUM_KEY_EXPIRED) { - textStream << tr("Expired Key "); + textStream << _("Expired Key") << " "; } if (signature->summary & GPGME_SIGSUM_CRL_MISSING) { - textStream << tr("Missing CRL "); + textStream << _("Missing CRL") << " "; } - grid->addWidget(new QLabel(tr(flags.toUtf8().constData())), 4, 1); + grid->addWidget(new QLabel(_(flags.toUtf8().constData())), 4, 1); return grid; } diff --git a/src/ui/widgets/VerifyKeyDetailBox.h b/src/ui/widgets/VerifyKeyDetailBox.h index 7a6ded4e..c1b26bb2 100644 --- a/src/ui/widgets/VerifyKeyDetailBox.h +++ b/src/ui/widgets/VerifyKeyDetailBox.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -33,8 +33,7 @@ namespace GpgFrontend::UI { class VerifyKeyDetailBox : public QGroupBox { Q_OBJECT public: - explicit VerifyKeyDetailBox(QWidget* parent, - KeyList* mKeyList, + explicit VerifyKeyDetailBox(QWidget* parent, KeyList* mKeyList, gpgme_signature_t signature); private slots: |