aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2025-02-02 20:03:21 +0000
committersaturneric <[email protected]>2025-02-02 20:03:21 +0000
commit39387a78e2e056fa946f92ec7509ef73ad3ecfa3 (patch)
treeebb8e2376c8a898b13dc862c2b5a8d3c07b6710b /src/ui
parentrefactor: rewrite subkey generate dialog and fix some issues discovered (diff)
downloadGpgFrontend-39387a78e2e056fa946f92ec7509ef73ad3ecfa3.tar.gz
GpgFrontend-39387a78e2e056fa946f92ec7509ef73ad3ecfa3.zip
refactor: make some function names shorter
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/SignersPicker.cpp8
-rw-r--r--src/ui/dialog/key_generate/KeyGenerateDialog.cpp52
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp19
-rw-r--r--src/ui/dialog/keypair_details/KeyPairDetailTab.cpp16
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp29
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp2
-rw-r--r--src/ui/main_window/MainWindowGpgOperaFunction.cpp15
7 files changed, 63 insertions, 78 deletions
diff --git a/src/ui/dialog/SignersPicker.cpp b/src/ui/dialog/SignersPicker.cpp
index 21996f5b..61a31606 100644
--- a/src/ui/dialog/SignersPicker.cpp
+++ b/src/ui/dialog/SignersPicker.cpp
@@ -49,11 +49,9 @@ SignersPicker::SignersPicker(int channel, QWidget* parent)
GpgKeyTableColumn::kNAME | GpgKeyTableColumn::kEMAIL_ADDRESS |
GpgKeyTableColumn::kKEY_ID | GpgKeyTableColumn::kUSAGE,
this);
- key_list_->AddListGroupTab(tr("Signers"), "signers",
- GpgKeyTableDisplayMode::kPRIVATE_KEY,
- [](const GpgKey& key) -> bool {
- return key.IsHasActualSigningCapability();
- });
+ key_list_->AddListGroupTab(
+ tr("Signers"), "signers", GpgKeyTableDisplayMode::kPRIVATE_KEY,
+ [](const GpgKey& key) -> bool { return key.IsHasActualSignCap(); });
key_list_->SlotRefresh();
auto* vbox2 = new QVBoxLayout();
diff --git a/src/ui/dialog/key_generate/KeyGenerateDialog.cpp b/src/ui/dialog/key_generate/KeyGenerateDialog.cpp
index 0251df8b..5a84700c 100644
--- a/src/ui/dialog/key_generate/KeyGenerateDialog.cpp
+++ b/src/ui/dialog/key_generate/KeyGenerateDialog.cpp
@@ -221,20 +221,20 @@ void KeyGenerateDialog::refresh_widgets_state() {
ui_->pEncrCheckBox->blockSignals(true);
ui_->pEncrCheckBox->setCheckState(
- gen_key_info_->IsAllowEncryption() ? Qt::Checked : Qt::Unchecked);
- ui_->pEncrCheckBox->setEnabled(gen_key_info_->IsAllowChangeEncryption());
+ gen_key_info_->IsAllowEncr() ? Qt::Checked : Qt::Unchecked);
+ ui_->pEncrCheckBox->setEnabled(gen_key_info_->IsAllowModifyEncr());
ui_->pEncrCheckBox->blockSignals(false);
ui_->pSignCheckBox->blockSignals(true);
ui_->pSignCheckBox->setCheckState(
- gen_key_info_->IsAllowSigning() ? Qt::Checked : Qt::Unchecked);
- ui_->pSignCheckBox->setEnabled(gen_key_info_->IsAllowChangeSigning());
+ gen_key_info_->IsAllowSign() ? Qt::Checked : Qt::Unchecked);
+ ui_->pSignCheckBox->setEnabled(gen_key_info_->IsAllowModifySign());
ui_->pSignCheckBox->blockSignals(false);
ui_->pAuthCheckBox->blockSignals(true);
ui_->pAuthCheckBox->setCheckState(
- gen_key_info_->IsAllowAuthentication() ? Qt::Checked : Qt::Unchecked);
- ui_->pAuthCheckBox->setEnabled(gen_key_info_->IsAllowChangeAuthentication());
+ gen_key_info_->IsAllowAuth() ? Qt::Checked : Qt::Unchecked);
+ ui_->pAuthCheckBox->setEnabled(gen_key_info_->IsAllowModifyAuth());
ui_->pAuthCheckBox->blockSignals(false);
ui_->noPassphraseCheckBox->setEnabled(gen_key_info_->IsAllowNoPassPhrase());
@@ -303,21 +303,20 @@ void KeyGenerateDialog::refresh_widgets_state() {
ui_->sEncrCheckBox->blockSignals(true);
ui_->sEncrCheckBox->setCheckState(
- gen_subkey_info_->IsAllowEncryption() ? Qt::Checked : Qt::Unchecked);
- ui_->sEncrCheckBox->setEnabled(gen_subkey_info_->IsAllowChangeEncryption());
+ gen_subkey_info_->IsAllowEncr() ? Qt::Checked : Qt::Unchecked);
+ ui_->sEncrCheckBox->setEnabled(gen_subkey_info_->IsAllowModifyEncr());
ui_->sEncrCheckBox->blockSignals(false);
ui_->sSignCheckBox->blockSignals(true);
ui_->sSignCheckBox->setCheckState(
- gen_subkey_info_->IsAllowSigning() ? Qt::Checked : Qt::Unchecked);
- ui_->sSignCheckBox->setEnabled(gen_subkey_info_->IsAllowChangeSigning());
+ gen_subkey_info_->IsAllowSign() ? Qt::Checked : Qt::Unchecked);
+ ui_->sSignCheckBox->setEnabled(gen_subkey_info_->IsAllowModifySign());
ui_->sSignCheckBox->blockSignals(false);
ui_->sAuthCheckBox->blockSignals(true);
ui_->sAuthCheckBox->setCheckState(
- gen_subkey_info_->IsAllowAuthentication() ? Qt::Checked : Qt::Unchecked);
- ui_->sAuthCheckBox->setEnabled(
- gen_subkey_info_->IsAllowChangeAuthentication());
+ gen_subkey_info_->IsAllowAuth() ? Qt::Checked : Qt::Unchecked);
+ ui_->sAuthCheckBox->setEnabled(gen_subkey_info_->IsAllowModifyAuth());
ui_->sAuthCheckBox->blockSignals(false);
ui_->sExpireDateTimeEdit->blockSignals(true);
@@ -354,30 +353,27 @@ void KeyGenerateDialog::set_signal_slot_config() {
refresh_widgets_state();
});
- connect(ui_->pEncrCheckBox, &QCheckBox::stateChanged, this,
- [this](int state) {
- gen_key_info_->SetAllowEncryption(state == Qt::Checked);
- });
- connect(ui_->pSignCheckBox, &QCheckBox::stateChanged, this,
- [this](int state) {
- gen_key_info_->SetAllowSigning(state == Qt::Checked);
- });
- connect(ui_->pAuthCheckBox, &QCheckBox::stateChanged, this,
- [this](int state) {
- gen_key_info_->SetAllowAuthentication(state == Qt::Checked);
- });
+ connect(
+ ui_->pEncrCheckBox, &QCheckBox::stateChanged, this,
+ [this](int state) { gen_key_info_->SetAllowEncr(state == Qt::Checked); });
+ connect(
+ ui_->pSignCheckBox, &QCheckBox::stateChanged, this,
+ [this](int state) { gen_key_info_->SetAllowSign(state == Qt::Checked); });
+ connect(
+ ui_->pAuthCheckBox, &QCheckBox::stateChanged, this,
+ [this](int state) { gen_key_info_->SetAllowAuth(state == Qt::Checked); });
connect(ui_->sEncrCheckBox, &QCheckBox::stateChanged, this,
[this](int state) {
- gen_subkey_info_->SetAllowEncryption(state == Qt::Checked);
+ gen_subkey_info_->SetAllowEncr(state == Qt::Checked);
});
connect(ui_->sSignCheckBox, &QCheckBox::stateChanged, this,
[this](int state) {
- gen_subkey_info_->SetAllowSigning(state == Qt::Checked);
+ gen_subkey_info_->SetAllowSign(state == Qt::Checked);
});
connect(ui_->sAuthCheckBox, &QCheckBox::stateChanged, this,
[this](int state) {
- gen_subkey_info_->SetAllowAuthentication(state == Qt::Checked);
+ gen_subkey_info_->SetAllowAuth(state == Qt::Checked);
});
connect(ui_->noPassphraseCheckBox, &QCheckBox::stateChanged, this,
diff --git a/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
index 0c4d30c4..c284290f 100644
--- a/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
@@ -98,13 +98,13 @@ void SubkeyGenerateDialog::set_signal_slot_config() {
});
connect(ui_->encrCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
- gen_subkey_info_->SetAllowEncryption(state == Qt::Checked);
+ gen_subkey_info_->SetAllowEncr(state == Qt::Checked);
});
connect(ui_->signCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
- gen_subkey_info_->SetAllowSigning(state == Qt::Checked);
+ gen_subkey_info_->SetAllowSign(state == Qt::Checked);
});
connect(ui_->authCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
- gen_subkey_info_->SetAllowAuthentication(state == Qt::Checked);
+ gen_subkey_info_->SetAllowAuth(state == Qt::Checked);
});
connect(ui_->algoComboBox, &QComboBox::currentTextChanged, this,
@@ -145,19 +145,18 @@ void SubkeyGenerateDialog::refresh_widgets_state() {
ui_->keyLengthComboBox->blockSignals(false);
ui_->encrCheckBox->blockSignals(true);
- ui_->encrCheckBox->setChecked(gen_subkey_info_->IsAllowEncryption());
- ui_->encrCheckBox->setEnabled(gen_subkey_info_->IsAllowChangeEncryption());
+ ui_->encrCheckBox->setChecked(gen_subkey_info_->IsAllowEncr());
+ ui_->encrCheckBox->setEnabled(gen_subkey_info_->IsAllowModifyEncr());
ui_->encrCheckBox->blockSignals(false);
ui_->signCheckBox->blockSignals(true);
- ui_->signCheckBox->setChecked(gen_subkey_info_->IsAllowSigning());
- ui_->signCheckBox->setEnabled(gen_subkey_info_->IsAllowChangeSigning());
+ ui_->signCheckBox->setChecked(gen_subkey_info_->IsAllowSign());
+ ui_->signCheckBox->setEnabled(gen_subkey_info_->IsAllowModifySign());
ui_->signCheckBox->blockSignals(false);
ui_->authCheckBox->blockSignals(true);
- ui_->authCheckBox->setChecked(gen_subkey_info_->IsAllowAuthentication());
- ui_->authCheckBox->setEnabled(
- gen_subkey_info_->IsAllowChangeAuthentication());
+ ui_->authCheckBox->setChecked(gen_subkey_info_->IsAllowAuth());
+ ui_->authCheckBox->setEnabled(gen_subkey_info_->IsAllowModifyAuth());
ui_->authCheckBox->blockSignals(false);
ui_->nonPassphraseCheckBox->setEnabled(
diff --git a/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
index 8450083f..88c7fbf5 100644
--- a/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
@@ -215,28 +215,28 @@ void KeyPairDetailTab::slot_refresh_key_info() {
QString buffer;
QTextStream usage_steam(&buffer);
- if (key_.IsHasCertificationCapability()) {
+ if (key_.IsHasCertCap()) {
usage_steam << tr("Certificate") << " ";
}
- if (key_.IsHasEncryptionCapability()) usage_steam << tr("Encrypt") << " ";
- if (key_.IsHasSigningCapability()) usage_steam << tr("Sign") << " ";
- if (key_.IsHasAuthenticationCapability()) usage_steam << tr("Auth") << " ";
+ if (key_.IsHasEncrCap()) usage_steam << tr("Encrypt") << " ";
+ if (key_.IsHasSignCap()) usage_steam << tr("Sign") << " ";
+ if (key_.IsHasAuthCap()) usage_steam << tr("Auth") << " ";
usage_var_label_->setText(usage_steam.readAll());
QString buffer_2;
QTextStream actual_usage_steam(&buffer_2);
- if (key_.IsHasActualCertificationCapability()) {
+ if (key_.IsHasActualCertCap()) {
actual_usage_steam << tr("Certificate") << " ";
}
- if (key_.IsHasActualEncryptionCapability()) {
+ if (key_.IsHasActualEncrCap()) {
actual_usage_steam << tr("Encrypt") << " ";
}
- if (key_.IsHasActualSigningCapability()) {
+ if (key_.IsHasActualSignCap()) {
actual_usage_steam << tr("Sign") << " ";
}
- if (key_.IsHasActualAuthenticationCapability()) {
+ if (key_.IsHasActualAuthCap()) {
actual_usage_steam << tr("Auth") << " ";
}
diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
index b37f610f..548b3473 100644
--- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
@@ -205,9 +205,8 @@ void KeyPairSubkeyTab::slot_refresh_subkey_list() {
tmp0->setTextAlignment(Qt::AlignCenter);
subkey_list_->setItem(row, 0, tmp0);
- auto* tmp1 = new QTableWidgetItem(subkey.IsHasCertificationCapability()
- ? tr("Primary Key")
- : tr("Subkey"));
+ auto* tmp1 = new QTableWidgetItem(subkey.IsHasCertCap() ? tr("Primary Key")
+ : tr("Subkey"));
tmp1->setTextAlignment(Qt::AlignCenter);
subkey_list_->setItem(row, 1, tmp1);
@@ -307,12 +306,12 @@ void KeyPairSubkeyTab::slot_refresh_subkey_detail() {
QString buffer;
QTextStream usage_steam(&buffer);
- if (subkey.IsHasCertificationCapability()) {
+ if (subkey.IsHasCertCap()) {
usage_steam << tr("Certificate") << " ";
}
- if (subkey.IsHasEncryptionCapability()) usage_steam << tr("Encrypt") << " ";
- if (subkey.IsHasSigningCapability()) usage_steam << tr("Sign") << " ";
- if (subkey.IsHasAuthenticationCapability()) usage_steam << tr("Auth") << " ";
+ if (subkey.IsHasEncrCap()) usage_steam << tr("Encrypt") << " ";
+ if (subkey.IsHasSignCap()) usage_steam << tr("Sign") << " ";
+ if (subkey.IsHasAuthCap()) usage_steam << tr("Auth") << " ";
usage_var_label_->setText(usage_steam.readAll());
@@ -348,15 +347,13 @@ void KeyPairSubkeyTab::slot_refresh_subkey_detail() {
fingerprint_var_label_->setText(BeautifyFingerprint(subkey.GetFingerprint()));
fingerprint_var_label_->setWordWrap(true); // for x448 and ed448
- export_subkey_button_->setText(subkey.IsHasCertificationCapability()
- ? tr("Export Primary Key")
- : tr("Export Subkey"));
- export_subkey_button_->setDisabled(!key_.IsPrivateKey() ||
- subkey.IsHasCertificationCapability() ||
- !subkey.IsSecretKey());
+ export_subkey_button_->setText(
+ subkey.IsHasCertCap() ? tr("Export Primary Key") : tr("Export Subkey"));
+ export_subkey_button_->setDisabled(
+ !key_.IsPrivateKey() || subkey.IsHasCertCap() || !subkey.IsSecretKey());
- key_type_var_label_->setText(
- subkey.IsHasCertificationCapability() ? tr("Primary Key") : tr("Subkey"));
+ key_type_var_label_->setText(subkey.IsHasCertCap() ? tr("Primary Key")
+ : tr("Subkey"));
revoke_var_label_->setText(subkey.IsRevoked() ? tr("Yes") : tr("No"));
if (!subkey.IsRevoked()) {
@@ -406,7 +403,7 @@ void KeyPairSubkeyTab::contextMenuEvent(QContextMenuEvent* event) {
if (key_.IsHasMasterKey() && !subkey_list_->selectedItems().isEmpty()) {
const auto& subkey = get_selected_subkey();
- if (subkey.IsHasCertificationCapability()) return;
+ if (subkey.IsHasCertCap()) return;
export_subkey_act_->setDisabled(!subkey.IsSecretKey());
edit_subkey_act_->setDisabled(!subkey.IsSecretKey());
diff --git a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
index 35f4e57f..4b9d4726 100644
--- a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
@@ -52,7 +52,7 @@ KeyUIDSignDialog::KeyUIDSignDialog(int channel, const GpgKey& key,
m_key_list_->AddListGroupTab(
tr("Signers"), "signers", GpgKeyTableDisplayMode::kPRIVATE_KEY,
[key_id](const GpgKey& key) -> bool {
- return !(key.IsDisabled() || !key.IsHasCertificationCapability() ||
+ return !(key.IsDisabled() || !key.IsHasCertCap() ||
!key.IsHasMasterKey() || key.IsExpired() || key.IsRevoked() ||
key_id == key.GetId());
});
diff --git a/src/ui/main_window/MainWindowGpgOperaFunction.cpp b/src/ui/main_window/MainWindowGpgOperaFunction.cpp
index 8395c8f8..984acb2f 100644
--- a/src/ui/main_window/MainWindowGpgOperaFunction.cpp
+++ b/src/ui/main_window/MainWindowGpgOperaFunction.cpp
@@ -56,8 +56,7 @@ auto MainWindow::encrypt_operation_key_validate(
contexts->keys = {};
} else {
contexts->keys = check_keys_helper(
- key_ids,
- [](const GpgKey& key) { return key.IsHasActualEncryptionCapability(); },
+ key_ids, [](const GpgKey& key) { return key.IsHasActualEncrCap(); },
tr("The selected keypair cannot be used for encryption."));
if (contexts->keys.empty()) return false;
}
@@ -205,8 +204,7 @@ void MainWindow::SlotSign() {
auto key_ids = m_key_list_->GetChecked();
contexts->keys = check_keys_helper(
- key_ids,
- [](const GpgKey& key) { return key.IsHasActualSigningCapability(); },
+ key_ids, [](const GpgKey& key) { return key.IsHasActualSignCap(); },
tr("The selected key contains a key that does not actually have a "
"sign usage."));
if (contexts->keys.empty()) return;
@@ -259,8 +257,7 @@ void MainWindow::SlotEncryptSign() {
auto key_ids = m_key_list_->GetChecked();
contexts->keys = check_keys_helper(
- key_ids,
- [](const GpgKey& key) { return key.IsHasActualEncryptionCapability(); },
+ key_ids, [](const GpgKey& key) { return key.IsHasActualEncrCap(); },
tr("The selected keypair cannot be used for encryption."));
if (contexts->keys.empty()) return;
@@ -375,8 +372,7 @@ void MainWindow::SlotFileSign(const QStringList& paths) {
auto key_ids = m_key_list_->GetChecked();
contexts->keys = check_keys_helper(
- key_ids,
- [](const GpgKey& key) { return key.IsHasActualSigningCapability(); },
+ key_ids, [](const GpgKey& key) { return key.IsHasActualSignCap(); },
tr("The selected key contains a key that does not actually have a "
"sign usage."));
if (contexts->keys.empty()) return;
@@ -459,8 +455,7 @@ void MainWindow::SlotFileEncryptSign(const QStringList& paths) {
auto key_ids = m_key_list_->GetChecked();
contexts->keys = check_keys_helper(
- key_ids,
- [](const GpgKey& key) { return key.IsHasActualEncryptionCapability(); },
+ key_ids, [](const GpgKey& key) { return key.IsHasActualEncrCap(); },
tr("The selected keypair cannot be used for encryption."));
if (contexts->keys.empty()) return;