From c1f5b3336836e15d193582e9b8f3e044f7d8bc1b Mon Sep 17 00:00:00 2001 From: saturneric Date: Thu, 29 Feb 2024 18:15:57 +0800 Subject: feat: add module controller and continue to work on module system 1. speed up building by reducing build info sheader including 2. add module controller 3. continue to work on module system --- src/ui/widgets/ModuleListView.cpp | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/ui/widgets/ModuleListView.cpp (limited to 'src/ui/widgets/ModuleListView.cpp') 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 + * + * 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 . + * + * 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 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 -- cgit v1.2.3 From 84b04d88723ef05f7873082c235ecfd56facf934 Mon Sep 17 00:00:00 2001 From: saturneric Date: Thu, 29 Feb 2024 22:36:25 +0800 Subject: feat: add prefix GF to all sdk and module symbols --- src/ui/widgets/ModuleListView.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/widgets/ModuleListView.cpp') diff --git a/src/ui/widgets/ModuleListView.cpp b/src/ui/widgets/ModuleListView.cpp index 05e4c021..41c8b259 100644 --- a/src/ui/widgets/ModuleListView.cpp +++ b/src/ui/widgets/ModuleListView.cpp @@ -35,6 +35,7 @@ namespace GpgFrontend::UI { ModuleListView::ModuleListView(QWidget *parent) : QListView(parent), model_(new QStringListModel(this)) { setModel(model_); + setEditTriggers(QAbstractItemView::NoEditTriggers); load_module_informations(); } -- cgit v1.2.3 From a961672975e3ee51442a1a1569f5894b96cf7aa9 Mon Sep 17 00:00:00 2001 From: saturneric Date: Mon, 15 Apr 2024 15:28:26 +0200 Subject: feat: prefer to show module name instead of module id --- src/ui/widgets/ModuleListView.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/ui/widgets/ModuleListView.cpp') diff --git a/src/ui/widgets/ModuleListView.cpp b/src/ui/widgets/ModuleListView.cpp index 41c8b259..6a386813 100644 --- a/src/ui/widgets/ModuleListView.cpp +++ b/src/ui/widgets/ModuleListView.cpp @@ -33,7 +33,7 @@ namespace GpgFrontend::UI { ModuleListView::ModuleListView(QWidget *parent) - : QListView(parent), model_(new QStringListModel(this)) { + : QListView(parent), model_(new QStandardItemModel(this)) { setModel(model_); setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -43,22 +43,28 @@ ModuleListView::ModuleListView(QWidget *parent) void ModuleListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { QListView::currentChanged(current, previous); - emit this->SignalSelectModule(model_->data(current).toString()); + auto *item = model_->itemFromIndex(current); + if (item != nullptr) { + emit this->SignalSelectModule(item->data(Qt::UserRole + 1).toString()); + } } void ModuleListView::load_module_informations() { - auto module_ids = - Module::ModuleManager::GetInstance().ListAllRegisteredModuleID(); + auto &module_manager = Module::ModuleManager::GetInstance(); + auto module_ids = module_manager.ListAllRegisteredModuleID(); - QStringList model_data; + model_->clear(); for (const auto &module_id : module_ids) { - model_data.append(module_id); + auto module = module_manager.SearchModule(module_id); + auto meta_data = module->GetModuleMetaData(); + auto *item = new QStandardItem(meta_data.value("Name", module_id)); + item->setData(module_id, Qt::UserRole + 1); + model_->appendRow(item); } - - model_->setStringList(model_data); } auto ModuleListView::GetCurrentModuleID() -> Module::ModuleIdentifier { - return model_->data(currentIndex()).toString(); + auto *item = model_->itemFromIndex(currentIndex()); + return item != nullptr ? item->data(Qt::UserRole + 1).toString() : ""; } }; // namespace GpgFrontend::UI -- cgit v1.2.3 From 3d2ab7c349b02740511f0f2113fd80f7f44c8333 Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 30 Apr 2024 16:07:33 +0200 Subject: feat: improve functions and ui on module --- src/ui/widgets/ModuleListView.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ui/widgets/ModuleListView.cpp') diff --git a/src/ui/widgets/ModuleListView.cpp b/src/ui/widgets/ModuleListView.cpp index 6a386813..ced602fb 100644 --- a/src/ui/widgets/ModuleListView.cpp +++ b/src/ui/widgets/ModuleListView.cpp @@ -56,8 +56,12 @@ void ModuleListView::load_module_informations() { model_->clear(); for (const auto &module_id : module_ids) { auto module = module_manager.SearchModule(module_id); + auto integrated_module = module_manager.IsIntegratedModule(module_id); auto meta_data = module->GetModuleMetaData(); - auto *item = new QStandardItem(meta_data.value("Name", module_id)); + + auto *item = new QStandardItem((integrated_module ? "*" : "") + + meta_data.value("Name", module_id)); + item->setData(module_id, Qt::UserRole + 1); model_->appendRow(item); } -- cgit v1.2.3