aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/dialog')
-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
5 files changed, 65 insertions, 44 deletions
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"),