From 9146f7ad486e34f52ad794db4c3085f913369a2c Mon Sep 17 00:00:00 2001 From: saturneric Date: Thu, 21 Nov 2024 22:54:02 +0100 Subject: [PATCH] feat: async gather_gnupg_info() --- CMakeLists.txt | 4 ++-- src/m_gpg_info/CMakeLists.txt | 2 +- src/m_gpg_info/GnuPGInfoGatheringModule.cpp | 2 +- src/m_gpg_info/GnupgTab.cpp | 16 ++++++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4492b56..83e1d34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,11 +77,11 @@ link_directories( if(GPGFRONTEND_QT5_BUILD) # Introduce Qt # Support Qt version: 5.15.x - find_package(Qt5 5.15 COMPONENTS Core Widgets Network LinguistTools REQUIRED) + find_package(Qt5 5.15 COMPONENTS Core Widgets Network LinguistTools Concurrent REQUIRED) else() # Introduce Qt # Support Qt version: 6.x - find_package(Qt6 6 COMPONENTS Core Widgets Network LinguistTools REQUIRED) + find_package(Qt6 6 COMPONENTS Core Widgets Network LinguistTools Concurrent REQUIRED) endif() # Qt configuration diff --git a/src/m_gpg_info/CMakeLists.txt b/src/m_gpg_info/CMakeLists.txt index e9f269d..6624e82 100644 --- a/src/m_gpg_info/CMakeLists.txt +++ b/src/m_gpg_info/CMakeLists.txt @@ -40,7 +40,7 @@ target_link_libraries(mod_gpg_info PRIVATE gpgfrontend_module_sdk) # link qt -target_link_libraries(mod_gpg_info PRIVATE Qt::Core Qt::Widgets) +target_link_libraries(mod_gpg_info PRIVATE Qt::Core Qt::Widgets Qt::Concurrent) # using std c++ 17 target_compile_features(mod_gpg_info PRIVATE cxx_std_17) diff --git a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp index 08611fe..e882d67 100644 --- a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp +++ b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp @@ -47,7 +47,7 @@ #include "GpgInfo.h" GF_MODULE_API_DEFINE("com.bktus.gpgfrontend.module.gnupg_info_gathering", - "GatherGnupgInfo", "1.0.0", + "GatherGnupgInfo", "1.0.1", "Try gathering gnupg informations.", "Saturneric") DEFINE_TRANSLATIONS_STRUCTURE(ModuleGnuPGInfoGathering); diff --git a/src/m_gpg_info/GnupgTab.cpp b/src/m_gpg_info/GnupgTab.cpp index 3d0d687..5123155 100644 --- a/src/m_gpg_info/GnupgTab.cpp +++ b/src/m_gpg_info/GnupgTab.cpp @@ -32,6 +32,8 @@ #include "GnupgTab.h" +#include + #include "GFModuleCommonUtils.hpp" #include "GFSDKModule.h" #include "GnuPGInfoGatheringModule.h" @@ -106,12 +108,14 @@ GnupgTab::GnupgTab(QWidget* parent) ui_->optionDetailsTable->setFocusPolicy(Qt::NoFocus); ui_->optionDetailsTable->setAlternatingRowColors(true); - if (GFModuleRetrieveRTValueOrDefaultBool( - DUP("ui"), DUP("env.state.gnupg_info_gathering"), 0) == 1) { - process_software_info(); - } else { - gather_gnupg_info(); - } + auto future = (QThreadPool::globalInstance(), [=]() { + if (GFModuleRetrieveRTValueOrDefaultBool( + DUP("ui"), DUP("env.state.gnupg_info_gathering"), 0) == 1) { + process_software_info(); + } else { + gather_gnupg_info(); + } + }); } void GnupgTab::process_software_info() {