aboutsummaryrefslogtreecommitdiffstats
path: root/src/m_pgp_inspect
diff options
context:
space:
mode:
Diffstat (limited to 'src/m_pgp_inspect')
-rw-r--r--src/m_pgp_inspect/PGPInspectDialog.cpp53
-rw-r--r--src/m_pgp_inspect/PGPInspectModel.cpp24
-rw-r--r--src/m_pgp_inspect/PGPInspectModule.cpp13
3 files changed, 44 insertions, 46 deletions
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);
}