aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/ExportKeyPackageDialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widgets/ExportKeyPackageDialog.cpp')
-rw-r--r--src/ui/widgets/ExportKeyPackageDialog.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/ui/widgets/ExportKeyPackageDialog.cpp b/src/ui/widgets/ExportKeyPackageDialog.cpp
index 29d2922e..1317c1e6 100644
--- a/src/ui/widgets/ExportKeyPackageDialog.cpp
+++ b/src/ui/widgets/ExportKeyPackageDialog.cpp
@@ -37,42 +37,42 @@
GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
KeyIdArgsListPtr key_ids, QWidget* parent)
: QDialog(parent),
- ui(std::make_shared<Ui_exportKeyPackageDialog>()),
+ ui_(std::make_shared<Ui_exportKeyPackageDialog>()),
key_ids_(std::move(key_ids)),
- mt(rd()) {
- ui->setupUi(this);
+ mt_(rd_()) {
+ ui_->setupUi(this);
generate_key_package_name();
- connect(ui->gnerateNameButton, &QPushButton::clicked, this,
+ connect(ui_->gnerateNameButton, &QPushButton::clicked, this,
[=]() { generate_key_package_name(); });
- connect(ui->setOutputPathButton, &QPushButton::clicked, this, [=]() {
+ connect(ui_->setOutputPathButton, &QPushButton::clicked, this, [=]() {
auto file_name = QFileDialog::getSaveFileName(
- this, _("Export Key Package"), ui->nameValueLabel->text() + ".gfepack",
+ this, _("Export Key Package"), ui_->nameValueLabel->text() + ".gfepack",
QString(_("Key Package")) + " (*.gfepack);;All Files (*)");
- ui->outputPathLabel->setText(file_name);
+ ui_->outputPathLabel->setText(file_name);
});
- connect(ui->generatePassphraseButton, &QPushButton::clicked, this, [=]() {
+ connect(ui_->generatePassphraseButton, &QPushButton::clicked, this, [=]() {
passphrase_ = generate_passphrase(256);
auto file_name = QFileDialog::getSaveFileName(
this, _("Export Key Package Passphrase"),
- ui->nameValueLabel->text() + ".key",
+ ui_->nameValueLabel->text() + ".key",
QString(_("Key File")) + " (*.key);;All Files (*)");
- ui->passphraseValueLabel->setText(file_name);
+ ui_->passphraseValueLabel->setText(file_name);
write_buffer_to_file(file_name.toStdString(), passphrase_);
});
- connect(ui->button_box_, &QDialogButtonBox::accepted, this, [=]() {
- if (ui->outputPathLabel->text().isEmpty()) {
+ connect(ui_->button_box_, &QDialogButtonBox::accepted, this, [=]() {
+ if (ui_->outputPathLabel->text().isEmpty()) {
QMessageBox::critical(
this, _("Forbidden"),
_("Please select an output path before exporting."));
return;
}
- if (ui->passphraseValueLabel->text().isEmpty()) {
+ if (ui_->passphraseValueLabel->text().isEmpty()) {
QMessageBox::critical(
this, _("Forbidden"),
_("Please generate a password to protect your key before exporting, "
@@ -84,7 +84,7 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
auto key_id_exported = std::make_unique<KeyIdArgsList>();
auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids_);
for (const auto& key : *keys) {
- if (ui->noPublicKeyCheckBox->isChecked() && !key.IsPrivateKey()) {
+ if (ui_->noPublicKeyCheckBox->isChecked() && !key.IsPrivateKey()) {
continue;
}
key_id_exported->push_back(key.GetId());
@@ -93,7 +93,7 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
ByteArrayPtr key_export_data = nullptr;
if (!GpgKeyImportExporter::GetInstance().ExportKeys(
key_ids_, key_export_data,
- ui->includeSecretKeyCheckBox->isChecked())) {
+ ui_->includeSecretKeyCheckBox->isChecked())) {
QMessageBox::critical(this, _("Error"), _("Export Key(s) Failed."));
this->close();
return;
@@ -108,7 +108,7 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
QAESEncryption::Padding::ISO);
auto encoded = encryption.encode(data, hash_key);
- write_buffer_to_file(ui->outputPathLabel->text().toStdString(),
+ write_buffer_to_file(ui_->outputPathLabel->text().toStdString(),
encoded.toStdString());
QMessageBox::information(
@@ -125,22 +125,22 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
"</b>");
});
- connect(ui->button_box_, &QDialogButtonBox::rejected, this,
+ connect(ui_->button_box_, &QDialogButtonBox::rejected, this,
[=]() { this->close(); });
- ui->nameLabel->setText(_("Key Package Name"));
- ui->selectOutputPathLabel->setText(_("Output Path"));
- ui->passphraseLabel->setText(_("Passphrase"));
- ui->tipsLabel->setText(
+ ui_->nameLabel->setText(_("Key Package Name"));
+ ui_->selectOutputPathLabel->setText(_("Output Path"));
+ ui_->passphraseLabel->setText(_("Passphrase"));
+ ui_->tipsLabel->setText(
_("Tips: You can use Key Package to safely and conveniently transfer "
"your public and private keys between devices."));
- ui->generatePassphraseButton->setText(_("Generate and Save Passphrase"));
- ui->gnerateNameButton->setText(_("Generate Key Package Name"));
- ui->setOutputPathButton->setText(_("Select Output Path"));
+ ui_->generatePassphraseButton->setText(_("Generate and Save Passphrase"));
+ ui_->gnerateNameButton->setText(_("Generate Key Package Name"));
+ ui_->setOutputPathButton->setText(_("Select Output Path"));
- ui->includeSecretKeyCheckBox->setText(
+ ui_->includeSecretKeyCheckBox->setText(
_("Include secret key (Think twice before acting)"));
- ui->noPublicKeyCheckBox->setText(
+ ui_->noPublicKeyCheckBox->setText(
_("Exclude keys that do not have a private key"));
setAttribute(Qt::WA_DeleteOnClose);
@@ -158,7 +158,7 @@ std::string GpgFrontend::UI::ExportKeyPackageDialog::generate_passphrase(
tmp_str.reserve(len);
for (int i = 0; i < len; ++i) {
- tmp_str += alphanum[dist(mt) % (sizeof(alphanum) - 1)];
+ tmp_str += alphanum[dist(mt_) % (sizeof(alphanum) - 1)];
}
return tmp_str;
@@ -166,8 +166,8 @@ std::string GpgFrontend::UI::ExportKeyPackageDialog::generate_passphrase(
void GpgFrontend::UI::ExportKeyPackageDialog::generate_key_package_name() {
std::uniform_int_distribution<int> dist(999, 99999);
- auto file_string = boost::format("KeyPackage_%1%") % dist(mt);
- ui->nameValueLabel->setText(file_string.str().c_str());
- ui->outputPathLabel->clear();
- ui->passphraseValueLabel->clear();
+ auto file_string = boost::format("KeyPackage_%1%") % dist(mt_);
+ ui_->nameValueLabel->setText(file_string.str().c_str());
+ ui_->outputPathLabel->clear();
+ ui_->passphraseValueLabel->clear();
}