diff options
Diffstat (limited to 'src/ui')
18 files changed, 336 insertions, 36 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 3f0686e2..5f22be00 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -36,7 +36,7 @@ aux_source_directory(thread UI_SOURCE) aux_source_directory(dialog/details UI_SOURCE) aux_source_directory(struct UI_SOURCE) aux_source_directory(dialog/import_export UI_SOURCE) -aux_source_directory(dialog/gnupg UI_SOURCE) +aux_source_directory(dialog/controller UI_SOURCE) aux_source_directory(dialog UI_SOURCE) aux_source_directory(function UI_SOURCE) diff --git a/src/ui/GpgFrontendApplication.cpp b/src/ui/GpgFrontendApplication.cpp index c832ffe0..ad07fa7b 100644 --- a/src/ui/GpgFrontendApplication.cpp +++ b/src/ui/GpgFrontendApplication.cpp @@ -30,7 +30,7 @@ #include <QTextCodec> -#include "GpgFrontendBuildInfo.h" +#include "core/utils/BuildInfoUtils.h" namespace GpgFrontend::UI { @@ -42,10 +42,12 @@ GpgFrontendApplication::GpgFrontendApplication(int &argc, char *argv[]) #endif // set the extra information of the build - GpgFrontendApplication::setApplicationVersion(BUILD_VERSION); - GpgFrontendApplication::setApplicationName(PROJECT_NAME); - GpgFrontendApplication::setApplicationDisplayName(PROJECT_NAME); - GpgFrontendApplication::setOrganizationName(PROJECT_NAME); + GpgFrontendApplication::setApplicationVersion(GetProjectBuildVersion()); + GpgFrontendApplication::setApplicationName(QString::fromUtf8((PROJECT_NAME))); + GpgFrontendApplication::setApplicationDisplayName( + QString::fromUtf8((PROJECT_NAME))); + GpgFrontendApplication::setOrganizationName( + QString::fromUtf8((PROJECT_NAME))); GpgFrontendApplication::setQuitOnLastWindowClosed(true); // don't show icons in menus diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index 9daca57b..5e24c8eb 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -30,7 +30,6 @@ #include <cstddef> -#include "GpgFrontendBuildInfo.h" #include "core/GpgConstants.h" #include "core/function/CoreSignalStation.h" #include "core/function/gpg/GpgKeyGetter.h" @@ -39,12 +38,13 @@ #include "core/thread/Task.h" #include "core/thread/TaskRunnerGetter.h" #include "core/typedef/GpgTypedef.h" +#include "core/utils/BuildInfoUtils.h" #include "core/utils/GpgUtils.h" #include "core/utils/IOUtils.h" #include "thread/KeyServerImportTask.h" #include "ui/UISignalStation.h" #include "ui/dialog/WaitingDialog.h" -#include "ui/dialog/gnupg/GnuPGControllerDialog.h" +#include "ui/dialog/controller/GnuPGControllerDialog.h" #include "ui/dialog/import_export/KeyServerImportDialog.h" #include "ui/struct/CacheObject.h" #include "ui/struct/SettingsObject.h" @@ -431,7 +431,7 @@ void CommonUtils::SlotImportKeyFromKeyServer( // Waiting for reply auto request = QNetworkRequest(req_url); request.setHeader(QNetworkRequest::UserAgentHeader, - HTTP_REQUEST_USER_AGENT); + GetHttpRequestUserAgent()); QNetworkReply *reply = network_manager->get(request); QEventLoop loop; diff --git a/src/ui/dialog/SignersPicker.h b/src/ui/dialog/SignersPicker.h index c7e1bfa5..cea8dd9a 100644 --- a/src/ui/dialog/SignersPicker.h +++ b/src/ui/dialog/SignersPicker.h @@ -56,13 +56,13 @@ class SignersPicker : public GeneralDialog { * * @return GpgFrontend::KeyIdArgsListPtr */ - KeyIdArgsListPtr GetCheckedSigners(); + auto GetCheckedSigners() -> KeyIdArgsListPtr; /** * * @return */ - [[nodiscard]] bool GetStatus() const; + [[nodiscard]] auto GetStatus() const -> bool; private: KeyList* key_list_; ///< diff --git a/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp b/src/ui/dialog/controller/GnuPGControllerDialog.cpp index f1fa87e2..f1fa87e2 100644 --- a/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp +++ b/src/ui/dialog/controller/GnuPGControllerDialog.cpp diff --git a/src/ui/dialog/gnupg/GnuPGControllerDialog.h b/src/ui/dialog/controller/GnuPGControllerDialog.h index 6e8ef797..6e8ef797 100644 --- a/src/ui/dialog/gnupg/GnuPGControllerDialog.h +++ b/src/ui/dialog/controller/GnuPGControllerDialog.h diff --git a/src/ui/dialog/controller/ModuleControllerDialog.cpp b/src/ui/dialog/controller/ModuleControllerDialog.cpp new file mode 100644 index 00000000..db177155 --- /dev/null +++ b/src/ui/dialog/controller/ModuleControllerDialog.cpp @@ -0,0 +1,111 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include "ModuleControllerDialog.h" + +#include "ui_ModuleControllerDialog.h" + +// +#include "core/module/ModuleManager.h" +#include "ui/widgets/ModuleListView.h" + +namespace GpgFrontend::UI { + +ModuleControllerDialog::ModuleControllerDialog(QWidget* parent) + : QDialog(parent), + ui_(std::make_shared<Ui_ModuleControllerDialog>()), + model_list_view_(new ModuleListView(this)) { + ui_->setupUi(this); + + model_list_view_->setMinimumWidth(250); + model_list_view_->setViewMode(QListView::ListMode); + model_list_view_->setMovement(QListView::Static); + + ui_->moduleListViewLayout->addWidget(model_list_view_); + connect(model_list_view_, &ModuleListView::SignalSelectModule, this, + &ModuleControllerDialog::slot_load_module_details); + + connect(ui_->activateButton, &QPushButton::clicked, this, [=]() { + auto module_id = model_list_view_->GetCurrentModuleID(); + if (module_id.isEmpty()) return; + + Module::ModuleManager::GetInstance().ActiveModule(module_id); + QTimer::singleShot(1000, [=]() { slot_load_module_details(module_id); }); + }); + + connect(ui_->triggerEventButton, &QPushButton::clicked, this, [=]() { + auto event_id = + QInputDialog::getText(this, "Please provide an Event ID", "Event ID"); + Module::TriggerEvent(event_id); + }); +} + +void ModuleControllerDialog::slot_load_module_details( + Module::ModuleIdentifier module_id) { + GF_UI_LOG_DEBUG("loading module detailes, module id: {}", module_id); + + auto module = Module::ModuleManager::GetInstance().SearchModule(module_id); + + ui_->moduleIDLabel->setText(module->GetModuleIdentifier()); + + QString buffer; + QTextStream info(&buffer); + + info << "# BASIC INFO" << Qt::endl << Qt::endl; + + info << tr("Version") << ": " << module->GetModuleVersion() << Qt::endl; + info << tr("Hash") << ": " << module->GetModuleHash() << Qt::endl; + info << tr("Path") << ": " << module->GetModulePath() << Qt::endl; + + info << tr("Active") << ": " + << (Module::ModuleManager::GetInstance().IsModuleActivated(module_id) + ? tr("True") + : tr("False")) + << Qt::endl; + + info << Qt::endl; + + info << "# METADATA" << Qt::endl << Qt::endl; + + for (const auto& metadata : module->GetModuleMetaData()) { + info << metadata.first << ": " << metadata.second << "\n"; + } + + info << Qt::endl; + + info << "# Listening Event" << Qt::endl << Qt::endl; + + auto listening_event_ids = + Module::ModuleManager::GetInstance().GetModuleListening(module_id); + for (const auto& event_id : listening_event_ids) { + info << " - " << event_id << "\n"; + } + + ui_->moduleInfoTextBrowser->setText(buffer); +} +} // namespace GpgFrontend::UI diff --git a/src/ui/dialog/controller/ModuleControllerDialog.h b/src/ui/dialog/controller/ModuleControllerDialog.h new file mode 100644 index 00000000..59b6cc6b --- /dev/null +++ b/src/ui/dialog/controller/ModuleControllerDialog.h @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +#include "core/module/Module.h" + +class Ui_ModuleControllerDialog; + +namespace GpgFrontend::UI { + +class ModuleListView; + +class ModuleControllerDialog : public QDialog { + Q_OBJECT + public: + /** + * @brief Construct a new Module Controller Dialog object + * + * @param parent + */ + explicit ModuleControllerDialog(QWidget* parent); + + private slots: + /** + * @brief + * + */ + void slot_load_module_details(Module::ModuleIdentifier); + + private: + std::shared_ptr<Ui_ModuleControllerDialog> ui_; ///< + ModuleListView* model_list_view_; +}; + +} // namespace GpgFrontend::UI diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 61b01dfe..e1fa3535 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -30,8 +30,8 @@ #include <openssl/opensslv.h> -#include "GpgFrontendBuildInfo.h" #include "core/module/ModuleManager.h" +#include "core/utils/BuildInfoUtils.h" #include "ui/dialog/help/GnupgTab.h" namespace GpgFrontend::UI { @@ -84,7 +84,7 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { auto text = "<center><h2>" + qApp->applicationName() + "</h2></center>" + "<center><b>" + qApp->applicationVersion() + "</b></center>" + - "<center>" + GIT_VERSION + "</center>" + "<br><center>" + + "<center>" + GetProjectBuildGitVersion() + "</center>" + "<br><center>" + tr("GpgFrontend is an easy-to-use, compact, cross-platform, " "and installation-free GnuPG Frontend." "It visualizes most of the common operations of GnuPG." @@ -99,7 +99,8 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { "href=\"mailto:[email protected]\">[email protected]</a>." + "<br><br> " + tr("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + " " + tr("and") + " " + "GPGME" + " " + gpgme_version + "<br>" + - tr("Built at") + " " + BUILD_TIMESTAMP + "</center>"; + tr("Built at") + " " + QLocale().toString(GetProjectBuildTimestamp()) + + "</center>"; auto* layout = new QGridLayout(); auto* pixmap_label = new QLabel(); @@ -140,8 +141,7 @@ TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { auto* layout = new QGridLayout(); - current_version_ = - QString("v") + VERSION_MAJOR + "." + VERSION_MINOR + "." + VERSION_PATCH; + current_version_ = GetProjectVersion(); auto* tips_label = new QLabel(); tips_label->setText( diff --git a/src/ui/dialog/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp index 0e0dca4d..3fc37c83 100644 --- a/src/ui/dialog/import_export/KeyUploadDialog.cpp +++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp @@ -30,10 +30,10 @@ #include <QtNetwork> -#include "GpgFrontendBuildInfo.h" #include "core/GpgModel.h" #include "core/function/gpg/GpgKeyGetter.h" #include "core/function/gpg/GpgKeyImportExporter.h" +#include "core/utils/BuildInfoUtils.h" #include "core/utils/GpgUtils.h" #include "ui/UserInterfaceUtils.h" #include "ui/struct/SettingsObject.h" @@ -116,7 +116,8 @@ void KeyUploadDialog::slot_upload_key_to_server( data.replace(" ", "+"); QNetworkRequest request(req_url); - request.setHeader(QNetworkRequest::UserAgentHeader, HTTP_REQUEST_USER_AGENT); + request.setHeader(QNetworkRequest::UserAgentHeader, + GetHttpRequestUserAgent()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h index 523c14f0..6847ec4a 100644 --- a/src/ui/main_window/MainWindow.h +++ b/src/ui/main_window/MainWindow.h @@ -430,7 +430,7 @@ class MainWindow : public GeneralMainWindow { QMenu* file_menu_{}; ///< Submenu for file-operations QMenu* edit_menu_{}; ///< Submenu for text-operations QMenu* crypt_menu_{}; ///< Submenu for crypt-operations - QMenu* gpg_menu_{}; ///< Submenu for help-operations + QMenu* advance_menu_{}; ///< Submenu for help-operations QMenu* help_menu_{}; ///< Submenu for help-operations QMenu* key_menu_{}; ///< Submenu for key-operations QMenu* view_menu_{}; ///< Submenu for view operations @@ -473,6 +473,7 @@ class MainWindow : public GeneralMainWindow { ///< breaks QAction* gnupg_controller_open_act_{}; ///< + QAction* module_controller_open_act_{}; ///< QAction* clean_gpg_password_cache_act_{}; ///< QAction* reload_components_act_{}; ///< QAction* restart_components_act_{}; ///< diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp index 8b6fc74c..3d321264 100644 --- a/src/ui/main_window/MainWindowUI.cpp +++ b/src/ui/main_window/MainWindowUI.cpp @@ -30,8 +30,9 @@ #include "core/function/GlobalSettingStation.h" #include "core/function/gpg/GpgAdvancedOperator.h" #include "core/module/ModuleManager.h" +#include "dialog/controller/ModuleControllerDialog.h" #include "ui/UserInterfaceUtils.h" -#include "ui/dialog/gnupg/GnuPGControllerDialog.h" +#include "ui/dialog/controller/GnuPGControllerDialog.h" #include "ui/dialog/help/AboutDialog.h" #include "ui/widgets/KeyList.h" #include "ui/widgets/TextEdit.h" @@ -404,6 +405,12 @@ void MainWindow::create_actions() { connect(gnupg_controller_open_act_, &QAction::triggered, this, [this]() { (new GnuPGControllerDialog(this))->exec(); }); + module_controller_open_act_ = new QAction(tr("Open Module Controller"), this); + module_controller_open_act_->setIcon(QIcon(":/icons/configure.png")); + module_controller_open_act_->setToolTip(tr("Open Module Controller Dialog")); + connect(module_controller_open_act_, &QAction::triggered, this, + [this]() { (new ModuleControllerDialog(this))->exec(); }); + /* * About Menu */ @@ -587,13 +594,13 @@ void MainWindow::create_menus() { import_key_menu_->addAction(import_key_from_key_server_act_); key_menu_->addAction(open_key_management_act_); - gpg_menu_ = menuBar()->addMenu(tr("GnuPG")); - gpg_menu_->addAction(clean_gpg_password_cache_act_); - gpg_menu_->addSeparator(); - gpg_menu_->addAction(reload_components_act_); - gpg_menu_->addAction(restart_components_act_); - gpg_menu_->addSeparator(); - gpg_menu_->addAction(gnupg_controller_open_act_); + advance_menu_ = menuBar()->addMenu(tr("Advance")); + advance_menu_->addAction(clean_gpg_password_cache_act_); + advance_menu_->addAction(reload_components_act_); + advance_menu_->addAction(restart_components_act_); + advance_menu_->addSeparator(); + advance_menu_->addAction(gnupg_controller_open_act_); + advance_menu_->addAction(module_controller_open_act_); steganography_menu_ = menuBar()->addMenu(tr("Steganography")); steganography_menu_->addAction(cut_pgp_header_act_); diff --git a/src/ui/thread/KeyServerImportTask.cpp b/src/ui/thread/KeyServerImportTask.cpp index c908f5d7..ed8b7646 100644 --- a/src/ui/thread/KeyServerImportTask.cpp +++ b/src/ui/thread/KeyServerImportTask.cpp @@ -28,8 +28,8 @@ #include "ui/thread/KeyServerImportTask.h" -#include "GpgFrontendBuildInfo.h" #include "core/function/gpg/GpgKeyImportExporter.h" +#include "core/utils/BuildInfoUtils.h" #include "ui/struct/SettingsObject.h" #include "ui/struct/settings/KeyServerSO.h" @@ -57,7 +57,7 @@ auto GpgFrontend::UI::KeyServerImportTask::Run() -> int { auto request = QNetworkRequest(req_url); request.setHeader(QNetworkRequest::UserAgentHeader, - HTTP_REQUEST_USER_AGENT); + GetHttpRequestUserAgent()); reply_ = manager_->get(request); connect(reply_, &QNetworkReply::finished, this, diff --git a/src/ui/thread/KeyServerSearchTask.cpp b/src/ui/thread/KeyServerSearchTask.cpp index eb650c4b..828ce5ac 100644 --- a/src/ui/thread/KeyServerSearchTask.cpp +++ b/src/ui/thread/KeyServerSearchTask.cpp @@ -28,7 +28,7 @@ #include "ui/thread/KeyServerSearchTask.h" -#include "GpgFrontendBuildInfo.h" +#include "core/utils/BuildInfoUtils.h" GpgFrontend::UI::KeyServerSearchTask::KeyServerSearchTask(QString keyserver_url, QString search_string) @@ -45,7 +45,8 @@ auto GpgFrontend::UI::KeyServerSearchTask::Run() -> int { "&op=index&options=mr"; auto request = QNetworkRequest(url_from_remote); - request.setHeader(QNetworkRequest::UserAgentHeader, HTTP_REQUEST_USER_AGENT); + request.setHeader(QNetworkRequest::UserAgentHeader, + GetHttpRequestUserAgent()); reply_ = manager_->get(request); connect(reply_, &QNetworkReply::finished, this, diff --git a/src/ui/thread/ListedKeyServerTestTask.cpp b/src/ui/thread/ListedKeyServerTestTask.cpp index 15ea959f..5f7e2dca 100644 --- a/src/ui/thread/ListedKeyServerTestTask.cpp +++ b/src/ui/thread/ListedKeyServerTestTask.cpp @@ -29,9 +29,8 @@ #include "ListedKeyServerTestTask.h" #include <QtNetwork> -#include <vector> -#include "GpgFrontendBuildInfo.h" +#include "core/utils/BuildInfoUtils.h" GpgFrontend::UI::ListedKeyServerTestTask::ListedKeyServerTestTask( QStringList urls, int timeout, QWidget* /*parent*/) @@ -53,7 +52,7 @@ auto GpgFrontend::UI::ListedKeyServerTestTask::Run() -> int { auto request = QNetworkRequest(key_url); request.setHeader(QNetworkRequest::UserAgentHeader, - HTTP_REQUEST_USER_AGENT); + GetHttpRequestUserAgent()); auto* network_reply = network_manager_->get(request); auto* timer = new QTimer(this); diff --git a/src/ui/thread/ProxyConnectionTestTask.cpp b/src/ui/thread/ProxyConnectionTestTask.cpp index 003205e5..c1d2f3e6 100644 --- a/src/ui/thread/ProxyConnectionTestTask.cpp +++ b/src/ui/thread/ProxyConnectionTestTask.cpp @@ -30,7 +30,7 @@ #include <QtNetwork> -#include "GpgFrontendBuildInfo.h" +#include "core/utils/BuildInfoUtils.h" GpgFrontend::UI::ProxyConnectionTestTask::ProxyConnectionTestTask(QString url, int timeout) @@ -43,7 +43,8 @@ GpgFrontend::UI::ProxyConnectionTestTask::ProxyConnectionTestTask(QString url, auto GpgFrontend::UI::ProxyConnectionTestTask::Run() -> int { auto request = QNetworkRequest(url_); - request.setHeader(QNetworkRequest::UserAgentHeader, HTTP_REQUEST_USER_AGENT); + request.setHeader(QNetworkRequest::UserAgentHeader, + GetHttpRequestUserAgent()); auto* network_reply = network_manager_->get(request); auto* timer = new QTimer(this); diff --git a/src/ui/widgets/ModuleListView.cpp b/src/ui/widgets/ModuleListView.cpp new file mode 100644 index 00000000..05e4c021 --- /dev/null +++ b/src/ui/widgets/ModuleListView.cpp @@ -0,0 +1,63 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include "ModuleListView.h" + +#include "core/module/ModuleManager.h" + +namespace GpgFrontend::UI { + +ModuleListView::ModuleListView(QWidget *parent) + : QListView(parent), model_(new QStringListModel(this)) { + setModel(model_); + + load_module_informations(); +} + +void ModuleListView::currentChanged(const QModelIndex ¤t, + const QModelIndex &previous) { + QListView::currentChanged(current, previous); + emit this->SignalSelectModule(model_->data(current).toString()); +} + +void ModuleListView::load_module_informations() { + auto module_ids = + Module::ModuleManager::GetInstance().ListAllRegisteredModuleID(); + + QStringList model_data; + for (const auto &module_id : module_ids) { + model_data.append(module_id); + } + + model_->setStringList(model_data); +} + +auto ModuleListView::GetCurrentModuleID() -> Module::ModuleIdentifier { + return model_->data(currentIndex()).toString(); +} +}; // namespace GpgFrontend::UI diff --git a/src/ui/widgets/ModuleListView.h b/src/ui/widgets/ModuleListView.h new file mode 100644 index 00000000..ba569a6f --- /dev/null +++ b/src/ui/widgets/ModuleListView.h @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +#include "core/module/Module.h" + +namespace GpgFrontend::UI { +class ModuleListView : public QListView { + Q_OBJECT + public: + explicit ModuleListView(QWidget *parent); + + auto GetCurrentModuleID() -> Module::ModuleIdentifier; + + signals: + void SignalSelectModule(Module::ModuleIdentifier); + + protected: + void currentChanged(const QModelIndex ¤t, + const QModelIndex &previous) override; + + private: + QStringListModel *model_; + + void load_module_informations(); +}; +}; // namespace GpgFrontend::UI
\ No newline at end of file |