aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-04-16 08:42:25 +0000
committersaturneric <[email protected]>2024-04-16 08:42:25 +0000
commit903985a4387cb108b64fe50d400fa7ad0bb32979 (patch)
tree9e4d486651bdbe8d186e826c51ec40616ca9056d
parentfix: high cpu usage when using file tab (diff)
downloadGpgFrontend-903985a4387cb108b64fe50d400fa7ad0bb32979.tar.gz
GpgFrontend-903985a4387cb108b64fe50d400fa7ad0bb32979.zip
fix: improve grt tab, mods name and its project structure
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/core/function/gpg/GpgAdvancedOperator.cpp15
-rw-r--r--src/module/CMakeLists.txt12
-rw-r--r--src/module/mods/gpg_info/CMakeLists.txt (renamed from src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt)18
-rw-r--r--src/module/mods/gpg_info/GFModuleExport.h (renamed from src/module/integrated/version_checking_module/GFModuleExport.h)2
-rw-r--r--src/module/mods/gpg_info/GnuPGInfoGatheringModule.cpp (renamed from src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp)0
-rw-r--r--src/module/mods/gpg_info/GnuPGInfoGatheringModule.h (renamed from src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h)0
-rw-r--r--src/module/mods/gpg_info/GpgInfo.cpp (renamed from src/module/integrated/gnupg_info_gathering_module/GpgInfo.cpp)0
-rw-r--r--src/module/mods/gpg_info/GpgInfo.h (renamed from src/module/integrated/gnupg_info_gathering_module/GpgInfo.h)0
-rw-r--r--src/module/mods/gpg_info/QtLoggerFmt.h (renamed from src/module/integrated/gnupg_info_gathering_module/QtLoggerFmt.h)0
-rw-r--r--src/module/mods/ver_check/CMakeLists.txt (renamed from src/module/integrated/version_checking_module/CMakeLists.txt)20
-rw-r--r--src/module/mods/ver_check/GFModuleExport.h (renamed from src/module/integrated/gnupg_info_gathering_module/GFModuleExport.h)2
-rw-r--r--src/module/mods/ver_check/QtLoggerFmt.h (renamed from src/module/integrated/version_checking_module/QtLoggerFmt.h)0
-rw-r--r--src/module/mods/ver_check/SoftwareVersion.cpp (renamed from src/module/integrated/version_checking_module/SoftwareVersion.cpp)0
-rw-r--r--src/module/mods/ver_check/SoftwareVersion.h (renamed from src/module/integrated/version_checking_module/SoftwareVersion.h)0
-rw-r--r--src/module/mods/ver_check/VersionCheckTask.cpp (renamed from src/module/integrated/version_checking_module/VersionCheckTask.cpp)0
-rw-r--r--src/module/mods/ver_check/VersionCheckTask.h (renamed from src/module/integrated/version_checking_module/VersionCheckTask.h)0
-rw-r--r--src/module/mods/ver_check/VersionCheckingModule.cpp (renamed from src/module/integrated/version_checking_module/VersionCheckingModule.cpp)0
-rw-r--r--src/module/mods/ver_check/VersionCheckingModule.h (renamed from src/module/integrated/version_checking_module/VersionCheckingModule.h)0
-rw-r--r--src/ui/dialog/settings/SettingsNetwork.cpp8
-rw-r--r--src/ui/widgets/GRTTreeView.cpp26
-rw-r--r--src/ui/widgets/GRTTreeView.h30
22 files changed, 105 insertions, 32 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 92856c45..384f322e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -370,6 +370,10 @@ if (BUILD_APPLICATION)
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT "Copying Binary into App Image")
add_custom_command(TARGET ${AppName} POST_BUILD
+ COMMAND /bin/mkdir -p ./gpgfrontend/usr/bin && /bin/mv -f ./mods ./gpgfrontend/usr/lib/
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Copying Mods into App Image")
+ add_custom_command(TARGET ${AppName} POST_BUILD
COMMAND /bin/mkdir -p ./gpgfrontend/usr/lib
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT "Complement to build the required architecture")
diff --git a/src/core/function/gpg/GpgAdvancedOperator.cpp b/src/core/function/gpg/GpgAdvancedOperator.cpp
index 205fe1aa..a99429ce 100644
--- a/src/core/function/gpg/GpgAdvancedOperator.cpp
+++ b/src/core/function/gpg/GpgAdvancedOperator.cpp
@@ -139,6 +139,11 @@ void GpgFrontend::GpgAdvancedOperator::ResetConfigures(OperationCallback cb) {
}
void GpgFrontend::GpgAdvancedOperator::StartGpgAgent(OperationCallback cb) {
+ if (!Module::IsModuleActivate(kGnuPGInfoGatheringModuleID)) {
+ cb(-1, TransferParams());
+ return;
+ }
+
const auto gpg_agent_path = Module::RetrieveRTValueTypedOrDefault<>(
kGnuPGInfoGatheringModuleID, "gnupg.gpg_agent_path", QString{});
GF_CORE_LOG_DEBUG("got gnupg agent path from rt: {}", gpg_agent_path);
@@ -162,6 +167,11 @@ void GpgFrontend::GpgAdvancedOperator::StartGpgAgent(OperationCallback cb) {
}
void GpgFrontend::GpgAdvancedOperator::StartDirmngr(OperationCallback cb) {
+ if (!Module::IsModuleActivate(kGnuPGInfoGatheringModuleID)) {
+ cb(-1, TransferParams());
+ return;
+ }
+
const auto dirmngr_path = Module::RetrieveRTValueTypedOrDefault<>(
kGnuPGInfoGatheringModuleID, "gnupg.dirmngr_path", QString{});
GF_CORE_LOG_DEBUG("got gnupg dirmngr path from rt: {}", dirmngr_path);
@@ -185,6 +195,11 @@ void GpgFrontend::GpgAdvancedOperator::StartDirmngr(OperationCallback cb) {
}
void GpgFrontend::GpgAdvancedOperator::StartKeyBoxd(OperationCallback cb) {
+ if (!Module::IsModuleActivate(kGnuPGInfoGatheringModuleID)) {
+ cb(-1, TransferParams());
+ return;
+ }
+
const auto keyboxd_path = Module::RetrieveRTValueTypedOrDefault<>(
kGnuPGInfoGatheringModuleID, "gnupg.keyboxd_path", QString{});
GF_CORE_LOG_DEBUG("got gnupg keyboxd path from rt: {}", keyboxd_path);
diff --git a/src/module/CMakeLists.txt b/src/module/CMakeLists.txt
index d298dbb6..8d894b00 100644
--- a/src/module/CMakeLists.txt
+++ b/src/module/CMakeLists.txt
@@ -51,16 +51,14 @@ if (XCODE_BUILD)
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${GPGFRONTEND_XOCDE_CODE_SIGN_IDENTITY}")
endif ()
-# tracking integrated modules
+# tracking modules
set(all_integrated_module_libraries "")
-file(GLOB children LIST_DIRECTORIES true "integrated/*")
+file(GLOB children LIST_DIRECTORIES true "mods/*")
foreach(child ${children})
if(IS_DIRECTORY ${child})
get_filename_component(dirName ${child} NAME)
- add_subdirectory("integrated/${dirName}")
-
- string(REPLACE "_module" "" stripped_module ${dirName})
- set(integrated_lib_name "gpgfrontend_integrated_module_${stripped_module}")
- list(APPEND all_integrated_module_libraries ${integrated_lib_name})
+ add_subdirectory("mods/${dirName}")
+
+ list(APPEND all_integrated_module_libraries ${dirName})
endif()
endforeach() \ No newline at end of file
diff --git a/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt b/src/module/mods/gpg_info/CMakeLists.txt
index 3f1645eb..6759456c 100644
--- a/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt
+++ b/src/module/mods/gpg_info/CMakeLists.txt
@@ -28,21 +28,21 @@
aux_source_directory(. INTEGRATED_MODULE_SOURCE)
# define libgpgfrontend_module
-add_library(gpgfrontend_gnupg_info_gathering SHARED ${INTEGRATED_MODULE_SOURCE})
+add_library(mod_gpg_info SHARED ${INTEGRATED_MODULE_SOURCE})
set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GFModuleExport.h")
-generate_export_header(gpgfrontend_gnupg_info_gathering
+generate_export_header(mod_gpg_info
BASE_NAME "GF_MODULE"
EXPORT_FILE_NAME "${_export_file}")
-target_include_directories(gpgfrontend_gnupg_info_gathering PRIVATE
+target_include_directories(mod_gpg_info PRIVATE
${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
# set output directory
-set_target_properties(gpgfrontend_gnupg_info_gathering PROPERTIES
+set_target_properties(mod_gpg_info PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mods)
if (XCODE_BUILD)
- set_target_properties(gpgfrontend_gnupg_info_gathering
+ set_target_properties(mod_gpg_info
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
@@ -52,16 +52,16 @@ if (XCODE_BUILD)
endif ()
# link sdk
-target_link_libraries(gpgfrontend_gnupg_info_gathering PRIVATE
+target_link_libraries(mod_gpg_info PRIVATE
gpgfrontend_module_sdk)
# link qt
-target_link_libraries(gpgfrontend_gnupg_info_gathering PRIVATE
+target_link_libraries(mod_gpg_info PRIVATE
Qt6::Core)
# property
-set_property(TARGET gpgfrontend_gnupg_info_gathering PROPERTY AUTOMOC ON)
+set_property(TARGET mod_gpg_info PROPERTY AUTOMOC ON)
# using std c++ 17
-target_compile_features(gpgfrontend_gnupg_info_gathering PRIVATE cxx_std_17) \ No newline at end of file
+target_compile_features(mod_gpg_info PRIVATE cxx_std_17) \ No newline at end of file
diff --git a/src/module/integrated/version_checking_module/GFModuleExport.h b/src/module/mods/gpg_info/GFModuleExport.h
index 6e02c878..a1fc1053 100644
--- a/src/module/integrated/version_checking_module/GFModuleExport.h
+++ b/src/module/mods/gpg_info/GFModuleExport.h
@@ -7,7 +7,7 @@
# define GF_MODULE_NO_EXPORT
#else
# ifndef GF_MODULE_EXPORT
-# ifdef gpgfrontend_version_checking_EXPORTS
+# ifdef mod_gpg_info_EXPORTS
/* We are building this library */
# define GF_MODULE_EXPORT __attribute__((visibility("default")))
# else
diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp b/src/module/mods/gpg_info/GnuPGInfoGatheringModule.cpp
index 3965c661..3965c661 100644
--- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp
+++ b/src/module/mods/gpg_info/GnuPGInfoGatheringModule.cpp
diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h b/src/module/mods/gpg_info/GnuPGInfoGatheringModule.h
index 35ee4ac3..35ee4ac3 100644
--- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h
+++ b/src/module/mods/gpg_info/GnuPGInfoGatheringModule.h
diff --git a/src/module/integrated/gnupg_info_gathering_module/GpgInfo.cpp b/src/module/mods/gpg_info/GpgInfo.cpp
index 680f4a8a..680f4a8a 100644
--- a/src/module/integrated/gnupg_info_gathering_module/GpgInfo.cpp
+++ b/src/module/mods/gpg_info/GpgInfo.cpp
diff --git a/src/module/integrated/gnupg_info_gathering_module/GpgInfo.h b/src/module/mods/gpg_info/GpgInfo.h
index 1aacc207..1aacc207 100644
--- a/src/module/integrated/gnupg_info_gathering_module/GpgInfo.h
+++ b/src/module/mods/gpg_info/GpgInfo.h
diff --git a/src/module/integrated/gnupg_info_gathering_module/QtLoggerFmt.h b/src/module/mods/gpg_info/QtLoggerFmt.h
index 23997465..23997465 100644
--- a/src/module/integrated/gnupg_info_gathering_module/QtLoggerFmt.h
+++ b/src/module/mods/gpg_info/QtLoggerFmt.h
diff --git a/src/module/integrated/version_checking_module/CMakeLists.txt b/src/module/mods/ver_check/CMakeLists.txt
index 19706e87..b011410f 100644
--- a/src/module/integrated/version_checking_module/CMakeLists.txt
+++ b/src/module/mods/ver_check/CMakeLists.txt
@@ -28,21 +28,21 @@
aux_source_directory(. INTEGRATED_MODULE_SOURCE)
# define libgpgfrontend_module
-add_library(gpgfrontend_version_checking SHARED ${INTEGRATED_MODULE_SOURCE})
+add_library(mod_ver_check SHARED ${INTEGRATED_MODULE_SOURCE})
set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GFModuleExport.h")
-generate_export_header(gpgfrontend_version_checking
+generate_export_header(mod_ver_check
BASE_NAME "GF_MODULE"
EXPORT_FILE_NAME "${_export_file}")
-target_include_directories(gpgfrontend_version_checking PRIVATE
+target_include_directories(mod_ver_check PRIVATE
${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
# set output directory
-set_target_properties(gpgfrontend_version_checking PROPERTIES
+set_target_properties(mod_ver_check PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mods)
if (XCODE_BUILD)
- set_target_properties(gpgfrontend_version_checking
+ set_target_properties(mod_ver_check
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
@@ -52,19 +52,19 @@ if (XCODE_BUILD)
endif ()
# link sdk
-target_link_libraries(gpgfrontend_version_checking PRIVATE
+target_link_libraries(mod_ver_check PRIVATE
gpgfrontend_module_sdk)
if(GPGFRONTEND_QT5_BUILD)
# link Qt
- target_link_libraries(gpgfrontend_version_checking PUBLIC Qt5::Core Qt5::Network)
+ target_link_libraries(mod_ver_check PUBLIC Qt5::Core Qt5::Network)
else()
# link Qt
- target_link_libraries(gpgfrontend_version_checking PUBLIC Qt6::Core Qt6::Network)
+ target_link_libraries(mod_ver_check PUBLIC Qt6::Core Qt6::Network)
endif()
# property
-set_property(TARGET gpgfrontend_version_checking PROPERTY AUTOMOC ON)
+set_property(TARGET mod_ver_check PROPERTY AUTOMOC ON)
# using std c++ 17
-target_compile_features(gpgfrontend_version_checking PRIVATE cxx_std_17) \ No newline at end of file
+target_compile_features(mod_ver_check PRIVATE cxx_std_17) \ No newline at end of file
diff --git a/src/module/integrated/gnupg_info_gathering_module/GFModuleExport.h b/src/module/mods/ver_check/GFModuleExport.h
index fd18dfb1..ce663b5f 100644
--- a/src/module/integrated/gnupg_info_gathering_module/GFModuleExport.h
+++ b/src/module/mods/ver_check/GFModuleExport.h
@@ -7,7 +7,7 @@
# define GF_MODULE_NO_EXPORT
#else
# ifndef GF_MODULE_EXPORT
-# ifdef gpgfrontend_gnupg_info_gathering_EXPORTS
+# ifdef mod_ver_check_EXPORTS
/* We are building this library */
# define GF_MODULE_EXPORT __attribute__((visibility("default")))
# else
diff --git a/src/module/integrated/version_checking_module/QtLoggerFmt.h b/src/module/mods/ver_check/QtLoggerFmt.h
index 23997465..23997465 100644
--- a/src/module/integrated/version_checking_module/QtLoggerFmt.h
+++ b/src/module/mods/ver_check/QtLoggerFmt.h
diff --git a/src/module/integrated/version_checking_module/SoftwareVersion.cpp b/src/module/mods/ver_check/SoftwareVersion.cpp
index cd864195..cd864195 100644
--- a/src/module/integrated/version_checking_module/SoftwareVersion.cpp
+++ b/src/module/mods/ver_check/SoftwareVersion.cpp
diff --git a/src/module/integrated/version_checking_module/SoftwareVersion.h b/src/module/mods/ver_check/SoftwareVersion.h
index 6b05d413..6b05d413 100644
--- a/src/module/integrated/version_checking_module/SoftwareVersion.h
+++ b/src/module/mods/ver_check/SoftwareVersion.h
diff --git a/src/module/integrated/version_checking_module/VersionCheckTask.cpp b/src/module/mods/ver_check/VersionCheckTask.cpp
index 5ea9c48e..5ea9c48e 100644
--- a/src/module/integrated/version_checking_module/VersionCheckTask.cpp
+++ b/src/module/mods/ver_check/VersionCheckTask.cpp
diff --git a/src/module/integrated/version_checking_module/VersionCheckTask.h b/src/module/mods/ver_check/VersionCheckTask.h
index df801570..df801570 100644
--- a/src/module/integrated/version_checking_module/VersionCheckTask.h
+++ b/src/module/mods/ver_check/VersionCheckTask.h
diff --git a/src/module/integrated/version_checking_module/VersionCheckingModule.cpp b/src/module/mods/ver_check/VersionCheckingModule.cpp
index 35d3b82e..35d3b82e 100644
--- a/src/module/integrated/version_checking_module/VersionCheckingModule.cpp
+++ b/src/module/mods/ver_check/VersionCheckingModule.cpp
diff --git a/src/module/integrated/version_checking_module/VersionCheckingModule.h b/src/module/mods/ver_check/VersionCheckingModule.h
index 35ee4ac3..35ee4ac3 100644
--- a/src/module/integrated/version_checking_module/VersionCheckingModule.h
+++ b/src/module/mods/ver_check/VersionCheckingModule.h
diff --git a/src/ui/dialog/settings/SettingsNetwork.cpp b/src/ui/dialog/settings/SettingsNetwork.cpp
index c7e1e9f6..a923e5a2 100644
--- a/src/ui/dialog/settings/SettingsNetwork.cpp
+++ b/src/ui/dialog/settings/SettingsNetwork.cpp
@@ -29,6 +29,7 @@
#include "SettingsNetwork.h"
#include "core/function/GlobalSettingStation.h"
+#include "core/module/ModuleManager.h"
#include "ui/thread/ProxyConnectionTestTask.h"
#include "ui_NetworkSettings.h"
@@ -86,8 +87,11 @@ GpgFrontend::UI::NetworkTab::NetworkTab(QWidget *parent)
ui_->forbidALLGnuPGNetworkConnectionCheckBox->setText(
tr("Forbid all GnuPG network connection."));
- ui_->prohibitUpdateCheck->setText(
- tr("Prohibit checking for version updates when the program starts."));
+
+ if (Module::IsModuleActivate(kVersionCheckingModuleID)) {
+ ui_->prohibitUpdateCheck->setText(
+ tr("Prohibit checking for version updates when the program starts."));
+ }
ui_->autoImportMissingKeyCheckBox->setText(
tr("Automatically import a missing key for signature verification."));
ui_->networkAbilityTipsLabel->setText(
diff --git a/src/ui/widgets/GRTTreeView.cpp b/src/ui/widgets/GRTTreeView.cpp
index f2ae42c2..09d7dcf0 100644
--- a/src/ui/widgets/GRTTreeView.cpp
+++ b/src/ui/widgets/GRTTreeView.cpp
@@ -33,10 +33,34 @@
namespace GpgFrontend::UI {
-GRTTreeView::GRTTreeView(QWidget *parent) : QTreeView(parent) {
+GRTTreeView::GRTTreeView(QWidget* parent) : QTreeView(parent) {
setModel(new Module::GlobalRegisterTableTreeModel(
Module::ModuleManager::GetInstance().GRT()));
+
+ connect(model(), &QFileSystemModel::layoutChanged, this,
+ &GRTTreeView::slot_adjust_column_widths);
+ connect(model(), &QFileSystemModel::dataChanged, this,
+ &GRTTreeView::slot_adjust_column_widths);
+ connect(this, &GRTTreeView::expanded, this,
+ &GRTTreeView::slot_adjust_column_widths);
+ connect(this, &GRTTreeView::collapsed, this,
+ &GRTTreeView::slot_adjust_column_widths);
}
GRTTreeView::~GRTTreeView() = default;
+
+void GRTTreeView::paintEvent(QPaintEvent* event) {
+ QTreeView::paintEvent(event);
+
+ if (!initial_resize_done_) {
+ slot_adjust_column_widths();
+ initial_resize_done_ = true;
+ }
+}
+
+void GRTTreeView::slot_adjust_column_widths() {
+ for (int i = 0; i < model()->columnCount(); ++i) {
+ this->resizeColumnToContents(i);
+ }
+}
} // namespace GpgFrontend::UI \ No newline at end of file
diff --git a/src/ui/widgets/GRTTreeView.h b/src/ui/widgets/GRTTreeView.h
index e730b698..6f3f83c8 100644
--- a/src/ui/widgets/GRTTreeView.h
+++ b/src/ui/widgets/GRTTreeView.h
@@ -33,9 +33,37 @@ namespace GpgFrontend::UI {
class GRTTreeView : public QTreeView {
Q_OBJECT
public:
- explicit GRTTreeView(QWidget *parent);
+ /**
+ * @brief Construct a new GRTTreeView object
+ *
+ * @param parent
+ */
+ explicit GRTTreeView(QWidget* parent);
+ /**
+ * @brief Destroy the GRTTreeView object
+ *
+ */
virtual ~GRTTreeView() override;
+
+ protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
+ void paintEvent(QPaintEvent* event) override;
+
+ private slots:
+
+ /**
+ * @brief
+ *
+ */
+ void slot_adjust_column_widths();
+
+ private:
+ bool initial_resize_done_ = false;
};
} // namespace GpgFrontend::UI \ No newline at end of file