aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2025-04-17 16:54:03 +0000
committersaturneric <[email protected]>2025-04-17 16:54:03 +0000
commitb84e661438dc0dba5862ee741fd4d1d0f881e2f6 (patch)
tree2822bffc3f1d4496837988bcffd00cfcce498790 /src
parentfeat: generate cark keys (diff)
downloadGpgFrontend-b84e661438dc0dba5862ee741fd4d1d0f881e2f6.tar.gz
GpgFrontend-b84e661438dc0dba5862ee741fd4d1d0f881e2f6.zip
chore: update and check translations
Diffstat (limited to 'src')
-rw-r--r--src/core/function/gpg/GpgAutomatonHandler.cpp2
-rw-r--r--src/core/function/gpg/GpgAutomatonHandler.h2
-rw-r--r--src/core/function/gpg/GpgSmartCardManager.cpp8
-rw-r--r--src/core/model/GpgKeyTableModel.cpp23
-rw-r--r--src/ui/dialog/ADSKsPicker.cpp2
-rw-r--r--src/ui/dialog/controller/SmartCardControllerDialog.cpp80
-rw-r--r--src/ui/dialog/key_generate/GenerateCardKeyDialog.cpp17
-rw-r--r--src/ui/dialog/key_generate/GenerateCardKeyDialog.h2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp8
9 files changed, 80 insertions, 64 deletions
diff --git a/src/core/function/gpg/GpgAutomatonHandler.cpp b/src/core/function/gpg/GpgAutomatonHandler.cpp
index 6cf06ab6..656bb018 100644
--- a/src/core/function/gpg/GpgAutomatonHandler.cpp
+++ b/src/core/function/gpg/GpgAutomatonHandler.cpp
@@ -28,8 +28,6 @@
#include "GpgAutomatonHandler.h"
-#include <utility>
-
#include "core/model/GpgData.h"
#include "core/model/GpgKey.h"
#include "core/utils/GpgUtils.h"
diff --git a/src/core/function/gpg/GpgAutomatonHandler.h b/src/core/function/gpg/GpgAutomatonHandler.h
index d142bbcc..4363cf30 100644
--- a/src/core/function/gpg/GpgAutomatonHandler.h
+++ b/src/core/function/gpg/GpgAutomatonHandler.h
@@ -28,8 +28,6 @@
#pragma once
-#include <utility>
-
#include "core/GpgFrontendCore.h"
#include "core/function/basic/GpgFunctionObject.h"
#include "core/function/gpg/GpgContext.h"
diff --git a/src/core/function/gpg/GpgSmartCardManager.cpp b/src/core/function/gpg/GpgSmartCardManager.cpp
index 9937ef7a..422f0b20 100644
--- a/src/core/function/gpg/GpgSmartCardManager.cpp
+++ b/src/core/function/gpg/GpgSmartCardManager.cpp
@@ -370,9 +370,9 @@ auto GpgSmartCardManager::GenerateKey(
return QString{};
};
- GpgAutomatonHandler::GetInstance(GetChannel())
- .DoCardInteract(serial_number, next_state_handler, action_handler);
-
- return {true, {}};
+ return {
+ GpgAutomatonHandler::GetInstance(GetChannel())
+ .DoCardInteract(serial_number, next_state_handler, action_handler),
+ "unknown error"};
}
} // namespace GpgFrontend \ No newline at end of file
diff --git a/src/core/model/GpgKeyTableModel.cpp b/src/core/model/GpgKeyTableModel.cpp
index db456431..d5de3844 100644
--- a/src/core/model/GpgKeyTableModel.cpp
+++ b/src/core/model/GpgKeyTableModel.cpp
@@ -154,14 +154,13 @@ auto GpgKeyTableModel::table_data_by_gpg_key_group(
auto GpgKeyTableModel::table_tooltip_by_gpg_key(
const QModelIndex & /*index*/, const GpgKey *key) const -> QVariant {
QStringList tooltip_lines;
- tooltip_lines << tr("ID: %1").arg(key->ID());
- tooltip_lines << tr("Algo: %1").arg(key->Algo());
- tooltip_lines << tr("Usage: %1").arg(GetUsagesByAbstractKey(key));
- tooltip_lines << tr("Trust: %1").arg(key->OwnerTrust());
- tooltip_lines << tr("Comment: %1")
- .arg(key->Comment().isEmpty()
- ? "<" + tr("No Comment") + ">"
- : key->Comment());
+ tooltip_lines << tr("ID") + ": " + key->ID();
+ tooltip_lines << tr("Algo") + ": " + key->Algo();
+ tooltip_lines << tr("Usage") + ": " + GetUsagesByAbstractKey(key);
+ tooltip_lines << tr("Trust") + ": " + key->OwnerTrust();
+ tooltip_lines << tr("Comment") + ": " +
+ (key->Comment().isEmpty() ? "<" + tr("No Comment") + ">"
+ : key->Comment());
const auto s_keys = key->SubKeys();
if (!s_keys.empty()) {
@@ -172,10 +171,10 @@ auto GpgKeyTableModel::table_tooltip_by_gpg_key(
for (const auto &s_key : s_keys) {
if (count++ >= 8) break;
const auto usages = GetUsagesByAbstractKey(&s_key);
- tooltip_lines << tr(" - ID: %1 | Algo: %2 | Usage: %3")
- .arg(s_key.ID())
- .arg(s_key.Algo())
- .arg(usages.trimmed());
+ tooltip_lines << " - " + tr("ID: %1 | Algo: %2 | Usage: %3")
+ .arg(s_key.ID())
+ .arg(s_key.Algo())
+ .arg(usages.trimmed());
}
}
diff --git a/src/ui/dialog/ADSKsPicker.cpp b/src/ui/dialog/ADSKsPicker.cpp
index 09648355..878c5e96 100644
--- a/src/ui/dialog/ADSKsPicker.cpp
+++ b/src/ui/dialog/ADSKsPicker.cpp
@@ -58,7 +58,7 @@ ADSKsPicker::ADSKsPicker(int channel, GpgKeyPtr key,
connect(confirm_button, &QPushButton::clicked, this, [=]() {
if (tree_view_->GetAllCheckedSubKey().isEmpty()) {
QMessageBox::information(this, tr("No Subkeys Selected"),
- tr("Please select at least one s_key."));
+ tr("Please select at least one Subkey."));
return;
}
diff --git a/src/ui/dialog/controller/SmartCardControllerDialog.cpp b/src/ui/dialog/controller/SmartCardControllerDialog.cpp
index fb812ad6..450f1a35 100644
--- a/src/ui/dialog/controller/SmartCardControllerDialog.cpp
+++ b/src/ui/dialog/controller/SmartCardControllerDialog.cpp
@@ -128,6 +128,9 @@ SmartCardControllerDialog::SmartCardControllerDialog(QWidget* parent)
connect(d, &GenerateCardKeyDialog::finished, this, [=](int ret) {
if (ret == 1) {
fetch_smart_card_info(serial_number);
+ } else {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Generate card key failed."));
}
});
});
@@ -174,6 +177,8 @@ void SmartCardControllerDialog::fetch_smart_card_info(
const QString& serial_number) {
if (!has_card_) return;
+ reset_status();
+
auto card_info =
GpgSmartCardManager::GetInstance(channel_).FetchCardInfoBySerialNumber(
serial_number);
@@ -200,44 +205,47 @@ void SmartCardControllerDialog::print_smart_card_info() {
out << "<h2>" << tr("OpenPGP Card Information") << "</h2>";
out << "<h3>" << tr("Basic Information") << "</h3><ul>";
- out << "<li><b>" << tr("Reader:") << "</b> " << card.reader << "</li>";
- out << "<li><b>" << tr("Serial Number:") << "</b> " << card.serial_number
+ out << "<li><b>" << tr("Reader") << ":" << "</b> " << card.reader << "</li>";
+ out << "<li><b>" << tr("Serial Number") << ":" << "</b> "
+ << card.serial_number << "</li>";
+ out << "<li><b>" << tr("Card Type") << ":" << "</b> " << card.card_type
+ << "</li>";
+ out << "<li><b>" << tr("Card Version") << ":" << "</b> " << card.card_version
<< "</li>";
- out << "<li><b>" << tr("Card Type:") << "</b> " << card.card_type << "</li>";
- out << "<li><b>" << tr("Card Version:") << "</b> " << card.card_version
+ out << "<li><b>" << tr("App Type") << ":" << "</b> " << card.app_type
<< "</li>";
- out << "<li><b>" << tr("App Type:") << "</b> " << card.app_type << "</li>";
- out << "<li><b>" << tr("App Version:") << "</b> " << card.app_version
+ out << "<li><b>" << tr("App Version") << ":" << "</b> " << card.app_version
<< "</li>";
- out << "<li><b>" << tr("Manufacturer ID:") << "</b> " << card.manufacturer_id
+ out << "<li><b>" << tr("Manufacturer ID") << ":" << "</b> "
+ << card.manufacturer_id << "</li>";
+ out << "<li><b>" << tr("Manufacturer") << ":" << "</b> " << card.manufacturer
<< "</li>";
- out << "<li><b>" << tr("Manufacturer:") << "</b> " << card.manufacturer
+ out << "<li><b>" << tr("Card Holder") << ":" << "</b> " << card.card_holder
<< "</li>";
- out << "<li><b>" << tr("Card Holder:") << "</b> " << card.card_holder
+ out << "<li><b>" << tr("Language") << ":" << "</b> " << card.display_language
<< "</li>";
- out << "<li><b>" << tr("Language:") << "</b> " << card.display_language
+ out << "<li><b>" << tr("Sex") << ":" << "</b> " << card.display_sex
<< "</li>";
- out << "<li><b>" << tr("Sex:") << "</b> " << card.display_sex << "</li>";
out << "</ul>";
out << "<h3>" << tr("Status") << "</h3><ul>";
- out << "<li><b>" << tr("Signature Counter:") << "</b> " << card.sig_counter
- << "</li>";
- out << "<li><b>" << tr("CHV1 Cached:") << "</b> " << card.chv1_cached
+ out << "<li><b>" << tr("Signature Counter") << ":" << "</b> "
+ << card.sig_counter << "</li>";
+ out << "<li><b>" << tr("CHV1 Cached") << ":" << "</b> " << card.chv1_cached
<< "</li>";
- out << "<li><b>" << tr("CHV Max Length:") << "</b> "
+ out << "<li><b>" << tr("CHV Max Length") << ":" << "</b> "
<< QString("%1, %2, %3")
.arg(card.chv_max_len[0])
.arg(card.chv_max_len[1])
.arg(card.chv_max_len[2])
<< "</li>";
- out << "<li><b>" << tr("CHV Retry Left:") << "</b> "
+ out << "<li><b>" << tr("CHV Retry Left") << ":" << "</b> "
<< QString("%1, %2, %3")
.arg(card.chv_retry[0])
.arg(card.chv_retry[1])
.arg(card.chv_retry[2])
<< "</li>";
- out << "<li><b>" << tr("KDF Status:") << "</b> ";
+ out << "<li><b>" << tr("KDF Status") << ":" << "</b> ";
switch (card.kdf_do_enabled) {
case 0:
out << tr("Not enabled");
@@ -253,18 +261,13 @@ void SmartCardControllerDialog::print_smart_card_info() {
break;
}
out << "</li>";
- out << "<li><b>" << tr("UIF:") << "</b><ul>";
- out << "<li>"
- << tr("Sign: %1").arg(card.uif.sign ? tr("✔ Enabled") : tr("❌ Disabled"))
- << "</li>";
- out << "<li>"
- << tr("Encrypt: %1")
- .arg(card.uif.encrypt ? tr("✔ Enabled") : tr("❌ Disabled"))
- << "</li>";
- out << "<li>"
- << tr("Authenticate: %1")
- .arg(card.uif.auth ? tr("✔ Enabled") : tr("❌ Disabled"))
- << "</li>";
+ out << "<li><b>" << tr("UIF") << ":" << "</b><ul>";
+ out << "<li>" << tr("Sign") << ":"
+ << (card.uif.sign ? tr("Enabled") : tr("Disabled")) << "</li>";
+ out << "<li>" << tr("Encrypt") << ":"
+ << (card.uif.encrypt ? tr("Enabled") : tr("Disabled")) << "</li>";
+ out << "<li>" << tr("Authenticate") << ":"
+ << (card.uif.auth ? tr("Enabled") : tr("Disabled")) << "</li>";
out << "</ul></li>";
out << "</ul>";
@@ -311,15 +314,15 @@ void SmartCardControllerDialog::print_smart_card_info() {
out << "<li>"
<< tr("KDF Supported: %1").arg(card.ext_cap.kdf ? tr("Yes") : tr("No"))
<< "</li>";
- out << "<li>" << tr("Status Indicator: %1").arg(card.ext_cap.status_indicator)
- << "</li>";
+ out << "<li>" << tr("Status Indicator")
+ << QString(": %1").arg(card.ext_cap.status_indicator) << "</li>";
out << "</ul>";
if (!card.additional_card_infos.isEmpty()) {
out << "<h3>" << tr("Additional Info") << "</h3><ul>";
for (auto it = card.additional_card_infos.begin();
it != card.additional_card_infos.end(); ++it) {
- out << "<li><b>" << tr("%1:").arg(it.key()) << "</b> " << it.value()
+ out << "<li><b>" << QString("%1:").arg(it.key()) << "</b> " << it.value()
<< "</li>";
}
out << "</ul>";
@@ -420,6 +423,8 @@ void SmartCardControllerDialog::slot_disable_controllers(bool disable) {
}
void SmartCardControllerDialog::slot_fetch_smart_card_keys() {
+ ui_->fetchButton->setDisabled(true);
+
GpgSmartCardManager::GetInstance().Fetch(
ui_->currentCardComboBox->currentText());
@@ -428,9 +433,9 @@ void SmartCardControllerDialog::slot_fetch_smart_card_keys() {
{{},
{"--card-status"},
[=](int exit_code, const QString&, const QString&) {
+ ui_->fetchButton->setDisabled(false);
LOG_D() << "gpg --card--status exit code: " << exit_code;
if (exit_code != 0) return;
-
emit UISignalStation::GetInstance() -> SignalKeyDatabaseRefresh();
}});
});
@@ -469,11 +474,12 @@ void SmartCardControllerDialog::modify_key_attribute(const QString& attr) {
if (attr == "DISP-SEX") {
QStringList options;
- options << tr("1 - Male") << tr("2 - Female");
+ options << "1 - " + tr("Male") << "2 - " + tr("Female");
const QString selected = QInputDialog::getItem(
this, tr("Modify Card Attribute"),
- tr("Select sex to store in '%1':").arg(attr), options, 0, false, &ok);
+ tr("Select sex to store in '%1'").arg(attr) + ": ", options, 0, false,
+ &ok);
if (!ok || selected.isEmpty()) return;
@@ -487,8 +493,8 @@ void SmartCardControllerDialog::modify_key_attribute(const QString& attr) {
} else {
value = QInputDialog::getText(
this, tr("Modify Card Attribute"),
- tr("Enter new value for attribute '%1':").arg(attr), QLineEdit::Normal,
- "", &ok);
+ tr("Enter new value for attribute '%1'").arg(attr) + ": ",
+ QLineEdit::Normal, "", &ok);
if (!ok || value.isEmpty()) {
LOG_D() << "user canceled or empty input.";
diff --git a/src/ui/dialog/key_generate/GenerateCardKeyDialog.cpp b/src/ui/dialog/key_generate/GenerateCardKeyDialog.cpp
index 91498d43..62d12986 100644
--- a/src/ui/dialog/key_generate/GenerateCardKeyDialog.cpp
+++ b/src/ui/dialog/key_generate/GenerateCardKeyDialog.cpp
@@ -47,13 +47,26 @@ GenerateCardKeyDialog::GenerateCardKeyDialog(int channel,
ui_(QSharedPointer<Ui_GenerateCardKeyDialog>::create()) {
ui_->setupUi(this);
- const auto min_date_time = QDateTime::currentDateTime().addDays(3);
- ui_->dateEdit->setMinimumDateTime(min_date_time);
+ ui_->nameLabel->setText(tr("Name"));
+ ui_->emailLabel->setText(tr("Email"));
+ ui_->commentLabel->setText(tr("Comment"));
+ ui_->expireLabel->setText(tr("Expire Date"));
+ ui_->nonExpireCheckBox->setText(tr("Non Expire"));
+ ui_->tipLabel->setText(
+ tr("Warning: This Operation will overwrite keys which exist on card!"));
+ ui_->generateButton->setText(tr("Generate"));
+
+ ui_->dateEdit->setMinimumDateTime(QDateTime::currentDateTime().addDays(3));
+ ui_->dateEdit->setMinimumDateTime(QDateTime::currentDateTime().addYears(2));
connect(ui_->generateButton, &QPushButton::clicked, this,
&GenerateCardKeyDialog::slot_generate_card_key);
+ connect(ui_->nonExpireCheckBox, &QCheckBox::stateChanged, this,
+ [=](int state) { ui_->dateEdit->setDisabled(state == Qt::Checked); });
+ setWindowTitle(tr("Card Key Generation"));
movePosition2CenterOfParent();
+ setModal(true);
this->show();
this->raise();
diff --git a/src/ui/dialog/key_generate/GenerateCardKeyDialog.h b/src/ui/dialog/key_generate/GenerateCardKeyDialog.h
index 93df5aaa..2062ac4d 100644
--- a/src/ui/dialog/key_generate/GenerateCardKeyDialog.h
+++ b/src/ui/dialog/key_generate/GenerateCardKeyDialog.h
@@ -34,6 +34,8 @@ class Ui_GenerateCardKeyDialog;
namespace GpgFrontend::UI {
class GenerateCardKeyDialog : public GeneralDialog {
+ Q_OBJECT
+
public:
/**
* @brief Construct a new Generate Card Key Dialog object
diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
index 90bd3537..73e7f4e5 100644
--- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
@@ -454,7 +454,7 @@ void KeyPairSubkeyTab::slot_refresh_key_info() {
void KeyPairSubkeyTab::slot_export_subkey() {
int ret = QMessageBox::question(
this, tr("Exporting Subkey"),
- "<h3>" + tr("You are about to export a private s_key.") + "</h3>\n" +
+ "<h3>" + tr("You are about to export a private subkey.") + "</h3>\n" +
tr("While subkeys are less critical than the primary key, "
"they should still be handled with care.") +
"<br /><br />" +
@@ -522,7 +522,7 @@ void KeyPairSubkeyTab::slot_delete_subkey() {
if (index == 0) {
QMessageBox::critical(
this, tr("Illegal Operation"),
- tr("Cannot delete the primary key or an invalid s_key."));
+ tr("Cannot delete the primary key or an invalid subkey."));
return;
}
@@ -571,7 +571,7 @@ void KeyPairSubkeyTab::slot_revoke_subkey() {
if (index == 0) {
QMessageBox::critical(
this, tr("Illegal Operation"),
- tr("Cannot revoke the primary key or an invalid s_key."));
+ tr("Cannot revoke the primary key or an invalid subkey."));
return;
}
@@ -589,7 +589,7 @@ void KeyPairSubkeyTab::slot_revoke_subkey() {
if (!res) {
QMessageBox::critical(
nullptr, tr("Revocation Failed"),
- tr("Failed to revoke the s_key. Please try again."));
+ tr("Failed to revoke the subkey. Please try again."));
} else {
QMessageBox::information(
nullptr, tr("Revocation Successful"),