diff options
author | Saturneric <[email protected]> | 2022-01-23 09:10:53 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-01-23 09:10:53 +0000 |
commit | 0dd16d72d75e2068b8365a49ef2696a4744575dd (patch) | |
tree | a463727ba5a5ee4d5afcfb0eaa4d8e6e48b7c930 /src | |
parent | <refactor>(ui): tidy up codes and comments. (diff) | |
download | GpgFrontend-0dd16d72d75e2068b8365a49ef2696a4744575dd.tar.gz GpgFrontend-0dd16d72d75e2068b8365a49ef2696a4744575dd.zip |
<refactor>(ui): tidy up codes and comments.
1. tidy up ui.
Diffstat (limited to '')
32 files changed, 1154 insertions, 634 deletions
diff --git a/src/ui/FindWidget.cpp b/src/ui/FindWidget.cpp index e6b82734..17a65ee4 100644 --- a/src/ui/FindWidget.cpp +++ b/src/ui/FindWidget.cpp @@ -31,8 +31,8 @@ namespace GpgFrontend::UI { FindWidget::FindWidget(QWidget* parent, PlainTextEditorPage* edit) - : QWidget(parent), mTextpage(edit) { - findEdit = new QLineEdit(this); + : QWidget(parent), m_text_page_(edit) { + find_edit_ = new QLineEdit(this); auto* closeButton = new QPushButton( this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), QString(), this); @@ -42,127 +42,129 @@ FindWidget::FindWidget(QWidget* parent, PlainTextEditorPage* edit) auto* notificationWidgetLayout = new QHBoxLayout(this); notificationWidgetLayout->setContentsMargins(10, 0, 0, 0); notificationWidgetLayout->addWidget(new QLabel(QString(_("Find")) + ": ")); - notificationWidgetLayout->addWidget(findEdit, 2); + notificationWidgetLayout->addWidget(find_edit_, 2); notificationWidgetLayout->addWidget(nextButton); notificationWidgetLayout->addWidget(previousButton); notificationWidgetLayout->addWidget(closeButton); this->setLayout(notificationWidgetLayout); - connect(findEdit, SIGNAL(textEdited(QString)), this, SLOT(slotFind())); - connect(findEdit, SIGNAL(returnPressed()), this, SLOT(slotFindNext())); - connect(nextButton, SIGNAL(clicked()), this, SLOT(slotFindNext())); - connect(previousButton, SIGNAL(clicked()), this, SLOT(slotFindPrevious())); - connect(closeButton, SIGNAL(clicked()), this, SLOT(slotClose())); + connect(find_edit_, SIGNAL(textEdited(QString)), this, SLOT(slot_find())); + connect(find_edit_, SIGNAL(returnPressed()), this, SLOT(slot_find_next())); + connect(nextButton, SIGNAL(clicked()), this, SLOT(slot_find_next())); + connect(previousButton, SIGNAL(clicked()), this, SLOT(slot_find_previous())); + connect(closeButton, SIGNAL(clicked()), this, SLOT(slot_close())); // The timer is necessary for setting the focus - QTimer::singleShot(0, findEdit, SLOT(setFocus())); + QTimer::singleShot(0, find_edit_, SLOT(setFocus())); } -void FindWidget::setBackground() { - auto cursor = mTextpage->GetTextPage()->textCursor(); +void FindWidget::set_background() { + auto cursor = m_text_page_->GetTextPage()->textCursor(); // if match is found set background of QLineEdit to white, otherwise to red - QPalette bgPalette(findEdit->palette()); + QPalette bgPalette(find_edit_->palette()); - if (!findEdit->text().isEmpty() && - mTextpage->GetTextPage()->document()->find(findEdit->text()).position() < - 0) { + if (!find_edit_->text().isEmpty() && m_text_page_->GetTextPage() + ->document() + ->find(find_edit_->text()) + .position() < 0) { bgPalette.setColor(QPalette::Base, "#ececba"); } else { bgPalette.setColor(QPalette::Base, Qt::white); } - findEdit->setPalette(bgPalette); + find_edit_->setPalette(bgPalette); } -void FindWidget::slotFindNext() { - QTextCursor cursor = mTextpage->GetTextPage()->textCursor(); - cursor = mTextpage->GetTextPage()->document()->find( - findEdit->text(), cursor, QTextDocument::FindCaseSensitively); +void FindWidget::slot_find_next() { + QTextCursor cursor = m_text_page_->GetTextPage()->textCursor(); + cursor = m_text_page_->GetTextPage()->document()->find( + find_edit_->text(), cursor, QTextDocument::FindCaseSensitively); // if end of document is reached, restart search from beginning if (cursor.position() == -1) { - cursor = mTextpage->GetTextPage()->document()->find( - findEdit->text(), cursor, QTextDocument::FindCaseSensitively); + cursor = m_text_page_->GetTextPage()->document()->find( + find_edit_->text(), cursor, QTextDocument::FindCaseSensitively); } // cursor should not stay at -1, otherwise text is not editable // todo: check how gedit handles this if (cursor.position() != -1) { - mTextpage->GetTextPage()->setTextCursor(cursor); + m_text_page_->GetTextPage()->setTextCursor(cursor); } - this->setBackground(); + this->set_background(); } -void FindWidget::slotFind() { - QTextCursor cursor = mTextpage->GetTextPage()->textCursor(); +void FindWidget::slot_find() { + QTextCursor cursor = m_text_page_->GetTextPage()->textCursor(); if (cursor.anchor() == -1) { - cursor = mTextpage->GetTextPage()->document()->find( - findEdit->text(), cursor, QTextDocument::FindCaseSensitively); + cursor = m_text_page_->GetTextPage()->document()->find( + find_edit_->text(), cursor, QTextDocument::FindCaseSensitively); } else { - cursor = mTextpage->GetTextPage()->document()->find( - findEdit->text(), cursor.anchor(), QTextDocument::FindCaseSensitively); + cursor = m_text_page_->GetTextPage()->document()->find( + find_edit_->text(), cursor.anchor(), + QTextDocument::FindCaseSensitively); } // if end of document is reached, restart search from beginning if (cursor.position() == -1) { - cursor = mTextpage->GetTextPage()->document()->find( - findEdit->text(), cursor, QTextDocument::FindCaseSensitively); + cursor = m_text_page_->GetTextPage()->document()->find( + find_edit_->text(), cursor, QTextDocument::FindCaseSensitively); } // cursor should not stay at -1, otherwise text is not editable // todo: check how gedit handles this if (cursor.position() != -1) { - mTextpage->GetTextPage()->setTextCursor(cursor); + m_text_page_->GetTextPage()->setTextCursor(cursor); } - this->setBackground(); + this->set_background(); } -void FindWidget::slotFindPrevious() { +void FindWidget::slot_find_previous() { QTextDocument::FindFlags flags; flags |= QTextDocument::FindBackward; flags |= QTextDocument::FindCaseSensitively; - QTextCursor cursor = mTextpage->GetTextPage()->textCursor(); - cursor = mTextpage->GetTextPage()->document()->find(findEdit->text(), cursor, - flags); + QTextCursor cursor = m_text_page_->GetTextPage()->textCursor(); + cursor = m_text_page_->GetTextPage()->document()->find(find_edit_->text(), + cursor, flags); // if begin of document is reached, restart search from end if (cursor.position() == -1) { - cursor = mTextpage->GetTextPage()->document()->find( - findEdit->text(), QTextCursor::End, flags); + cursor = m_text_page_->GetTextPage()->document()->find( + find_edit_->text(), QTextCursor::End, flags); } // cursor should not stay at -1, otherwise text is not editable // todo: check how gedit handles this if (cursor.position() != -1) { - mTextpage->GetTextPage()->setTextCursor(cursor); + m_text_page_->GetTextPage()->setTextCursor(cursor); } - this->setBackground(); + this->set_background(); } void FindWidget::keyPressEvent(QKeyEvent* e) { switch (e->key()) { case Qt::Key_Escape: - this->slotClose(); + this->slot_close(); break; case Qt::Key_F3: if (e->modifiers() & Qt::ShiftModifier) { - this->slotFindPrevious(); + this->slot_find_previous(); } else { - this->slotFindNext(); + this->slot_find_next(); } break; } } -void FindWidget::slotClose() { - QTextCursor cursor = mTextpage->GetTextPage()->textCursor(); +void FindWidget::slot_close() { + QTextCursor cursor = m_text_page_->GetTextPage()->textCursor(); if (cursor.position() == -1) { cursor.setPosition(0); - mTextpage->GetTextPage()->setTextCursor(cursor); + m_text_page_->GetTextPage()->setTextCursor(cursor); } - mTextpage->setFocus(); + m_text_page_->setFocus(); close(); } diff --git a/src/ui/FindWidget.h b/src/ui/FindWidget.h index 985cd26f..dfe50f9c 100644 --- a/src/ui/FindWidget.h +++ b/src/ui/FindWidget.h @@ -48,27 +48,50 @@ class FindWidget : public QWidget { */ explicit FindWidget(QWidget* parent, PlainTextEditorPage* edit); - private: + protected: + /** + * @brief + * + * @param e + */ void keyPressEvent(QKeyEvent* e) override; + private: /** * @details Set background of findEdit to red, if no match is found (Documents * textcursor position equals -1), otherwise set it to white. */ - void setBackground(); + void set_background(); - PlainTextEditorPage* mTextpage; /** Textedit associated to the notification */ - QLineEdit* findEdit; /** Label holding the text shown in infoBoard */ + PlainTextEditorPage* + m_text_page_; ///< Textedit associated to the notification + QLineEdit* find_edit_; ///< Label holding the text shown in infoBoard private slots: - void slotFindNext(); + /** + * @brief + * + */ + void slot_find_next(); - void slotFindPrevious(); + /** + * @brief + * + */ + void slot_find_previous(); - void slotFind(); + /** + * @brief + * + */ + void slot_find(); - void slotClose(); + /** + * @brief + * + */ + void slot_close(); }; } // namespace GpgFrontend::UI diff --git a/src/ui/GpgFrontendUI.h b/src/ui/GpgFrontendUI.h index c587c1fc..c8e8e3e8 100644 --- a/src/ui/GpgFrontendUI.h +++ b/src/ui/GpgFrontendUI.h @@ -29,16 +29,26 @@ #ifndef GPGFRONTEND_GPGFRONTENDUI_H #define GPGFRONTEND_GPGFRONTENDUI_H +/** + * Basic dependency + */ #include <QtCore> #include <QtNetwork> #include <QtPrintSupport> #include <QtWidgets> #include <optional> +/** + * Project internal dependencies + */ #include "GpgFrontend.h" #include "gpg/GpgConstants.h" #include "gpg/GpgModel.h" +/** + * 3rd party dependencies + */ + #undef LIBCONFIGXX_STATIC #define LIBCONFIGXX_STATIC #include <qt-aes/qaesencryption.h> diff --git a/src/ui/KeyImportDetailDialog.cpp b/src/ui/KeyImportDetailDialog.cpp index ef9114bf..26e75832 100644 --- a/src/ui/KeyImportDetailDialog.cpp +++ b/src/ui/KeyImportDetailDialog.cpp @@ -33,9 +33,9 @@ namespace GpgFrontend::UI { KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, bool automatic, QWidget* parent) - : QDialog(parent), mResult(std::move(result)) { + : QDialog(parent), m_result_(std::move(result)) { // If no key for import found, just show a message - if (mResult.considered == 0) { + if (m_result_.considered == 0) { if (automatic) QMessageBox::information(parent, _("Key Update Details"), _("No keys found")); @@ -48,12 +48,12 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, } else { auto* mv_box = new QVBoxLayout(); - this->createGeneralInfoBox(); - mv_box->addWidget(generalInfoBox); - this->createKeysTable(); - mv_box->addWidget(keysTable); - this->createButtonBox(); - mv_box->addWidget(buttonBox); + this->create_general_info_box(); + mv_box->addWidget(general_info_box_); + this->create_keys_table(); + mv_box->addWidget(keys_table_); + this->create_button_box(); + mv_box->addWidget(button_box_); this->setLayout(mv_box); if (automatic) @@ -73,97 +73,97 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, } } -void KeyImportDetailDialog::createGeneralInfoBox() { +void KeyImportDetailDialog::create_general_info_box() { // GridBox for general import information - generalInfoBox = new QGroupBox(_("General key info")); - auto* generalInfoBoxLayout = new QGridLayout(generalInfoBox); + general_info_box_ = new QGroupBox(_("General key info")); + auto* generalInfoBoxLayout = new QGridLayout(general_info_box_); generalInfoBoxLayout->addWidget(new QLabel(QString(_("Considered")) + ": "), 1, 0); generalInfoBoxLayout->addWidget( - new QLabel(QString::number(mResult.considered)), 1, 1); + new QLabel(QString::number(m_result_.considered)), 1, 1); int row = 2; - if (mResult.unchanged != 0) { + if (m_result_.unchanged != 0) { generalInfoBoxLayout->addWidget( new QLabel(QString(_("Public unchanged")) + ": "), row, 0); generalInfoBoxLayout->addWidget( - new QLabel(QString::number(mResult.unchanged)), row, 1); + new QLabel(QString::number(m_result_.unchanged)), row, 1); row++; } - if (mResult.imported != 0) { + if (m_result_.imported != 0) { generalInfoBoxLayout->addWidget(new QLabel(QString(_("Imported")) + ": "), row, 0); generalInfoBoxLayout->addWidget( - new QLabel(QString::number(mResult.imported)), row, 1); + new QLabel(QString::number(m_result_.imported)), row, 1); row++; } - if (mResult.not_imported != 0) { + if (m_result_.not_imported != 0) { generalInfoBoxLayout->addWidget( new QLabel(QString(_("Not Imported")) + ": "), row, 0); generalInfoBoxLayout->addWidget( - new QLabel(QString::number(mResult.not_imported)), row, 1); + new QLabel(QString::number(m_result_.not_imported)), row, 1); row++; } - if (mResult.secret_read != 0) { + if (m_result_.secret_read != 0) { generalInfoBoxLayout->addWidget( new QLabel(QString(_("Private Read")) + ": "), row, 0); generalInfoBoxLayout->addWidget( - new QLabel(QString::number(mResult.secret_read)), row, 1); + new QLabel(QString::number(m_result_.secret_read)), row, 1); row++; } - if (mResult.secret_imported != 0) { + if (m_result_.secret_imported != 0) { generalInfoBoxLayout->addWidget( new QLabel(QString(_("Private Imported")) + ": "), row, 0); generalInfoBoxLayout->addWidget( - new QLabel(QString::number(mResult.secret_imported)), row, 1); + new QLabel(QString::number(m_result_.secret_imported)), row, 1); row++; } - if (mResult.secret_unchanged != 0) { + if (m_result_.secret_unchanged != 0) { generalInfoBoxLayout->addWidget( new QLabel(QString(_("Private Unchanged")) + ": "), row, 0); generalInfoBoxLayout->addWidget( - new QLabel(QString::number(mResult.secret_unchanged)), row, 1); + new QLabel(QString::number(m_result_.secret_unchanged)), row, 1); row++; } } -void KeyImportDetailDialog::createKeysTable() { - LOG(INFO) << "KeyImportDetailDialog::createKeysTable() Called"; +void KeyImportDetailDialog::create_keys_table() { + LOG(INFO) << "KeyImportDetailDialog::create_keys_table() Called"; - keysTable = new QTableWidget(this); - keysTable->setRowCount(0); - keysTable->setColumnCount(4); - keysTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + keys_table_ = new QTableWidget(this); + keys_table_->setRowCount(0); + keys_table_->setColumnCount(4); + keys_table_->setEditTriggers(QAbstractItemView::NoEditTriggers); // Nothing is selectable - keysTable->setSelectionMode(QAbstractItemView::NoSelection); + keys_table_->setSelectionMode(QAbstractItemView::NoSelection); QStringList headerLabels; headerLabels << _("Name") << _("Email") << _("Status") << _("Fingerprint"); - keysTable->verticalHeader()->hide(); + keys_table_->verticalHeader()->hide(); - keysTable->setHorizontalHeaderLabels(headerLabels); + keys_table_->setHorizontalHeaderLabels(headerLabels); int row = 0; - for (const auto& imp_key : mResult.importedKeys) { - keysTable->setRowCount(row + 1); + for (const auto& imp_key : m_result_.importedKeys) { + keys_table_->setRowCount(row + 1); GpgKey key = GpgKeyGetter::GetInstance().GetKey(imp_key.fpr); if (!key.IsGood()) continue; - keysTable->setItem( + keys_table_->setItem( row, 0, new QTableWidgetItem(QString::fromStdString(key.GetName()))); - keysTable->setItem( + keys_table_->setItem( row, 1, new QTableWidgetItem(QString::fromStdString(key.GetEmail()))); - keysTable->setItem( - row, 2, new QTableWidgetItem(getStatusString(imp_key.import_status))); - keysTable->setItem( + keys_table_->setItem( + row, 2, new QTableWidgetItem(get_status_string(imp_key.import_status))); + keys_table_->setItem( row, 3, new QTableWidgetItem(QString::fromStdString(imp_key.fpr))); row++; } - keysTable->horizontalHeader()->setSectionResizeMode( + keys_table_->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::ResizeToContents); - keysTable->horizontalHeader()->setStretchLastSection(true); - keysTable->resizeColumnsToContents(); + keys_table_->horizontalHeader()->setStretchLastSection(true); + keys_table_->resizeColumnsToContents(); } -QString KeyImportDetailDialog::getStatusString(int keyStatus) { +QString KeyImportDetailDialog::get_status_string(int keyStatus) { QString statusString; // keystatus is greater than 15, if key is private if (keyStatus > 15) { @@ -195,8 +195,8 @@ QString KeyImportDetailDialog::getStatusString(int keyStatus) { return statusString; } -void KeyImportDetailDialog::createButtonBox() { - buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(close())); +void KeyImportDetailDialog::create_button_box() { + button_box_ = new QDialogButtonBox(QDialogButtonBox::Ok); + connect(button_box_, SIGNAL(accepted()), this, SLOT(close())); } } // namespace GpgFrontend::UI diff --git a/src/ui/KeyImportDetailDialog.h b/src/ui/KeyImportDetailDialog.h index 83cb7d55..b7eedc2e 100644 --- a/src/ui/KeyImportDetailDialog.h +++ b/src/ui/KeyImportDetailDialog.h @@ -35,24 +35,57 @@ #include "ui/GpgFrontendUI.h" namespace GpgFrontend::UI { + +/** + * @brief + * + */ class KeyImportDetailDialog : public QDialog { Q_OBJECT public: + /** + * @brief Construct a new Key Import Detail Dialog object + * + * @param result + * @param automatic + * @param parent + */ KeyImportDetailDialog(GpgImportInformation result, bool automatic, QWidget* parent = nullptr); private: - void createGeneralInfoBox(); - void createKeysTable(); - void createButtonBox(); - static QString getStatusString(int keyStatus); - - QTableWidget* keysTable{}; - QGroupBox* generalInfoBox{}; - QGroupBox* keyInfoBox{}; - QDialogButtonBox* buttonBox{}; - GpgImportInformation mResult; + /** + * @brief Create a general info box object + * + */ + void create_general_info_box(); + + /** + * @brief Create a keys table object + * + */ + void create_keys_table(); + + /** + * @brief Create a button box object + * + */ + void create_button_box(); + + /** + * @brief Get the status string object + * + * @param keyStatus + * @return QString + */ + static QString get_status_string(int keyStatus); + + QTableWidget* keys_table_{}; ///< + QGroupBox* general_info_box_{}; ///< + QGroupBox* key_info_box_{}; ///< + QDialogButtonBox* button_box_{}; ///< + GpgImportInformation m_result_; ///< }; } // namespace GpgFrontend::UI diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp index d236d81f..4b470607 100755 --- a/src/ui/KeyMgmt.cpp +++ b/src/ui/KeyMgmt.cpp @@ -92,10 +92,10 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) { key_list_->SlotRefresh(); - createActions(); - createMenus(); - createToolBars(); - connect(this, SIGNAL(signalStatusBarChanged(QString)), this->parent(), + create_actions(); + create_menus(); + create_tool_bars(); + connect(this, SIGNAL(SignalStatusBarChanged(QString)), this->parent(), SLOT(slotSetStatusBarText(QString))); auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); @@ -150,137 +150,143 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) { this->statusBar()->show(); setWindowTitle(_("KeyPair Management")); - key_list_->AddMenuAction(deleteSelectedKeysAct); - key_list_->AddMenuAction(showKeyDetailsAct); + key_list_->AddMenuAction(delete_selected_keys_act_); + key_list_->AddMenuAction(show_key_details_act_); - connect(this, SIGNAL(signalKeyStatusUpdated()), SignalStation::GetInstance(), + connect(this, SIGNAL(SignalKeyStatusUpdated()), SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh())); - connect(SignalStation::GetInstance(), &SignalStation::signalRefreshStatusBar, + connect(SignalStation::GetInstance(), &SignalStation::SignalRefreshStatusBar, this, [=](const QString& message, int timeout) { statusBar()->showMessage(message, timeout); }); } -void KeyMgmt::createActions() { - openKeyFileAct = new QAction(_("Open"), this); - openKeyFileAct->setShortcut(QKeySequence(_("Ctrl+O"))); - openKeyFileAct->setToolTip(_("Open Key File")); - connect(importKeyFromFileAct, &QAction::triggered, this, - [&]() { CommonUtils::GetInstance()->slotImportKeyFromFile(this); }); - - closeAct = new QAction(_("Close"), this); - closeAct->setShortcut(QKeySequence(_("Ctrl+Q"))); - closeAct->setIcon(QIcon(":exit.png")); - closeAct->setToolTip(_("Close")); - connect(closeAct, SIGNAL(triggered()), this, SLOT(close())); - - generateKeyPairAct = new QAction(_("New Keypair"), this); - generateKeyPairAct->setShortcut(QKeySequence(_("Ctrl+N"))); - generateKeyPairAct->setIcon(QIcon(":key_generate.png")); - generateKeyPairAct->setToolTip(_("Generate KeyPair")); - connect(generateKeyPairAct, SIGNAL(triggered()), this, - SLOT(slotGenerateKeyDialog())); - - generateSubKeyAct = new QAction(_("New Subkey"), this); - generateSubKeyAct->setShortcut(QKeySequence(_("Ctrl+Shift+N"))); - generateSubKeyAct->setIcon(QIcon(":key_generate.png")); - generateSubKeyAct->setToolTip(_("Generate Subkey For Selected KeyPair")); - connect(generateSubKeyAct, SIGNAL(triggered()), this, - SLOT(slotGenerateSubKey())); - - importKeyFromFileAct = new QAction(_("File"), this); - importKeyFromFileAct->setIcon(QIcon(":import_key_from_file.png")); - importKeyFromFileAct->setToolTip(_("Import New Key From File")); - connect(importKeyFromFileAct, &QAction::triggered, this, - [&]() { CommonUtils::GetInstance()->slotImportKeyFromFile(this); }); - - importKeyFromClipboardAct = new QAction(_("Clipboard"), this); - importKeyFromClipboardAct->setIcon(QIcon(":import_key_from_clipboard.png")); - importKeyFromClipboardAct->setToolTip(_("Import New Key From Clipboard")); - connect(importKeyFromClipboardAct, &QAction::triggered, this, [&]() { - CommonUtils::GetInstance()->slotImportKeyFromClipboard(this); +void KeyMgmt::create_actions() { + open_key_file_act_ = new QAction(_("Open"), this); + open_key_file_act_->setShortcut(QKeySequence(_("Ctrl+O"))); + open_key_file_act_->setToolTip(_("Open Key File")); + connect(import_key_from_file_act_, &QAction::triggered, this, + [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); }); + + close_act_ = new QAction(_("Close"), this); + close_act_->setShortcut(QKeySequence(_("Ctrl+Q"))); + close_act_->setIcon(QIcon(":exit.png")); + close_act_->setToolTip(_("Close")); + connect(close_act_, SIGNAL(triggered()), this, SLOT(close())); + + generate_key_pair_act_ = new QAction(_("New Keypair"), this); + generate_key_pair_act_->setShortcut(QKeySequence(_("Ctrl+N"))); + generate_key_pair_act_->setIcon(QIcon(":key_generate.png")); + generate_key_pair_act_->setToolTip(_("Generate KeyPair")); + connect(generate_key_pair_act_, SIGNAL(triggered()), this, + SLOT(SlotGenerateKeyDialog())); + + generate_subkey_act_ = new QAction(_("New Subkey"), this); + generate_subkey_act_->setShortcut(QKeySequence(_("Ctrl+Shift+N"))); + generate_subkey_act_->setIcon(QIcon(":key_generate.png")); + generate_subkey_act_->setToolTip(_("Generate Subkey For Selected KeyPair")); + connect(generate_subkey_act_, SIGNAL(triggered()), this, + SLOT(SlotGenerateSubKey())); + + import_key_from_file_act_ = new QAction(_("File"), this); + import_key_from_file_act_->setIcon(QIcon(":import_key_from_file.png")); + import_key_from_file_act_->setToolTip(_("Import New Key From File")); + connect(import_key_from_file_act_, &QAction::triggered, this, + [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); }); + + import_key_from_clipboard_act_ = new QAction(_("Clipboard"), this); + import_key_from_clipboard_act_->setIcon( + QIcon(":import_key_from_clipboard.png")); + import_key_from_clipboard_act_->setToolTip( + _("Import New Key From Clipboard")); + connect(import_key_from_clipboard_act_, &QAction::triggered, this, [&]() { + CommonUtils::GetInstance()->SlotImportKeyFromClipboard(this); }); - importKeyFromKeyServerAct = new QAction(_("Keyserver"), this); - importKeyFromKeyServerAct->setIcon(QIcon(":import_key_from_server.png")); - importKeyFromKeyServerAct->setToolTip(_("Import New Key From Keyserver")); - connect(importKeyFromKeyServerAct, &QAction::triggered, this, [&]() { - CommonUtils::GetInstance()->slotImportKeyFromKeyServer(this); + import_key_from_key_server_act_ = new QAction(_("Keyserver"), this); + import_key_from_key_server_act_->setIcon( + QIcon(":import_key_from_server.png")); + import_key_from_key_server_act_->setToolTip( + _("Import New Key From Keyserver")); + connect(import_key_from_key_server_act_, &QAction::triggered, this, [&]() { + CommonUtils::GetInstance()->SlotImportKeyFromKeyServer(this); }); - importKeysFromKeyPackageAct = new QAction(_("Key Package"), this); - importKeysFromKeyPackageAct->setIcon(QIcon(":key_package.png")); - importKeysFromKeyPackageAct->setToolTip( + import_keys_from_key_package_act_ = new QAction(_("Key Package"), this); + import_keys_from_key_package_act_->setIcon(QIcon(":key_package.png")); + import_keys_from_key_package_act_->setToolTip( _("Import Key(s) From a Key Package")); - connect(importKeysFromKeyPackageAct, &QAction::triggered, this, - &KeyMgmt::slotImportKeyPackage); - - exportKeyToClipboardAct = new QAction(_("Export To Clipboard"), this); - exportKeyToClipboardAct->setIcon(QIcon(":export_key_to_clipboard.png")); - exportKeyToClipboardAct->setToolTip(_("Export Selected Key(s) To Clipboard")); - connect(exportKeyToClipboardAct, SIGNAL(triggered()), this, - SLOT(slotExportKeyToClipboard())); - - exportKeyToFileAct = new QAction(_("Export To Key Package"), this); - exportKeyToFileAct->setIcon(QIcon(":key_package.png")); - exportKeyToFileAct->setToolTip(_("Export Checked Key(s) To a Key Package")); - connect(exportKeyToFileAct, SIGNAL(triggered()), this, - SLOT(slotExportKeyToKeyPackage())); - - exportKeyAsOpenSSHFormat = new QAction(_("Export As OpenSSH"), this); - exportKeyAsOpenSSHFormat->setIcon(QIcon(":ssh-key.png")); - exportKeyAsOpenSSHFormat->setToolTip( + connect(import_keys_from_key_package_act_, &QAction::triggered, this, + &KeyMgmt::SlotImportKeyPackage); + + export_key_to_clipboard_act_ = new QAction(_("Export To Clipboard"), this); + export_key_to_clipboard_act_->setIcon(QIcon(":export_key_to_clipboard.png")); + export_key_to_clipboard_act_->setToolTip( + _("Export Selected Key(s) To Clipboard")); + connect(export_key_to_clipboard_act_, SIGNAL(triggered()), this, + SLOT(SlotExportKeyToClipboard())); + + export_key_to_file_act_ = new QAction(_("Export To Key Package"), this); + export_key_to_file_act_->setIcon(QIcon(":key_package.png")); + export_key_to_file_act_->setToolTip( + _("Export Checked Key(s) To a Key Package")); + connect(export_key_to_file_act_, SIGNAL(triggered()), this, + SLOT(SlotExportKeyToKeyPackage())); + + export_key_as_open_ssh_format_ = new QAction(_("Export As OpenSSH"), this); + export_key_as_open_ssh_format_->setIcon(QIcon(":ssh-key.png")); + export_key_as_open_ssh_format_->setToolTip( _("Export Selected Key(s) As OpenSSH Format to File")); - connect(exportKeyAsOpenSSHFormat, SIGNAL(triggered()), this, - SLOT(slotExportAsOpenSSHFormat())); - - deleteSelectedKeysAct = new QAction(_("Delete Selected Key(s)"), this); - deleteSelectedKeysAct->setToolTip(_("Delete the Selected keys")); - connect(deleteSelectedKeysAct, SIGNAL(triggered()), this, - SLOT(slotDeleteSelectedKeys())); - - deleteCheckedKeysAct = new QAction(_("Delete Checked Key(s)"), this); - deleteCheckedKeysAct->setToolTip(_("Delete the Checked keys")); - deleteCheckedKeysAct->setIcon(QIcon(":button_delete.png")); - connect(deleteCheckedKeysAct, SIGNAL(triggered()), this, - SLOT(slotDeleteCheckedKeys())); - - showKeyDetailsAct = new QAction(_("Show Key Details"), this); - showKeyDetailsAct->setToolTip(_("Show Details for this Key")); - connect(showKeyDetailsAct, SIGNAL(triggered()), this, - SLOT(slotShowKeyDetails())); + connect(export_key_as_open_ssh_format_, SIGNAL(triggered()), this, + SLOT(SlotExportAsOpenSSHFormat())); + + delete_selected_keys_act_ = new QAction(_("Delete Selected Key(s)"), this); + delete_selected_keys_act_->setToolTip(_("Delete the Selected keys")); + connect(delete_selected_keys_act_, SIGNAL(triggered()), this, + SLOT(SlotDeleteSelectedKeys())); + + delete_checked_keys_act_ = new QAction(_("Delete Checked Key(s)"), this); + delete_checked_keys_act_->setToolTip(_("Delete the Checked keys")); + delete_checked_keys_act_->setIcon(QIcon(":button_delete.png")); + connect(delete_checked_keys_act_, SIGNAL(triggered()), this, + SLOT(SlotDeleteCheckedKeys())); + + show_key_details_act_ = new QAction(_("Show Key Details"), this); + show_key_details_act_->setToolTip(_("Show Details for this Key")); + connect(show_key_details_act_, SIGNAL(triggered()), this, + SLOT(SlotShowKeyDetails())); } -void KeyMgmt::createMenus() { - fileMenu = menuBar()->addMenu(_("File")); - fileMenu->addAction(openKeyFileAct); - fileMenu->addAction(closeAct); - - keyMenu = menuBar()->addMenu(_("Key")); - generateKeyMenu = keyMenu->addMenu(_("Generate Key")); - generateKeyMenu->addAction(generateKeyPairAct); - generateKeyMenu->addAction(generateSubKeyAct); - - importKeyMenu = keyMenu->addMenu(_("Import Key")); - importKeyMenu->addAction(importKeyFromFileAct); - importKeyMenu->addAction(importKeyFromClipboardAct); - importKeyMenu->addAction(importKeyFromKeyServerAct); - importKeyMenu->addAction(importKeysFromKeyPackageAct); - - keyMenu->addAction(exportKeyToFileAct); - keyMenu->addAction(exportKeyToClipboardAct); - keyMenu->addAction(exportKeyAsOpenSSHFormat); - keyMenu->addSeparator(); - keyMenu->addAction(deleteCheckedKeysAct); +void KeyMgmt::create_menus() { + file_menu_ = menuBar()->addMenu(_("File")); + file_menu_->addAction(open_key_file_act_); + file_menu_->addAction(close_act_); + + key_menu_ = menuBar()->addMenu(_("Key")); + generate_key_menu_ = key_menu_->addMenu(_("Generate Key")); + generate_key_menu_->addAction(generate_key_pair_act_); + generate_key_menu_->addAction(generate_subkey_act_); + + import_key_menu_ = key_menu_->addMenu(_("Import Key")); + import_key_menu_->addAction(import_key_from_file_act_); + import_key_menu_->addAction(import_key_from_clipboard_act_); + import_key_menu_->addAction(import_key_from_key_server_act_); + import_key_menu_->addAction(import_keys_from_key_package_act_); + + key_menu_->addAction(export_key_to_file_act_); + key_menu_->addAction(export_key_to_clipboard_act_); + key_menu_->addAction(export_key_as_open_ssh_format_); + key_menu_->addSeparator(); + key_menu_->addAction(delete_checked_keys_act_); } -void KeyMgmt::createToolBars() { +void KeyMgmt::create_tool_bars() { QToolBar* keyToolBar = addToolBar(_("Key")); keyToolBar->setObjectName("keytoolbar"); // add button with popup menu for import auto* generateToolButton = new QToolButton(this); - generateToolButton->setMenu(generateKeyMenu); + generateToolButton->setMenu(generate_key_menu_); generateToolButton->setPopupMode(QToolButton::InstantPopup); generateToolButton->setIcon(QIcon(":key_generate.png")); generateToolButton->setText(_("Generate")); @@ -290,7 +296,7 @@ void KeyMgmt::createToolBars() { // add button with popup menu for import auto* toolButton = new QToolButton(this); - toolButton->setMenu(importKeyMenu); + toolButton->setMenu(import_key_menu_); toolButton->setPopupMode(QToolButton::InstantPopup); toolButton->setIcon(QIcon(":key_import.png")); toolButton->setToolTip(_("Import key")); @@ -299,30 +305,30 @@ void KeyMgmt::createToolBars() { keyToolBar->addWidget(toolButton); keyToolBar->addSeparator(); - keyToolBar->addAction(deleteCheckedKeysAct); + keyToolBar->addAction(delete_checked_keys_act_); keyToolBar->addSeparator(); - keyToolBar->addAction(exportKeyToFileAct); - keyToolBar->addAction(exportKeyToClipboardAct); - keyToolBar->addAction(exportKeyAsOpenSSHFormat); + keyToolBar->addAction(export_key_to_file_act_); + keyToolBar->addAction(export_key_to_clipboard_act_); + keyToolBar->addAction(export_key_as_open_ssh_format_); } -void KeyMgmt::slotDeleteSelectedKeys() { - deleteKeysWithWarning(key_list_->GetSelected()); +void KeyMgmt::SlotDeleteSelectedKeys() { + delete_keys_with_warning(key_list_->GetSelected()); } -void KeyMgmt::slotDeleteCheckedKeys() { - deleteKeysWithWarning(key_list_->GetChecked()); +void KeyMgmt::SlotDeleteCheckedKeys() { + delete_keys_with_warning(key_list_->GetChecked()); } -void KeyMgmt::deleteKeysWithWarning(KeyIdArgsListPtr key_ids) { +void KeyMgmt::delete_keys_with_warning(KeyIdArgsListPtr uidList) { /** * TODO: Different Messages for private/public key, check if * more than one selected... compare to seahorse "delete-dialog" */ - if (key_ids->empty()) return; + if (uidList->empty()) return; QString keynames; - for (const auto& key_id : *key_ids) { + for (const auto& key_id : *uidList) { auto key = GpgKeyGetter::GetInstance().GetKey(key_id); if (!key.IsGood()) continue; keynames.append(QString::fromStdString(key.GetName())); @@ -341,12 +347,12 @@ void KeyMgmt::deleteKeysWithWarning(KeyIdArgsListPtr key_ids) { QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { - GpgKeyOpera::GetInstance().DeleteKeys(std::move(key_ids)); - emit signalKeyStatusUpdated(); + GpgKeyOpera::GetInstance().DeleteKeys(std::move(uidList)); + emit SignalKeyStatusUpdated(); } } -void KeyMgmt::slotShowKeyDetails() { +void KeyMgmt::SlotShowKeyDetails() { auto keys_selected = key_list_->GetSelected(); if (keys_selected->empty()) return; @@ -360,7 +366,7 @@ void KeyMgmt::slotShowKeyDetails() { new KeyDetailsDialog(key); } -void KeyMgmt::slotExportKeyToKeyPackage() { +void KeyMgmt::SlotExportKeyToKeyPackage() { auto keys_checked = key_list_->GetChecked(); if (keys_checked->empty()) { QMessageBox::critical( @@ -370,10 +376,10 @@ void KeyMgmt::slotExportKeyToKeyPackage() { } auto dialog = new ExportKeyPackageDialog(std::move(keys_checked), this); dialog->exec(); - emit signalStatusBarChanged(QString(_("key(s) exported"))); + emit SignalStatusBarChanged(QString(_("key(s) exported"))); } -void KeyMgmt::slotExportKeyToClipboard() { +void KeyMgmt::SlotExportKeyToClipboard() { auto keys_checked = key_list_->GetChecked(); if (keys_checked->empty()) { QMessageBox::critical( @@ -390,17 +396,17 @@ void KeyMgmt::slotExportKeyToClipboard() { QApplication::clipboard()->setText(QString::fromStdString(*key_export_data)); } -void KeyMgmt::slotGenerateKeyDialog() { +void KeyMgmt::SlotGenerateKeyDialog() { auto* keyGenDialog = new KeyGenDialog(this); keyGenDialog->show(); } void KeyMgmt::closeEvent(QCloseEvent* event) { - slotSaveWindowState(); + SlotSaveWindowState(); QMainWindow::closeEvent(event); } -void KeyMgmt::slotGenerateSubKey() { +void KeyMgmt::SlotGenerateSubKey() { auto keys_selected = key_list_->GetSelected(); if (keys_selected->empty()) { QMessageBox::information( @@ -423,7 +429,7 @@ void KeyMgmt::slotGenerateSubKey() { auto dialog = new SubkeyGenerateDialog(key.GetId(), this); dialog->show(); } -void KeyMgmt::slotSaveWindowState() { +void KeyMgmt::SlotSaveWindowState() { auto& settings = GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings(); @@ -470,7 +476,7 @@ void KeyMgmt::slotSaveWindowState() { GlobalSettingStation::GetInstance().SyncSettings(); } -void KeyMgmt::slotExportAsOpenSSHFormat() { +void KeyMgmt::SlotExportAsOpenSSHFormat() { ByteArrayPtr key_export_data = nullptr; auto keys_checked = key_list_->GetChecked(); @@ -511,11 +517,11 @@ void KeyMgmt::slotExportAsOpenSSHFormat() { if (!file_name.isEmpty()) { write_buffer_to_file(file_name.toStdString(), *key_export_data); - emit signalStatusBarChanged(QString(_("key(s) exported"))); + emit SignalStatusBarChanged(QString(_("key(s) exported"))); } } -void KeyMgmt::slotImportKeyPackage() { +void KeyMgmt::SlotImportKeyPackage() { auto key_package_file_name = QFileDialog::getOpenFileName( this, _("Import Key Package"), {}, QString(_("Key Package")) + " (*.gfepack);;All Files (*)"); diff --git a/src/ui/KeyMgmt.h b/src/ui/KeyMgmt.h index 2e6bc814..3bf0b4d2 100755 --- a/src/ui/KeyMgmt.h +++ b/src/ui/KeyMgmt.h @@ -38,72 +38,151 @@ namespace GpgFrontend::UI { +/** + * @brief + * + */ class KeyMgmt : public QMainWindow { Q_OBJECT public: + /** + * @brief Construct a new Key Mgmt object + * + * @param parent + */ explicit KeyMgmt(QWidget* parent = nullptr); public slots: - void slotGenerateSubKey(); - - void slotExportKeyToKeyPackage(); - - void slotExportKeyToClipboard(); - - void slotExportAsOpenSSHFormat(); - - void slotDeleteSelectedKeys(); - - void slotDeleteCheckedKeys(); - - void slotGenerateKeyDialog(); - - void slotShowKeyDetails(); - - void slotSaveWindowState(); - - void slotImportKeyPackage(); + /** + * @brief + * + */ + void SlotGenerateSubKey(); + + /** + * @brief + * + */ + void SlotExportKeyToKeyPackage(); + + /** + * @brief + * + */ + void SlotExportKeyToClipboard(); + + /** + * @brief + * + */ + void SlotExportAsOpenSSHFormat(); + + /** + * @brief + * + */ + void SlotDeleteSelectedKeys(); + + /** + * @brief + * + */ + void SlotDeleteCheckedKeys(); + + /** + * @brief + * + */ + void SlotGenerateKeyDialog(); + + /** + * @brief + * + */ + void SlotShowKeyDetails(); + + /** + * @brief + * + */ + void SlotSaveWindowState(); + + /** + * @brief + * + */ + void SlotImportKeyPackage(); signals: - void signalStatusBarChanged(QString); + /** + * @brief + * + */ + void SignalStatusBarChanged(QString); - void signalKeyStatusUpdated(); + /** + * @brief + * + */ + void SignalKeyStatusUpdated(); private: - void createMenus(); - - void createActions(); - - void createToolBars(); - - void deleteKeysWithWarning(GpgFrontend::KeyIdArgsListPtr uidList); - - KeyList* key_list_; - QMenu* fileMenu{}; - QMenu* keyMenu{}; - QMenu* generateKeyMenu{}; - QMenu* importKeyMenu{}; - QAction* openKeyFileAct{}; - QAction* exportKeyToFileAct{}; - QAction* exportKeyAsOpenSSHFormat{}; - QAction* exportKeyToClipboardAct{}; - QAction* deleteCheckedKeysAct{}; - QAction* deleteSelectedKeysAct{}; - QAction* generateKeyDialogAct{}; - QAction* generateKeyPairAct{}; - QAction* generateSubKeyAct{}; - QAction* importKeyFromClipboardAct{}; - QAction* importKeyFromFileAct{}; - QAction* importKeyFromKeyServerAct{}; - QAction* importKeysFromKeyPackageAct{}; - QAction* closeAct{}; - QAction* showKeyDetailsAct{}; - KeyServerImportDialog* importDialog{}; + /** + * @brief Create a menus object + * + */ + void create_menus(); + + /** + * @brief Create a actions object + * + */ + void create_actions(); + + /** + * @brief Create a tool bars object + * + */ + void create_tool_bars(); + + /** + * @brief + * + * @param uidList + */ + void delete_keys_with_warning(GpgFrontend::KeyIdArgsListPtr uidList); + + KeyList* key_list_; ///< + QMenu* file_menu_{}; ///< + QMenu* key_menu_{}; ///< + QMenu* generate_key_menu_{}; ///< + QMenu* import_key_menu_{}; ///< + QAction* open_key_file_act_{}; ///< + QAction* export_key_to_file_act_{}; ///< + QAction* export_key_as_open_ssh_format_{}; ///< + QAction* export_key_to_clipboard_act_{}; ///< + QAction* delete_checked_keys_act_{}; ///< + QAction* delete_selected_keys_act_{}; ///< + QAction* generate_key_dialog_act_{}; ///< + QAction* generate_key_pair_act_{}; ///< + QAction* generate_subkey_act_{}; ///< + QAction* import_key_from_clipboard_act_{}; ///< + QAction* import_key_from_file_act_{}; ///< + QAction* import_key_from_key_server_act_{}; ///< + QAction* import_keys_from_key_package_act_{}; ///< + QAction* close_act_{}; ///< + QAction* show_key_details_act_{}; ///< + KeyServerImportDialog* import_dialog_{}; ///< protected: + /** + * @brief + * + * @param event + */ void closeEvent(QCloseEvent* event) override; }; diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp index 5aedc282..0cc3d195 100644 --- a/src/ui/KeyServerImportDialog.cpp +++ b/src/ui/KeyServerImportDialog.cpp @@ -37,7 +37,7 @@ namespace GpgFrontend::UI { KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent) - : QDialog(parent), mAutomatic(automatic) { + : QDialog(parent), m_automatic_(automatic) { // Layout for messagebox auto* messageLayout = new QHBoxLayout; @@ -45,37 +45,37 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent) setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); } else { // Buttons - closeButton = createButton(_("Close"), SLOT(close())); - importButton = createButton(_("Import ALL"), SLOT(slotImport())); - importButton->setDisabled(true); - searchButton = createButton(_("Search"), SLOT(slotSearch())); + close_button_ = create_button(_("Close"), SLOT(close())); + import_button_ = create_button(_("Import ALL"), SLOT(slot_import())); + import_button_->setDisabled(true); + search_button_ = create_button(_("Search"), SLOT(slot_search())); // Line edit for search string - searchLabel = new QLabel(QString(_("Search String")) + _(": ")); - searchLineEdit = new QLineEdit(); + search_label_ = new QLabel(QString(_("Search String")) + _(": ")); + search_line_edit_ = new QLineEdit(); // combobox for keyserverlist - keyServerLabel = new QLabel(QString(_("Key Server")) + _(": ")); - keyServerComboBox = createComboBox(); + key_server_label_ = new QLabel(QString(_("Key Server")) + _(": ")); + key_server_combo_box_ = create_comboBox(); // table containing the keys found - createKeysTable(); - message = new QLabel; - message->setFixedHeight(24); - icon = new QLabel; - icon->setFixedHeight(24); - - messageLayout->addWidget(icon); - messageLayout->addWidget(message); + create_keys_table(); + message_ = new QLabel; + message_->setFixedHeight(24); + icon_ = new QLabel; + icon_->setFixedHeight(24); + + messageLayout->addWidget(icon_); + messageLayout->addWidget(message_); messageLayout->addStretch(); } // Network Waiting - waitingBar = new QProgressBar(); - waitingBar->setVisible(false); - waitingBar->setRange(0, 0); - waitingBar->setFixedWidth(200); - messageLayout->addWidget(waitingBar); + waiting_bar_ = new QProgressBar(); + waiting_bar_->setVisible(false); + waiting_bar_->setRange(0, 0); + waiting_bar_->setFixedWidth(200); + messageLayout->addWidget(waiting_bar_); auto* mainLayout = new QGridLayout; @@ -83,19 +83,19 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent) if (automatic) { mainLayout->addLayout(messageLayout, 0, 0, 1, 3); } else { - mainLayout->addWidget(searchLabel, 1, 0); - mainLayout->addWidget(searchLineEdit, 1, 1); - mainLayout->addWidget(searchButton, 1, 2); - mainLayout->addWidget(keyServerLabel, 2, 0); - mainLayout->addWidget(keyServerComboBox, 2, 1); - mainLayout->addWidget(keysTable, 3, 0, 1, 3); + mainLayout->addWidget(search_label_, 1, 0); + mainLayout->addWidget(search_line_edit_, 1, 1); + mainLayout->addWidget(search_button_, 1, 2); + mainLayout->addWidget(key_server_label_, 2, 0); + mainLayout->addWidget(key_server_combo_box_, 2, 1); + mainLayout->addWidget(keys_table_, 3, 0, 1, 3); mainLayout->addLayout(messageLayout, 4, 0, 1, 3); // Layout for import and close button auto* buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); - buttonsLayout->addWidget(importButton); - buttonsLayout->addWidget(closeButton); + buttonsLayout->addWidget(import_button_); + buttonsLayout->addWidget(close_button_); mainLayout->addLayout(buttonsLayout, 6, 0, 1, 3); } @@ -135,21 +135,21 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent) this->setModal(true); - connect(this, SIGNAL(signalKeyImported()), SignalStation::GetInstance(), + connect(this, SIGNAL(SignalKeyImported()), SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh())); // save window pos and size to configure file - connect(this, SIGNAL(finished(int)), this, SLOT(slotSaveWindowState())); + connect(this, SIGNAL(finished(int)), this, SLOT(slot_save_window_state())); } -QPushButton* KeyServerImportDialog::createButton(const QString& text, - const char* member) { +QPushButton* KeyServerImportDialog::create_button(const QString& text, + const char* member) { auto* button = new QPushButton(text); connect(button, SIGNAL(clicked()), this, member); return button; } -QComboBox* KeyServerImportDialog::createComboBox() { +QComboBox* KeyServerImportDialog::create_comboBox() { auto* comboBox = new QComboBox; comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); @@ -177,78 +177,80 @@ QComboBox* KeyServerImportDialog::createComboBox() { return comboBox; } -void KeyServerImportDialog::createKeysTable() { - keysTable = new QTableWidget(); - keysTable->setColumnCount(4); +void KeyServerImportDialog::create_keys_table() { + keys_table_ = new QTableWidget(); + keys_table_->setColumnCount(4); // always a whole row is marked - keysTable->setSelectionBehavior(QAbstractItemView::SelectRows); - keysTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + keys_table_->setSelectionBehavior(QAbstractItemView::SelectRows); + keys_table_->setEditTriggers(QAbstractItemView::NoEditTriggers); // Make just one row selectable - keysTable->setSelectionMode(QAbstractItemView::SingleSelection); + keys_table_->setSelectionMode(QAbstractItemView::SingleSelection); QStringList labels; labels << _("UID") << _("Creation date") << _("KeyID") << _("Tag"); - keysTable->horizontalHeader()->setSectionResizeMode( + keys_table_->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::ResizeToContents); - keysTable->setHorizontalHeaderLabels(labels); - keysTable->verticalHeader()->hide(); + keys_table_->setHorizontalHeaderLabels(labels); + keys_table_->verticalHeader()->hide(); - connect(keysTable, SIGNAL(cellActivated(int, int)), this, SLOT(slotImport())); + connect(keys_table_, SIGNAL(cellActivated(int, int)), this, + SLOT(slot_import())); } -void KeyServerImportDialog::setMessage(const QString& text, bool error) { - if (mAutomatic) return; +void KeyServerImportDialog::set_message(const QString& text, bool error) { + if (m_automatic_) return; - message->setText(text); + message_->setText(text); if (error) { - icon->setPixmap( + icon_->setPixmap( QPixmap(":error.png").scaled(QSize(24, 24), Qt::KeepAspectRatio)); } else { - icon->setPixmap( + icon_->setPixmap( QPixmap(":info.png").scaled(QSize(24, 24), Qt::KeepAspectRatio)); } } -void KeyServerImportDialog::slotSearch() { - if (searchLineEdit->text().isEmpty()) { - setMessage("<h4>" + QString(_("Text is empty.")) + "</h4>", false); +void KeyServerImportDialog::slot_search() { + if (search_line_edit_->text().isEmpty()) { + set_message("<h4>" + QString(_("Text is empty.")) + "</h4>", false); return; } - QUrl url_from_remote = keyServerComboBox->currentText() + - "/pks/lookup?search=" + searchLineEdit->text() + + QUrl url_from_remote = key_server_combo_box_->currentText() + + "/pks/lookup?search=" + search_line_edit_->text() + "&op=index&options=mr"; - qnam = new QNetworkAccessManager(this); - QNetworkReply* reply = qnam->get(QNetworkRequest(url_from_remote)); + network_access_manager_ = new QNetworkAccessManager(this); + QNetworkReply* reply = + network_access_manager_->get(QNetworkRequest(url_from_remote)); - connect(reply, SIGNAL(finished()), this, SLOT(slotSearchFinished())); + connect(reply, SIGNAL(finished()), this, SLOT(slot_search_finished())); - setLoading(true); - this->searchButton->setDisabled(true); - this->keyServerComboBox->setDisabled(true); - this->searchLineEdit->setReadOnly(true); - this->importButton->setDisabled(true); + set_loading(true); + this->search_button_->setDisabled(true); + this->key_server_combo_box_->setDisabled(true); + this->search_line_edit_->setReadOnly(true); + this->import_button_->setDisabled(true); while (reply->isRunning()) { QApplication::processEvents(); } - this->searchButton->setDisabled(false); - this->keyServerComboBox->setDisabled(false); - this->searchLineEdit->setReadOnly(false); - this->importButton->setDisabled(false); - setLoading(false); + this->search_button_->setDisabled(false); + this->key_server_combo_box_->setDisabled(false); + this->search_line_edit_->setReadOnly(false); + this->import_button_->setDisabled(false); + set_loading(false); } -void KeyServerImportDialog::slotSearchFinished() { - LOG(INFO) << "KeyServerImportDialog::slotSearchFinished Called"; +void KeyServerImportDialog::slot_search_finished() { + LOG(INFO) << "KeyServerImportDialog::slot_search_finished Called"; auto* reply = qobject_cast<QNetworkReply*>(sender()); - keysTable->clearContents(); - keysTable->setRowCount(0); + keys_table_->clearContents(); + keys_table_->setRowCount(0); QString first_line = QString(reply->readLine(1024)); auto error = reply->error(); @@ -256,16 +258,16 @@ void KeyServerImportDialog::slotSearchFinished() { qDebug() << "Error From Reply" << reply->errorString(); switch (error) { case QNetworkReply::ContentNotFoundError: - setMessage(_("Not Key Found"), true); + set_message(_("Not Key Found"), true); break; case QNetworkReply::TimeoutError: - setMessage(_("Timeout"), true); + set_message(_("Timeout"), true); break; case QNetworkReply::HostNotFoundError: - setMessage(_("Key Server Not Found"), true); + set_message(_("Key Server Not Found"), true); break; default: - setMessage(_("Connection Error"), true); + set_message(_("Connection Error"), true); } return; } @@ -273,38 +275,39 @@ void KeyServerImportDialog::slotSearchFinished() { if (first_line.contains("Error")) { QString text = QString(reply->readLine(1024)); if (text.contains("Too many responses")) { - setMessage( + set_message( "<h4>" + QString(_("Too many responses from keyserver!")) + "</h4>", true); return; } else if (text.contains("No keys found")) { // if string looks like hex string, search again with 0x prepended QRegExp rx("[0-9A-Fa-f]*"); - QString query = searchLineEdit->text(); + QString query = search_line_edit_->text(); if (rx.exactMatch(query)) { - setMessage( + set_message( "<h4>" + QString(_("No keys found, input may be kexId, retrying search " "with 0x.")) + "</h4>", true); - searchLineEdit->setText(query.prepend("0x")); - this->slotSearch(); + search_line_edit_->setText(query.prepend("0x")); + this->slot_search(); return; } else { - setMessage( + set_message( "<h4>" + QString(_("No keys found containing the search string!")) + "</h4>", true); return; } } else if (text.contains("Insufficiently specific words")) { - setMessage("<h4>" + QString(_("Insufficiently specific search string!")) + - "</h4>", - true); + set_message("<h4>" + + QString(_("Insufficiently specific search string!")) + + "</h4>", + true); return; } else { - setMessage(text, true); + set_message(text, true); return; } } else { @@ -320,23 +323,23 @@ void KeyServerImportDialog::slotSearchFinished() { strikeout = false; QString flags = line[line.size() - 1]; - keysTable->setRowCount(row + 1); + keys_table_->setRowCount(row + 1); // flags can be "d" for disabled, "r" for revoked // or "e" for expired if (flags.contains("r") or flags.contains("d") or flags.contains("e")) { strikeout = true; if (flags.contains("e")) { - keysTable->setItem(row, 3, - new QTableWidgetItem(QString("expired"))); + keys_table_->setItem(row, 3, + new QTableWidgetItem(QString("expired"))); } if (flags.contains("r")) { - keysTable->setItem(row, 3, - new QTableWidgetItem(QString(_("revoked")))); + keys_table_->setItem(row, 3, + new QTableWidgetItem(QString(_("revoked")))); } if (flags.contains("d")) { - keysTable->setItem(row, 3, - new QTableWidgetItem(QString(_("disabled")))); + keys_table_->setItem(row, 3, + new QTableWidgetItem(QString(_("disabled")))); } } @@ -345,13 +348,13 @@ void KeyServerImportDialog::slotSearchFinished() { auto* uid = new QTableWidgetItem(); if (line2.size() > 1) { uid->setText(line2[1]); - keysTable->setItem(row, 0, uid); + keys_table_->setItem(row, 0, uid); } auto* creation_date = new QTableWidgetItem( QDateTime::fromTime_t(line[4].toInt()).toString("dd. MMM. yyyy")); - keysTable->setItem(row, 1, creation_date); + keys_table_->setItem(row, 1, creation_date); auto* keyid = new QTableWidgetItem(line[1]); - keysTable->setItem(row, 2, keyid); + keys_table_->setItem(row, 2, keyid); if (strikeout) { QFont strike = uid->font(); strike.setStrikeOut(true); @@ -363,12 +366,12 @@ void KeyServerImportDialog::slotSearchFinished() { } else { if (line[0] == "uid") { QStringList l; - int height = keysTable->rowHeight(row - 1); - keysTable->setRowHeight(row - 1, height + 16); - QString tmp = keysTable->item(row - 1, 0)->text(); + int height = keys_table_->rowHeight(row - 1); + keys_table_->setRowHeight(row - 1, height + 16); + QString tmp = keys_table_->item(row - 1, 0)->text(); tmp.append(QString("\n") + line[1]); auto* tmp1 = new QTableWidgetItem(tmp); - keysTable->setItem(row - 1, 0, tmp1); + keys_table_->setItem(row - 1, 0, tmp1); if (strikeout) { QFont strike = tmp1->font(); strike.setStrikeOut(true); @@ -376,31 +379,31 @@ void KeyServerImportDialog::slotSearchFinished() { } } } - setMessage( + set_message( QString("<h4>") + QString(_("%1 keys found. Double click a key to import it.")) .arg(row) + "</h4>", false); } - keysTable->resizeColumnsToContents(); - importButton->setDisabled(keysTable->size().isEmpty()); + keys_table_->resizeColumnsToContents(); + import_button_->setDisabled(keys_table_->size().isEmpty()); } reply->deleteLater(); } -void KeyServerImportDialog::slotImport() { - LOG(INFO) << _("Current Row") << keysTable->currentRow(); - if (keysTable->currentRow() > -1) { - QString keyid = keysTable->item(keysTable->currentRow(), 2)->text(); - slotImport(QStringList(keyid), keyServerComboBox->currentText()); +void KeyServerImportDialog::slot_import() { + LOG(INFO) << _("Current Row") << keys_table_->currentRow(); + if (keys_table_->currentRow() > -1) { + QString keyid = keys_table_->item(keys_table_->currentRow(), 2)->text(); + SlotImport(QStringList(keyid), key_server_combo_box_->currentText()); } } -void KeyServerImportDialog::slotImport(const KeyIdArgsListPtr& keys) { +void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) { std::string target_keyserver; - if (keyServerComboBox != nullptr) { - target_keyserver = keyServerComboBox->currentText().toStdString(); + if (key_server_combo_box_ != nullptr) { + target_keyserver = key_server_combo_box_->currentText().toStdString(); } if (target_keyserver.empty()) { try { @@ -422,13 +425,13 @@ void KeyServerImportDialog::slotImport(const KeyIdArgsListPtr& keys) { auto key_ids = QStringList(); for (const auto& key_id : *keys) key_ids.append(QString::fromStdString(key_id)); - slotImport(key_ids, QUrl(target_keyserver.c_str())); + SlotImport(key_ids, QUrl(target_keyserver.c_str())); } -void KeyServerImportDialog::slotImport(const QStringList& keyIds, - const QUrl& keyServerUrl) { +void KeyServerImportDialog::SlotImport(const QStringList& keyIds, + const QUrl& keyserverUrl) { for (const auto& keyId : keyIds) { - QUrl req_url(keyServerUrl.scheme() + "://" + keyServerUrl.host() + + QUrl req_url(keyserverUrl.scheme() + "://" + keyserverUrl.host() + "/pks/lookup?op=get&search=0x" + keyId + "&options=mr"); LOG(INFO) << "request url" << req_url.toString().toStdString(); @@ -436,16 +439,16 @@ void KeyServerImportDialog::slotImport(const QStringList& keyIds, QNetworkReply* reply = manager->get(QNetworkRequest(req_url)); connect(reply, &QNetworkReply::finished, this, - [&, keyId]() { this->slotImportFinished(keyId); }); + [&, keyId]() { this->slot_import_finished(keyId); }); LOG(INFO) << "loading start"; - setLoading(true); + set_loading(true); while (reply->isRunning()) QApplication::processEvents(); - setLoading(false); + set_loading(false); LOG(INFO) << "loading done"; } } -void KeyServerImportDialog::slotImportFinished(const QString& keyid) { +void KeyServerImportDialog::slot_import_finished(const QString& keyid) { LOG(INFO) << _("Called"); auto* reply = qobject_cast<QNetworkReply*>(sender()); @@ -455,19 +458,19 @@ void KeyServerImportDialog::slotImportFinished(const QString& keyid) { auto error = reply->error(); if (error != QNetworkReply::NoError) { LOG(ERROR) << "Error From Reply" << reply->errorString().toStdString(); - if (!mAutomatic) { + if (!m_automatic_) { switch (error) { case QNetworkReply::ContentNotFoundError: - setMessage(_("Key Not Found"), true); + set_message(_("Key Not Found"), true); break; case QNetworkReply::TimeoutError: - setMessage(_("Timeout"), true); + set_message(_("Timeout"), true); break; case QNetworkReply::HostNotFoundError: - setMessage(_("Key Server Not Found"), true); + set_message(_("Key Server Not Found"), true); break; default: - setMessage(_("Connection Error"), true); + set_message(_("Connection Error"), true); } } else { switch (error) { @@ -489,7 +492,7 @@ void KeyServerImportDialog::slotImportFinished(const QString& keyid) { _("General Connection Error")); } } - if (mAutomatic) { + if (m_automatic_) { setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); } @@ -498,19 +501,19 @@ void KeyServerImportDialog::slotImportFinished(const QString& keyid) { reply->deleteLater(); - this->importKeys(std::make_unique<ByteArray>(key.constData(), key.length())); + this->import_keys(std::make_unique<ByteArray>(key.constData(), key.length())); - if (!mAutomatic) { - setMessage(QString("<h4>") + _("Key Imported") + "</h4>", false); + if (!m_automatic_) { + set_message(QString("<h4>") + _("Key Imported") + "</h4>", false); } } -void KeyServerImportDialog::importKeys(ByteArrayPtr in_data) { +void KeyServerImportDialog::import_keys(ByteArrayPtr in_data) { GpgImportInformation result = GpgKeyImportExporter::GetInstance().ImportKey(std::move(in_data)); - emit signalKeyImported(); + emit SignalKeyImported(); QWidget* _parent = qobject_cast<QWidget*>(parent()); - if (mAutomatic) { + if (m_automatic_) { auto dialog = new KeyImportDetailDialog(result, true, _parent); dialog->show(); this->accept(); @@ -520,32 +523,32 @@ void KeyServerImportDialog::importKeys(ByteArrayPtr in_data) { } } -void KeyServerImportDialog::setLoading(bool status) { - waitingBar->setVisible(status); - if (!mAutomatic) { - icon->setVisible(!status); - message->setVisible(!status); +void KeyServerImportDialog::set_loading(bool status) { + waiting_bar_->setVisible(status); + if (!m_automatic_) { + icon_->setVisible(!status); + message_->setVisible(!status); } } KeyServerImportDialog::KeyServerImportDialog(QWidget* parent) - : QDialog(parent), mAutomatic(true) { + : QDialog(parent), m_automatic_(true) { setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); // Network Waiting - waitingBar = new QProgressBar(); - waitingBar->setVisible(false); - waitingBar->setRange(0, 0); - waitingBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - waitingBar->setTextVisible(false); + waiting_bar_ = new QProgressBar(); + waiting_bar_->setVisible(false); + waiting_bar_->setRange(0, 0); + waiting_bar_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + waiting_bar_->setTextVisible(false); // Layout for messagebox auto* layout = new QHBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - layout->addWidget(waitingBar); + layout->addWidget(waiting_bar_); - keyServerComboBox = createComboBox(); + key_server_combo_box_ = create_comboBox(); this->setLayout(layout); this->setWindowTitle(_("Update Keys from Keyserver")); @@ -553,10 +556,10 @@ KeyServerImportDialog::KeyServerImportDialog(QWidget* parent) this->setModal(true); } -void KeyServerImportDialog::slotSaveWindowState() { +void KeyServerImportDialog::slot_save_window_state() { LOG(INFO) << _("Called"); - if (mAutomatic) return; + if (m_automatic_) return; auto& settings = GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings(); diff --git a/src/ui/KeyServerImportDialog.h b/src/ui/KeyServerImportDialog.h index 00a91742..f2619464 100644 --- a/src/ui/KeyServerImportDialog.h +++ b/src/ui/KeyServerImportDialog.h @@ -36,60 +36,146 @@ namespace GpgFrontend::UI { +/** + * @brief + * + */ class KeyServerImportDialog : public QDialog { Q_OBJECT public: + /** + * @brief Construct a new Key Server Import Dialog object + * + * @param automatic + * @param parent + */ KeyServerImportDialog(bool automatic, QWidget* parent); + /** + * @brief Construct a new Key Server Import Dialog object + * + * @param parent + */ explicit KeyServerImportDialog(QWidget* parent); - void slotImport(const KeyIdArgsListPtr& keys); - - void slotImport(const QStringList& keyIds, const QUrl& keyserverUrl); + public slots: - signals: - void signalKeyImported(); - - private slots: + /** + * @brief + * + * @param keys + */ + void SlotImport(const KeyIdArgsListPtr& keys); - void slotImport(); + /** + * @brief + * + * @param keyIds + * @param keyserverUrl + */ + void SlotImport(const QStringList& keyIds, const QUrl& keyserverUrl); - void slotSearchFinished(); + signals: - void slotImportFinished(const QString& keyid); + /** + * @brief + * + */ + void SignalKeyImported(); - void slotSearch(); + private slots: - void slotSaveWindowState(); + /** + * @brief + * + */ + void slot_import(); + + /** + * @brief + * + */ + void slot_search_finished(); + + /** + * @brief + * + * @param keyid + */ + void slot_import_finished(const QString& keyid); + + /** + * @brief + * + */ + void slot_search(); + + /** + * @brief + * + */ + void slot_save_window_state(); private: - void createKeysTable(); - - void setMessage(const QString& text, bool error); - - void importKeys(ByteArrayPtr in_data); - - void setLoading(bool status); - - QPushButton* createButton(const QString& text, const char* member); - - QComboBox* createComboBox(); - - bool mAutomatic = false; - - QLineEdit* searchLineEdit{}; - QComboBox* keyServerComboBox{}; - QProgressBar* waitingBar; - QLabel* searchLabel{}; - QLabel* keyServerLabel{}; - QLabel* message{}; - QLabel* icon{}; - QPushButton* closeButton{}; - QPushButton* importButton{}; - QPushButton* searchButton{}; - QTableWidget* keysTable{}; - QNetworkAccessManager* qnam{}; + /** + * @brief Create a keys table object + * + */ + void create_keys_table(); + + /** + * @brief Set the message object + * + * @param text + * @param error + */ + void set_message(const QString& text, bool error); + + /** + * @brief + * + * @param in_data + */ + void import_keys(ByteArrayPtr in_data); + + /** + * @brief Set the loading object + * + * @param status + */ + void set_loading(bool status); + + /** + * @brief Create a button object + * + * @param text + * @param member + * @return QPushButton* + */ + QPushButton* create_button(const QString& text, const char* member); + + /** + * @brief Create a comboBox object + * + * @return QComboBox* + */ + QComboBox* create_comboBox(); + + bool m_automatic_ = false; ///< + + QLineEdit* search_line_edit_{}; ///< + QComboBox* key_server_combo_box_{}; ///< + QProgressBar* waiting_bar_; ///< + QLabel* search_label_{}; ///< + QLabel* key_server_label_{}; ///< + QLabel* message_{}; ///< + QLabel* icon_{}; ///< + QPushButton* close_button_{}; ///< + QPushButton* import_button_{}; ///< + QPushButton* search_button_{}; ///< + QTableWidget* keys_table_{}; ///< + QNetworkAccessManager* network_access_manager_{}; ///< }; } // namespace GpgFrontend::UI diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/KeyUploadDialog.cpp index 60aa3ead..bbca43b7 100644 --- a/src/ui/KeyUploadDialog.cpp +++ b/src/ui/KeyUploadDialog.cpp @@ -38,7 +38,7 @@ namespace GpgFrontend::UI { KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids, QWidget* parent) - : QDialog(parent), mKeys(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) { + : QDialog(parent), m_keys_(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) { auto* pb = new QProgressBar(); pb->setRange(0, 0); pb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); @@ -55,13 +55,13 @@ KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids, this->setFixedSize(240, 42); } -void KeyUploadDialog::slotUpload() { +void KeyUploadDialog::SlotUpload() { auto out_data = std::make_unique<ByteArray>(); - GpgKeyImportExporter::GetInstance().ExportKeys(*mKeys, out_data); - uploadKeyToServer(*out_data); + GpgKeyImportExporter::GetInstance().ExportKeys(*m_keys_, out_data); + slot_upload_key_to_server(*out_data); } -void KeyUploadDialog::uploadKeyToServer( +void KeyUploadDialog::slot_upload_key_to_server( const GpgFrontend::ByteArray& keys_data) { std::string target_keyserver; if (target_keyserver.empty()) { @@ -109,7 +109,7 @@ void KeyUploadDialog::uploadKeyToServer( // Send Post Data QNetworkReply* reply = qnam->post(request, postData); - connect(reply, SIGNAL(finished()), this, SLOT(slotUploadFinished())); + connect(reply, SIGNAL(finished()), this, SLOT(slot_upload_finished())); // Keep Waiting while (reply->isRunning()) { @@ -121,7 +121,7 @@ void KeyUploadDialog::uploadKeyToServer( this->close(); } -void KeyUploadDialog::slotUploadFinished() { +void KeyUploadDialog::slot_upload_finished() { auto* reply = qobject_cast<QNetworkReply*>(sender()); QByteArray response = reply->readAll(); diff --git a/src/ui/KeyUploadDialog.h b/src/ui/KeyUploadDialog.h index 3b8ea2e6..b3e0e726 100644 --- a/src/ui/KeyUploadDialog.h +++ b/src/ui/KeyUploadDialog.h @@ -34,24 +34,47 @@ namespace GpgFrontend::UI { +/** + * @brief + * + */ class KeyUploadDialog : public QDialog { Q_OBJECT public: + /** + * @brief Construct a new Key Upload Dialog object + * + * @param keys_ids + * @param parent + */ explicit KeyUploadDialog(const KeyIdArgsListPtr& keys_ids, QWidget* parent); public slots: - void slotUpload(); + /** + * @brief + * + */ + void SlotUpload(); private slots: - void uploadKeyToServer(const GpgFrontend::ByteArray& keys_data); + /** + * @brief + * + * @param keys_data + */ + void slot_upload_key_to_server(const GpgFrontend::ByteArray& keys_data); - void slotUploadFinished(); + /** + * @brief + * + */ + void slot_upload_finished(); private: - KeyListPtr mKeys; - QByteArray mKeyData; + KeyListPtr m_keys_; ///< + QByteArray m_key_data_; ///< }; } // namespace GpgFrontend::UI diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 71301cbd..b02dd7c5 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -73,7 +73,7 @@ void MainWindow::init() noexcept { connect(edit_->tab_widget_, SIGNAL(currentChanged(int)), this, SLOT(slot_disable_tab_actions(int))); connect(SignalStation::GetInstance(), - &SignalStation::signalRefreshStatusBar, this, + &SignalStation::SignalRefreshStatusBar, this, [=](const QString& message, int timeout) { statusBar()->showMessage(message, timeout); }); diff --git a/src/ui/QuitDialog.cpp b/src/ui/QuitDialog.cpp index 0d5232b5..31a2aefe 100755 --- a/src/ui/QuitDialog.cpp +++ b/src/ui/QuitDialog.cpp @@ -36,42 +36,42 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) : QDialog(parent) { setWindowTitle(_("Unsaved Files")); setModal(true); - discarded = false; + discarded_ = false; /* * Table of unsaved documents */ QHashIterator<int, QString> i(unsavedDocs); int row = 0; - mFileList = new QTableWidget(this); - mFileList->horizontalHeader()->hide(); - mFileList->setColumnCount(3); - mFileList->setColumnWidth(0, 20); - mFileList->setColumnHidden(2, true); - mFileList->verticalHeader()->hide(); - mFileList->setShowGrid(false); - mFileList->setEditTriggers(QAbstractItemView::NoEditTriggers); - mFileList->setFocusPolicy(Qt::NoFocus); - mFileList->horizontalHeader()->setStretchLastSection(true); + m_fileList_ = new QTableWidget(this); + m_fileList_->horizontalHeader()->hide(); + m_fileList_->setColumnCount(3); + m_fileList_->setColumnWidth(0, 20); + m_fileList_->setColumnHidden(2, true); + m_fileList_->verticalHeader()->hide(); + m_fileList_->setShowGrid(false); + m_fileList_->setEditTriggers(QAbstractItemView::NoEditTriggers); + m_fileList_->setFocusPolicy(Qt::NoFocus); + m_fileList_->horizontalHeader()->setStretchLastSection(true); // fill the table i.toFront(); // jump to the end of list to fill the table backwards while (i.hasNext()) { i.next(); - mFileList->setRowCount(mFileList->rowCount() + 1); + m_fileList_->setRowCount(m_fileList_->rowCount() + 1); // checkbox in front of filename auto* tmp0 = new QTableWidgetItem(); tmp0->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); tmp0->setCheckState(Qt::Checked); - mFileList->setItem(row, 0, tmp0); + m_fileList_->setItem(row, 0, tmp0); // filename auto* tmp1 = new QTableWidgetItem(i.value()); - mFileList->setItem(row, 1, tmp1); + m_fileList_->setItem(row, 1, tmp1); // tab-index in hidden column auto* tmp2 = new QTableWidgetItem(QString::number(i.key())); - mFileList->setItem(row, 2, tmp2); + m_fileList_->setItem(row, 2, tmp2); ++row; } /* @@ -111,7 +111,7 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); QPushButton* btnNoKey = buttonBox->button(QDialogButtonBox::Discard); - connect(btnNoKey, SIGNAL(clicked()), SLOT(slotMyDiscard())); + connect(btnNoKey, SIGNAL(clicked()), SLOT(slot_my_discard())); /* * Set the layout @@ -119,24 +119,24 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) auto* vbox = new QVBoxLayout(); vbox->addWidget(warnBox); vbox->addWidget(checkLabel); - vbox->addWidget(mFileList); + vbox->addWidget(m_fileList_); vbox->addWidget(note_label); vbox->addWidget(buttonBox); this->setLayout(vbox); } -void QuitDialog::slotMyDiscard() { - discarded = true; +void QuitDialog::slot_my_discard() { + discarded_ = true; reject(); } -bool QuitDialog::isDiscarded() const { return discarded; } +bool QuitDialog::IsDiscarded() const { return discarded_; } -QList<int> QuitDialog::getTabIdsToSave() { +QList<int> QuitDialog::GetTabIdsToSave() { QList<int> tabIdsToSave; - for (int i = 0; i < mFileList->rowCount(); i++) { - if (mFileList->item(i, 0)->checkState() == Qt::Checked) { - tabIdsToSave << mFileList->item(i, 2)->text().toInt(); + for (int i = 0; i < m_fileList_->rowCount(); i++) { + if (m_fileList_->item(i, 0)->checkState() == Qt::Checked) { + tabIdsToSave << m_fileList_->item(i, 2)->text().toInt(); } } return tabIdsToSave; diff --git a/src/ui/QuitDialog.h b/src/ui/QuitDialog.h index db441faa..2d09790b 100755 --- a/src/ui/QuitDialog.h +++ b/src/ui/QuitDialog.h @@ -33,23 +33,48 @@ namespace GpgFrontend::UI { +/** + * @brief + * + */ class QuitDialog : public QDialog { Q_OBJECT public: + /** + * @brief Construct a new Quit Dialog object + * + * @param parent + * @param unsavedDocs + */ QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs); - [[nodiscard]] bool isDiscarded() const; + /** + * @brief + * + * @return true + * @return false + */ + [[nodiscard]] bool IsDiscarded() const; - QList<int> getTabIdsToSave(); + /** + * @brief Get the Tab Ids To Save object + * + * @return QList<int> + */ + QList<int> GetTabIdsToSave(); private slots: - void slotMyDiscard(); + /** + * @brief + * + */ + void slot_my_discard(); private: - bool discarded; - QTableWidget* mFileList; + bool discarded_; ///< + QTableWidget* m_fileList_; ///< }; } // namespace GpgFrontend::UI diff --git a/src/ui/ShowCopyDialog.cpp b/src/ui/ShowCopyDialog.cpp index e331885c..1ede6aee 100644 --- a/src/ui/ShowCopyDialog.cpp +++ b/src/ui/ShowCopyDialog.cpp @@ -33,21 +33,21 @@ namespace GpgFrontend::UI { ShowCopyDialog::ShowCopyDialog(const QString& text, const QString& info, QWidget* parent) : QDialog(parent) { - textEdit = new QTextEdit(); - textEdit->setReadOnly(true); - textEdit->setLineWrapMode(QTextEdit::WidgetWidth); - textEdit->setText(text); - copyButton = new QPushButton("Copy"); - connect(copyButton, SIGNAL(clicked(bool)), this, SLOT(slotCopyText())); + text_edit_ = new QTextEdit(); + text_edit_->setReadOnly(true); + text_edit_->setLineWrapMode(QTextEdit::WidgetWidth); + text_edit_->setText(text); + copy_button_ = new QPushButton("Copy"); + connect(copy_button_, SIGNAL(clicked(bool)), this, SLOT(slot_copy_text())); - infoLabel = new QLabel(); - infoLabel->setText(info); - infoLabel->setWordWrap(true); + info_label_ = new QLabel(); + info_label_->setText(info); + info_label_->setWordWrap(true); auto* layout = new QVBoxLayout(); - layout->addWidget(textEdit); - layout->addWidget(copyButton); - layout->addWidget(infoLabel); + layout->addWidget(text_edit_); + layout->addWidget(copy_button_); + layout->addWidget(info_label_); this->setWindowTitle("Short Ciphertext"); this->resize(320, 120); @@ -55,9 +55,9 @@ ShowCopyDialog::ShowCopyDialog(const QString& text, const QString& info, this->setLayout(layout); } -void ShowCopyDialog::slotCopyText() { +void ShowCopyDialog::slot_copy_text() { QClipboard* cb = QApplication::clipboard(); - cb->setText(textEdit->toPlainText()); + cb->setText(text_edit_->toPlainText()); } } // namespace GpgFrontend::UI diff --git a/src/ui/ShowCopyDialog.h b/src/ui/ShowCopyDialog.h index dbfbed2a..62cd9da5 100644 --- a/src/ui/ShowCopyDialog.h +++ b/src/ui/ShowCopyDialog.h @@ -33,20 +33,35 @@ namespace GpgFrontend::UI { +/** + * @brief + * + */ class ShowCopyDialog : public QDialog { Q_OBJECT public: + /** + * @brief Construct a new Show Copy Dialog object + * + * @param text + * @param info + * @param parent + */ explicit ShowCopyDialog(const QString& text, const QString& info = "", QWidget* parent = nullptr); private slots: - void slotCopyText(); + /** + * @brief + * + */ + void slot_copy_text(); private: - QLabel* infoLabel; - QTextEdit* textEdit; - QPushButton* copyButton; + QLabel* info_label_; ///< + QTextEdit* text_edit_; ///< + QPushButton* copy_button_; ///< }; } // namespace GpgFrontend::UI diff --git a/src/ui/SignalStation.h b/src/ui/SignalStation.h index 6bd27bc8..dbf978be 100644 --- a/src/ui/SignalStation.h +++ b/src/ui/SignalStation.h @@ -34,20 +34,45 @@ namespace GpgFrontend::UI { +/** + * @brief + * + */ class SignalStation : public QObject { Q_OBJECT static std::unique_ptr<SignalStation> _instance; public: + /** + * @brief Get the Instance object + * + * @return SignalStation* + */ static SignalStation* GetInstance(); signals: - void KeyDatabaseRefresh(); + /** + * @brief + * + */ + void SignalKeyDatabaseRefresh(); - void signalRefreshInfoBoard(const QString& text, + /** + * @brief + * + * @param text + * @param verify_label_status + */ + void SignalRefreshInfoBoard(const QString& text, InfoBoardStatus verify_label_status); - void signalRefreshStatusBar(const QString& message, int timeout); + /** + * @brief + * + * @param message + * @param timeout + */ + void SignalRefreshStatusBar(const QString& message, int timeout); }; } // namespace GpgFrontend::UI diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index c9fa1de2..df60f34f 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -41,7 +41,7 @@ namespace GpgFrontend::UI { std::unique_ptr<GpgFrontend::UI::CommonUtils> - GpgFrontend::UI::CommonUtils::_instance = nullptr; + GpgFrontend::UI::CommonUtils::instance_ = nullptr; #ifdef SMTP_SUPPORT void send_an_email(QWidget* parent, InfoBoardWidget* info_board, @@ -96,7 +96,7 @@ void import_unknown_key_from_keyserver(QWidget* parent, signature = signature->next; } dialog.show(); - dialog.slotImport(key_ids); + dialog.SlotImport(key_ids); } } @@ -148,16 +148,16 @@ void process_operation(QWidget* parent, const std::string& waiting_title, } CommonUtils* CommonUtils::GetInstance() { - if (_instance == nullptr) { - _instance = std::make_unique<CommonUtils>(); + if (instance_ == nullptr) { + instance_ = std::make_unique<CommonUtils>(); } - return _instance.get(); + return instance_.get(); } CommonUtils::CommonUtils() : QWidget(nullptr) { - connect(this, SIGNAL(signalKeyStatusUpdated()), SignalStation::GetInstance(), + connect(this, SIGNAL(SignalKeyStatusUpdated()), SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh())); - connect(this, &CommonUtils::signalGnupgNotInstall, this, []() { + connect(this, &CommonUtils::SignalGnupgNotInstall, this, []() { QMessageBox::critical( nullptr, _("ENV Loading Failed"), _("Gnupg(gpg) is not installed correctly, please follow the " @@ -168,36 +168,36 @@ CommonUtils::CommonUtils() : QWidget(nullptr) { }); } -void CommonUtils::slotImportKeys(QWidget* parent, +void CommonUtils::SlotImportKeys(QWidget* parent, const std::string& in_buffer) { GpgImportInformation result = GpgKeyImportExporter::GetInstance().ImportKey( std::make_unique<ByteArray>(in_buffer)); - emit signalKeyStatusUpdated(); + emit SignalKeyStatusUpdated(); new KeyImportDetailDialog(result, false, parent); } -void CommonUtils::slotImportKeyFromFile(QWidget* parent) { +void CommonUtils::SlotImportKeyFromFile(QWidget* parent) { QString file_name = QFileDialog::getOpenFileName( this, _("Open Key"), QString(), QString(_("Key Files")) + " (*.asc *.txt);;" + _("Keyring files") + " (*.gpg);;All Files (*)"); if (!file_name.isNull()) { - slotImportKeys(parent, read_all_data_in_file(file_name.toStdString())); + SlotImportKeys(parent, read_all_data_in_file(file_name.toStdString())); } } -void CommonUtils::slotImportKeyFromKeyServer(QWidget* parent) { +void CommonUtils::SlotImportKeyFromKeyServer(QWidget* parent) { auto dialog = new KeyServerImportDialog(false, parent); dialog->show(); } -void CommonUtils::slotImportKeyFromClipboard(QWidget* parent) { +void CommonUtils::SlotImportKeyFromClipboard(QWidget* parent) { QClipboard* cb = QApplication::clipboard(); - slotImportKeys(parent, + SlotImportKeys(parent, cb->text(QClipboard::Clipboard).toUtf8().toStdString()); } -void CommonUtils::slotExecuteGpgCommand( +void CommonUtils::SlotExecuteGpgCommand( const QStringList& arguments, const std::function<void(QProcess*)>& interact_func) { QEventLoop looper; @@ -243,7 +243,7 @@ void CommonUtils::slotExecuteGpgCommand( dialog->deleteLater(); } -void CommonUtils::slotImportKeyFromKeyServer( +void CommonUtils::SlotImportKeyFromKeyServer( int ctx_channel, const KeyIdArgsList& key_ids, const ImportCallbackFunctiopn& callback) { std::string target_keyserver; diff --git a/src/ui/UserInterfaceUtils.h b/src/ui/UserInterfaceUtils.h index 6cb4f7f3..6b7e4ca3 100644 --- a/src/ui/UserInterfaceUtils.h +++ b/src/ui/UserInterfaceUtils.h @@ -43,66 +43,172 @@ class InfoBoardWidget; class TextEdit; #ifdef SMTP_SUPPORT +/** + * @brief + * + * @param parent + * @param info_board + * @param text + * @param attach_signature + */ void send_an_email(QWidget* parent, InfoBoardWidget* info_board, const QString& text, bool attach_signature = true); #endif - +/** + * @brief + * + * @param parent + * @param info_board + * @param error + * @param verify_result + */ void show_verify_details(QWidget* parent, InfoBoardWidget* info_board, GpgError error, const GpgVerifyResult& verify_result); +/** + * @brief + * + * @param parent + * @param verify_res + */ void import_unknown_key_from_keyserver(QWidget* parent, const VerifyResultAnalyse& verify_res); +/** + * @brief + * + * @param info_board + * @param status + * @param report_text + */ void refresh_info_board(InfoBoardWidget* info_board, int status, const std::string& report_text); +/** + * @brief + * + * @param edit + * @param info_board + * @param result_analyse + */ void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board, const ResultAnalyse& result_analyse); +/** + * @brief + * + * @param edit + * @param info_board + * @param result_analyse_a + * @param result_analyse_b + */ void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board, const ResultAnalyse& result_analyse_a, const ResultAnalyse& result_analyse_b); +/** + * @brief + * + * @param parent + * @param waiting_title + * @param func + */ void process_operation(QWidget* parent, const std::string& waiting_title, const std::function<void()>& func); +/** + * @brief + * + */ class CommonUtils : public QWidget { Q_OBJECT public: - static CommonUtils* GetInstance(); + /** + * @brief + * + */ + using ImportCallbackFunctiopn = std::function<void( + const std::string&, const std::string&, size_t, size_t)>; + /** + * @brief Construct a new Common Utils object + * + */ CommonUtils(); - using ImportCallbackFunctiopn = std::function<void( - const std::string&, const std::string&, size_t, size_t)>; + /** + * @brief Get the Instance object + * + * @return CommonUtils* + */ + static CommonUtils* GetInstance(); signals: - void signalKeyStatusUpdated(); - - void signalGnupgNotInstall(); + /** + * @brief + * + */ + void SignalKeyStatusUpdated(); + + /** + * @brief + * + */ + void SignalGnupgNotInstall(); public slots: - - void slotImportKeys(QWidget* parent, const std::string& in_buffer); - - void slotImportKeyFromFile(QWidget* parent); - - void slotImportKeyFromKeyServer(QWidget* parent); - - void slotImportKeyFromClipboard(QWidget* parent); - - static void slotImportKeyFromKeyServer( + /** + * @brief + * + * @param parent + * @param in_buffer + */ + void SlotImportKeys(QWidget* parent, const std::string& in_buffer); + + /** + * @brief + * + * @param parent + */ + void SlotImportKeyFromFile(QWidget* parent); + + /** + * @brief + * + * @param parent + */ + void SlotImportKeyFromKeyServer(QWidget* parent); + + /** + * @brief + * + * @param parent + */ + void SlotImportKeyFromClipboard(QWidget* parent); + + /** + * @brief + * + * @param ctx_channel + * @param key_ids + * @param callback + */ + static void SlotImportKeyFromKeyServer( int ctx_channel, const GpgFrontend::KeyIdArgsList& key_ids, const GpgFrontend::UI::CommonUtils::ImportCallbackFunctiopn& callback); - void slotExecuteGpgCommand( + /** + * @brief + * + * @param arguments + * @param interact_func + */ + void SlotExecuteGpgCommand( const QStringList& arguments, const std::function<void(QProcess*)>& interact_func); - private slots: - private: - static std::unique_ptr<CommonUtils> _instance; + static std::unique_ptr<CommonUtils> instance_; ///< }; } // namespace GpgFrontend::UI diff --git a/src/ui/WaitingDialog.h b/src/ui/WaitingDialog.h index 274447a8..1bb6a22b 100644 --- a/src/ui/WaitingDialog.h +++ b/src/ui/WaitingDialog.h @@ -33,16 +33,20 @@ namespace GpgFrontend::UI { +/** + * @brief + * + */ class WaitingDialog : public QDialog { Q_OBJECT public: + /** + * @brief Construct a new Waiting Dialog object + * + * @param title + * @param parent + */ WaitingDialog(const QString& title, QWidget* parent); - - public slots: - - private slots: - - private: }; } // namespace GpgFrontend::UI diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp index de3beb54..189e6c61 100644 --- a/src/ui/Wizard.cpp +++ b/src/ui/Wizard.cpp @@ -56,10 +56,10 @@ Wizard::Wizard(QWidget* parent) : QWizard(parent) { } setStartId(next_page_id); - connect(this, SIGNAL(accepted()), this, SLOT(slotWizardAccepted())); + connect(this, SIGNAL(accepted()), this, SLOT(slot_wizard_accepted())); } -void Wizard::slotWizardAccepted() { +void Wizard::slot_wizard_accepted() { LOG(INFO) << _("Called"); // Don't show is mapped to show -> negation try { @@ -78,7 +78,7 @@ void Wizard::slotWizardAccepted() { LOG(ERROR) << _("Setting Operation Error"); } if (field("openHelp").toBool()) { - emit signalOpenHelp("docu.html#content"); + emit SignalOpenHelp("docu.html#content"); } } @@ -173,17 +173,17 @@ ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { layout->addWidget(encrDecyTextLabel); layout->addWidget(signVerifyTextLabel); setLayout(layout); - nextPage = Wizard::Page_Conclusion; + next_page_ = Wizard::Page_Conclusion; } -int ChoosePage::nextId() const { return nextPage; } +int ChoosePage::nextId() const { return next_page_; } -void ChoosePage::slotJumpPage(const QString& page) { +void ChoosePage::slot_jump_page(const QString& page) { QMetaObject qmo = Wizard::staticMetaObject; int index = qmo.indexOfEnumerator("WizardPages"); QMetaEnum m = qmo.enumerator(index); - nextPage = m.keyToValue(page.toUtf8().data()); + next_page_ = m.keyToValue(page.toUtf8().data()); wizard()->next(); } @@ -219,14 +219,14 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { layout->addWidget(linkLabel); layout->addWidget(createKeyButtonBox); connect(createKeyButton, SIGNAL(clicked(bool)), this, - SLOT(slotGenerateKeyDialog())); + SLOT(slot_generate_key_dialog())); setLayout(layout); } int KeyGenPage::nextId() const { return Wizard::Page_Conclusion; } -void KeyGenPage::slotGenerateKeyDialog() { +void KeyGenPage::slot_generate_key_dialog() { LOG(INFO) << "Try Opening KeyGenDialog"; (new KeyGenDialog(this))->show(); wizard()->next(); @@ -251,19 +251,19 @@ ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { bottomLabel->setOpenExternalLinks(true); bottomLabel->setWordWrap(true); - openHelpCheckBox = new QCheckBox(_("Open offline help.")); - openHelpCheckBox->setChecked(true); + open_help_check_box_ = new QCheckBox(_("Open offline help.")); + open_help_check_box_->setChecked(true); - dontShowWizardCheckBox = new QCheckBox(_("Dont show the wizard again.")); - dontShowWizardCheckBox->setChecked(true); + dont_show_wizard_checkbox_ = new QCheckBox(_("Dont show the wizard again.")); + dont_show_wizard_checkbox_->setChecked(true); - registerField("showWizard", dontShowWizardCheckBox); + registerField("showWizard", dont_show_wizard_checkbox_); // registerField("openHelp", openHelpCheckBox); auto* layout = new QVBoxLayout; layout->addWidget(bottomLabel); // layout->addWidget(openHelpCheckBox); - layout->addWidget(dontShowWizardCheckBox); + layout->addWidget(dont_show_wizard_checkbox_); setLayout(layout); setVisible(true); } diff --git a/src/ui/Wizard.h b/src/ui/Wizard.h index 93ae586e..48aa4aa5 100644 --- a/src/ui/Wizard.h +++ b/src/ui/Wizard.h @@ -37,6 +37,10 @@ namespace GpgFrontend::UI { +/** + * @brief + * + */ class Wizard : public QWizard { Q_OBJECT Q_ENUMS(WizardPages) @@ -44,21 +48,50 @@ class Wizard : public QWizard { public: enum WizardPages { Page_Intro, Page_Choose, Page_GenKey, Page_Conclusion }; + /** + * @brief Construct a new Wizard object + * + * @param parent + */ explicit Wizard(QWidget* parent = nullptr); private slots: - void slotWizardAccepted(); + /** + * @brief + * + */ + void slot_wizard_accepted(); signals: - void signalOpenHelp(QString page); + /** + * @brief + * + * @param page + */ + void SignalOpenHelp(QString page); }; +/** + * @brief + * + */ class IntroPage : public QWizardPage { Q_OBJECT public: + /** + * @brief Construct a new Intro Page object + * + * @param parent + */ explicit IntroPage(QWidget* parent = nullptr); + protected: + /** + * @brief + * + * @return int + */ [[nodiscard]] int nextId() const override; }; @@ -66,42 +99,89 @@ class ChoosePage : public QWizardPage { Q_OBJECT public: + /** + * @brief Construct a new Choose Page object + * + * @param parent + */ explicit ChoosePage(QWidget* parent = nullptr); private slots: - void slotJumpPage(const QString& page); - - private: + /** + * @brief + * + * @param page + */ + void slot_jump_page(const QString& page); + + protected: + /** + * @brief + * + * @return int + */ [[nodiscard]] int nextId() const override; - int nextPage; + int next_page_; ///< }; +/** + * @brief + * + */ class KeyGenPage : public QWizardPage { Q_OBJECT public: + /** + * @brief Construct a new Key Gen Page object + * + * @param parent + */ explicit KeyGenPage(QWidget* parent = nullptr); + /** + * @brief + * + * @return int + */ [[nodiscard]] int nextId() const override; private slots: - void slotGenerateKeyDialog(); + /** + * @brief + * + */ + void slot_generate_key_dialog(); }; +/** + * @brief + * + */ class ConclusionPage : public QWizardPage { Q_OBJECT public: + /** + * @brief Construct a new Conclusion Page object + * + * @param parent + */ explicit ConclusionPage(QWidget* parent = nullptr); + /** + * @brief + * + * @return int + */ [[nodiscard]] int nextId() const override; private: - QCheckBox* dontShowWizardCheckBox; - QCheckBox* openHelpCheckBox; + QCheckBox* dont_show_wizard_checkbox_; ///< + QCheckBox* open_help_check_box_; ///< }; } // namespace GpgFrontend::UI diff --git a/src/ui/keypair_details/KeyPairOperaTab.cpp b/src/ui/keypair_details/KeyPairOperaTab.cpp index e238f0a5..dd8d8367 100644 --- a/src/ui/keypair_details/KeyPairOperaTab.cpp +++ b/src/ui/keypair_details/KeyPairOperaTab.cpp @@ -257,7 +257,7 @@ void KeyPairOperaTab::slot_upload_key_to_server() { keys->push_back(m_key_.GetId()); auto* dialog = new KeyUploadDialog(keys, this); dialog->show(); - dialog->slotUpload(); + dialog->SlotUpload(); } void KeyPairOperaTab::slot_update_key_from_server() { @@ -265,7 +265,7 @@ void KeyPairOperaTab::slot_update_key_from_server() { keys->push_back(m_key_.GetId()); auto* dialog = new KeyServerImportDialog(this); dialog->show(); - dialog->slotImport(keys); + dialog->SlotImport(keys); } void KeyPairOperaTab::slot_gen_revoke_cert() { @@ -280,7 +280,7 @@ void KeyPairOperaTab::slot_gen_revoke_cert() { if (dialog.exec()) m_output_file_name = dialog.selectedFiles().front(); if (!m_output_file_name.isEmpty()) - CommonUtils::GetInstance()->slotExecuteGpgCommand( + CommonUtils::GetInstance()->SlotExecuteGpgCommand( {"--command-fd", "0", "--status-fd", "1", "--no-tty", "-o", m_output_file_name, "--gen-revoke", m_key_.GetFingerprint().c_str()}, [](QProcess* proc) -> void { diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp index 7090021a..c2426dfb 100644 --- a/src/ui/main_window/MainWindowSlotFunction.cpp +++ b/src/ui/main_window/MainWindowSlotFunction.cpp @@ -504,14 +504,14 @@ void MainWindow::refresh_keys_from_key_server() { auto* dialog = new KeyServerImportDialog(this); dialog->show(); - dialog->slotImport(key_ids); + dialog->SlotImport(key_ids); } void MainWindow::upload_key_to_server() { auto key_ids = m_key_list_->GetSelected(); auto* dialog = new KeyUploadDialog(key_ids, this); dialog->show(); - dialog->slotUpload(); + dialog->SlotUpload(); } void MainWindow::SlotOpenFile(QString& path) { edit_->SlotOpenFile(path); } diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index 052bc018..9919b95b 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -44,7 +44,7 @@ void MainWindow::slot_start_wizard() { void MainWindow::slot_import_key_from_edit() { if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) return; - CommonUtils::GetInstance()->slotImportKeys( + CommonUtils::GetInstance()->SlotImportKeys( this, edit_->CurTextPage()->GetTextPage()->toPlainText().toStdString()); } diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp index 85e2ae08..df89bb34 100644 --- a/src/ui/main_window/MainWindowUI.cpp +++ b/src/ui/main_window/MainWindowUI.cpp @@ -210,7 +210,7 @@ void MainWindow::create_actions() { import_key_from_file_act_->setIcon(QIcon(":import_key_from_file.png")); import_key_from_file_act_->setToolTip(_("Import New Key From File")); connect(import_key_from_file_act_, &QAction::triggered, this, - [&]() { CommonUtils::GetInstance()->slotImportKeyFromFile(this); }); + [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); }); import_key_from_clipboard_act_ = new QAction(_("Clipboard"), this); import_key_from_clipboard_act_->setIcon( @@ -218,7 +218,7 @@ void MainWindow::create_actions() { import_key_from_clipboard_act_->setToolTip( _("Import New Key From Clipboard")); connect(import_key_from_clipboard_act_, &QAction::triggered, this, [&]() { - CommonUtils::GetInstance()->slotImportKeyFromClipboard(this); + CommonUtils::GetInstance()->SlotImportKeyFromClipboard(this); }); import_key_from_key_server_act_ = new QAction(_("Keyserver"), this); @@ -227,7 +227,7 @@ void MainWindow::create_actions() { import_key_from_key_server_act_->setToolTip( _("Import New Key From Keyserver")); connect(import_key_from_key_server_act_, &QAction::triggered, this, [&]() { - CommonUtils::GetInstance()->slotImportKeyFromKeyServer(this); + CommonUtils::GetInstance()->SlotImportKeyFromKeyServer(this); }); import_key_from_edit_act_ = new QAction(_("Editor"), this); diff --git a/src/ui/thread/CtxCheckThread.cpp b/src/ui/thread/CtxCheckThread.cpp index bbcb1503..7808968d 100644 --- a/src/ui/thread/CtxCheckThread.cpp +++ b/src/ui/thread/CtxCheckThread.cpp @@ -33,7 +33,7 @@ GpgFrontend::UI::CtxCheckThread::CtxCheckThread() : QThread(nullptr) { connect(this, &CtxCheckThread::SignalGnupgNotInstall, - CommonUtils::GetInstance(), &CommonUtils::signalGnupgNotInstall); + CommonUtils::GetInstance(), &CommonUtils::SignalGnupgNotInstall); } void GpgFrontend::UI::CtxCheckThread::run() { diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index 49ecd9dd..97d2217a 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -94,7 +94,7 @@ FilePage::FilePage(QWidget* parent) }); connect(this, &FilePage::SignalRefreshInfoBoard, SignalStation::GetInstance(), - &SignalStation::signalRefreshInfoBoard); + &SignalStation::SignalRefreshInfoBoard); } void FilePage::slot_file_tree_view_item_clicked(const QModelIndex& index) { diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp index 3911acc1..3d5db85c 100644 --- a/src/ui/widgets/InfoBoardWidget.cpp +++ b/src/ui/widgets/InfoBoardWidget.cpp @@ -50,7 +50,7 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent) connect(ui_->clearButton, &QPushButton::clicked, this, &InfoBoardWidget::SlotReset); - connect(SignalStation::GetInstance(), &SignalStation::signalRefreshInfoBoard, + connect(SignalStation::GetInstance(), &SignalStation::SignalRefreshInfoBoard, this, &InfoBoardWidget::SlotRefresh); } diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 32a2e4ed..37378529 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -77,7 +77,7 @@ void KeyList::init() { // register key database refresh signal connect(this, &KeyList::SignalRefreshDatabase, SignalStation::GetInstance(), - &SignalStation::KeyDatabaseRefresh); + &SignalStation::SignalKeyDatabaseRefresh); connect(SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh()), this, SLOT(SlotRefresh())); connect(ui_->refreshKeyListButton, &QPushButton::clicked, this, @@ -89,7 +89,7 @@ void KeyList::init() { connect(ui_->syncButton, &QPushButton::clicked, this, &KeyList::slot_sync_with_key_server); connect(this, &KeyList::SignalRefreshStatusBar, SignalStation::GetInstance(), - &SignalStation::signalRefreshStatusBar); + &SignalStation::SignalRefreshStatusBar); setAcceptDrops(true); @@ -462,7 +462,7 @@ void KeyList::slot_sync_with_key_server() { ui_->syncButton->setDisabled(true); emit SignalRefreshStatusBar(_("Syncing Key List..."), 3000); - CommonUtils::slotImportKeyFromKeyServer( + CommonUtils::SlotImportKeyFromKeyServer( m_key_list_id_, key_ids, [=](const std::string& key_id, const std::string& status, size_t current_index, size_t all_index) { diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp index 3ac6e138..a0e16081 100644 --- a/src/ui/widgets/TextEdit.cpp +++ b/src/ui/widgets/TextEdit.cpp @@ -334,14 +334,14 @@ bool TextEdit::MaybeSaveAnyTab() { // if result is QDialog::Rejected, discard or cancel was clicked if (result == QDialog::Rejected) { // return true, if discard is clicked, so app can be closed - if (dialog->isDiscarded()) { + if (dialog->IsDiscarded()) { return true; } else { return false; } } else { bool all_saved = true; - QList<int> tabIdsToSave = dialog->getTabIdsToSave(); + QList<int> tabIdsToSave = dialog->GetTabIdsToSave(); for (const auto& tabId : tabIdsToSave) { tab_widget_->setCurrentIndex(tabId); diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp index 02afa4ee..014072af 100644 --- a/src/ui/widgets/VerifyKeyDetailBox.cpp +++ b/src/ui/widgets/VerifyKeyDetailBox.cpp @@ -160,7 +160,7 @@ void VerifyKeyDetailBox::slot_import_form_key_server() { auto* importDialog = new KeyServerImportDialog(false, this); auto key_ids = std::make_unique<KeyIdArgsList>(); key_ids->push_back(fpr_); - importDialog->slotImport(key_ids); + importDialog->SlotImport(key_ids); } QGridLayout* VerifyKeyDetailBox::create_key_info_grid( |