diff options
| -rw-r--r-- | src/m_email/EMailModule.cpp | 35 | ||||
| -rw-r--r-- | src/m_gpg_info/GnuPGInfoGatheringModule.cpp | 7 | ||||
| -rw-r--r-- | src/m_im/ImCodec.cpp | 44 | ||||
| -rw-r--r-- | src/m_im/ImModule.cpp | 66 | ||||
| -rw-r--r-- | src/m_im/ImSettingsPage.cpp | 85 | ||||
| -rw-r--r-- | src/m_key_server_sync/KeyServerBatchLogic.cpp | 33 | ||||
| -rw-r--r-- | src/m_key_server_sync/KeyServerProbe.cpp | 7 | ||||
| -rw-r--r-- | src/m_key_server_sync/KeyServerSyncModule.cpp | 149 | ||||
| -rw-r--r-- | src/m_pgp_inspect/PGPInspectDialog.cpp | 53 | ||||
| -rw-r--r-- | src/m_pgp_inspect/PGPInspectModel.cpp | 24 | ||||
| -rw-r--r-- | src/m_pgp_inspect/PGPInspectModule.cpp | 13 | ||||
| -rw-r--r-- | src/m_ver_check/VersionCheckingModule.cpp | 24 |
12 files changed, 258 insertions, 282 deletions
diff --git a/src/m_email/EMailModule.cpp b/src/m_email/EMailModule.cpp index ce36887..48b24e1 100644 --- a/src/m_email/EMailModule.cpp +++ b/src/m_email/EMailModule.cpp @@ -80,6 +80,7 @@ #include "EMailBasicGpgOpera.h" #include "EMailHelper.h" #include "EMailVerificationPayload.h" +#include "GFModuleTr.h" namespace { @@ -436,17 +437,17 @@ auto OnActivate() -> GFResult { // translates it when shown, after the module translators are installed. const bool editor = gf::ui::RegisterNativeWidgetFactory<EMailPageView>( "editor", - {GC_TR("E-Mail"), "", "eml", - GC_TR("E-Mail Message (*.eml);;All Files (*)"), ":/icons/email.png", 0, - 0}, + {GTrC::Noop("E-Mail"), "", "eml", + GTrC::Noop("E-Mail Message (*.eml);;All Files (*)"), ":/icons/email.png", + 0, 0}, [](const QCborMap& /*args*/) { return new EMailPageView(); }); const bool settings = gf::ui::RegisterNativeWidget<EMailAccountSettingsPage>( "settings", - {GC_TR("Mail Accounts"), GC_TR("mail,email,imap,smtp,account,send"), "", - "", "", 0, 0}, + {GTrC::Noop("Mail Accounts"), + GTrC::Noop("mail,email,imap,smtp,account,send"), "", "", "", 0, 0}, [](const QCborMap& /*args*/) { return new EMailAccountSettingsPage(); }); const bool imap = gf::ui::RegisterNativeWidget<EMailImapController>( - "imap", {GC_TR("IMAP Controller"), "", "", "", "", 1100, 720}, + "imap", {GTrC::Noop("IMAP Controller"), "", "", "", "", 1100, 720}, [](const QCborMap& /*args*/) { auto* controller = new EMailImapController(); // The narrow boundary: raw bytes in, a document out. The controller @@ -1694,8 +1695,8 @@ namespace { struct NewMessage { static constexpr gf::cmd::Meta kMeta{ GF_MODULE_ID ".new_message", - GC_TR("Mail Editor"), - GC_TR("Open a new text editor for email."), + GTrC::Noop("Mail Editor"), + GTrC::Noop("Open a new text editor for email."), "", 0, gf::cmd::kNeedsGuiThread}; @@ -1713,12 +1714,13 @@ auto DoNewMessage(const gf::cmd::CommandContext& /*ctx*/, /// Advanced > Open IMAP Controller. struct OpenImapController { - static constexpr gf::cmd::Meta kMeta{GF_MODULE_ID ".open_imap_controller", - GC_TR("Open IMAP Controller"), - GC_TR("Open IMAP Controller Dialog"), - "", - 0, - gf::cmd::kNeedsGuiThread}; + static constexpr gf::cmd::Meta kMeta{ + GF_MODULE_ID ".open_imap_controller", + GTrC::Noop("Open IMAP Controller"), + GTrC::Noop("Open IMAP Controller Dialog"), + "", + 0, + gf::cmd::kNeedsGuiThread}; using Args = gf::cmd::Unit; using Result = gf::cmd::Unit; }; @@ -1731,9 +1733,8 @@ auto DoOpenImapController(const gf::cmd::CommandContext& /*ctx*/, if (!EMailImapController::HasUsableAccount()) { Commands().Invoke<gf::cmd::host::AppMessage>( {gf::cmd::host::AppMessage::Severity::kInfo, - QCoreApplication::translate("GTrC", "No mail account"), - QCoreApplication::translate( - "GTrC", + GTrC::tr("No mail account"), + GTrC::tr( "Configure a mail account with IMAP enabled in Settings first.")}); return gf::cmd::Outcome<gf::cmd::Unit>::Success({}); } diff --git a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp index 4ea4bc9..454102f 100644 --- a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp +++ b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp @@ -47,6 +47,7 @@ #include "GFModule.h" #include "GFModuleIdentity.h" +#include "GFModuleTr.h" #include "GFSDKHostCommands.hpp" #include "GnupgTab.h" #include "GpgInfo.h" @@ -88,8 +89,8 @@ class GnupgInfoWidget : public QWidget, public gf::ui::DialogWidget { /// script's; it only opens the module's own dialog. struct ShowGnupgInfo { static constexpr gf::cmd::Meta kMeta{GF_MODULE_ID ".show_gnupg_info", - GC_TR("GnuPG"), - GC_TR("Information about GnuPG"), + GTrC::Noop("GnuPG"), + GTrC::Noop("Information about GnuPG"), "", 0, gf::cmd::kNeedsGuiThread}; @@ -110,7 +111,7 @@ auto DoShowGnupgInfo(const gf::cmd::CommandContext & /*ctx*/, auto OnActivate() -> GFResult { LOG_INFO("gnupg info gathering module registering"); const bool ok = gf::ui::RegisterNativeWidget<GnupgInfoWidget>( - "info", {GC_TR("GnuPG"), "", "", "", ":/icons/key.png", 500, 600}, + "info", {GTrC::Noop("GnuPG"), "", "", "", ":/icons/key.png", 500, 600}, [](const QCborMap & /*args*/) { return new GnupgInfoWidget(); }); return ok ? GFResult::Ok() : GFResult::Fail("the GnuPG information widget was not registered"); diff --git a/src/m_im/ImCodec.cpp b/src/m_im/ImCodec.cpp index 54efc60..0dc5d82 100644 --- a/src/m_im/ImCodec.cpp +++ b/src/m_im/ImCodec.cpp @@ -33,6 +33,7 @@ #include <QJsonDocument> #include <QJsonObject> +#include "GFModuleTr.h" #include "ImToken.h" namespace ImCodec { @@ -41,10 +42,6 @@ namespace { constexpr char kPhraseBlobVersion = '\x01'; -auto Tr(const char* text) -> QString { - return QCoreApplication::translate("GTrC", text); -} - /** * @brief The "Instant Messaging" card: how the token is framed and, above * all, whether a shared book phrase is in use -- the default book only hides @@ -58,34 +55,36 @@ auto BookCard(const QString& phrase, qsizetype payload, qsizetype token_len) fields.append(QJsonArray{k, v}); }; - add(Tr("Encoding"), QStringLiteral("Base58 (Bitcoin/IPFS)")); - add(Tr("Container Format"), QString("v%1").arg(ImToken::FormatVersion())); - add(Tr("Message Book"), configured ? Tr("Shared phrase (Argon2id)") - : Tr("Default, no shared phrase set")); + add(GTrC::tr("Encoding"), QStringLiteral("Base58 (Bitcoin/IPFS)")); + add(GTrC::tr("Container Format"), + QString("v%1").arg(ImToken::FormatVersion())); + add(GTrC::tr("Message Book"), + configured ? GTrC::tr("Shared phrase (Argon2id)") + : GTrC::tr("Default, no shared phrase set")); // Lets both sides confirm they are on the same book. Only meaningful with a // phrase: everyone shares the default book, so its digest says nothing. if (configured) { - add(Tr("Book Fingerprint"), ImToken::BookFingerprintOf(phrase)); + add(GTrC::tr("Book Fingerprint"), ImToken::BookFingerprintOf(phrase)); } else { - add(Tr("Set a Phrase"), Tr("Settings > Instant Messaging")); + add(GTrC::tr("Set a Phrase"), GTrC::tr("Settings > Instant Messaging")); } if (payload > 0) { - add(Tr("OpenPGP Payload"), Tr("%1 bytes").arg(payload)); + add(GTrC::tr("OpenPGP Payload"), GTrC::tr("%1 bytes").arg(payload)); } if (token_len > 0) { - add(Tr("Token Length"), Tr("%1 characters").arg(token_len)); + add(GTrC::tr("Token Length"), GTrC::tr("%1 characters").arg(token_len)); } if (payload > 0 && token_len > 0) { // Random padding plus Base58 expansion. The padding part is deliberately // random, so this ratio does not pin down the true payload length. const auto ratio = static_cast<double>(token_len) / static_cast<double>(payload); - add(Tr("Wire Overhead"), + add(GTrC::tr("Wire Overhead"), QString("+%1%").arg((ratio * 100.0) - 100.0, 0, 'f', 0)); } return QJsonObject{ - {QStringLiteral("title"), Tr("Instant Messaging")}, + {QStringLiteral("title"), GTrC::tr("Instant Messaging")}, {QStringLiteral("status"), configured ? QStringLiteral("ok") : QStringLiteral("warn")}, {QStringLiteral("fields"), fields}}; @@ -94,7 +93,8 @@ auto BookCard(const QString& phrase, qsizetype payload, qsizetype token_len) auto CardsJson(const QJsonObject& card) -> QString { const QJsonObject payload{ {QStringLiteral("description"), - Tr("An Instant Messaging section followed by the OpenPGP result.")}, + GTrC::tr( + "An Instant Messaging section followed by the OpenPGP result.")}, {QStringLiteral("cards"), QJsonArray{card}}}; return QString::fromUtf8( QJsonDocument(payload).toJson(QJsonDocument::Compact)); @@ -123,10 +123,11 @@ auto EncodeOutput(const QByteArray& pgp, const QString& phrase) -> Answer { // Checked here so the user is told what went wrong and what to do about it. const auto limit = ImToken::MaxPayloadBytes(); if (pgp.size() > limit) { - a.error = Tr("This message is too long to send as an instant message.\n\n" - "The encrypted message is %1 bytes, and the " - "instant-messaging format carries at most %2. Shorten the " - "text, or send it as a normal OpenPGP message instead.") + a.error = GTrC::tr( + "This message is too long to send as an instant message.\n\n" + "The encrypted message is %1 bytes, and the " + "instant-messaging format carries at most %2. Shorten the " + "text, or send it as a normal OpenPGP message instead.") .arg(pgp.size()) .arg(limit); return a; @@ -134,8 +135,9 @@ auto EncodeOutput(const QByteArray& pgp, const QString& phrase) -> Answer { const auto token = ImToken::Encode(pgp, phrase); if (token.isEmpty()) { - a.error = Tr("Failed to prepare the instant message: the encrypted " - "message could not be converted into a token."); + a.error = GTrC::tr( + "Failed to prepare the instant message: the encrypted " + "message could not be converted into a token."); return a; } diff --git a/src/m_im/ImModule.cpp b/src/m_im/ImModule.cpp index 008ec13..371cb35 100644 --- a/src/m_im/ImModule.cpp +++ b/src/m_im/ImModule.cpp @@ -27,12 +27,13 @@ */ #include <GFModule.h> + #include <GFSDK.hpp> #include <GFSDKHostCommands.hpp> - #include <QtWidgets> #include "GFModuleIdentity.h" +#include "GFModuleTr.h" #include "ImCodec.h" #include "ImSettingsPage.h" @@ -62,10 +63,6 @@ using Severity = host::AppMessage::Severity; /// read in the group the Host used to keep it in. constexpr auto kWarnDefaultBookKey = "warn_default_book"; -auto Tr(const char* text) -> QString { - return QCoreApplication::translate("GTrC", text); -} - auto ToResult(const ImCodec::Answer& a) -> host::CodecResult { host::CodecResult r; r.outcome = static_cast<host::CodecOutcome>(a.outcome); @@ -84,17 +81,24 @@ auto BytesOf(const gf::cmd::Blob& blob) -> QByteArray { struct Decode { static constexpr gf::cmd::Meta kMeta{ - GF_MODULE_ID ".decode", GC_TR("Instant Message Token"), - GC_TR("Recognise and unwrap instant messaging tokens before decrypting"), - "", 0, gf::cmd::kInputDecoder}; + GF_MODULE_ID ".decode", + GTrC::Noop("Instant Message Token"), + GTrC::Noop( + "Recognise and unwrap instant messaging tokens before decrypting"), + "", + 0, + gf::cmd::kInputDecoder}; using Args = host::CodecArgs; using Result = host::CodecResult; }; struct Encode { static constexpr gf::cmd::Meta kMeta{ - GF_MODULE_ID ".encode", GC_TR("Instant Message Token"), - GC_TR("Wrap an encrypted message as an instant messaging token"), "", 0, + GF_MODULE_ID ".encode", + GTrC::Noop("Instant Message Token"), + GTrC::Noop("Wrap an encrypted message as an instant messaging token"), + "", + 0, gf::cmd::kOutputEncoder}; using Args = host::CodecArgs; using Result = host::CodecResult; @@ -127,9 +131,9 @@ auto ConfirmDefaultBook() -> bool { QMessageBox box; box.setIcon(QMessageBox::Information); - box.setWindowTitle(Tr("No Message Book Phrase Set")); - box.setText(Tr("You have not set a Message Book phrase.")); - box.setInformativeText(Tr( + box.setWindowTitle(GTrC::tr("No Message Book Phrase Set")); + box.setText(GTrC::tr("You have not set a Message Book phrase.")); + box.setInformativeText(GTrC::tr( "Instant messages are hidden using a shared \"Message Book\". " "Without a phrase, GpgFrontend falls back to the built-in default " "book and that book ships in every copy of the program. It hides " @@ -141,11 +145,11 @@ auto ConfirmDefaultBook() -> bool { "are writing to. You must both use exactly the same one.")); auto* settings_button = - box.addButton(Tr("Open Settings..."), QMessageBox::ActionRole); + box.addButton(GTrC::tr("Open Settings..."), QMessageBox::ActionRole); auto* continue_button = - box.addButton(Tr("Continue with Default"), QMessageBox::AcceptRole); - auto* never_button = - box.addButton(Tr("Continue, Don't Ask Again"), QMessageBox::AcceptRole); + box.addButton(GTrC::tr("Continue with Default"), QMessageBox::AcceptRole); + auto* never_button = box.addButton(GTrC::tr("Continue, Don't Ask Again"), + QMessageBox::AcceptRole); box.addButton(QMessageBox::Cancel); box.setDefaultButton(settings_button); box.exec(); @@ -173,9 +177,12 @@ struct TargetArgs { struct EncryptIm { static constexpr gf::cmd::Meta kMeta{ - GF_MODULE_ID ".encrypt", GC_TR("IM Encrypt"), - GC_TR("Encrypt the message as a single-line token for chat apps"), "", - GF_HOST_CAP_EDITOR, gf::cmd::kNeedsGuiThread}; + GF_MODULE_ID ".encrypt", + GTrC::Noop("IM Encrypt"), + GTrC::Noop("Encrypt the message as a single-line token for chat apps"), + "", + GF_HOST_CAP_EDITOR, + gf::cmd::kNeedsGuiThread}; using Args = TargetArgs; using Result = gf::cmd::Unit; static auto State(const gf::cmd::CommandContext&) -> uint32_t; @@ -183,10 +190,13 @@ struct EncryptIm { struct EncryptSignIm { static constexpr gf::cmd::Meta kMeta{ - GF_MODULE_ID ".encrypt_sign", GC_TR("IM Encrypt && Sign"), - GC_TR("Encrypt and sign the message as a single-line token for chat " - "apps"), - "", GF_HOST_CAP_EDITOR, gf::cmd::kNeedsGuiThread}; + GF_MODULE_ID ".encrypt_sign", + GTrC::Noop("IM Encrypt && Sign"), + GTrC::Noop("Encrypt and sign the message as a single-line token for chat " + "apps"), + "", + GF_HOST_CAP_EDITOR, + gf::cmd::kNeedsGuiThread}; using Args = TargetArgs; using Result = gf::cmd::Unit; static auto State(const gf::cmd::CommandContext&) -> uint32_t; @@ -236,9 +246,9 @@ auto OnActivate() -> GFResult { // Registered untranslated: the Host translates presentation when shown. const bool settings = gf::ui::RegisterNativeWidget<ImSettingsPage>( "settings", - {GC_TR("Instant Messaging"), - GC_TR("instant messaging,message book,phrase,fingerprint,token"), "", - "", "", 0, 0}, + {GTrC::Noop("Instant Messaging"), + GTrC::Noop("instant messaging,message book,phrase,fingerprint,token"), + "", "", "", 0, 0}, [](const QCborMap& /*args*/) { return new ImSettingsPage(); }); return settings ? GFResult::Ok() : GFResult::Fail("the settings page was not registered"); @@ -268,6 +278,6 @@ const GFModuleHooks kHooks = { } // namespace extern "C" GF_MODULE_EXPORT auto GFModuleGetApi(uint32_t abi) - -> const GFModuleApi * { + -> const GFModuleApi* { return GFModuleRuntimeGetApi(abi, &kHooks); } diff --git a/src/m_im/ImSettingsPage.cpp b/src/m_im/ImSettingsPage.cpp index a2f1d84..f74d1f5 100644 --- a/src/m_im/ImSettingsPage.cpp +++ b/src/m_im/ImSettingsPage.cpp @@ -29,9 +29,9 @@ #include "ImSettingsPage.h" #include <GFSDK.hpp> - #include <QtWidgets> +#include "GFModuleTr.h" #include "ImCodec.h" #include "ImToken.h" @@ -60,10 +60,6 @@ auto MonospaceFont(const QWidget* widget) -> QFont { return font; } -auto Tr(const char* text) -> QString { - return QCoreApplication::translate("GTrC", text); -} - /// Where the phrase lives: the module's own secret store. constexpr auto kPhraseKey = "book_phrase"; @@ -74,13 +70,15 @@ ImSettingsPage::ImSettingsPage(QWidget* parent) : QWidget(parent) { // The Message Book phrase whitens every instant-messaging token: its bytes // derive the shuffle + XOR that hide the message, so without the same phrase // a token is indistinguishable from random text. - auto* book_box = new QGroupBox(Tr("Message Book Phrase"), this); + auto* book_box = new QGroupBox(GTrC::tr("Message Book Phrase"), this); auto* book_layout = new QVBoxLayout(book_box); auto* intro = new QLabel( - Tr("A long secret you share with one friend. It makes your messages look " - "like random text, so nobody can tell they are PGP at all. You and " - "your friend must use exactly the same phrase."), + GTrC::tr( + "A long secret you share with one friend. It makes your messages " + "look " + "like random text, so nobody can tell they are PGP at all. You and " + "your friend must use exactly the same phrase."), book_box); intro->setWordWrap(true); book_layout->addWidget(intro); @@ -91,7 +89,7 @@ ImSettingsPage::ImSettingsPage(QWidget* parent) : QWidget(parent) { phrase_edit_->setFont(MonospaceFont(this)); phrase_edit_->setLineWrapMode(QPlainTextEdit::WidgetWidth); phrase_edit_->setPlaceholderText( - Tr("No phrase set. Messages use the built-in default book.")); + GTrC::tr("No phrase set. Messages use the built-in default book.")); phrase_edit_->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); phrase_edit_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); phrase_edit_->setFixedHeight(phrase_edit_->fontMetrics().lineSpacing() * 5 + @@ -107,10 +105,10 @@ ImSettingsPage::ImSettingsPage(QWidget* parent) : QWidget(parent) { // One click gives a phrase no one will ever guess; the user's only job is to // get it to their friend privately. - auto* generate_button = new QPushButton(Tr("Generate"), book_box); - generate_button->setToolTip( - Tr("Create a new random phrase. Share it with your friend so you both " - "use the same one.")); + auto* generate_button = new QPushButton(GTrC::tr("Generate"), book_box); + generate_button->setToolTip(GTrC::tr( + "Create a new random phrase. Share it with your friend so you both " + "use the same one.")); connect(generate_button, &QPushButton::clicked, this, [this]() { const auto phrase = ImToken::GeneratePhrase(); if (phrase.isEmpty()) return; @@ -119,27 +117,27 @@ ImSettingsPage::ImSettingsPage(QWidget* parent) : QWidget(parent) { set_revealed(true); }); - reveal_button_ = new QPushButton(Tr("Show"), book_box); - reveal_button_->setToolTip(Tr("Show or hide the phrase.")); + reveal_button_ = new QPushButton(GTrC::tr("Show"), book_box); + reveal_button_->setToolTip(GTrC::tr("Show or hide the phrase.")); connect(reveal_button_, &QPushButton::clicked, this, [this]() { set_revealed(!revealed_); }); - auto* copy_button = new QPushButton(Tr("Copy"), book_box); - copy_button->setToolTip(Tr("Copy the phrase to the clipboard.")); + auto* copy_button = new QPushButton(GTrC::tr("Copy"), book_box); + copy_button->setToolTip(GTrC::tr("Copy the phrase to the clipboard.")); connect(copy_button, &QPushButton::clicked, this, [this]() { QApplication::clipboard()->setText(phrase_); }); - auto* paste_button = new QPushButton(Tr("Paste"), book_box); + auto* paste_button = new QPushButton(GTrC::tr("Paste"), book_box); paste_button->setToolTip( - Tr("Replace the phrase with the one on the clipboard.")); + GTrC::tr("Replace the phrase with the one on the clipboard.")); connect(paste_button, &QPushButton::clicked, this, [this]() { const auto text = CleanPhrase(QApplication::clipboard()->text()); if (!text.isEmpty()) set_phrase(text); }); - auto* clear_button = new QPushButton(Tr("Clear"), book_box); + auto* clear_button = new QPushButton(GTrC::tr("Clear"), book_box); clear_button->setToolTip( - Tr("Remove the phrase and fall back to the default book.")); + GTrC::tr("Remove the phrase and fall back to the default book.")); connect(clear_button, &QPushButton::clicked, this, [this]() { set_phrase({}); }); @@ -157,13 +155,14 @@ ImSettingsPage::ImSettingsPage(QWidget* parent) : QWidget(parent) { book_layout->addLayout(button_row); // ---- checking both sides agree ----------------------------------------- - auto* check_box = new QGroupBox(Tr("Book Fingerprint"), this); + auto* check_box = new QGroupBox(GTrC::tr("Book Fingerprint"), this); auto* check_layout = new QVBoxLayout(check_box); auto* check_note = new QLabel( - Tr("A short code made from your phrase. Read it out with your friend to " - "be sure you both have the same one. Unlike the phrase, this code is " - "safe to say out loud."), + GTrC::tr( + "A short code made from your phrase. Read it out with your friend to " + "be sure you both have the same one. Unlike the phrase, this code is " + "safe to say out loud."), check_box); check_note->setWordWrap(true); check_layout->addWidget(check_note); @@ -175,8 +174,9 @@ ImSettingsPage::ImSettingsPage(QWidget* parent) : QWidget(parent) { fingerprint_label_->setFont(fpr_font); fingerprint_label_->setTextInteractionFlags(Qt::TextSelectableByMouse); - auto* copy_fpr_button = new QPushButton(Tr("Copy"), check_box); - copy_fpr_button->setToolTip(Tr("Copy the fingerprint to the clipboard.")); + auto* copy_fpr_button = new QPushButton(GTrC::tr("Copy"), check_box); + copy_fpr_button->setToolTip( + GTrC::tr("Copy the fingerprint to the clipboard.")); connect(copy_fpr_button, &QPushButton::clicked, this, [this]() { QApplication::clipboard()->setText(fingerprint_); }); @@ -188,8 +188,9 @@ ImSettingsPage::ImSettingsPage(QWidget* parent) : QWidget(parent) { check_layout->addLayout(fpr_row); auto* storage_note = new QLabel( - Tr("The phrase is stored in the encrypted cache, never in the settings " - "file. Send it to your friend over a private channel."), + GTrC::tr( + "The phrase is stored in the encrypted cache, never in the settings " + "file. Send it to your friend over a private channel."), this); storage_note->setWordWrap(true); @@ -224,7 +225,7 @@ auto ImSettingsPage::ApplySettings() -> bool { void ImSettingsPage::set_revealed(bool revealed) { revealed_ = revealed; - reveal_button_->setText(revealed ? Tr("Hide") : Tr("Show")); + reveal_button_->setText(revealed ? GTrC::tr("Hide") : GTrC::tr("Show")); const QScopedValueRollback<bool> guard(syncing_, true); // Masked, the box is a placeholder rather than an editor: editing dots @@ -244,8 +245,9 @@ void ImSettingsPage::set_phrase(const QString& phrase) { } phrase_state_label_->setText( - phrase_.isEmpty() ? Tr("No phrase set. Using the built-in default.") - : Tr("Phrase set. %1 characters.").arg(phrase_.size())); + phrase_.isEmpty() + ? GTrC::tr("No phrase set. Using the built-in default.") + : GTrC::tr("Phrase set. %1 characters.").arg(phrase_.size())); schedule_fingerprint_update(); } @@ -255,7 +257,7 @@ void ImSettingsPage::schedule_fingerprint_update() { // phrase and must not overwrite what we are about to compute. ++fingerprint_request_; set_fingerprint({}); - fingerprint_label_->setText(Tr("Calculating…")); + fingerprint_label_->setText(GTrC::tr("Calculating…")); fingerprint_timer_->start(); } @@ -285,16 +287,15 @@ void ImSettingsPage::set_fingerprint(const QString& fingerprint) { : fingerprint); } - auto ImBookPhrase() -> QString { - return ImCodec::DecodePhraseBlob( - gf::sdk::CacheText(GFModuleSdkContext(), GF_STORE_SECURE_DURABLE, - kPhraseKey) - .toUtf8()); + return ImCodec::DecodePhraseBlob(gf::sdk::CacheText(GFModuleSdkContext(), + GF_STORE_SECURE_DURABLE, + kPhraseKey) + .toUtf8()); } void ImSetBookPhrase(const QString& phrase) { - gf::sdk::SetCacheText( - GFModuleSdkContext(), GF_STORE_SECURE_DURABLE, kPhraseKey, - QString::fromUtf8(ImCodec::EncodePhraseBlob(phrase))); + gf::sdk::SetCacheText(GFModuleSdkContext(), GF_STORE_SECURE_DURABLE, + kPhraseKey, + QString::fromUtf8(ImCodec::EncodePhraseBlob(phrase))); } diff --git a/src/m_key_server_sync/KeyServerBatchLogic.cpp b/src/m_key_server_sync/KeyServerBatchLogic.cpp index 02b93fc..77411bc 100644 --- a/src/m_key_server_sync/KeyServerBatchLogic.cpp +++ b/src/m_key_server_sync/KeyServerBatchLogic.cpp @@ -31,6 +31,8 @@ #include <QCoreApplication> #include <QSet> +#include "GFModuleTr.h" + namespace KeyServerBatchLogic { namespace { @@ -39,7 +41,7 @@ namespace { auto WithFailures(QString headline, const QStringList& failures) -> QString { if (failures.isEmpty()) return headline; headline += QStringLiteral("\n\n"); - headline += QCoreApplication::translate("GTrC", "Failed:"); + headline += GTrC::tr("Failed:"); for (const auto& f : failures) headline += QStringLiteral("\n") + f; return headline; } @@ -74,8 +76,7 @@ auto JoinForImport(const QList<QByteArray>& blocks) -> QByteArray { } auto NotFoundText() -> QString { - return QCoreApplication::translate("GTrC", - "The key server does not have this key."); + return GTrC::tr("The key server does not have this key."); } auto IsNotFound(const QString& error) -> bool { @@ -84,25 +85,21 @@ auto IsNotFound(const QString& error) -> bool { auto RefreshSummary(int fetched, int total, const QStringList& failures) -> QString { - return WithFailures( - QCoreApplication::translate("GTrC", - "%1 of %2 keys were fetched from the key " - "server.") - .arg(fetched) - .arg(total), - failures); + return WithFailures(GTrC::tr("%1 of %2 keys were fetched from the key " + "server.") + .arg(fetched) + .arg(total), + failures); } auto PublishSummary(int published, int total, const QString& host, const QStringList& failures) -> QString { - return WithFailures( - QCoreApplication::translate("GTrC", - "%1 of %2 keys were published to the key " - "server %3.") - .arg(published) - .arg(total) - .arg(host), - failures); + return WithFailures(GTrC::tr("%1 of %2 keys were published to the key " + "server %3.") + .arg(published) + .arg(total) + .arg(host), + failures); } } // namespace KeyServerBatchLogic diff --git a/src/m_key_server_sync/KeyServerProbe.cpp b/src/m_key_server_sync/KeyServerProbe.cpp index 8506182..10d56ef 100644 --- a/src/m_key_server_sync/KeyServerProbe.cpp +++ b/src/m_key_server_sync/KeyServerProbe.cpp @@ -36,6 +36,7 @@ #include <optional> #include "GFModule.h" +#include "GFModuleTr.h" namespace { @@ -242,10 +243,8 @@ void KeyServerProber::settle(bool is_hkp, ProbeVerdict verdict) { const auto unreachable = hkp_verdict_ == ProbeVerdict::kUnreachable && vks_verdict_ == ProbeVerdict::kUnreachable; result_.detail = - unreachable ? QCoreApplication::translate( - "GTrC", "The server could not be reached.") - : QCoreApplication::translate( - "GTrC", + unreachable ? GTrC::tr("The server could not be reached.") + : GTrC::tr( "The server responded, but not as a key server: it " "supports neither the HKP nor the VKS interface."); } diff --git a/src/m_key_server_sync/KeyServerSyncModule.cpp b/src/m_key_server_sync/KeyServerSyncModule.cpp index aae1387..2e3af37 100644 --- a/src/m_key_server_sync/KeyServerSyncModule.cpp +++ b/src/m_key_server_sync/KeyServerSyncModule.cpp @@ -36,6 +36,7 @@ #include "GFModule.h" #include "GFModuleIdentity.h" +#include "GFModuleTr.h" #include "GFSDKHostCommands.hpp" #include "GFSDKUI.h" #include "KeyServerBatchLogic.h" @@ -151,11 +152,8 @@ void FetchKey(const KeyServerList::Route& route, const QString& handle, auto ConfirmHkpPublish(const QString& url) -> bool { const auto host = QUrl(url).host(); return QMessageBox::warning( - nullptr, - QCoreApplication::translate("GTrC", - "Publish Without Verification?"), - QCoreApplication::translate( - "GTrC", + nullptr, GTrC::tr("Publish Without Verification?"), + GTrC::tr( "%1 does not support verified publishing (VKS), so the key " "would be uploaded over HKP instead.\n\n" "The server will not confirm your email address, and the " @@ -229,8 +227,7 @@ class KeyServerBatch : public QObject { const auto exported = gf::sdk::ExportKey( GFModuleSdkContext(), static_cast<int>(key.channel), key.key_id, true); if (exported.isEmpty()) { - failures_.append(QCoreApplication::translate( - "GTrC", "%1: the public key could not be exported") + failures_.append(GTrC::tr("%1: the public key could not be exported") .arg(key.fingerprint)); return Schedule(); } @@ -278,13 +275,11 @@ class KeyServerBatch : public QObject { static_cast<int>(keys_.front().channel), KeyServerBatchLogic::JoinForImport(blocks_)); } - Tell(severity, - QCoreApplication::translate("GTrC", "Key Refresh Finished"), + Tell(severity, GTrC::tr("Key Refresh Finished"), KeyServerBatchLogic::RefreshSummary(static_cast<int>(blocks_.size()), total, failures_)); } else { - Tell(severity, - QCoreApplication::translate("GTrC", "Key Publishing Finished"), + Tell(severity, GTrC::tr("Key Publishing Finished"), KeyServerBatchLogic::PublishSummary( done_, total, QUrl(route_.url).host(), failures_)); } @@ -305,11 +300,9 @@ QPointer<KeyServerBatch> g_batch; void StartBatch(KeyServerBatch::Kind kind, QList<BatchKey> keys) { if (!g_batch.isNull()) { - Tell(Severity::kInfo, QCoreApplication::translate("GTrC", "Key Server"), - QCoreApplication::translate( - "GTrC", - "A key server operation is already running. Try again " - "when it has finished.")); + Tell(Severity::kInfo, GTrC::tr("Key Server"), + GTrC::tr("A key server operation is already running. Try again " + "when it has finished.")); return; } auto* batch = new KeyServerBatch(kind, std::move(keys)); @@ -338,7 +331,7 @@ auto OnActivate() -> GFResult { // installed yet, so anything translated here would be stuck at the source // text for the rest of the session. The Host translates it when shown. const bool search = gf::ui::RegisterNativeWidget<SearchKeyDialog>( - "search", {GC_TR("Key Server"), "", "", "", "", 0, 0}, + "search", {GTrC::Noop("Key Server"), "", "", "", "", 0, 0}, [](const QCborMap& /*args*/) { auto* dialog = new SearchKeyDialog(); QString preset; @@ -353,8 +346,9 @@ auto OnActivate() -> GFResult { }); const bool settings = gf::ui::RegisterNativeWidget<KeyServerSettingsPage>( "settings", - {GC_TR("Key Servers"), - GC_TR("keyserver,key server,hkp,vks,publish,search"), "", "", "", 0, 0}, + {GTrC::Noop("Key Servers"), + GTrC::Noop("keyserver,key server,hkp,vks,publish,search"), "", "", "", 0, + 0}, [](const QCborMap& /*args*/) { return new KeyServerSettingsPage(); }); return search && settings @@ -368,12 +362,9 @@ auto UploadKeyToServer(int channel, const QString& key_id) -> int { const auto exported = gf::sdk::ExportKey(GFModuleSdkContext(), channel, key_id, true); if (exported.isEmpty()) { - Tell(Severity::kError, - QCoreApplication::translate("GTrC", "Key Upload Failed"), - QCoreApplication::translate( - "GTrC", - "Failed to export the public key before uploading.\n" - "Key: %1") + Tell(Severity::kError, GTrC::tr("Key Upload Failed"), + GTrC::tr("Failed to export the public key before uploading.\n" + "Key: %1") .arg(key_id)); return -1; } @@ -393,26 +384,19 @@ auto UploadKeyToServer(int channel, const QString& key_id) -> int { [server, key_id](QNetworkReply::NetworkError error, const QString& error_string) { if (error != QNetworkReply::NoError) { - Tell(Severity::kError, - QCoreApplication::translate("GTrC", "Key Upload Failed"), - QCoreApplication::translate( - "GTrC", - "Failed to upload public key to the server.\n" - "Fingerprint: %1\n" - "Error: %2") + Tell(Severity::kError, GTrC::tr("Key Upload Failed"), + GTrC::tr("Failed to upload public key to the server.\n" + "Fingerprint: %1\n" + "Error: %2") .arg(key_id, error_string)); return; } // No verification mail follows an HKP upload, so do not promise one. - Tell(Severity::kInfo, - QCoreApplication::translate("GTrC", - "Public Key Upload Successful"), - QCoreApplication::translate( - "GTrC", - "The public key was uploaded to the key server %2 over " - "HKP.\n" - "Fingerprint: %1") + Tell(Severity::kInfo, GTrC::tr("Public Key Upload Successful"), + GTrC::tr("The public key was uploaded to the key server %2 over " + "HKP.\n" + "Fingerprint: %1") .arg(key_id, QUrl(server).host())); }); QObject::connect(pks, &PKSInterface::SignalKeyServerKeyUploadResult, pks, @@ -428,8 +412,8 @@ auto UploadKeyToServer(int channel, const QString& key_id) -> int { [server](const QString& fpr, const QJsonObject& status, const QString& token) { // Handle successful response - QString status_message = QCoreApplication::translate( - "GTrC", "The following email addresses have status:\n"); + QString status_message = + GTrC::tr("The following email addresses have status:\n"); QStringList email_list; if (!status.isEmpty()) { for (auto it = status.constBegin(); it != status.constEnd(); ++it) { @@ -438,8 +422,7 @@ auto UploadKeyToServer(int channel, const QString& key_id) -> int { email_list.append(it.key()); } } else { - status_message += QCoreApplication::translate( - "GTrC", "Could not parse status information."); + status_message += GTrC::tr("Could not parse status information."); } // Name the server that was actually used: it is configurable now, so a @@ -447,30 +430,23 @@ auto UploadKeyToServer(int channel, const QString& key_id) -> int { const auto host = QUrl(server).host(); // Notify user of successful upload and status details - Tell( - Severity::kInfo, - QCoreApplication::translate("GTrC", "Public Key Upload Successful"), - QCoreApplication::translate( - "GTrC", - "The public key was successfully uploaded to the " - "key server %4.\n" - "Fingerprint: %1\n\n" - "%2\n" - "Please check your email (%3) for further " - "verification from %4.") - .arg(fpr, status_message, email_list.join(", "), host)); + Tell(Severity::kInfo, GTrC::tr("Public Key Upload Successful"), + GTrC::tr("The public key was successfully uploaded to the " + "key server %4.\n" + "Fingerprint: %1\n\n" + "%2\n" + "Please check your email (%3) for further " + "verification from %4.") + .arg(fpr, status_message, email_list.join(", "), host)); }); QObject::connect( vks, &VKSInterface::SignalErrorOccurred, QThread::currentThread(), [key_id](const QString& error, const QString& data) { - Tell(Severity::kError, - QCoreApplication::translate("GTrC", "Key Upload Failed"), - QCoreApplication::translate( - "GTrC", - "Failed to upload public key to the server.\n" - "Fingerprint: %1\n" - "Error: %2") + Tell(Severity::kError, GTrC::tr("Key Upload Failed"), + GTrC::tr("Failed to upload public key to the server.\n" + "Fingerprint: %1\n" + "Error: %2") .arg(key_id, error)); }); @@ -497,13 +473,10 @@ auto UpdateKeyFromKeyServer(int channel, const QString& fpr) -> int { Q_UNUSED(data); // Name the server: it is the user's choice now, and a failure they // cannot attribute to a host is one they cannot fix. - Tell(Severity::kError, - QCoreApplication::translate("GTrC", "Key Update Failed"), - QCoreApplication::translate( - "GTrC", - "Failed to retrieve public key from %3.\n" - "Key ID: %1\n" - "Error: %2") + Tell(Severity::kError, GTrC::tr("Key Update Failed"), + GTrC::tr("Failed to retrieve public key from %3.\n" + "Key ID: %1\n" + "Error: %2") .arg(fpr, error, host)); }); return 0; @@ -543,9 +516,9 @@ auto KeysOf(const KeyArgs& a) -> QList<BatchKey> { struct PublishKey { static constexpr gf::cmd::Meta kMeta{ GF_MODULE_ID ".publish_key", - GC_TR("Publish Public Key to Key Server"), - GC_TR("Upload the public key to the key server used for syncing"), - GC_TR("Key Server Operations"), + GTrC::Noop("Publish Public Key to Key Server"), + GTrC::Noop("Upload the public key to the key server used for syncing"), + GTrC::Noop("Key Server Operations"), 0, gf::cmd::kNeedsGuiThread}; using Args = KeyArgs; @@ -555,9 +528,10 @@ struct PublishKey { struct RefreshKey { static constexpr gf::cmd::Meta kMeta{ GF_MODULE_ID ".refresh_key", - GC_TR("Refresh Public Key From Key Server"), - GC_TR("Import the latest copy of the public key from the key server"), - GC_TR("Key Server Operations"), + GTrC::Noop("Refresh Public Key From Key Server"), + GTrC::Noop( + "Import the latest copy of the public key from the key server"), + GTrC::Noop("Key Server Operations"), 0, gf::cmd::kNeedsGuiThread}; using Args = KeyArgs; @@ -567,9 +541,9 @@ struct RefreshKey { struct CheckPublication { static constexpr gf::cmd::Meta kMeta{ GF_MODULE_ID ".check_publication", - GC_TR("Check Publication Status"), - GC_TR("Ask the key server whether it has this public key"), - GC_TR("Key Server Operations"), + GTrC::Noop("Check Publication Status"), + GTrC::Noop("Ask the key server whether it has this public key"), + GTrC::Noop("Key Server Operations"), 0, gf::cmd::kNeedsGuiThread}; using Args = KeyArgs; @@ -579,8 +553,8 @@ struct CheckPublication { struct SearchKey { static constexpr gf::cmd::Meta kMeta{ GF_MODULE_ID ".search_key", - GC_TR("Key Server"), - GC_TR("Import public keys from a trusted key server."), + GTrC::Noop("Key Server"), + GTrC::Noop("Import public keys from a trusted key server."), "", 0, gf::cmd::kNeedsGuiThread}; @@ -637,26 +611,21 @@ auto DoCheckPublication(const gf::cmd::CommandContext& /*ctx*/, const auto fpr = keys.front().fingerprint; const auto route = KeyServerList::SyncRoute(); const auto host = QUrl(route.url).host(); - const auto title = QCoreApplication::translate("GTrC", "Publication Status"); + const auto title = GTrC::tr("Publication Status"); FetchKey( route, fpr, true, [title, host](const QString&) { Tell(Severity::kInfo, title, - QCoreApplication::translate( - "GTrC", "The public key has been published on %1.") - .arg(host)); + GTrC::tr("The public key has been published on %1.").arg(host)); }, [title, host](const QString& error, const QString&) { if (KeyServerBatchLogic::IsNotFound(error)) { Tell(Severity::kInfo, title, - QCoreApplication::translate( - "GTrC", "The public key is not published on %1.") - .arg(host)); + GTrC::tr("The public key is not published on %1.").arg(host)); return; } Tell(Severity::kWarning, title, - QCoreApplication::translate( - "GTrC", "Could not ask %1 about this key.\n\n%2") + GTrC::tr("Could not ask %1 about this key.\n\n%2") .arg(host, error)); }); return gf::cmd::Outcome<gf::cmd::Unit>::Success({}); diff --git a/src/m_pgp_inspect/PGPInspectDialog.cpp b/src/m_pgp_inspect/PGPInspectDialog.cpp index 9dcab4e..79ef097 100644 --- a/src/m_pgp_inspect/PGPInspectDialog.cpp +++ b/src/m_pgp_inspect/PGPInspectDialog.cpp @@ -39,6 +39,8 @@ #include <QVBoxLayout> #include <array> +#include "GFModuleTr.h" + namespace { /// Which column holds what. Packet rows use the first only; a field row puts @@ -96,7 +98,7 @@ auto PGPInspectBytes(const QByteArray& data) -> PGPInspectDocument { PGPInspectDialog::PGPInspectDialog(const PGPInspectDocument& document, qint64 size, QWidget* parent) : QDialog(parent), document_(document), size_(size) { - setWindowTitle(QCoreApplication::translate("GTrC", "OpenPGP Structure")); + setWindowTitle(GTrC::tr("OpenPGP Structure")); setAttribute(Qt::WA_DeleteOnClose); resize(820, 620); create_widgets(); @@ -106,15 +108,13 @@ PGPInspectDialog::PGPInspectDialog(const PGPInspectDocument& document, void PGPInspectDialog::create_widgets() { search_ = new QLineEdit(this); search_->setClearButtonEnabled(true); - search_->setPlaceholderText( - QCoreApplication::translate("GTrC", "Search packets, fields and values")); + search_->setPlaceholderText(GTrC::tr("Search packets, fields and values")); connect(search_, &QLineEdit::textChanged, this, &PGPInspectDialog::slot_filter_changed); tree_ = new QTreeWidget(this); tree_->setColumnCount(2); - tree_->setHeaderLabels({QCoreApplication::translate("GTrC", "Structure"), - QCoreApplication::translate("GTrC", "Value")}); + tree_->setHeaderLabels({GTrC::tr("Structure"), GTrC::tr("Value")}); tree_->header()->setSectionResizeMode(kLabelColumn, QHeaderView::ResizeToContents); tree_->header()->setSectionResizeMode(kValueColumn, QHeaderView::Stretch); @@ -136,8 +136,7 @@ void PGPInspectDialog::render_document() { if (!document_.valid) { summary_label_->setText( document_.parse_error.isEmpty() - ? QCoreApplication::translate( - "GTrC", "The current tab holds no OpenPGP data.") + ? GTrC::tr("The current tab holds no OpenPGP data.") : document_.parse_error); return; } @@ -151,29 +150,28 @@ void PGPInspectDialog::render_document() { // the armor headers and the CRC verdict too. QVector<PGPInspectField> facts; if (block.has_armor) { - facts.push_back({QCoreApplication::translate("GTrC", "Armor Type"), - block.armor.block_type}); - facts.push_back( - {QCoreApplication::translate("GTrC", "CRC24"), block.armor.crc24}); + facts.push_back({GTrC::tr("Armor Type"), block.armor.block_type}); + facts.push_back({GTrC::tr("CRC24"), block.armor.crc24}); facts += block.armor.headers; } if (block.has_cleartext) { - facts.push_back({QCoreApplication::translate("GTrC", "Signed Text"), - HumanSize(block.cleartext_text_size)}); + facts.push_back( + {GTrC::tr("Signed Text"), HumanSize(block.cleartext_text_size)}); facts += block.cleartext_headers; } if (!block.error.isEmpty()) { - facts.push_back( - {QCoreApplication::translate("GTrC", "Problem"), block.error}); + facts.push_back({GTrC::tr("Problem"), block.error}); } add_fields(item, facts); if (block.has_armor && block.armor.crc24 == QLatin1String("mismatch")) { - item->setForeground( - kLabelColumn, QBrush(QColor(GFUIThemeColorForRole(GFModuleSdkContext(), GF_UI_COLOR_DANGER)))); + item->setForeground(kLabelColumn, + QBrush(QColor(GFUIThemeColorForRole( + GFModuleSdkContext(), GF_UI_COLOR_DANGER)))); } else if (!block.error.isEmpty()) { - item->setForeground( - kLabelColumn, QBrush(QColor(GFUIThemeColorForRole(GFModuleSdkContext(), GF_UI_COLOR_WARNING)))); + item->setForeground(kLabelColumn, + QBrush(QColor(GFUIThemeColorForRole( + GFModuleSdkContext(), GF_UI_COLOR_WARNING)))); } add_packets(item, block.packets); @@ -184,8 +182,7 @@ void PGPInspectDialog::render_document() { // The count goes through a local: a function call inside a translate() // %n argument makes lupdate silently skip EVERY string in the file. const int packet_count = document_.PacketCount(); - auto summary = QCoreApplication::translate("GTrC", "%1, %2, %n packet(s)", - nullptr, packet_count) + auto summary = GTrC::tr("%1, %2, %n packet(s)", nullptr, packet_count) .arg(document_.format, HumanSize(size_)); if (!document_.errors.isEmpty()) { summary += @@ -202,14 +199,14 @@ void PGPInspectDialog::add_packets(QTreeWidgetItem* parent, item->setText(kLabelColumn, PGPInspectPacketSummary(packet, index++)); if (packet.Malformed()) { - item->setForeground( - kLabelColumn, QBrush(QColor(GFUIThemeColorForRole(GFModuleSdkContext(), GF_UI_COLOR_WARNING)))); + item->setForeground(kLabelColumn, + QBrush(QColor(GFUIThemeColorForRole( + GFModuleSdkContext(), GF_UI_COLOR_WARNING)))); } auto fields = packet.fields; if (packet.Malformed()) { - fields.push_back( - {QCoreApplication::translate("GTrC", "Problem"), packet.error}); + fields.push_back({GTrC::tr("Problem"), packet.error}); } add_fields(item, fields); @@ -223,9 +220,9 @@ void PGPInspectDialog::add_fields(QTreeWidgetItem* parent, auto* row = new QTreeWidgetItem(parent); row->setText(kLabelColumn, field.label); row->setText(kValueColumn, field.value); - row->setForeground( - kLabelColumn, - QBrush(QColor(GFUIThemeColorForRole(GFModuleSdkContext(), GF_UI_COLOR_MUTED_TEXT)))); + row->setForeground(kLabelColumn, + QBrush(QColor(GFUIThemeColorForRole( + GFModuleSdkContext(), GF_UI_COLOR_MUTED_TEXT)))); } } diff --git a/src/m_pgp_inspect/PGPInspectModel.cpp b/src/m_pgp_inspect/PGPInspectModel.cpp index 874b349..c9ab6db 100644 --- a/src/m_pgp_inspect/PGPInspectModel.cpp +++ b/src/m_pgp_inspect/PGPInspectModel.cpp @@ -34,6 +34,8 @@ #include <QJsonObject> #include <QJsonParseError> +#include "GFModuleTr.h" + namespace { auto ParseFields(const QJsonValue& value) -> QVector<PGPInspectField> { @@ -126,8 +128,7 @@ auto ParsePGPInspectDocument(const QByteArray& json) -> PGPInspectDocument { return document; } if (!parsed.isObject()) { - document.parse_error = - QCoreApplication::translate("GTrC", "The inspector returned no data."); + document.parse_error = GTrC::tr("The inspector returned no data."); return document; } @@ -154,18 +155,16 @@ auto PGPInspectPacketSummary(const PGPInspectPacket& packet, int index) // "#1 Signature (tag 2) v4 @0x0000 189 B". The offset is hexadecimal // because that is what every other packet dumper prints, and what a reader // comparing two tools needs in order to line them up. - auto summary = QCoreApplication::translate("GTrC", "#%1 %2 (tag %3)") + auto summary = GTrC::tr("#%1 %2 (tag %3)") .arg(index) - .arg(packet.tag_name.isEmpty() - ? QCoreApplication::translate("GTrC", "Unknown") - : packet.tag_name) + .arg(packet.tag_name.isEmpty() ? GTrC::tr("Unknown") + : packet.tag_name) .arg(packet.tag); if (packet.version >= 0) summary += QString(" v%1").arg(packet.version); summary += QString(" @0x%1").arg(packet.offset, 4, 16, QChar('0')); - summary += QCoreApplication::translate("GTrC", " %1 B") - .arg(packet.header_length + packet.body_length); + summary += GTrC::tr(" %1 B").arg(packet.header_length + packet.body_length); if (packet.length_type != QLatin1String("fixed") && !packet.length_type.isEmpty()) { @@ -177,15 +176,12 @@ auto PGPInspectPacketSummary(const PGPInspectPacket& packet, int index) auto PGPInspectBlockSummary(const PGPInspectBlock& block, int index) -> QString { if (block.kind == QLatin1String("cleartext")) { - return QCoreApplication::translate("GTrC", - "Block %1: cleartext-signed message") - .arg(index); + return GTrC::tr("Block %1: cleartext-signed message").arg(index); } if (block.has_armor) { - return QCoreApplication::translate("GTrC", "Block %1: armored, %2") + return GTrC::tr("Block %1: armored, %2") .arg(index) .arg(block.armor.block_type); } - return QCoreApplication::translate("GTrC", "Block %1: binary packet stream") - .arg(index); + return GTrC::tr("Block %1: binary packet stream").arg(index); } diff --git a/src/m_pgp_inspect/PGPInspectModule.cpp b/src/m_pgp_inspect/PGPInspectModule.cpp index 5753b9a..a957255 100644 --- a/src/m_pgp_inspect/PGPInspectModule.cpp +++ b/src/m_pgp_inspect/PGPInspectModule.cpp @@ -27,9 +27,11 @@ */ #include <GFModule.h> + #include <GFSDKHostCommands.hpp> #include "GFModuleIdentity.h" +#include "GFModuleTr.h" #include "PGPInspectDialog.h" namespace { @@ -57,8 +59,10 @@ auto InspectCurrentTab() -> PGPInspectDocument { struct OpenInspector { static constexpr gf::cmd::Meta kMeta{ GF_MODULE_ID ".open_inspector", - GC_TR("Open OpenPGP Structure Inspector"), - GC_TR("Show the packet structure of the current tab"), "", 0, + GTrC::Noop("Open OpenPGP Structure Inspector"), + GTrC::Noop("Show the packet structure of the current tab"), + "", + 0, gf::cmd::kNeedsGuiThread}; using Args = gf::cmd::Unit; using Result = gf::cmd::Unit; @@ -86,7 +90,8 @@ auto OnActivate() -> GFResult { // it is offered is ui/main.lua's business. const bool ok = gf::ui::RegisterNativeWidget<PGPInspectDialog>( "inspector", - {GC_TR("OpenPGP Structure"), "", "", "", ":/icons/help.png", 820, 620}, + {GTrC::Noop("OpenPGP Structure"), "", "", "", ":/icons/help.png", 820, + 620}, [](const QCborMap& /*args*/) { const auto bytes = PGPInspectCurrentTabBytes(); return new PGPInspectDialog(PGPInspectBytes(bytes), bytes.size()); @@ -117,6 +122,6 @@ const GFModuleHooks kHooks = { }; extern "C" GF_MODULE_EXPORT auto GFModuleGetApi(uint32_t abi) - -> const GFModuleApi * { + -> const GFModuleApi* { return GFModuleRuntimeGetApi(abi, &kHooks); } diff --git a/src/m_ver_check/VersionCheckingModule.cpp b/src/m_ver_check/VersionCheckingModule.cpp index 71dde75..75845bf 100644 --- a/src/m_ver_check/VersionCheckingModule.cpp +++ b/src/m_ver_check/VersionCheckingModule.cpp @@ -42,6 +42,7 @@ #include "GFModule.h" #include "GFModuleIdentity.h" +#include "GFModuleTr.h" #include "UpdateChecker.h" #include "UpdateTab.h" #include "Utils.h" @@ -129,16 +130,13 @@ class UpdateWidget : public QWidget, public gf::ui::DialogWidget { class UpdateSettingsWidget : public QWidget, public gf::ui::SettingsWidget { public: UpdateSettingsWidget() { - auto* box = new QGroupBox( - QCoreApplication::translate("GTrC", "Update Checking"), this); + auto* box = new QGroupBox(GTrC::tr("Update Checking"), this); auto* column = new QVBoxLayout(box); - check_ = - new QCheckBox(QCoreApplication::translate( - "GTrC", - "Checking for version updates when the application " - "starts."), - box); + check_ = new QCheckBox( + GTrC::tr("Checking for version updates when the application " + "starts."), + box); column->addWidget(check_); auto* layout = new QVBoxLayout(this); @@ -165,8 +163,8 @@ class UpdateSettingsWidget : public QWidget, public gf::ui::SettingsWidget { struct CheckForUpdates { static constexpr gf::cmd::Meta kMeta{ GF_MODULE_ID ".check_for_updates", - GC_TR("Check for Updates"), - GC_TR("See whether a newer GpgFrontend is available"), + GTrC::Noop("Check for Updates"), + GTrC::Noop("See whether a newer GpgFrontend is available"), "", 0, gf::cmd::kNeedsGuiThread}; @@ -214,12 +212,12 @@ auto OnActivate() -> GFResult { "update_checking_api"); const bool dialog = gf::ui::RegisterNativeWidget<UpdateWidget>( - "update", {GC_TR("Check for Updates"), "", "", "", "", 0, 0}, + "update", {GTrC::Noop("Check for Updates"), "", "", "", "", 0, 0}, [](const QCborMap& /*args*/) { return new UpdateWidget(); }); const bool settings = gf::ui::RegisterNativeWidget<UpdateSettingsWidget>( "settings", - {GC_TR("Updates"), GC_TR("update,version,check,github"), "", "", "", 0, - 0}, + {GTrC::Noop("Updates"), GTrC::Noop("update,version,check,github"), "", "", + "", 0, 0}, [](const QCborMap& /*args*/) { return new UpdateSettingsWidget(); }); return dialog && settings ? GFResult::Ok() |
