aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-01-23 07:26:15 +0000
committerSaturneric <[email protected]>2022-01-23 07:26:15 +0000
commit6618e827ec8aba22dee519aab77fec345afdb063 (patch)
tree037a12bc5bb909a56001978de0fdb56d117d397c /src
parent<refactor>(ui): tidy up codes and comments. (diff)
downloadGpgFrontend-6618e827ec8aba22dee519aab77fec345afdb063.tar.gz
GpgFrontend-6618e827ec8aba22dee519aab77fec345afdb063.zip
<refactor>(ui): tidy up codes and comments.
1. tidy up smtp.
Diffstat (limited to '')
-rw-r--r--src/ui/UserInterfaceUtils.cpp4
-rw-r--r--src/ui/smtp/EmailListEditor.cpp56
-rw-r--r--src/ui/smtp/EmailListEditor.h37
-rw-r--r--src/ui/smtp/IMAPFolder.h28
-rw-r--r--src/ui/smtp/ReceiveMailDialog.cpp6
-rw-r--r--src/ui/smtp/ReceiveMailDialog.h25
-rw-r--r--src/ui/smtp/RecipientsPicker.cpp2
-rw-r--r--src/ui/smtp/RecipientsPicker.h19
-rw-r--r--src/ui/smtp/SendMailDialog.cpp176
-rw-r--r--src/ui/smtp/SendMailDialog.h90
-rw-r--r--src/ui/smtp/SenderPicker.cpp2
-rw-r--r--src/ui/smtp/SenderPicker.h19
12 files changed, 305 insertions, 159 deletions
diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp
index be3921a2..b72ee925 100644
--- a/src/ui/UserInterfaceUtils.cpp
+++ b/src/ui/UserInterfaceUtils.cpp
@@ -56,8 +56,8 @@ void send_an_email(QWidget* parent, InfoBoardWidget* info_board,
}
if (smtp_enabled) {
auto dialog = new SendMailDialog(text, parent);
- dialog->setContentEncryption(false);
- dialog->setAttachSignature(attach_signature);
+ dialog->SetContentEncryption(false);
+ dialog->SetAttachSignature(attach_signature);
dialog->show();
} else {
QMessageBox::warning(nullptr, _("Function Disabled"),
diff --git a/src/ui/smtp/EmailListEditor.cpp b/src/ui/smtp/EmailListEditor.cpp
index 4d46ec77..b5147115 100644
--- a/src/ui/smtp/EmailListEditor.cpp
+++ b/src/ui/smtp/EmailListEditor.cpp
@@ -32,8 +32,8 @@
GpgFrontend::UI::EmailListEditor::EmailListEditor(const QString& email_list,
QWidget* parent)
- : QDialog(parent), ui(std::make_shared<Ui_EmailListEditorDialog>()) {
- ui->setupUi(this);
+ : QDialog(parent), ui_(std::make_shared<Ui_EmailListEditorDialog>()) {
+ ui_->setupUi(this);
QStringList email_string_list = email_list.split(';');
@@ -42,53 +42,53 @@ GpgFrontend::UI::EmailListEditor::EmailListEditor(const QString& email_list,
auto _recipient = recipient.trimmed();
if (check_email_address(_recipient)) {
auto item = new QListWidgetItem(_recipient);
- ui->emaillistWidget->addItem(item);
+ ui_->emaillistWidget->addItem(item);
item->setFlags(item->flags() | Qt::ItemIsEditable);
}
}
}
- connect(ui->addEmailAddressButton, &QPushButton::clicked, this, [=]() {
+ connect(ui_->addEmailAddressButton, &QPushButton::clicked, this, [=]() {
auto item = new QListWidgetItem("new email address");
- ui->emaillistWidget->addItem(item);
+ ui_->emaillistWidget->addItem(item);
item->setFlags(item->flags() | Qt::ItemIsEditable);
});
- connect(
- ui->actionDelete_Selected_Email_Address, &QAction::triggered, this,
- [=]() {
- const auto row_size = ui->emaillistWidget->count();
- for (int i = 0; i < row_size; i++) {
- auto item = ui->emaillistWidget->item(i);
- if (!item->isSelected()) continue;
- delete ui->emaillistWidget->takeItem(ui->emaillistWidget->row(item));
- break;
- }
- });
+ connect(ui_->actionDelete_Selected_Email_Address, &QAction::triggered, this,
+ [=]() {
+ const auto row_size = ui_->emaillistWidget->count();
+ for (int i = 0; i < row_size; i++) {
+ auto item = ui_->emaillistWidget->item(i);
+ if (!item->isSelected()) continue;
+ delete ui_->emaillistWidget->takeItem(
+ ui_->emaillistWidget->row(item));
+ break;
+ }
+ });
- ui->titleLabel->setText(_("Email List:"));
- ui->tipsLabel->setText(
+ ui_->titleLabel->setText(_("Email List:"));
+ ui_->tipsLabel->setText(
_("Tips: You can double-click the email address in the edit list, or "
"click the email to pop up the option menu."));
- ui->addEmailAddressButton->setText(_("Add An Email Address"));
+ ui_->addEmailAddressButton->setText(_("Add An Email Address"));
this->setWindowTitle(_("Email List Editor"));
- ui->actionDelete_Selected_Email_Address->setText(_("Delete"));
+ ui_->actionDelete_Selected_Email_Address->setText(_("Delete"));
- popupMenu = new QMenu(this);
- popupMenu->addAction(ui->actionDelete_Selected_Email_Address);
+ popup_menu_ = new QMenu(this);
+ popup_menu_->addAction(ui_->actionDelete_Selected_Email_Address);
this->exec();
}
bool GpgFrontend::UI::EmailListEditor::check_email_address(
const QString& email_address) {
- return re_email.match(email_address).hasMatch();
+ return re_email_.match(email_address).hasMatch();
}
-QString GpgFrontend::UI::EmailListEditor::getEmailList() {
+QString GpgFrontend::UI::EmailListEditor::GetEmailList() {
QString email_list;
- for (int i = 0; i < ui->emaillistWidget->count(); ++i) {
- QListWidgetItem* item = ui->emaillistWidget->item(i);
+ for (int i = 0; i < ui_->emaillistWidget->count(); ++i) {
+ QListWidgetItem* item = ui_->emaillistWidget->item(i);
if (check_email_address(item->text())) {
email_list.append(item->text());
email_list.append("; ");
@@ -100,7 +100,7 @@ QString GpgFrontend::UI::EmailListEditor::getEmailList() {
void GpgFrontend::UI::EmailListEditor::contextMenuEvent(
QContextMenuEvent* event) {
QWidget::contextMenuEvent(event);
- if (ui->emaillistWidget->selectedItems().length() > 0) {
- popupMenu->exec(event->globalPos());
+ if (ui_->emaillistWidget->selectedItems().length() > 0) {
+ popup_menu_->exec(event->globalPos());
}
}
diff --git a/src/ui/smtp/EmailListEditor.h b/src/ui/smtp/EmailListEditor.h
index aacd9d9e..b716ff66 100644
--- a/src/ui/smtp/EmailListEditor.h
+++ b/src/ui/smtp/EmailListEditor.h
@@ -34,23 +34,50 @@
class Ui_EmailListEditorDialog;
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class EmailListEditor : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Email List Editor object
+ *
+ * @param email_list
+ * @param parent
+ */
explicit EmailListEditor(const QString& email_list, QWidget* parent);
- QString getEmailList();
- private:
- std::shared_ptr<Ui_EmailListEditorDialog> ui;
- QMenu* popupMenu{};
+ /**
+ * @brief Get the Email List object
+ *
+ * @return QString
+ */
+ QString GetEmailList();
- QRegularExpression re_email{
+ private:
+ std::shared_ptr<Ui_EmailListEditorDialog> ui_; ///<
+ QMenu* popup_menu_{}; ///<
+ QRegularExpression re_email_{
R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
+ /**
+ * @brief
+ *
+ * @param email_address
+ * @return true
+ * @return false
+ */
bool check_email_address(const QString& email_address);
protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
void contextMenuEvent(QContextMenuEvent* event) override;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/IMAPFolder.h b/src/ui/smtp/IMAPFolder.h
index a0ac4eae..8d09eb94 100644
--- a/src/ui/smtp/IMAPFolder.h
+++ b/src/ui/smtp/IMAPFolder.h
@@ -35,19 +35,43 @@ class folder;
};
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class IMAPFolder {
public:
+ /**
+ * @brief Construct a new IMAPFolder object
+ *
+ * @param folder
+ */
explicit IMAPFolder(std::shared_ptr<vmime::net::folder> folder);
+ /**
+ * @brief Set the Parent Folder object
+ *
+ * @param parent_node
+ */
void SetParentFolder(IMAPFolder* parent_node);
+ /**
+ * @brief Get the Tree Widget Item object
+ *
+ * @return QTreeWidgetItem*
+ */
QTreeWidgetItem* GetTreeWidgetItem();
+ /**
+ * @brief Get the Vmime Folder object
+ *
+ * @return vmime::net::folder*
+ */
vmime::net::folder* GetVmimeFolder();
private:
- std::shared_ptr<vmime::net::folder> folder_;
- QTreeWidgetItem* tree_node_;
+ std::shared_ptr<vmime::net::folder> folder_; ///<
+ QTreeWidgetItem* tree_node_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/ReceiveMailDialog.cpp b/src/ui/smtp/ReceiveMailDialog.cpp
index 10c46149..765e8baa 100644
--- a/src/ui/smtp/ReceiveMailDialog.cpp
+++ b/src/ui/smtp/ReceiveMailDialog.cpp
@@ -31,11 +31,11 @@
#include "ui_ReceiveMailDialog.h"
GpgFrontend::UI::ReceiveMailDialog::ReceiveMailDialog(QWidget *parent)
- : QDialog(parent), ui(std::make_shared<Ui_ReceiveMailDialog>()) {
- ui->setupUi(this);
+ : QDialog(parent), ui_(std::make_shared<Ui_ReceiveMailDialog>()) {
+ ui_->setupUi(this);
}
-void GpgFrontend::UI::ReceiveMailDialog::slotRefreshData() {}
+void GpgFrontend::UI::ReceiveMailDialog::slot_refresh_data() {}
void GpgFrontend::UI::ReceiveMailDialog::list_sub_folders(
GpgFrontend::UI::IMAPFolder *parent_folder,
diff --git a/src/ui/smtp/ReceiveMailDialog.h b/src/ui/smtp/ReceiveMailDialog.h
index b21b4b6d..2ccb2664 100644
--- a/src/ui/smtp/ReceiveMailDialog.h
+++ b/src/ui/smtp/ReceiveMailDialog.h
@@ -41,21 +41,38 @@ namespace GpgFrontend::UI {
class IMAPFolder;
+/**
+ * @brief
+ *
+ */
class ReceiveMailDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Receive Mail Dialog object
+ *
+ * @param parent
+ */
explicit ReceiveMailDialog(QWidget* parent);
private slots:
- void slotRefreshData();
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_data();
private:
- std::shared_ptr<Ui_ReceiveMailDialog> ui;
+ std::shared_ptr<Ui_ReceiveMailDialog> ui_; ///<
+ std::vector<std::shared_ptr<IMAPFolder>> folders_; ///<
+ /**
+ * @brief
+ *
+ * @param parent_folder
+ */
void list_sub_folders(IMAPFolder* parent_folder,
const std::shared_ptr<vmime::net::folder>&);
-
- std::vector<std::shared_ptr<IMAPFolder>> folders;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/RecipientsPicker.cpp b/src/ui/smtp/RecipientsPicker.cpp
index a647c53e..17a08705 100644
--- a/src/ui/smtp/RecipientsPicker.cpp
+++ b/src/ui/smtp/RecipientsPicker.cpp
@@ -75,6 +75,6 @@ GpgFrontend::UI::RecipientsPicker::RecipientsPicker(
}
GpgFrontend::KeyIdArgsListPtr
-GpgFrontend::UI::RecipientsPicker::getCheckedRecipients() {
+GpgFrontend::UI::RecipientsPicker::GetCheckedRecipients() {
return key_list_->getChecked();
}
diff --git a/src/ui/smtp/RecipientsPicker.h b/src/ui/smtp/RecipientsPicker.h
index 928ce04b..252bbd58 100644
--- a/src/ui/smtp/RecipientsPicker.h
+++ b/src/ui/smtp/RecipientsPicker.h
@@ -35,18 +35,33 @@ namespace GpgFrontend::UI {
class KeyList;
+/**
+ * @brief
+ *
+ */
class RecipientsPicker : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Recipients Picker object
+ *
+ * @param current_key_ids
+ * @param parent
+ */
explicit RecipientsPicker(
const GpgFrontend::KeyIdArgsListPtr& current_key_ids,
QWidget* parent = nullptr);
- GpgFrontend::KeyIdArgsListPtr getCheckedRecipients();
+ /**
+ * @brief Get the Checked Recipients object
+ *
+ * @return GpgFrontend::KeyIdArgsListPtr
+ */
+ GpgFrontend::KeyIdArgsListPtr GetCheckedRecipients();
private:
- KeyList* key_list_;
+ KeyList* key_list_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/SendMailDialog.cpp b/src/ui/smtp/SendMailDialog.cpp
index b44cabf7..ce67e08e 100644
--- a/src/ui/smtp/SendMailDialog.cpp
+++ b/src/ui/smtp/SendMailDialog.cpp
@@ -42,9 +42,9 @@
namespace GpgFrontend::UI {
SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
- : QDialog(parent), ui(std::make_shared<Ui_SendMailDialog>()) {
+ : QDialog(parent), ui_(std::make_shared<Ui_SendMailDialog>()) {
// read from settings
- initSettings();
+ init_settings();
if (smtp_address_.isEmpty()) {
QMessageBox::critical(
@@ -56,18 +56,18 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
return;
}
- ui->setupUi(this);
+ ui_->setupUi(this);
- ui->ccInputWidget->setHidden(true);
- ui->bccInputWidget->setHidden(true);
- ui->textEdit->setText(text);
- ui->errorLabel->setHidden(true);
+ ui_->ccInputWidget->setHidden(true);
+ ui_->bccInputWidget->setHidden(true);
+ ui_->textEdit->setText(text);
+ ui_->errorLabel->setHidden(true);
- ui->senderEdit->setText(default_sender_);
+ ui_->senderEdit->setText(default_sender_);
- if (!default_sender_gpg_key_id.isEmpty()) {
+ if (!default_sender_gpg_key_id_.isEmpty()) {
auto key = GpgKeyGetter::GetInstance().GetKey(
- default_sender_gpg_key_id.toStdString());
+ default_sender_gpg_key_id_.toStdString());
if (key.IsGood() && key.IsPrivateKey() &&
key.IsHasActualSigningCapability()) {
sender_key_id_ = key.GetId();
@@ -75,69 +75,69 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
}
}
- connect(ui->ccButton, &QPushButton::clicked, [=]() {
- ui->ccInputWidget->setHidden(!ui->ccInputWidget->isHidden());
- ui->ccEdit->clear();
+ connect(ui_->ccButton, &QPushButton::clicked, [=]() {
+ ui_->ccInputWidget->setHidden(!ui_->ccInputWidget->isHidden());
+ ui_->ccEdit->clear();
});
- connect(ui->bccButton, &QPushButton::clicked, [=]() {
- ui->bccInputWidget->setHidden(!ui->bccInputWidget->isHidden());
- ui->bccEdit->clear();
+ connect(ui_->bccButton, &QPushButton::clicked, [=]() {
+ ui_->bccInputWidget->setHidden(!ui_->bccInputWidget->isHidden());
+ ui_->bccEdit->clear();
});
#ifdef SMTP_SUPPORT
- connect(ui->sendMailButton, &QPushButton::clicked, this,
- &SendMailDialog::slotConfirm);
+ connect(ui_->sendMailButton, &QPushButton::clicked, this,
+ &SendMailDialog::slot_confirm);
#endif
- connect(ui->senderKeySelectButton, &QPushButton::clicked, this, [=]() {
+ connect(ui_->senderKeySelectButton, &QPushButton::clicked, this, [=]() {
auto picker = new SenderPicker(sender_key_id_, this);
- sender_key_id_ = picker->getCheckedSender();
+ sender_key_id_ = picker->GetCheckedSender();
set_sender_value_label();
});
- connect(ui->recipientKeySelectButton, &QPushButton::clicked, this, [=]() {
+ connect(ui_->recipientKeySelectButton, &QPushButton::clicked, this, [=]() {
auto picker = new RecipientsPicker(recipients_key_ids_, this);
- recipients_key_ids_ = picker->getCheckedRecipients();
+ recipients_key_ids_ = picker->GetCheckedRecipients();
set_recipients_value_label();
});
- connect(ui->recipientsEditButton, &QPushButton::clicked, this, [=]() {
- auto editor = new EmailListEditor(ui->recipientEdit->text(), this);
- ui->recipientEdit->setText(editor->getEmailList());
+ connect(ui_->recipientsEditButton, &QPushButton::clicked, this, [=]() {
+ auto editor = new EmailListEditor(ui_->recipientEdit->text(), this);
+ ui_->recipientEdit->setText(editor->GetEmailList());
});
- connect(ui->ccEditButton, &QPushButton::clicked, this, [=]() {
- auto editor = new EmailListEditor(ui->ccEdit->text(), this);
- ui->ccEdit->setText(editor->getEmailList());
+ connect(ui_->ccEditButton, &QPushButton::clicked, this, [=]() {
+ auto editor = new EmailListEditor(ui_->ccEdit->text(), this);
+ ui_->ccEdit->setText(editor->GetEmailList());
});
- connect(ui->bccEditButton, &QPushButton::clicked, this, [=]() {
- auto editor = new EmailListEditor(ui->bccEdit->text(), this);
- ui->bccEdit->setText(editor->getEmailList());
+ connect(ui_->bccEditButton, &QPushButton::clicked, this, [=]() {
+ auto editor = new EmailListEditor(ui_->bccEdit->text(), this);
+ ui_->bccEdit->setText(editor->GetEmailList());
});
- ui->ccButton->setText(_("CC"));
- ui->bccButton->setText(_("BCC"));
- ui->senderLabel->setText(_("Sender"));
- ui->recipientLabel->setText(_("Recipient"));
- ui->subjectLabel->setText(_("Mail Subject"));
- ui->bccLabel->setText(_("BCC"));
- ui->ccLabel->setText(_("CC"));
- ui->tipsLabel->setText(
+ ui_->ccButton->setText(_("CC"));
+ ui_->bccButton->setText(_("BCC"));
+ ui_->senderLabel->setText(_("Sender"));
+ ui_->recipientLabel->setText(_("Recipient"));
+ ui_->subjectLabel->setText(_("Mail Subject"));
+ ui_->bccLabel->setText(_("BCC"));
+ ui_->ccLabel->setText(_("CC"));
+ ui_->tipsLabel->setText(
_("Tips: You can fill in multiple email addresses, please separate them "
"with \";\"."));
- ui->sendMailButton->setText(_("Send Message"));
- ui->senderKeySelectButton->setText(_("Select Sender GPG Key"));
- ui->recipientKeySelectButton->setText(_("Select Recipient(s) GPG Key"));
- ui->gpgOperaLabel->setText(_("GPG Operations"));
- ui->attacSignatureCheckBox->setText(_("Attach signature"));
- ui->attachSenderPublickeyCheckBox->setText(_("Attach sender's public key"));
- ui->contentEncryptCheckBox->setText(_("Encrypt content"));
- ui->recipientsEditButton->setText(_("Edit Recipients(s)"));
- ui->ccEditButton->setText(_("Edit CC(s)"));
- ui->bccEditButton->setText(_("Edit BCC(s)"));
- ui->senderKeyLabel->setText(_("Sender GPG Key: "));
- ui->recipientKeysLabel->setText(_("Recipient(s) GPG Key: "));
+ ui_->sendMailButton->setText(_("Send Message"));
+ ui_->senderKeySelectButton->setText(_("Select Sender GPG Key"));
+ ui_->recipientKeySelectButton->setText(_("Select Recipient(s) GPG Key"));
+ ui_->gpgOperaLabel->setText(_("GPG Operations"));
+ ui_->attacSignatureCheckBox->setText(_("Attach signature"));
+ ui_->attachSenderPublickeyCheckBox->setText(_("Attach sender's public key"));
+ ui_->contentEncryptCheckBox->setText(_("Encrypt content"));
+ ui_->recipientsEditButton->setText(_("Edit Recipients(s)"));
+ ui_->ccEditButton->setText(_("Edit CC(s)"));
+ ui_->bccEditButton->setText(_("Edit BCC(s)"));
+ ui_->senderKeyLabel->setText(_("Sender GPG Key: "));
+ ui_->recipientKeysLabel->setText(_("Recipient(s) GPG Key: "));
auto pos = QPoint(100, 100);
LOG(INFO) << "parent" << parent;
@@ -151,18 +151,18 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
}
bool SendMailDialog::check_email_address(const QString& str) {
- return re_email.match(str).hasMatch();
+ return re_email_.match(str).hasMatch();
}
#ifdef SMTP_SUPPORT
-void SendMailDialog::slotConfirm() {
+void SendMailDialog::slot_confirm() {
QString errString;
- ui->errorLabel->clear();
- ui->errorLabel->setHidden(true);
- QStringList rcpt_string_list = ui->recipientEdit->text().split(';');
- QStringList cc_string_list = ui->ccEdit->text().split(';');
- QStringList bcc_string_list = ui->bccEdit->text().split(';');
+ ui_->errorLabel->clear();
+ ui_->errorLabel->setHidden(true);
+ QStringList rcpt_string_list = ui_->recipientEdit->text().split(';');
+ QStringList cc_string_list = ui_->ccEdit->text().split(';');
+ QStringList bcc_string_list = ui_->bccEdit->text().split(';');
if (rcpt_string_list.isEmpty()) {
errString.append(QString(" ") + _("Recipient cannot be empty") + " \n");
@@ -177,17 +177,17 @@ void SendMailDialog::slotConfirm() {
}
}
}
- if (ui->senderEdit->text().isEmpty()) {
+ if (ui_->senderEdit->text().isEmpty()) {
errString.append(QString(" ") + _("Sender cannot be empty") + " \n");
- } else if (!check_email_address(ui->senderEdit->text())) {
+ } else if (!check_email_address(ui_->senderEdit->text())) {
errString.append(QString(" ") + _("Sender's email is invalid") + " \n");
}
- if (ui->subjectEdit->text().isEmpty()) {
+ if (ui_->subjectEdit->text().isEmpty()) {
errString.append(QString(" ") + _("Subject cannot be empty") + " \n");
}
- if (!ui->ccEdit->text().isEmpty())
+ if (!ui_->ccEdit->text().isEmpty())
for (const auto& cc : cc_string_list) {
LOG(INFO) << "cc" << cc.trimmed().toStdString();
if (!check_email_address(cc.trimmed())) {
@@ -197,7 +197,7 @@ void SendMailDialog::slotConfirm() {
}
}
- if (!ui->bccEdit->text().isEmpty())
+ if (!ui_->bccEdit->text().isEmpty())
for (const auto& bcc : bcc_string_list) {
LOG(INFO) << "bcc" << bcc.trimmed().toStdString();
if (!check_email_address(bcc.trimmed())) {
@@ -208,12 +208,12 @@ void SendMailDialog::slotConfirm() {
}
if (!errString.isEmpty()) {
- ui->errorLabel->setAutoFillBackground(true);
- QPalette error = ui->errorLabel->palette();
+ ui_->errorLabel->setAutoFillBackground(true);
+ QPalette error = ui_->errorLabel->palette();
error.setColor(QPalette::Window, "#ff8080");
- ui->errorLabel->setPalette(error);
- ui->errorLabel->setText(errString);
- ui->errorLabel->setHidden(false);
+ ui_->errorLabel->setPalette(error);
+ ui_->errorLabel->setText(errString);
+ ui_->errorLabel->setHidden(false);
return;
}
@@ -236,19 +236,19 @@ void SendMailDialog::slotConfirm() {
bool identity_needed = identity_enable_;
auto username = username_.toStdString();
auto password = password_.toStdString();
- auto sender_address = ui->senderEdit->text().toStdString();
+ auto sender_address = ui_->senderEdit->text().toStdString();
auto thread = new SMTPSendMailThread(
host, port, connection_type, identity_needed, username, password, this);
- thread->setSender(ui->senderEdit->text());
- thread->setRecipient(ui->recipientEdit->text());
- thread->setCC(ui->ccEdit->text());
- thread->setBCC(ui->bccEdit->text());
- thread->setSubject(ui->subjectEdit->text());
- thread->addTextContent(ui->textEdit->toPlainText());
+ thread->setSender(ui_->senderEdit->text());
+ thread->setRecipient(ui_->recipientEdit->text());
+ thread->setCC(ui_->ccEdit->text());
+ thread->setBCC(ui_->bccEdit->text());
+ thread->setSubject(ui_->subjectEdit->text());
+ thread->addTextContent(ui_->textEdit->toPlainText());
- if (ui->contentEncryptCheckBox->checkState() == Qt::Checked) {
+ if (ui_->contentEncryptCheckBox->checkState() == Qt::Checked) {
if (recipients_key_ids_ == nullptr || recipients_key_ids_->empty()) {
QMessageBox::critical(
this, _("Forbidden"),
@@ -264,7 +264,7 @@ void SendMailDialog::slotConfirm() {
}
}
- if (ui->attacSignatureCheckBox->checkState() == Qt::Checked) {
+ if (ui_->attacSignatureCheckBox->checkState() == Qt::Checked) {
if (sender_key_id_.empty()) {
QMessageBox::critical(
this, _("Forbidden"),
@@ -278,7 +278,7 @@ void SendMailDialog::slotConfirm() {
}
}
- if (ui->attachSenderPublickeyCheckBox->checkState() == Qt::Checked) {
+ if (ui_->attachSenderPublickeyCheckBox->checkState() == Qt::Checked) {
if (sender_key_id_.empty()) {
QMessageBox::critical(
this, _("Forbidden"),
@@ -305,7 +305,7 @@ void SendMailDialog::slotConfirm() {
waiting_dialog->setLabel(waiting_dialog_label);
waiting_dialog->resize(420, 120);
connect(thread, &SMTPSendMailThread::signalSMTPResult, this,
- &SendMailDialog::slotTestSMTPConnectionResult);
+ &SendMailDialog::slot_test_smtp_connection_result);
connect(thread, &QThread::finished, [=]() {
waiting_dialog->finished(0);
waiting_dialog->deleteLater();
@@ -325,7 +325,7 @@ void SendMailDialog::slotConfirm() {
loop.exec();
}
-void SendMailDialog::initSettings() {
+void SendMailDialog::init_settings() {
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
try {
@@ -377,7 +377,7 @@ void SendMailDialog::initSettings() {
}
try {
- default_sender_gpg_key_id =
+ default_sender_gpg_key_id_ =
settings.lookup("smtp.default_sender_gpg_key_id").c_str();
} catch (...) {
LOG(ERROR) << _("Setting Operation Error")
@@ -389,7 +389,7 @@ void SendMailDialog::initSettings() {
void SendMailDialog::set_sender_value_label() {
auto key = GpgKeyGetter::GetInstance().GetKey(sender_key_id_);
if (key.IsGood()) {
- ui->senderKeyValueLabel->setText(key.GetUIDs()->front().GetUID().c_str());
+ ui_->senderKeyValueLabel->setText(key.GetUIDs()->front().GetUID().c_str());
}
}
@@ -401,10 +401,10 @@ void SendMailDialog::set_recipients_value_label() {
ss << key.GetUIDs()->front().GetUID().c_str() << ";";
}
}
- ui->recipientsKeyValueLabel->setText(ss.str().c_str());
+ ui_->recipientsKeyValueLabel->setText(ss.str().c_str());
}
-void SendMailDialog::slotTestSMTPConnectionResult(const QString& result) {
+void SendMailDialog::slot_test_smtp_connection_result(const QString& result) {
if (result == "Fail to connect SMTP server") {
QMessageBox::critical(this, _("Fail"), _("Fail to Connect SMTP Server."));
} else if (result == "Fail to login") {
@@ -428,12 +428,12 @@ void SendMailDialog::slotTestSMTPConnectionResult(const QString& result) {
QMessageBox::critical(this, _("Fail"), _("Unknown error."));
}
}
-void SendMailDialog::setContentEncryption(bool on) {
- ui->contentEncryptCheckBox->setCheckState(on ? Qt::Checked : Qt::Unchecked);
+void SendMailDialog::SetContentEncryption(bool on) {
+ ui_->contentEncryptCheckBox->setCheckState(on ? Qt::Checked : Qt::Unchecked);
}
-void SendMailDialog::setAttachSignature(bool on) {
- ui->attacSignatureCheckBox->setCheckState(on ? Qt::Checked : Qt::Unchecked);
+void SendMailDialog::SetAttachSignature(bool on) {
+ ui_->attacSignatureCheckBox->setCheckState(on ? Qt::Checked : Qt::Unchecked);
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/SendMailDialog.h b/src/ui/smtp/SendMailDialog.h
index 70c25b55..3d745e11 100644
--- a/src/ui/smtp/SendMailDialog.h
+++ b/src/ui/smtp/SendMailDialog.h
@@ -35,47 +35,95 @@ class Ui_SendMailDialog;
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class SendMailDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Send Mail Dialog object
+ *
+ * @param text
+ * @param parent
+ */
explicit SendMailDialog(const QString& text, QWidget* parent = nullptr);
- void setContentEncryption(bool on);
+ /**
+ * @brief Set the Content Encryption object
+ *
+ * @param on
+ */
+ void SetContentEncryption(bool on);
- void setAttachSignature(bool on);
+ /**
+ * @brief Set the Attach Signature object
+ *
+ * @param on
+ */
+ void SetAttachSignature(bool on);
private slots:
- void slotConfirm();
+ /**
+ * @brief
+ *
+ */
+ void slot_confirm();
- void slotTestSMTPConnectionResult(const QString& result);
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void slot_test_smtp_connection_result(const QString& result);
private:
- void initSettings();
-
- std::shared_ptr<Ui_SendMailDialog> ui;
-
- bool ability_enable_ = false;
- bool identity_enable_ = false;
- QString smtp_address_;
- QString username_;
- QString password_;
- QString default_sender_;
- QString connection_type_settings_ = "None";
- QString default_sender_gpg_key_id = {};
- int port_ = 25;
-
- GpgFrontend::KeyId sender_key_id_;
+ /**
+ * @brief
+ *
+ */
+ void init_settings();
+
+ std::shared_ptr<Ui_SendMailDialog> ui_; ///<
+
+ bool ability_enable_ = false; ///<
+ bool identity_enable_ = false; ///<
+ QString smtp_address_; ///<
+ QString username_; ///<
+ QString password_; ///<
+ QString default_sender_; ///<
+ QString connection_type_settings_ = "None"; ///<
+ QString default_sender_gpg_key_id_ = {}; ///<
+ int port_ = 25; ///<
+
+ GpgFrontend::KeyId sender_key_id_; ///<
GpgFrontend::KeyIdArgsListPtr recipients_key_ids_ =
- std::make_unique<GpgFrontend::KeyIdArgsList>();
+ std::make_unique<GpgFrontend::KeyIdArgsList>(); ///<
- QRegularExpression re_email{
+ QRegularExpression re_email_{
R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
+ /**
+ * @brief
+ *
+ * @param str
+ * @return true
+ * @return false
+ */
bool check_email_address(const QString& str);
+ /**
+ * @brief Set the sender value label object
+ *
+ */
void set_sender_value_label();
+ /**
+ * @brief Set the recipients value label object
+ *
+ */
void set_recipients_value_label();
};
diff --git a/src/ui/smtp/SenderPicker.cpp b/src/ui/smtp/SenderPicker.cpp
index a2b54169..e88f57cc 100644
--- a/src/ui/smtp/SenderPicker.cpp
+++ b/src/ui/smtp/SenderPicker.cpp
@@ -71,7 +71,7 @@ GpgFrontend::UI::SenderPicker::SenderPicker(const KeyId& current_key_id,
this->exec();
}
-GpgFrontend::KeyId GpgFrontend::UI::SenderPicker::getCheckedSender() {
+GpgFrontend::KeyId GpgFrontend::UI::SenderPicker::GetCheckedSender() {
auto checked_keys = key_list_->getChecked();
if (!checked_keys->empty()) {
return key_list_->getChecked()->front();
diff --git a/src/ui/smtp/SenderPicker.h b/src/ui/smtp/SenderPicker.h
index 6efeeaf2..ce8cd8e6 100644
--- a/src/ui/smtp/SenderPicker.h
+++ b/src/ui/smtp/SenderPicker.h
@@ -35,16 +35,31 @@ namespace GpgFrontend::UI {
class KeyList;
+/**
+ * @brief
+ *
+ */
class SenderPicker : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Sender Picker object
+ *
+ * @param current_key_id
+ * @param parent
+ */
explicit SenderPicker(const KeyId& current_key_id, QWidget* parent = nullptr);
- GpgFrontend::KeyId getCheckedSender();
+ /**
+ * @brief Get the Checked Sender object
+ *
+ * @return GpgFrontend::KeyId
+ */
+ GpgFrontend::KeyId GetCheckedSender();
private:
- KeyList* key_list_;
+ KeyList* key_list_; ///<
};
} // namespace GpgFrontend::UI