From daaa83549d42395161e34a40e18c3615801b1501 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Sun, 29 Aug 2021 18:49:58 +0800 Subject: Start to rewrite gpg core. --- src/ui/keypair_details/KeyNewUIDDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/keypair_details/KeyNewUIDDialog.cpp') diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/keypair_details/KeyNewUIDDialog.cpp index e12af750..7c6e1ca5 100644 --- a/src/ui/keypair_details/KeyNewUIDDialog.cpp +++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp @@ -24,7 +24,7 @@ #include "ui/keypair_details/KeyNewUIDDialog.h" -KeyNewUIDDialog::KeyNewUIDDialog(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent) : +KeyNewUIDDialog::KeyNewUIDDialog(GpgFrontend::GpgContext *ctx, const GpgKey &key, QWidget *parent) : mCtx(ctx), mKey(key), QDialog(parent) { name = new QLineEdit(); -- cgit v1.2.3 From 3c65d087eeee687ac01af2e80f3dd538f9a2c230 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Sat, 2 Oct 2021 22:08:50 +0800 Subject: UI Framework Modified. --- src/ui/keypair_details/KeyNewUIDDialog.cpp | 134 ++++++++++++++--------------- 1 file changed, 66 insertions(+), 68 deletions(-) (limited to 'src/ui/keypair_details/KeyNewUIDDialog.cpp') diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/keypair_details/KeyNewUIDDialog.cpp index 7c6e1ca5..a22250c1 100644 --- a/src/ui/keypair_details/KeyNewUIDDialog.cpp +++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp @@ -24,79 +24,77 @@ #include "ui/keypair_details/KeyNewUIDDialog.h" -KeyNewUIDDialog::KeyNewUIDDialog(GpgFrontend::GpgContext *ctx, const GpgKey &key, QWidget *parent) : - mCtx(ctx), mKey(key), QDialog(parent) { - - name = new QLineEdit(); - name->setMinimumWidth(240); - email = new QLineEdit(); - email->setMinimumWidth(240); - comment = new QLineEdit(); - comment->setMinimumWidth(240); - createButton = new QPushButton("Create"); - errorLabel = new QLabel(); - - auto gridLayout = new QGridLayout(); - gridLayout->addWidget(new QLabel(tr("Name")), 0, 0); - gridLayout->addWidget(new QLabel(tr("Email")), 1, 0); - gridLayout->addWidget(new QLabel(tr("Comment")), 2, 0); - - - gridLayout->addWidget(name, 0 ,1); - gridLayout->addWidget(email, 1 ,1); - gridLayout->addWidget(comment, 2 ,1); - - gridLayout->addWidget(createButton, 3, 0, 1, 2); - gridLayout->addWidget(errorLabel, 4, 0, 1, 2); - - connect(createButton, SIGNAL(clicked(bool)), this, SLOT(slotCreateNewUID())); - - this->setLayout(gridLayout); - this->setWindowTitle(tr("Create New UID")); - this->setAttribute(Qt::WA_DeleteOnClose, true); - this->setModal(true); +#include "gpg/function/GpgKeyGetter.h" +#include "gpg/function/UidOperator.h" + +namespace GpgFrontend::UI { +KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) + : QDialog(parent), mKey(GpgKeyGetter::GetInstance().GetKey(key_id)) { + name = new QLineEdit(); + name->setMinimumWidth(240); + email = new QLineEdit(); + email->setMinimumWidth(240); + comment = new QLineEdit(); + comment->setMinimumWidth(240); + createButton = new QPushButton("Create"); + errorLabel = new QLabel(); + + auto gridLayout = new QGridLayout(); + gridLayout->addWidget(new QLabel(tr("Name")), 0, 0); + gridLayout->addWidget(new QLabel(tr("Email")), 1, 0); + gridLayout->addWidget(new QLabel(tr("Comment")), 2, 0); + + gridLayout->addWidget(name, 0, 1); + gridLayout->addWidget(email, 1, 1); + gridLayout->addWidget(comment, 2, 1); + + gridLayout->addWidget(createButton, 3, 0, 1, 2); + gridLayout->addWidget(errorLabel, 4, 0, 1, 2); + + connect(createButton, SIGNAL(clicked(bool)), this, SLOT(slotCreateNewUID())); + + this->setLayout(gridLayout); + this->setWindowTitle(tr("Create New UID")); + this->setAttribute(Qt::WA_DeleteOnClose, true); + this->setModal(true); } void KeyNewUIDDialog::slotCreateNewUID() { - - QString errorString = ""; - + QString errorString = ""; + + /** + * check for errors in keygen dialog input + */ + if ((name->text()).size() < 5) { + errorString.append(tr(" Name must contain at least five characters. \n")); + } + if (email->text().isEmpty() || !check_email_address(email->text())) { + errorString.append(tr(" Please give a email address. \n")); + } + + if (errorString.isEmpty()) { + if (UidOperator::GetInstance().addUID(mKey, name->text().toStdString(), + comment->text().toStdString(), + email->text().toStdString())) + emit finished(1); + else + emit finished(-1); + + } else { /** - * check for errors in keygen dialog input + * create error message */ - if ((name->text()).size() < 5) { - errorString.append(tr(" Name must contain at least five characters. \n")); - } if(email->text().isEmpty() || !check_email_address(email->text())) { - errorString.append(tr(" Please give a email address. \n")); - } - - if (errorString.isEmpty()) { - GpgUID uid; - uid.name = name->text(); - uid.email = email->text(); - uid.comment = comment->text(); - - if(mCtx->addUID(mKey, uid)) { - emit finished(1); - - } else { - emit finished(-1); - } - - } else { - /** - * create error message - */ - errorLabel->setAutoFillBackground(true); - QPalette error = errorLabel->palette(); - error.setColor(QPalette::Window, "#ff8080"); - errorLabel->setPalette(error); - errorLabel->setText(errorString); - - this->show(); - } + errorLabel->setAutoFillBackground(true); + QPalette error = errorLabel->palette(); + error.setColor(QPalette::Window, "#ff8080"); + errorLabel->setPalette(error); + errorLabel->setText(errorString); + + this->show(); + } } -bool KeyNewUIDDialog::check_email_address(const QString &str) { - return re_email.match(str).hasMatch(); +bool KeyNewUIDDialog::check_email_address(const QString& str) { + return re_email.match(str).hasMatch(); } +} // namespace GpgFrontend::UI -- cgit v1.2.3 From d7e953b25a28a846b0aafa7003f33432b7e107f5 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Mon, 29 Nov 2021 10:57:43 +0800 Subject: Fix Known Bugs. 1. Import Keys. 2. Import Keys From Server. 3. UID Management. --- src/ui/keypair_details/KeyNewUIDDialog.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/ui/keypair_details/KeyNewUIDDialog.cpp') diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/keypair_details/KeyNewUIDDialog.cpp index a22250c1..00401231 100644 --- a/src/ui/keypair_details/KeyNewUIDDialog.cpp +++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp @@ -26,6 +26,7 @@ #include "gpg/function/GpgKeyGetter.h" #include "gpg/function/UidOperator.h" +#include "ui/SignalStation.h" namespace GpgFrontend::UI { KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) @@ -49,7 +50,10 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) gridLayout->addWidget(comment, 2, 1); gridLayout->addWidget(createButton, 3, 0, 1, 2); - gridLayout->addWidget(errorLabel, 4, 0, 1, 2); + gridLayout->addWidget( + new QLabel(tr("Notice: The New UID Created will be set as Primary.")), 4, + 0, 1, 2); + gridLayout->addWidget(errorLabel, 5, 0, 1, 2); connect(createButton, SIGNAL(clicked(bool)), this, SLOT(slotCreateNewUID())); @@ -57,6 +61,9 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) this->setWindowTitle(tr("Create New UID")); this->setAttribute(Qt::WA_DeleteOnClose, true); this->setModal(true); + + connect(this, SIGNAL(signalUIDCreated()), SignalStation::GetInstance(), + SIGNAL(KeyDatabaseRefresh())); } void KeyNewUIDDialog::slotCreateNewUID() { @@ -75,9 +82,10 @@ void KeyNewUIDDialog::slotCreateNewUID() { if (errorString.isEmpty()) { if (UidOperator::GetInstance().addUID(mKey, name->text().toStdString(), comment->text().toStdString(), - email->text().toStdString())) + email->text().toStdString())) { emit finished(1); - else + emit signalUIDCreated(); + } else emit finished(-1); } else { -- cgit v1.2.3 From 1ae8663decb3163b92d32b80cefb46eb678a5af6 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Thu, 2 Dec 2021 01:25:46 +0800 Subject: Add i18n Support 1. Remove Qt Linguist. 2. Add GNU gettext libraries. 3. Modified source codes to meet with i18n support. --- src/ui/keypair_details/KeyNewUIDDialog.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/ui/keypair_details/KeyNewUIDDialog.cpp') diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/keypair_details/KeyNewUIDDialog.cpp index 00401231..809a05f8 100644 --- a/src/ui/keypair_details/KeyNewUIDDialog.cpp +++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -41,9 +41,9 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) errorLabel = new QLabel(); auto gridLayout = new QGridLayout(); - gridLayout->addWidget(new QLabel(tr("Name")), 0, 0); - gridLayout->addWidget(new QLabel(tr("Email")), 1, 0); - gridLayout->addWidget(new QLabel(tr("Comment")), 2, 0); + gridLayout->addWidget(new QLabel(_("Name")), 0, 0); + gridLayout->addWidget(new QLabel(_("Email")), 1, 0); + gridLayout->addWidget(new QLabel(_("Comment")), 2, 0); gridLayout->addWidget(name, 0, 1); gridLayout->addWidget(email, 1, 1); @@ -51,14 +51,14 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) gridLayout->addWidget(createButton, 3, 0, 1, 2); gridLayout->addWidget( - new QLabel(tr("Notice: The New UID Created will be set as Primary.")), 4, + new QLabel(_("Notice: The New UID Created will be set as Primary.")), 4, 0, 1, 2); gridLayout->addWidget(errorLabel, 5, 0, 1, 2); connect(createButton, SIGNAL(clicked(bool)), this, SLOT(slotCreateNewUID())); this->setLayout(gridLayout); - this->setWindowTitle(tr("Create New UID")); + this->setWindowTitle(_("Create New UID")); this->setAttribute(Qt::WA_DeleteOnClose, true); this->setModal(true); @@ -67,19 +67,20 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) } void KeyNewUIDDialog::slotCreateNewUID() { - QString errorString = ""; + std::stringstream error_stream; /** * check for errors in keygen dialog input */ if ((name->text()).size() < 5) { - errorString.append(tr(" Name must contain at least five characters. \n")); + error_stream << " " << _("Name must contain at least five characters.") + << std::endl; } if (email->text().isEmpty() || !check_email_address(email->text())) { - errorString.append(tr(" Please give a email address. \n")); + error_stream << " " << _("Please give a email address.") << std::endl; } - - if (errorString.isEmpty()) { + auto error_string = error_stream.str(); + if (error_string.empty()) { if (UidOperator::GetInstance().addUID(mKey, name->text().toStdString(), comment->text().toStdString(), email->text().toStdString())) { @@ -96,7 +97,7 @@ void KeyNewUIDDialog::slotCreateNewUID() { QPalette error = errorLabel->palette(); error.setColor(QPalette::Window, "#ff8080"); errorLabel->setPalette(error); - errorLabel->setText(errorString); + errorLabel->setText(error_string.c_str()); this->show(); } -- cgit v1.2.3