aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/debug.yml3
-rw-r--r--.github/workflows/release-deb-package.yml32
-rw-r--r--.github/workflows/release.yml3
-rw-r--r--CMakeLists.txt4
-rw-r--r--gpgfrontend.qrc1
-rw-r--r--resource/icons/gnupg.pngbin0 -> 7198 bytes
-rw-r--r--src/CMakeLists.txt43
-rw-r--r--src/before_exit.cpp4
-rw-r--r--src/core/CMakeLists.txt6
-rw-r--r--src/core/GpgContext.cpp5
-rw-r--r--src/core/GpgInfo.h1
-rw-r--r--src/core/function/ArchiveFileOperator.cpp12
-rw-r--r--src/core/function/ArchiveFileOperator.h10
-rw-r--r--src/core/function/DataObjectOperator.cpp1
-rw-r--r--src/core/function/FileOperator.cpp66
-rw-r--r--src/core/function/GlobalSettingStation.h4
-rw-r--r--src/core/function/KeyPackageOperator.cpp3
-rw-r--r--src/core/function/PassphraseGenerator.cpp50
-rw-r--r--src/core/function/aes/aes_ssl.h8
-rw-r--r--src/core/function/aes/aes_ssl_cbc.cpp2
-rw-r--r--src/core/function/gpg/GpgCommandExecutor.h3
-rw-r--r--src/core/function/gpg/GpgFileOpera.h1
-rw-r--r--src/core/function/gpg/GpgKeyOpera.cpp7
-rw-r--r--src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp4
-rw-r--r--src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp4
-rw-r--r--src/core/function/result_analyse/GpgSignResultAnalyse.cpp2
-rw-r--r--src/core/model/GpgKey.cpp7
-rw-r--r--src/ui/CMakeLists.txt12
-rw-r--r--src/ui/GpgFrontendApplication.cpp7
-rw-r--r--src/ui/GpgFrontendApplication.h2
-rw-r--r--src/ui/GpgFrontendUIInit.cpp2
-rw-r--r--src/ui/UserInterfaceUtils.cpp3
-rw-r--r--src/ui/UserInterfaceUtils.h10
-rw-r--r--src/ui/dialog/GeneralDialog.cpp88
-rw-r--r--src/ui/dialog/GeneralDialog.h66
-rwxr-xr-xsrc/ui/dialog/QuitDialog.cpp4
-rwxr-xr-xsrc/ui/dialog/QuitDialog.h3
-rw-r--r--src/ui/dialog/SignersPicker.cpp (renamed from src/ui/widgets/SignersPicker.cpp)23
-rw-r--r--src/ui/dialog/SignersPicker.h (renamed from src/ui/widgets/SignersPicker.h)17
-rw-r--r--src/ui/dialog/Wizard.h6
-rw-r--r--src/ui/dialog/details/SignatureDetailsDialog.cpp (renamed from src/ui/details/SignatureDetailsDialog.cpp)0
-rw-r--r--src/ui/dialog/details/SignatureDetailsDialog.h (renamed from src/ui/details/SignatureDetailsDialog.h)1
-rw-r--r--src/ui/dialog/details/VerifyDetailsDialog.cpp (renamed from src/ui/details/VerifyDetailsDialog.cpp)0
-rw-r--r--src/ui/dialog/details/VerifyDetailsDialog.h (renamed from src/ui/details/VerifyDetailsDialog.h)0
-rw-r--r--src/ui/dialog/help/AboutDialog.cpp (renamed from src/ui/help/AboutDialog.cpp)28
-rw-r--r--src/ui/dialog/help/AboutDialog.h (renamed from src/ui/help/AboutDialog.h)3
-rw-r--r--src/ui/dialog/help/GnupgTab.cpp66
-rw-r--r--src/ui/dialog/help/GnupgTab.h53
-rw-r--r--src/ui/dialog/import_export/ExportKeyPackageDialog.cpp (renamed from src/ui/import_export/ExportKeyPackageDialog.cpp)6
-rw-r--r--src/ui/dialog/import_export/ExportKeyPackageDialog.h (renamed from src/ui/import_export/ExportKeyPackageDialog.h)3
-rw-r--r--src/ui/dialog/import_export/KeyImportDetailDialog.cpp (renamed from src/ui/import_export/KeyImportDetailDialog.cpp)6
-rw-r--r--src/ui/dialog/import_export/KeyImportDetailDialog.h (renamed from src/ui/import_export/KeyImportDetailDialog.h)3
-rw-r--r--src/ui/dialog/import_export/KeyServerImportDialog.cpp (renamed from src/ui/import_export/KeyServerImportDialog.cpp)270
-rw-r--r--src/ui/dialog/import_export/KeyServerImportDialog.h (renamed from src/ui/import_export/KeyServerImportDialog.h)45
-rw-r--r--src/ui/dialog/import_export/KeyUploadDialog.cpp (renamed from src/ui/import_export/KeyUploadDialog.cpp)8
-rw-r--r--src/ui/dialog/import_export/KeyUploadDialog.h (renamed from src/ui/import_export/KeyUploadDialog.h)3
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.cpp (renamed from src/ui/key_generate/KeygenDialog.cpp)5
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.h (renamed from src/ui/key_generate/KeygenDialog.h)3
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp (renamed from src/ui/key_generate/SubkeyGenerateDialog.cpp)5
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.h (renamed from src/ui/key_generate/SubkeyGenerateDialog.h)3
-rw-r--r--src/ui/dialog/keypair_details/KeyDetailsDialog.cpp (renamed from src/ui/keypair_details/KeyDetailsDialog.cpp)12
-rw-r--r--src/ui/dialog/keypair_details/KeyDetailsDialog.h (renamed from src/ui/keypair_details/KeyDetailsDialog.h)3
-rw-r--r--src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp (renamed from src/ui/keypair_details/KeyNewUIDDialog.cpp)14
-rw-r--r--src/ui/dialog/keypair_details/KeyNewUIDDialog.h (renamed from src/ui/keypair_details/KeyNewUIDDialog.h)3
-rw-r--r--src/ui/dialog/keypair_details/KeyPairDetailTab.cpp (renamed from src/ui/keypair_details/KeyPairDetailTab.cpp)2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairDetailTab.h (renamed from src/ui/keypair_details/KeyPairDetailTab.h)24
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.cpp (renamed from src/ui/keypair_details/KeyPairOperaTab.cpp)4
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.h (renamed from src/ui/keypair_details/KeyPairOperaTab.h)0
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp (renamed from src/ui/keypair_details/KeyPairSubkeyTab.cpp)2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.h (renamed from src/ui/keypair_details/KeyPairSubkeyTab.h)2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairUIDTab.cpp (renamed from src/ui/keypair_details/KeyPairUIDTab.cpp)2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairUIDTab.h (renamed from src/ui/keypair_details/KeyPairUIDTab.h)0
-rw-r--r--src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp (renamed from src/ui/keypair_details/KeySetExpireDateDialog.cpp)6
-rw-r--r--src/ui/dialog/keypair_details/KeySetExpireDateDialog.h (renamed from src/ui/keypair_details/KeySetExpireDateDialog.h)3
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp (renamed from src/ui/keypair_details/KeyUIDSignDialog.cpp)6
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.h (renamed from src/ui/keypair_details/KeyUIDSignDialog.h)3
-rw-r--r--src/ui/dialog/settings/SettingsAdvanced.cpp (renamed from src/ui/settings/SettingsAdvanced.cpp)0
-rw-r--r--src/ui/dialog/settings/SettingsAdvanced.h (renamed from src/ui/settings/SettingsAdvanced.h)0
-rw-r--r--src/ui/dialog/settings/SettingsAppearance.cpp (renamed from src/ui/settings/SettingsAppearance.cpp)26
-rw-r--r--src/ui/dialog/settings/SettingsAppearance.h (renamed from src/ui/settings/SettingsAppearance.h)0
-rw-r--r--src/ui/dialog/settings/SettingsDialog.cpp (renamed from src/ui/settings/SettingsDialog.cpp)13
-rw-r--r--[-rwxr-xr-x]src/ui/dialog/settings/SettingsDialog.h (renamed from src/ui/settings/SettingsDialog.h)5
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.cpp (renamed from src/ui/settings/SettingsGeneral.cpp)0
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.h (renamed from src/ui/settings/SettingsGeneral.h)0
-rw-r--r--src/ui/dialog/settings/SettingsKeyServer.cpp (renamed from src/ui/settings/SettingsKeyServer.cpp)35
-rw-r--r--src/ui/dialog/settings/SettingsKeyServer.h (renamed from src/ui/settings/SettingsKeyServer.h)0
-rw-r--r--src/ui/dialog/settings/SettingsNetwork.cpp (renamed from src/ui/settings/SettingsNetwork.cpp)0
-rw-r--r--src/ui/dialog/settings/SettingsNetwork.h (renamed from src/ui/settings/SettingsNetwork.h)0
-rw-r--r--src/ui/main_window/GeneralMainWindow.cpp135
-rw-r--r--src/ui/main_window/GeneralMainWindow.h81
-rw-r--r--[-rwxr-xr-x]src/ui/main_window/KeyMgmt.cpp (renamed from src/ui/KeyMgmt.cpp)119
-rw-r--r--[-rwxr-xr-x]src/ui/main_window/KeyMgmt.h (renamed from src/ui/KeyMgmt.h)25
-rw-r--r--src/ui/main_window/MainWindow.cpp70
-rw-r--r--src/ui/main_window/MainWindow.h15
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp5
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp11
-rw-r--r--src/ui/main_window/MainWindowSlotUI.cpp10
-rw-r--r--src/ui/main_window/MainWindowUI.cpp9
-rw-r--r--src/ui/struct/SettingsObject.h3
-rw-r--r--src/ui/thread/KeyServerImportTask.cpp64
-rw-r--r--src/ui/thread/KeyServerImportTask.h80
-rw-r--r--src/ui/thread/KeyServerSearchTask.cpp59
-rw-r--r--src/ui/thread/KeyServerSearchTask.h76
-rw-r--r--src/ui/thread/ListedKeyServerTestTask.h4
-rw-r--r--src/ui/widgets/FilePage.h2
-rw-r--r--src/ui/widgets/FindWidget.cpp6
-rw-r--r--src/ui/widgets/InfoBoardWidget.cpp4
-rw-r--r--src/ui/widgets/InfoBoardWidget.h2
-rw-r--r--src/ui/widgets/KeyList.h2
-rw-r--r--src/ui/widgets/VerifyKeyDetailBox.cpp2
-rw-r--r--src/ui/widgets/VerifyKeyDetailBox.h2
-rw-r--r--third_party/encoding-detect/TextEncodingDetect.cpp313
-rw-r--r--third_party/encoding-detect/TextEncodingDetect.h85
m---------third_party/gpgme0
114 files changed, 1343 insertions, 1046 deletions
diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml
index 0615b530..05add7a5 100644
--- a/.github/workflows/debug.yml
+++ b/.github/workflows/debug.yml
@@ -23,8 +23,9 @@ jobs:
build:
strategy:
matrix:
- os: [ 'ubuntu-latest', 'macos-10.15', 'windows-latest' ]
+ os: [ 'ubuntu-latest', 'macos-10.15', 'macos-11', 'macos-12', 'windows-latest' ]
runs-on: ${{ matrix.os }}
+ continue-on-error: true
steps:
- name: Set git to use LF(Windows) or CRLF(MacOS) line endings
diff --git a/.github/workflows/release-deb-package.yml b/.github/workflows/release-deb-package.yml
index 454a579f..f5aff6a0 100644
--- a/.github/workflows/release-deb-package.yml
+++ b/.github/workflows/release-deb-package.yml
@@ -23,8 +23,9 @@ jobs:
build:
strategy:
matrix:
- os: [ 'ubuntu-20.04' ]
+ os: [ 'ubuntu-20.04', 'ubuntu-22.04' ]
runs-on: ${{ matrix.os }}
+ continue-on-error: true
steps:
- uses: actions/checkout@v2
@@ -35,6 +36,22 @@ jobs:
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+ - name: Install Dependence (Ubuntu 18.04)
+ run: |
+ sudo apt-get update
+ sudo apt-get -y install build-essential binutils git autoconf automake gettext texinfo qt5-default
+ sudo apt-get -y install gcc-8 g++-8 ninja-build
+ sudo apt-get -y install libconfig++-dev libboost-all-dev libarchive-dev libssl-dev
+ sudo apt-get -y install gpgsm libxcb-xinerama0 libxcb-icccm4-dev libcups2-dev libdrm-dev libegl1-mesa-dev
+ sudo apt-get -y install libgcrypt11-dev libnss3-dev libpci-dev libpulse-dev libudev-dev libxtst-dev gyp
+ sudo apt-get -y install libglu1-mesa-dev libfontconfig1-dev libx11-xcb-dev libicu-dev libxcb-image0
+ sudo apt-get -y install libglu1-mesa-dev libfontconfig1-dev libx11-xcb-dev libicu-dev libxcb-*
+ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8
+ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8
+ sudo update-alternatives --set gcc "/usr/bin/gcc-8"
+ sudo update-alternatives --set g++ "/usr/bin/g++-8"
+ if: matrix.os == 'ubuntu-18.04'
+
- name: Install Dependence (Ubuntu 20.04)
run: |
sudo apt-get update
@@ -44,6 +61,16 @@ jobs:
sudo apt-get -y install gpg
if: matrix.os == 'ubuntu-20.04'
+ - name: Install Dependence (Ubuntu 22.04)
+ run: |
+ sudo apt-get update
+ sudo apt-get -y install build-essential binutils git autoconf automake gettext texinfo
+ sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
+ sudo apt-get -y install gcc g++ ninja-build
+ sudo apt-get -y install libarchive-dev libconfig++-dev libboost-all-dev libssl-dev
+ sudo apt-get -y install gpg
+ if: matrix.os == 'ubuntu-22.04'
+
- name: Build gpg-error (Linux)
run: |
cd ${{github.workspace}}/third_party/libgpg-error
@@ -51,7 +78,6 @@ jobs:
./configure --enable-maintainer-mode --enable-static=yes && make -j2
sudo make install
cd ${{github.workspace}}
- if: matrix.os == 'ubuntu-20.04'
- name: Build assuan (Linux)
run: |
@@ -60,7 +86,6 @@ jobs:
./configure --enable-maintainer-mode && make -j2
sudo make install
cd ${{github.workspace}}
- if: matrix.os == 'ubuntu-20.04'
- name: Build GpgME (Linux)
run: |
@@ -69,7 +94,6 @@ jobs:
./configure --enable-maintainer-mode --enable-languages=cpp && make -j2
sudo make install
cd ${{github.workspace}}
- if: matrix.os == 'ubuntu-20.04'
- name: Build & Package GpgFrontend (Linux DEB Package)
# Build your program with the given configuration
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3ec10770..15e5b298 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -23,8 +23,9 @@ jobs:
build:
strategy:
matrix:
- os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-2019' ]
+ os: [ 'ubuntu-18.04', 'macos-10.15', 'macos-11', 'macos-12', 'windows-2019' ]
runs-on: ${{ matrix.os }}
+ continue-on-error: true
steps:
- name: Set git to use LF(Windows) or CRLF(MacOS) line endings
run: |
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eecb01b0..171238eb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@
cmake_minimum_required(VERSION 3.16)
# define project
-project(GpgFrontend VERSION 2.0.8 LANGUAGES CXX)
+project(GpgFrontend VERSION 2.0.9 LANGUAGES CXX)
# show cmake version
message(STATUS "GpgFrontend Build Configuration Started CMAKE Version ${CMAKE_VERSION}")
@@ -433,7 +433,7 @@ find_package(OpenSSL REQUIRED)
# Introduce Qt
if (QT5_ENV_SUPPORT)
# Support Qt version Both 5.12.x and 5.15.x
- find_package(Qt5 5.12 COMPONENTS Core Test Widgets PrintSupport Network REQUIRED)
+ find_package(Qt5 5.9 COMPONENTS Core Test Widgets PrintSupport Network REQUIRED)
# Qt configuration
set(CMAKE_AUTOMOC ON)
diff --git a/gpgfrontend.qrc b/gpgfrontend.qrc
index f034cf37..7f4a9c68 100644
--- a/gpgfrontend.qrc
+++ b/gpgfrontend.qrc
@@ -41,6 +41,7 @@
<file alias="format-line-spacing-double.png">resource/icons/format-line-spacing-double.png</file>
<file alias="format-line-spacing-normal.png">resource/icons/format-line-spacing-normal.png</file>
<file alias="format-line-spacing-triple.png">resource/icons/format-line-spacing-triple.png</file>
+ <file alias="gnupg.png">resource/icons/gnupg.png</file>
<file alias="gpgfrontend.png">resource/icons/gpgfrontend.png</file>
<file alias="importance.png">resource/icons/importance.png</file>
<file alias="importkey_editor.png">resource/icons/importkey_editor.png</file>
diff --git a/resource/icons/gnupg.png b/resource/icons/gnupg.png
new file mode 100644
index 00000000..2a209e21
--- /dev/null
+++ b/resource/icons/gnupg.png
Binary files differ
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fb38cb9a..4df4579a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -129,7 +129,7 @@ if (BASIC_ENV_CONFIG)
configure_file(${CMAKE_SOURCE_DIR}/src/GpgFrontend.h.in ${CMAKE_SOURCE_DIR}/src/GpgFrontend.h @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/src/GpgFrontendBuildInfo.h.in ${CMAKE_SOURCE_DIR}/src/GpgFrontendBuildInfo.h @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/src/GpgFrontendBuildInstallInfo.h.in ${CMAKE_SOURCE_DIR}/src/GpgFrontendBuildInstallInfo.h @ONLY)
- if(APPLE)
+ if (APPLE)
configure_file(${CMAKE_SOURCE_DIR}/resource/plist/ExportOptions.plist.in ${CMAKE_BINARY_DIR}/ExportOptions.plist @ONLY)
endif ()
endif ()
@@ -183,7 +183,7 @@ if (APPLICATION_BUILD)
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
if (MINGW)
add_executable(${AppName} WIN32 ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
- # custom app bundle packing
+ # custom app bundle packing
elseif (APPLE AND NOT XCODE_BUILD)
add_executable(${AppName} MACOSX_BUNDLE ${ICON_RESOURCE} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
set_target_properties(${AppName} PROPERTIES
@@ -212,7 +212,7 @@ if (APPLICATION_BUILD)
COMMAND /bin/mkdir -p ./gpgfrontend/usr/lib
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT "Complement to build the required architecture")
- # app bundle packing using xcode
+ # app bundle packing using xcode
elseif (APPLE AND XCODE_BUILD)
add_executable(${AppName} MACOSX_BUNDLE ${ICON_RESOURCE} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
set_target_properties(${AppName} PROPERTIES
@@ -272,10 +272,10 @@ if (APPLICATION_BUILD)
message(STATUS "Link Application Library For Linux")
target_link_libraries(${AppName} crypto pthread)
# issue on filesystem support of gcc
- if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 9.0)
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 9.0)
target_link_libraries(${AppName} stdc++fs)
endif ()
- endif()
+ endif ()
endif ()
# using c++ standard 17
@@ -314,6 +314,14 @@ if (LINUX AND LINUX_INSTALL_SOFTWARE)
install(DIRECTORY ${LOCALE_OUTPUT_PATH}/
DESTINATION ${CMAKE_INSTALL_FULL_LOCALEDIR})
endif ()
+
+ cmake_host_system_information(RESULT PRETTY_NAME QUERY DISTRIB_PRETTY_NAME)
+ cmake_host_system_information(RESULT DISTRO QUERY DISTRIB_INFO)
+
+ foreach(VAR IN LISTS DISTRO)
+ message(STATUS "${VAR}=`${${VAR}}`")
+ endforeach()
+
if (APP_PACKAGE_DEB)
message(STATUS "Configure Deb Package")
SET(CPACK_GENERATOR "DEB")
@@ -323,7 +331,30 @@ if (LINUX AND LINUX_INSTALL_SOFTWARE)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_PACKAGE_CONTACT "[email protected]")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Saturneric")
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "gpg (>= 2.2), libqt5core5a (>= 5.9), libqt5gui5 (>= 5.9), libqt5widgets5 (>= 5.9), libqt5network5 (>= 5.9), libqt5printsupport5 (>= 5.9), libconfig++9v5 (>=1.5), libarchive13(>= 3.4), openssl(>= 1.1.1), libicu66")
+
+ if (${DISTRO_NAME} MATCHES "Ubuntu")
+ if (${DISTRO_VERSION_ID} STREQUAL "22.04")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "gpg (>= 2.2), libqt5core5a (>= 5.9), libqt5gui5 (>= 5.9), libqt5widgets5 (>= 5.9), libqt5network5 (>= 5.9), libqt5printsupport5 (>= 5.9), libconfig++9v5 (>=1.5), libarchive13(>= 3.4), openssl(>= 1.1.1), libicu70")
+ elseif (${DISTRO_VERSION_ID} STREQUAL "20.04")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "gpg (>= 2.2), libqt5core5a (>= 5.9), libqt5gui5 (>= 5.9), libqt5widgets5 (>= 5.9), libqt5network5 (>= 5.9), libqt5printsupport5 (>= 5.9), libconfig++9v5 (>=1.5), libarchive13(>= 3.4), openssl(>= 1.1.1), libicu66")
+ endif ()
+ endif ()
+
+ set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
+ set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
+ set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
+ include(CPack)
+ endif ()
+ if (APP_PACKAGE_RPM)
+ message(STATUS "Configure Rpm Package")
+ SET(CPACK_GENERATOR "RPM")
+ set(CPACK_INSTALL_PREFIX "/usr/local/")
+ set(CPACK_PACKAGE_NAME "gpgfrontend")
+ set(CPACK_DEBIAN_PACKAGE_NAME "gpgfrontend")
+ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
+ set(CPACK_PACKAGE_CONTACT "[email protected]")
+ SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Saturneric")
+
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
diff --git a/src/before_exit.cpp b/src/before_exit.cpp
index 04e245db..f13649db 100644
--- a/src/before_exit.cpp
+++ b/src/before_exit.cpp
@@ -32,6 +32,4 @@
* @brief Actions performed before exiting the application
*
*/
-void before_exit() {
- LOG(INFO) << "called";
-}
+void before_exit() { LOG(INFO) << "called"; }
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index f9c354a2..0282b58c 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -60,7 +60,7 @@ aux_source_directory(${CMAKE_SOURCE_DIR}/third_party/encoding-detect ENCODING_DE
target_sources(gpgfrontend_core PUBLIC ${ENCODING_DETECT_SOURCE_CODE})
# icu
-if(APPLE)
+if (APPLE)
target_include_directories(gpgfrontend_core PRIVATE /usr/local/opt/icu4c/include)
target_link_directories(gpgfrontend_core PRIVATE /usr/local/opt/icu4c/lib)
target_link_libraries(gpgfrontend_core PRIVATE icui18n icuuc icudata)
@@ -77,10 +77,10 @@ target_link_libraries(gpgfrontend_core PRIVATE gpgme assuan gpg-error)
target_link_libraries(gpgfrontend_core PUBLIC OpenSSL::SSL OpenSSL::Crypto)
# link boost libraries
target_link_libraries(gpgfrontend_core PUBLIC ${Boost_LIBRARIES})
-if(MINGW)
+if (MINGW)
# for uuid ability in mingw
target_link_libraries(gpgfrontend_core PUBLIC bcrypt)
-endif()
+endif ()
# link libarchive
target_link_libraries(gpgfrontend_core PRIVATE archive)
diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp
index 7e656dfb..28857d32 100644
--- a/src/core/GpgContext.cpp
+++ b/src/core/GpgContext.cpp
@@ -93,7 +93,9 @@ GpgContext::GpgContext(const GpgContextInitArgs &args) : args_(args) {
: engine_info->file_name)
<< std::string(engine_info->home_dir == nullptr
? "null"
- : engine_info->home_dir);
+ : engine_info->home_dir)
+ << std::string(engine_info->version ? "null"
+ : engine_info->version);
switch (engine_info->protocol) {
case GPGME_PROTOCOL_OpenPGP:
@@ -110,6 +112,7 @@ GpgContext::GpgContext(const GpgContextInitArgs &args) : args_(args) {
info_.GpgConfPath = engine_info->file_name;
break;
case GPGME_PROTOCOL_ASSUAN:
+ info_.AssuanPath = engine_info->file_name;
break;
case GPGME_PROTOCOL_G13:
break;
diff --git a/src/core/GpgInfo.h b/src/core/GpgInfo.h
index 71c5f9a9..d0453b9f 100644
--- a/src/core/GpgInfo.h
+++ b/src/core/GpgInfo.h
@@ -42,6 +42,7 @@ class GpgInfo {
std::string DatabasePath; ///<
std::string GnupgVersion; ///<
std::string GpgConfPath; ///<
+ std::string AssuanPath; ///<
std::string CMSPath; ///<
std::string GpgMEVersion; ///<
};
diff --git a/src/core/function/ArchiveFileOperator.cpp b/src/core/function/ArchiveFileOperator.cpp
index 17f29df1..64c7389e 100644
--- a/src/core/function/ArchiveFileOperator.cpp
+++ b/src/core/function/ArchiveFileOperator.cpp
@@ -151,7 +151,8 @@ void GpgFrontend::ArchiveFileOperator::CreateArchive(
#ifdef WINDOWS
auto entry_path =
- QString::fromStdWString(std::wstring(archive_entry_pathname_w(entry))).toUtf8()
+ QString::fromStdWString(std::wstring(archive_entry_pathname_w(entry)))
+ .toUtf8()
.toStdString();
#else
auto entry_path = std::string(archive_entry_pathname_utf8(entry));
@@ -161,7 +162,6 @@ void GpgFrontend::ArchiveFileOperator::CreateArchive(
<< archive_entry_size(entry) << " bytes"
<< "file type" << archive_entry_filetype(entry);
-
r = archive_write_header(a, entry);
if (r < ARCHIVE_OK) {
LOG(ERROR) << "archive_write_header() failed: "
@@ -231,11 +231,11 @@ void GpgFrontend::ArchiveFileOperator::ExtractArchive(
LOG(ERROR) << "cannot read from stdin";
}
#ifdef WINDOWS
- if (archive_read_open_filename_w(a, archive_path.wstring().c_str(),
- 10240) != ARCHIVE_OK) {
+ if (archive_read_open_filename_w(a, archive_path.wstring().c_str(), 10240) !=
+ ARCHIVE_OK) {
#else
- if (archive_read_open_filename(a, archive_path.u8string().c_str(),
- 10240) != ARCHIVE_OK) {
+ if (archive_read_open_filename(a, archive_path.u8string().c_str(), 10240) !=
+ ARCHIVE_OK) {
#endif
LOG(ERROR) << "archive_read_open_filename() failed: "
<< archive_error_string(a);
diff --git a/src/core/function/ArchiveFileOperator.h b/src/core/function/ArchiveFileOperator.h
index 28d1ad65..4db5af5f 100644
--- a/src/core/function/ArchiveFileOperator.h
+++ b/src/core/function/ArchiveFileOperator.h
@@ -46,15 +46,13 @@ class GPGFRONTEND_CORE_EXPORT ArchiveFileOperator {
public:
static void ListArchive(const std::filesystem::path &archive_path);
- static void CreateArchive(
- const std::filesystem::path &base_path,
- const std::filesystem::path &archive_path,
+ static void CreateArchive(const std::filesystem::path &base_path,
+ const std::filesystem::path &archive_path,
int compress,
const std::vector<std::filesystem::path> &files);
- static void ExtractArchive(
- const std::filesystem::path &archive_path,
- const std::filesystem::path &base_path);
+ static void ExtractArchive(const std::filesystem::path &archive_path,
+ const std::filesystem::path &base_path);
};
} // namespace GpgFrontend
diff --git a/src/core/function/DataObjectOperator.cpp b/src/core/function/DataObjectOperator.cpp
index d5b746d6..2744c448 100644
--- a/src/core/function/DataObjectOperator.cpp
+++ b/src/core/function/DataObjectOperator.cpp
@@ -29,6 +29,7 @@
#include "DataObjectOperator.h"
#include <qt-aes/qaesencryption.h>
+
#include <boost/date_time.hpp>
#include "core/function/FileOperator.h"
diff --git a/src/core/function/FileOperator.cpp b/src/core/function/FileOperator.cpp
index 4977b3a9..fcbdb91c 100644
--- a/src/core/function/FileOperator.cpp
+++ b/src/core/function/FileOperator.cpp
@@ -1,30 +1,30 @@
/**
-* 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 <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
-*
-*/
+ * 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 <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 "FileOperator.h"
@@ -56,9 +56,11 @@ bool GpgFrontend::FileOperator::ReadFileStd(
const std::filesystem::path& file_name, std::string& data) {
QByteArray byte_data;
#ifdef WINDOWS
- bool res = ReadFile(QString::fromStdU16String(file_name.u16string()).toUtf8(), byte_data);
+ bool res = ReadFile(QString::fromStdU16String(file_name.u16string()).toUtf8(),
+ byte_data);
#else
- bool res = ReadFile(QString::fromStdString(file_name.u8string()).toUtf8(), byte_data);
+ bool res = ReadFile(QString::fromStdString(file_name.u8string()).toUtf8(),
+ byte_data);
#endif
data = byte_data.toStdString();
return res;
@@ -66,7 +68,8 @@ bool GpgFrontend::FileOperator::ReadFileStd(
bool GpgFrontend::FileOperator::WriteFileStd(
const std::filesystem::path& file_name, const std::string& data) {
- return WriteFile(QString::fromStdString(file_name.u8string()).toUtf8(), QByteArray::fromStdString(data));
+ return WriteFile(QString::fromStdString(file_name.u8string()).toUtf8(),
+ QByteArray::fromStdString(data));
}
std::string GpgFrontend::FileOperator::CalculateHash(
@@ -80,12 +83,11 @@ std::string GpgFrontend::FileOperator::CalculateHash(
ss << " " << _("filename") << _(": ")
<< file_path.filename().u8string().c_str() << std::endl;
-
QFile f(info.filePath());
f.open(QFile::ReadOnly);
auto buffer = f.readAll();
- ss << " " << _("file size(bytes)") << _(": ")
- << buffer.size() << std::endl;
+ ss << " " << _("file size(bytes)") << _(": ") << buffer.size()
+ << std::endl;
f.close();
if (f.open(QFile::ReadOnly)) {
auto hash_md5 = QCryptographicHash(QCryptographicHash::Md5);
diff --git a/src/core/function/GlobalSettingStation.h b/src/core/function/GlobalSettingStation.h
index ccf8e8f0..58282466 100644
--- a/src/core/function/GlobalSettingStation.h
+++ b/src/core/function/GlobalSettingStation.h
@@ -142,8 +142,8 @@ class GPGFRONTEND_CORE_EXPORT GlobalSettingStation
void SyncSettings() noexcept;
private:
- std::filesystem::path app_path_ =
- QCoreApplication::applicationDirPath().toStdString(); ///< Program Location
+ std::filesystem::path app_path_ = QCoreApplication::applicationDirPath()
+ .toStdString(); ///< Program Location
std::filesystem::path app_data_path_ =
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
.toStdString(); ///< Program Data Location
diff --git a/src/core/function/KeyPackageOperator.cpp b/src/core/function/KeyPackageOperator.cpp
index 67fa3fac..3779c64b 100644
--- a/src/core/function/KeyPackageOperator.cpp
+++ b/src/core/function/KeyPackageOperator.cpp
@@ -72,7 +72,6 @@ bool KeyPackageOperator::ImportKeyPackage(
const std::filesystem::path& key_package_path,
const std::filesystem::path& phrase_path,
GpgFrontend::GpgImportInformation& import_info) {
-
LOG(INFO) << "Importing key package: " << key_package_path.u8string();
std::string encrypted_data;
@@ -101,7 +100,7 @@ bool KeyPackageOperator::ImportKeyPackage(
auto decoded = encryption.removePadding(encryption.decode(encoded, hash_key));
auto key_data = QByteArray::fromBase64(decoded);
- LOG(INFO) << "key data" << key_data.size();
+ LOG(INFO) << "key data" << key_data.size();
if (!key_data.startsWith(GpgConstants::PGP_PUBLIC_KEY_BEGIN) &&
!key_data.startsWith(GpgConstants::PGP_PRIVATE_KEY_BEGIN)) {
return false;
diff --git a/src/core/function/PassphraseGenerator.cpp b/src/core/function/PassphraseGenerator.cpp
index 0267edda..de963fa1 100644
--- a/src/core/function/PassphraseGenerator.cpp
+++ b/src/core/function/PassphraseGenerator.cpp
@@ -1,29 +1,29 @@
/**
-* 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 <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
-*
+ * 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 <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 "PassphraseGenerator.h"
diff --git a/src/core/function/aes/aes_ssl.h b/src/core/function/aes/aes_ssl.h
index b5f0820f..e75b68dd 100644
--- a/src/core/function/aes/aes_ssl.h
+++ b/src/core/function/aes/aes_ssl.h
@@ -29,11 +29,11 @@
#ifndef GPGFRONTEND_AES_SSL_H
#define GPGFRONTEND_AES_SSL_H
-#include "GpgFrontend.h"
-
#include <openssl/aes.h>
#include <openssl/evp.h>
+#include "GpgFrontend.h"
+
namespace GpgFrontend::RawAPI {
/**
@@ -69,6 +69,6 @@ uint8_t *aes_256_cbc_encrypt(EVP_CIPHER_CTX *e, uint8_t *plaintext, int *len);
*/
uint8_t *aes_256_cbc_decrypt(EVP_CIPHER_CTX *e, uint8_t *ciphertext, int *len);
-} // namespace GpgFrontend::RawAPI
+} // namespace GpgFrontend::RawAPI
-#endif // GPGFRONTEND_AES_SSL_H
+#endif // GPGFRONTEND_AES_SSL_H
diff --git a/src/core/function/aes/aes_ssl_cbc.cpp b/src/core/function/aes/aes_ssl_cbc.cpp
index 95ae0ce2..88a54baa 100644
--- a/src/core/function/aes/aes_ssl_cbc.cpp
+++ b/src/core/function/aes/aes_ssl_cbc.cpp
@@ -96,4 +96,4 @@ uint8_t *aes_256_cbc_decrypt(EVP_CIPHER_CTX *e, uint8_t *ciphertext, int *len) {
return plaintext;
}
-} // namespace GpgFrontend::RawAPI \ No newline at end of file
+} // namespace GpgFrontend::RawAPI \ No newline at end of file
diff --git a/src/core/function/gpg/GpgCommandExecutor.h b/src/core/function/gpg/GpgCommandExecutor.h
index 00d9b43d..40ee22df 100644
--- a/src/core/function/gpg/GpgCommandExecutor.h
+++ b/src/core/function/gpg/GpgCommandExecutor.h
@@ -42,7 +42,8 @@ namespace GpgFrontend {
* @brief Extra commands related to GPG
*
*/
-class GPGFRONTEND_CORE_EXPORT GpgCommandExecutor : public SingletonFunctionObject<GpgCommandExecutor> {
+class GPGFRONTEND_CORE_EXPORT GpgCommandExecutor
+ : public SingletonFunctionObject<GpgCommandExecutor> {
public:
/**
* @brief Construct a new Gpg Command Executor object
diff --git a/src/core/function/gpg/GpgFileOpera.h b/src/core/function/gpg/GpgFileOpera.h
index 3f223535..dc81bc53 100644
--- a/src/core/function/gpg/GpgFileOpera.h
+++ b/src/core/function/gpg/GpgFileOpera.h
@@ -43,7 +43,6 @@ namespace GpgFrontend {
class GPGFRONTEND_CORE_EXPORT GpgFileOpera
: public SingletonFunctionObject<GpgFileOpera> {
public:
-
explicit GpgFileOpera(
int channel = SingletonFunctionObject::GetDefaultChannel());
diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp
index e36edfd9..03d8c8d9 100644
--- a/src/core/function/gpg/GpgKeyOpera.cpp
+++ b/src/core/function/gpg/GpgKeyOpera.cpp
@@ -36,13 +36,12 @@
#include <string>
#include <vector>
-#include "core/GpgConstants.h"
-#include "core/GpgGenKeyInfo.h"
#include "GpgCommandExecutor.h"
#include "GpgKeyGetter.h"
+#include "core/GpgConstants.h"
+#include "core/GpgGenKeyInfo.h"
-GpgFrontend::GpgKeyOpera::GpgKeyOpera(
- int channel)
+GpgFrontend::GpgKeyOpera::GpgKeyOpera(int channel)
: SingletonFunctionObject<GpgKeyOpera>(channel) {}
/**
diff --git a/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp b/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp
index ff3d2e27..d3ec8d6e 100644
--- a/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp
@@ -30,8 +30,8 @@
#include "function/gpg/GpgKeyGetter.h"
-GpgFrontend::GpgDecryptResultAnalyse::GpgDecryptResultAnalyse(GpgError m_error,
- GpgDecrResult m_result)
+GpgFrontend::GpgDecryptResultAnalyse::GpgDecryptResultAnalyse(
+ GpgError m_error, GpgDecrResult m_result)
: error_(m_error), result_(std::move(m_result)) {}
void GpgFrontend::GpgDecryptResultAnalyse::do_analyse() {
diff --git a/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp b/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp
index 053a15a5..9b3b9700 100644
--- a/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp
@@ -28,8 +28,8 @@
#include "GpgEncryptResultAnalyse.h"
-GpgFrontend::GpgEncryptResultAnalyse::GpgEncryptResultAnalyse(GpgError error,
- GpgEncrResult result)
+GpgFrontend::GpgEncryptResultAnalyse::GpgEncryptResultAnalyse(
+ GpgError error, GpgEncrResult result)
: error_(error), result_(std::move(result)) {}
void GpgFrontend::GpgEncryptResultAnalyse::do_analyse() {
diff --git a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp
index e389523c..a47b8e3e 100644
--- a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp
@@ -31,7 +31,7 @@
#include "function/gpg/GpgKeyGetter.h"
GpgFrontend::GpgSignResultAnalyse::GpgSignResultAnalyse(GpgError error,
- GpgSignResult result)
+ GpgSignResult result)
: error_(error), result_(std::move(result)) {}
void GpgFrontend::GpgSignResultAnalyse::do_analyse() {
diff --git a/src/core/model/GpgKey.cpp b/src/core/model/GpgKey.cpp
index 4b9d11d3..ad88a649 100644
--- a/src/core/model/GpgKey.cpp
+++ b/src/core/model/GpgKey.cpp
@@ -45,9 +45,7 @@ bool GpgFrontend::GpgKey::operator<=(const GpgKey &o) const {
return this->GetId() < o.GetId();
}
-GpgFrontend::GpgKey::operator gpgme_key_t() const {
- return key_ref_.get();
-}
+GpgFrontend::GpgKey::operator gpgme_key_t() const { return key_ref_.get(); }
bool GpgFrontend::GpgKey::IsGood() const { return key_ref_ != nullptr; }
@@ -226,10 +224,9 @@ bool GpgFrontend::GpgKey::IsHasActualEncryptionCapability() const {
return false;
}
-
GpgFrontend::GpgKey GpgFrontend::GpgKey::Copy() const {
gpgme_key_ref(key_ref_.get());
- auto* _new_key_ref = key_ref_.get();
+ auto *_new_key_ref = key_ref_.get();
return GpgKey(std::move(_new_key_ref));
}
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 6e3ee4be..24158e27 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -26,16 +26,16 @@
# tracking source files
aux_source_directory(. UI_SOURCE)
-aux_source_directory(keypair_details UI_SOURCE)
+aux_source_directory(dialog/keypair_details UI_SOURCE)
aux_source_directory(widgets UI_SOURCE)
-aux_source_directory(key_generate UI_SOURCE)
+aux_source_directory(dialog/key_generate UI_SOURCE)
aux_source_directory(main_window UI_SOURCE)
-aux_source_directory(help UI_SOURCE)
-aux_source_directory(settings UI_SOURCE)
+aux_source_directory(dialog/help UI_SOURCE)
+aux_source_directory(dialog/settings UI_SOURCE)
aux_source_directory(thread UI_SOURCE)
-aux_source_directory(details UI_SOURCE)
+aux_source_directory(dialog/details UI_SOURCE)
aux_source_directory(struct UI_SOURCE)
-aux_source_directory(import_export UI_SOURCE)
+aux_source_directory(dialog/import_export UI_SOURCE)
aux_source_directory(dialog UI_SOURCE)
# define libgpgfrontend_ui
diff --git a/src/ui/GpgFrontendApplication.cpp b/src/ui/GpgFrontendApplication.cpp
index 4cb50b43..b1c5beed 100644
--- a/src/ui/GpgFrontendApplication.cpp
+++ b/src/ui/GpgFrontendApplication.cpp
@@ -30,7 +30,7 @@
namespace GpgFrontend::UI {
-GpgFrontendApplication::GpgFrontendApplication(int &argc, char **argv)
+GpgFrontendApplication::GpgFrontendApplication(int &argc, char *argv[])
: QApplication(argc, argv) {
#ifndef MACOS
this->setWindowIcon(QIcon(":gpgfrontend.png"));
@@ -57,12 +57,15 @@ GpgFrontendApplication *GpgFrontendApplication::GetInstance(int argc,
char *argv[],
bool new_instance) {
static GpgFrontendApplication *instance = nullptr;
+ static int static_argc = argc;
+ static char **static_argv = argv;
+
if (new_instance || !instance) {
if (instance != nullptr) {
instance->quit();
delete instance;
}
- instance = new GpgFrontendApplication(argc, argv);
+ instance = new GpgFrontendApplication(static_argc, static_argv);
}
return instance;
}
diff --git a/src/ui/GpgFrontendApplication.h b/src/ui/GpgFrontendApplication.h
index 52a0a610..06338bb6 100644
--- a/src/ui/GpgFrontendApplication.h
+++ b/src/ui/GpgFrontendApplication.h
@@ -40,7 +40,7 @@ class GPGFRONTEND_UI_EXPORT GpgFrontendApplication : public QApplication {
* @param argc
* @param argv
*/
- explicit GpgFrontendApplication(int &argc, char **argv);
+ explicit GpgFrontendApplication(int &argc, char *argv[]);
/**
* @brief Destroy the GpgFrontend Application object
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp
index 022f0748..5cbca31b 100644
--- a/src/ui/GpgFrontendUIInit.cpp
+++ b/src/ui/GpgFrontendUIInit.cpp
@@ -103,8 +103,8 @@ void InitGpgFrontendUI(QApplication* app) {
// show the loading window
waiting_dialog->setModal(true);
- waiting_dialog->show();
waiting_dialog->setFocus();
+ waiting_dialog->show();
// new local event looper
QEventLoop looper;
diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp
index adcbd6ff..586d72ab 100644
--- a/src/ui/UserInterfaceUtils.cpp
+++ b/src/ui/UserInterfaceUtils.cpp
@@ -276,6 +276,9 @@ void CommonUtils::SlotImportKeyFromKeyServer(
const int target_key_server_index =
key_server_json.Check("default_server", 0);
+ if (target_key_server_index >= key_server_list.size()) {
+ throw std::runtime_error("default_server index out of range");
+ }
target_keyserver =
key_server_list[target_key_server_index].get<std::string>();
diff --git a/src/ui/UserInterfaceUtils.h b/src/ui/UserInterfaceUtils.h
index bfd8a3ae..bcfa28d2 100644
--- a/src/ui/UserInterfaceUtils.h
+++ b/src/ui/UserInterfaceUtils.h
@@ -110,6 +110,16 @@ void process_operation(
/**
* @brief
*
+ * @param parent
+ * @param key_id
+ * @param key_server
+ */
+void import_key_from_keyserver(QWidget* parent, const std::string& key_id,
+ const std::string& key_server);
+
+/**
+ * @brief
+ *
*/
class CommonUtils : public QWidget {
Q_OBJECT
diff --git a/src/ui/dialog/GeneralDialog.cpp b/src/ui/dialog/GeneralDialog.cpp
new file mode 100644
index 00000000..d07c2497
--- /dev/null
+++ b/src/ui/dialog/GeneralDialog.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2022. 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 <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 "GeneralDialog.h"
+
+#include "ui/struct/SettingsObject.h"
+
+GpgFrontend::UI::GeneralDialog::GeneralDialog(std::string name, QWidget *parent)
+ : name_(std::move(name)), QDialog(parent) {
+ slot_restore_settings();
+ connect(this, &QDialog::finished, this, &GeneralDialog::slot_save_settings);
+}
+
+GpgFrontend::UI::GeneralDialog::~GeneralDialog() = default;
+
+void GpgFrontend::UI::GeneralDialog::slot_restore_settings() noexcept {
+ try {
+ LOG(INFO) << name_ << _("Called");
+
+ SettingsObject general_windows_state(name_ + "_dialog_state");
+
+ bool window_save = general_windows_state.Check("window_save", true);
+
+ // Restore window size & location
+ if (window_save) {
+ int x = general_windows_state.Check("window_pos").Check("x", 100),
+ y = general_windows_state.Check("window_pos").Check("y", 100);
+
+ this->move({x, y});
+ pos_ = {x, y};
+
+ int width =
+ general_windows_state.Check("window_size").Check("width", 400),
+ height =
+ general_windows_state.Check("window_size").Check("height", 247);
+
+ this->resize({width, height});
+ size_ = {width, height};
+
+ }
+
+ } catch (...) {
+ LOG(ERROR) << name_ << "error";
+ }
+}
+
+void GpgFrontend::UI::GeneralDialog::slot_save_settings() noexcept {
+ try {
+ LOG(INFO) << name_ << _("Called");
+
+ SettingsObject general_windows_state(name_ + "_dialog_state");
+
+ // window position and size
+ general_windows_state["window_pos"]["x"] = pos().x();
+ general_windows_state["window_pos"]["y"] = pos().y();
+
+ general_windows_state["window_size"]["width"] = size_.width();
+ general_windows_state["window_size"]["height"] = size_.height();
+ general_windows_state["window_save"] = true;
+
+ } catch (...) {
+ LOG(ERROR) << name_ << "error";
+ }
+}
diff --git a/src/ui/dialog/GeneralDialog.h b/src/ui/dialog/GeneralDialog.h
new file mode 100644
index 00000000..ca480c8b
--- /dev/null
+++ b/src/ui/dialog/GeneralDialog.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2022. 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 <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
+ */
+
+#ifndef GPGFRONTEND_GENERALDIALOG_H
+#define GPGFRONTEND_GENERALDIALOG_H
+
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+class GeneralDialog : public QDialog {
+ public:
+ /**
+ *
+ * @param name
+ */
+ explicit GeneralDialog(std::string name, QWidget* parent = nullptr);
+
+ /**
+ *
+ */
+ ~GeneralDialog() override;
+
+ private slots:
+ /**
+ *
+ */
+ void slot_restore_settings() noexcept;
+
+ /**
+ *
+ */
+ void slot_save_settings() noexcept;
+
+ private:
+ std::string name_; ///<
+ QPoint pos_; ///<
+ QSize size_; ///<
+};
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_GENERALDIALOG_H
diff --git a/src/ui/dialog/QuitDialog.cpp b/src/ui/dialog/QuitDialog.cpp
index da0be488..87b1c1e1 100755
--- a/src/ui/dialog/QuitDialog.cpp
+++ b/src/ui/dialog/QuitDialog.cpp
@@ -33,7 +33,7 @@
namespace GpgFrontend::UI {
QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs)
- : QDialog(parent) {
+ : GeneralDialog("quit_dialog", parent) {
setWindowTitle(_("Unsaved Files"));
setModal(true);
discarded_ = false;
@@ -111,7 +111,7 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs)
connect(buttonBox, &QDialogButtonBox::accepted, this, &QuitDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QuitDialog::reject);
QPushButton* btnNoKey = buttonBox->button(QDialogButtonBox::Discard);
- connect(btnNoKey, &QPushButton::clicked, this,&QuitDialog::slot_my_discard);
+ connect(btnNoKey, &QPushButton::clicked, this, &QuitDialog::slot_my_discard);
/*
* Set the layout
diff --git a/src/ui/dialog/QuitDialog.h b/src/ui/dialog/QuitDialog.h
index 2d09790b..2fd9e382 100755
--- a/src/ui/dialog/QuitDialog.h
+++ b/src/ui/dialog/QuitDialog.h
@@ -30,6 +30,7 @@
#define __QUITDIALOG_H__
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -37,7 +38,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class QuitDialog : public QDialog {
+class QuitDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/widgets/SignersPicker.cpp b/src/ui/dialog/SignersPicker.cpp
index 75f6b2ba..a670e514 100644
--- a/src/ui/widgets/SignersPicker.cpp
+++ b/src/ui/dialog/SignersPicker.cpp
@@ -1,7 +1,7 @@
-/**
- * Copyright (C) 2021 Saturneric
+/*
+ * Copyright (c) 2022. Saturneric
*
- * This file is part of GpgFrontend.
+ * 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
@@ -23,18 +23,24 @@
* Saturneric<[email protected]> starting on May 12, 2021.
*
* SPDX-License-Identifier: GPL-3.0-or-later
- *
*/
-#include "ui/widgets/SignersPicker.h"
+#include "SignersPicker.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
-SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) {
+SignersPicker::SignersPicker(QWidget* parent)
+ : GeneralDialog(typeid(SignersPicker).name(), parent) {
auto confirm_button = new QPushButton(_("Confirm"));
- connect(confirm_button, &QPushButton::clicked, this, &SignersPicker::accept);
+ auto cancel_button = new QPushButton(_("Cancel"));
+
+ connect(confirm_button, &QPushButton::clicked, [=]() {
+ this->accepted_ = true;
+ });
+ connect(confirm_button, &QPushButton::clicked, this, &QDialog::accept);
+ connect(cancel_button, &QPushButton::clicked, this, &QDialog::reject);
/*Setup KeyList*/
key_list_ = new KeyList(false, this);
@@ -55,6 +61,7 @@ SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) {
"\n" +
_("If no key is selected, the default key will be used for signing.")));
vbox2->addWidget(confirm_button);
+ vbox2->addWidget(cancel_button);
vbox2->addStretch(0);
setLayout(vbox2);
@@ -71,4 +78,6 @@ GpgFrontend::KeyIdArgsListPtr SignersPicker::GetCheckedSigners() {
return key_list_->GetPrivateChecked();
}
+bool SignersPicker::GetStatus() const { return this->accepted_; }
+
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/SignersPicker.h b/src/ui/dialog/SignersPicker.h
index 30f872f8..5533f9d8 100644
--- a/src/ui/widgets/SignersPicker.h
+++ b/src/ui/dialog/SignersPicker.h
@@ -1,7 +1,7 @@
-/**
- * Copyright (C) 2021 Saturneric
+/*
+ * Copyright (c) 2022. Saturneric
*
- * This file is part of GpgFrontend.
+ * 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
@@ -23,13 +23,13 @@
* Saturneric<[email protected]> starting on May 12, 2021.
*
* SPDX-License-Identifier: GPL-3.0-or-later
- *
*/
#ifndef GPGFRONTEND_ZH_CN_TS_SIGNERSPIRCKER_H
#define GPGFRONTEND_ZH_CN_TS_SIGNERSPIRCKER_H
#include "GpgFrontendUI.h"
+#include "ui/dialog//GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -39,7 +39,7 @@ class KeyList;
* @brief
*
*/
-class SignersPicker : public QDialog {
+class SignersPicker : public GeneralDialog {
Q_OBJECT
public:
@@ -57,8 +57,15 @@ class SignersPicker : public QDialog {
*/
GpgFrontend::KeyIdArgsListPtr GetCheckedSigners();
+ /**
+ *
+ * @return
+ */
+ [[nodiscard]] bool GetStatus() const;
+
private:
KeyList* key_list_; ///<
+ bool accepted_ = false;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/dialog/Wizard.h b/src/ui/dialog/Wizard.h
index eb093550..879dc5d9 100644
--- a/src/ui/dialog/Wizard.h
+++ b/src/ui/dialog/Wizard.h
@@ -30,10 +30,10 @@
#define WIZARD_H
#include "core/GpgConstants.h"
+#include "main_window/KeyMgmt.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/KeyMgmt.h"
-#include "ui/key_generate/KeygenDialog.h"
-#include "ui/settings/SettingsDialog.h"
+#include "ui/dialog/key_generate/KeygenDialog.h"
+#include "ui/dialog/settings/SettingsDialog.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/details/SignatureDetailsDialog.cpp b/src/ui/dialog/details/SignatureDetailsDialog.cpp
index a3ad03b3..a3ad03b3 100644
--- a/src/ui/details/SignatureDetailsDialog.cpp
+++ b/src/ui/dialog/details/SignatureDetailsDialog.cpp
diff --git a/src/ui/details/SignatureDetailsDialog.h b/src/ui/dialog/details/SignatureDetailsDialog.h
index 847b320b..7b01d054 100644
--- a/src/ui/details/SignatureDetailsDialog.h
+++ b/src/ui/dialog/details/SignatureDetailsDialog.h
@@ -28,6 +28,7 @@
#ifndef GPGFRONTEND_SIGNATUREDETAILSDIALOG_H
#define GPGFRONTEND_SIGNATUREDETAILSDIALOG_H
+
#include "ui/GpgFrontendUI.h"
class SignatureDetailsDialog : public QDialog {
diff --git a/src/ui/details/VerifyDetailsDialog.cpp b/src/ui/dialog/details/VerifyDetailsDialog.cpp
index d2af4ee1..d2af4ee1 100644
--- a/src/ui/details/VerifyDetailsDialog.cpp
+++ b/src/ui/dialog/details/VerifyDetailsDialog.cpp
diff --git a/src/ui/details/VerifyDetailsDialog.h b/src/ui/dialog/details/VerifyDetailsDialog.h
index 97e2cc2d..97e2cc2d 100644
--- a/src/ui/details/VerifyDetailsDialog.h
+++ b/src/ui/dialog/details/VerifyDetailsDialog.h
diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp
index e8fbeb1b..6b6e4356 100644
--- a/src/ui/help/AboutDialog.cpp
+++ b/src/ui/dialog/help/AboutDialog.cpp
@@ -26,39 +26,43 @@
*
*/
-#include "ui/help/AboutDialog.h"
+#include "AboutDialog.h"
#include "GpgFrontendBuildInfo.h"
#include "core/function/GlobalSettingStation.h"
#include "core/thread/TaskRunnerGetter.h"
+#include "ui/dialog/help/GnupgTab.h"
#include "ui/thread/VersionCheckTask.h"
namespace GpgFrontend::UI {
-AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) : QDialog(parent) {
+AboutDialog::AboutDialog(int defaultIndex, QWidget* parent)
+ : GeneralDialog(typeid(AboutDialog).name(), parent) {
this->setWindowTitle(QString(_("About")) + " " + qApp->applicationName());
- auto* tabWidget = new QTabWidget;
- auto* infoTab = new InfoTab();
- auto* translatorsTab = new TranslatorsTab();
+ auto* tab_widget = new QTabWidget;
+ auto* info_tab = new InfoTab();
+ auto* gnupg_tab = new GnupgTab();
+ auto* translators_tab = new TranslatorsTab();
update_tab_ = new UpdateTab();
- tabWidget->addTab(infoTab, _("About Software"));
- tabWidget->addTab(translatorsTab, _("Translators"));
- tabWidget->addTab(update_tab_, _("Update"));
+ tab_widget->addTab(info_tab, _("About GpgFrontend"));
+ tab_widget->addTab(gnupg_tab, _("GnuPG"));
+ tab_widget->addTab(translators_tab, _("Translators"));
+ tab_widget->addTab(update_tab_, _("Update"));
- connect(tabWidget, &QTabWidget::currentChanged, this,
+ connect(tab_widget, &QTabWidget::currentChanged, this,
[&](int index) { LOG(INFO) << "Current Index" << index; });
- if (defaultIndex < tabWidget->count() && defaultIndex >= 0) {
- tabWidget->setCurrentIndex(defaultIndex);
+ if (defaultIndex < tab_widget->count() && defaultIndex >= 0) {
+ tab_widget->setCurrentIndex(defaultIndex);
}
auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(buttonBox, &QDialogButtonBox::accepted, this, &AboutDialog::close);
auto* mainLayout = new QVBoxLayout;
- mainLayout->addWidget(tabWidget);
+ mainLayout->addWidget(tab_widget);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
diff --git a/src/ui/help/AboutDialog.h b/src/ui/dialog/help/AboutDialog.h
index 40d93f3e..09a63734 100644
--- a/src/ui/help/AboutDialog.h
+++ b/src/ui/dialog/help/AboutDialog.h
@@ -31,6 +31,7 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/struct/SoftwareVersion.h"
namespace GpgFrontend::UI {
@@ -116,7 +117,7 @@ class UpdateTab : public QWidget {
* @brief Class for handling the about dialog
*
*/
-class AboutDialog : public QDialog {
+class AboutDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/dialog/help/GnupgTab.cpp b/src/ui/dialog/help/GnupgTab.cpp
new file mode 100644
index 00000000..48787987
--- /dev/null
+++ b/src/ui/dialog/help/GnupgTab.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2022. 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 <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
+ */
+
+//
+// Created by eric on 2022/7/23.
+//
+
+#include "GnupgTab.h"
+
+GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent) : QWidget(parent) {
+ GpgContext& ctx = GpgContext::GetInstance();
+ auto info = ctx.GetInfo();
+
+ auto* pixmap = new QPixmap(":gnupg.png");
+ auto* text = new QString(
+ "<center><h2>" + QString(_("GnuPG")) + "</h2></center>" + "<center><b>" +
+ QString(_("GnuPG Version")) + ": " +
+ QString::fromStdString(info.GnupgVersion) + "</b></center>" +
+ "<center><b>" + +"</b></center>" + "<center>" +
+ QString(_("GpgME Version")) + ": " +
+ QString::fromStdString(info.GpgMEVersion) + "</center><br /><hr />" +
+ "<h3>" + QString(_("PATHs")) + "</h3>" + QString(_("GpgConf")) + ": " +
+ QString::fromStdString(info.GpgConfPath) + "<br />" +
+ QString(_("GnuPG")) + ": " + QString::fromStdString(info.AppPath) +
+ "<br />" + QString(_("CMS")) + ": " +
+ QString::fromStdString(info.CMSPath) + "<br />");
+
+ auto* layout = new QGridLayout();
+ auto* pixmapLabel = new QLabel();
+ pixmapLabel->setPixmap(*pixmap);
+ layout->addWidget(pixmapLabel, 0, 0, 1, -1, Qt::AlignCenter);
+ auto* aboutLabel = new QLabel();
+ aboutLabel->setText(*text);
+ aboutLabel->setWordWrap(true);
+ aboutLabel->setOpenExternalLinks(true);
+ layout->addWidget(aboutLabel, 1, 0, 1, -1);
+ layout->addItem(
+ new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Fixed), 2, 1,
+ 1, 1);
+
+ setLayout(layout);
+}
diff --git a/src/ui/dialog/help/GnupgTab.h b/src/ui/dialog/help/GnupgTab.h
new file mode 100644
index 00000000..4fc7ff22
--- /dev/null
+++ b/src/ui/dialog/help/GnupgTab.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2022. 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 <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
+ */
+
+//
+// Created by eric on 2022/7/23.
+//
+
+#ifndef GPGFRONTEND_GNUPGTAB_H
+#define GPGFRONTEND_GNUPGTAB_H
+
+#include "core/GpgContext.h"
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI{
+class GnupgTab: public QWidget {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Info Tab object
+ *
+ * @param parent
+ */
+ explicit GnupgTab(QWidget* parent = nullptr);
+};
+}
+
+
+
+#endif // GPGFRONTEND_GNUPGTAB_H
diff --git a/src/ui/import_export/ExportKeyPackageDialog.cpp b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
index d6f303f6..312cd946 100644
--- a/src/ui/import_export/ExportKeyPackageDialog.cpp
+++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
@@ -30,13 +30,13 @@
#include <boost/format.hpp>
-#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/KeyPackageOperator.h"
+#include "core/function/gpg/GpgKeyGetter.h"
#include "ui_ExportKeyPackageDialog.h"
GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
KeyIdArgsListPtr key_ids, QWidget* parent)
- : QDialog(parent),
+ : GeneralDialog(typeid(ExportKeyPackageDialog).name(), parent),
ui_(std::make_shared<Ui_exportKeyPackageDialog>()),
key_ids_(std::move(key_ids)) {
ui_->setupUi(this);
@@ -141,5 +141,5 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
_("Exclude keys that do not have a private key"));
setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(_("exportKeyPackageDialog"));
+ setWindowTitle(_("Export As Key Package"));
}
diff --git a/src/ui/import_export/ExportKeyPackageDialog.h b/src/ui/dialog/import_export/ExportKeyPackageDialog.h
index ecf13b1d..c5f9a2b1 100644
--- a/src/ui/import_export/ExportKeyPackageDialog.h
+++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.h
@@ -30,6 +30,7 @@
#define GPGFRONTEND_EXPORTKEYPACKAGEDIALOG_H
#include "GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
class Ui_exportKeyPackageDialog;
@@ -39,7 +40,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class ExportKeyPackageDialog : public QDialog {
+class ExportKeyPackageDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/import_export/KeyImportDetailDialog.cpp b/src/ui/dialog/import_export/KeyImportDetailDialog.cpp
index 766d2d81..31183a34 100644
--- a/src/ui/import_export/KeyImportDetailDialog.cpp
+++ b/src/ui/dialog/import_export/KeyImportDetailDialog.cpp
@@ -33,7 +33,8 @@
namespace GpgFrontend::UI {
KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result,
bool automatic, QWidget* parent)
- : QDialog(parent), m_result_(std::move(result)) {
+ : GeneralDialog(typeid(KeyImportDetailDialog).name(), parent),
+ m_result_(std::move(result)) {
// If no key for import found, just show a message
if (m_result_.considered == 0) {
if (automatic)
@@ -197,6 +198,7 @@ QString KeyImportDetailDialog::get_status_string(int keyStatus) {
void KeyImportDetailDialog::create_button_box() {
button_box_ = new QDialogButtonBox(QDialogButtonBox::Ok);
- connect(button_box_, &QDialogButtonBox::accepted, this, &KeyImportDetailDialog::close);
+ connect(button_box_, &QDialogButtonBox::accepted, this,
+ &KeyImportDetailDialog::close);
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/import_export/KeyImportDetailDialog.h b/src/ui/dialog/import_export/KeyImportDetailDialog.h
index a648f205..06f44e94 100644
--- a/src/ui/import_export/KeyImportDetailDialog.h
+++ b/src/ui/dialog/import_export/KeyImportDetailDialog.h
@@ -32,6 +32,7 @@
#include "core/GpgContext.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -39,7 +40,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyImportDetailDialog : public QDialog {
+class KeyImportDetailDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/import_export/KeyServerImportDialog.cpp b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
index e359238c..6430a22e 100644
--- a/src/ui/import_export/KeyServerImportDialog.cpp
+++ b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
@@ -28,17 +28,21 @@
#include "KeyServerImportDialog.h"
+#include <string>
#include <utility>
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
+#include "thread/KeyServerImportTask.h"
#include "ui/SignalStation.h"
#include "ui/struct/SettingsObject.h"
+#include "ui/thread/KeyServerSearchTask.h"
namespace GpgFrontend::UI {
KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
- : QDialog(parent), m_automatic_(automatic) {
+ : GeneralDialog("key_server_import_dialog", parent),
+ m_automatic_(automatic) {
// Layout for messagebox
auto* message_layout = new QHBoxLayout();
@@ -115,36 +119,6 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
if (automatic) {
this->setFixedSize(240, 42);
- } else {
- auto pos = QPoint(150, 150);
- LOG(INFO) << "parent" << parent;
- if (parent) pos += parent->pos();
- LOG(INFO) << "pos default" << pos.x() << pos.y();
- auto size = QSize(800, 500);
-
- try {
- SettingsObject key_server_import_state("key_server_import_state");
- bool window_save = key_server_import_state.Check("window_save", true);
-
- // Restore window size & location
- if (window_save) {
- int x = key_server_import_state.Check("window_pos").Check("x", pos.x()),
- y = key_server_import_state.Check("window_pos").Check("y", pos.y());
-
- pos = QPoint(x, y);
- int width = key_server_import_state.Check("window_size")
- .Check("width", size.width()),
- height = key_server_import_state.Check("window_size")
- .Check("height", size.height());
-
- size = QSize(width, height);
- }
- } catch (...) {
- LOG(WARNING) << "cannot read pos or size from settings object";
- }
-
- this->resize(size);
- this->move(pos);
}
this->setModal(true);
@@ -152,10 +126,31 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
connect(this, &KeyServerImportDialog::SignalKeyImported,
SignalStation::GetInstance(),
&SignalStation::SignalKeyDatabaseRefresh);
+}
+
+KeyServerImportDialog::KeyServerImportDialog(QWidget* parent)
+ : GeneralDialog("key_server_import_dialog", parent), m_automatic_(true) {
+ setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
+
+ // Network Waiting
+ 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(waiting_bar_);
- // save window pos and size to configure file
- connect(this, &KeyServerImportDialog::finished, this,
- &KeyServerImportDialog::slot_save_window_state);
+ key_server_combo_box_ = create_comboBox();
+
+ this->setLayout(layout);
+ this->setWindowTitle(_("Update Keys from Keyserver"));
+ this->setFixedSize(240, 42);
+ this->setModal(true);
}
QComboBox* KeyServerImportDialog::create_comboBox() {
@@ -174,6 +169,9 @@ QComboBox* KeyServerImportDialog::create_comboBox() {
}
int default_key_server_index = key_server_json.Check("default_server", 0);
+ if (default_key_server_index >= key_server_list.size()) {
+ throw std::runtime_error("default_server index out of range");
+ }
std::string default_key_server =
key_server_list[default_key_server_index].get<std::string>();
@@ -227,45 +225,44 @@ void KeyServerImportDialog::slot_search() {
return;
}
- QUrl url_from_remote = key_server_combo_box_->currentText() +
- "/pks/lookup?search=" + search_line_edit_->text() +
- "&op=index&options=mr";
- network_access_manager_ = new QNetworkAccessManager(this);
- QNetworkReply* reply =
- network_access_manager_->get(QNetworkRequest(url_from_remote));
+ auto* task = new KeyServerSearchTask(
+ key_server_combo_box_->currentText().toStdString(),
+ search_line_edit_->text().toStdString());
- connect(reply, &QNetworkReply::finished, this,
+ connect(task, &KeyServerSearchTask::SignalKeyServerSearchResult, this,
&KeyServerImportDialog::slot_search_finished);
+ connect(task, &KeyServerSearchTask::SignalKeyServerSearchResult, this, [=]() {
+ 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);
+ });
+
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->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);
+ Thread::TaskRunnerGetter::GetInstance()
+ .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network)
+ ->PostTask(task);
}
-void KeyServerImportDialog::slot_search_finished() {
- LOG(INFO) << "Called";
-
- auto* reply = qobject_cast<QNetworkReply*>(sender());
+void KeyServerImportDialog::slot_search_finished(
+ QNetworkReply::NetworkError error, QByteArray buffer) {
+ LOG(INFO) << "Called" << error << buffer.size();
+ LOG(INFO) << buffer.toStdString();
keys_table_->clearContents();
keys_table_->setRowCount(0);
- QString first_line = QString(reply->readLine(1024));
- auto error = reply->error();
+ auto stream = QTextStream(buffer);
+
if (error != QNetworkReply::NoError) {
- LOG(INFO) << "Error From Reply" << reply->errorString().toStdString();
+ LOG(INFO) << "Error From Reply" << error;
switch (error) {
case QNetworkReply::ContentNotFoundError:
@@ -283,8 +280,9 @@ void KeyServerImportDialog::slot_search_finished() {
return;
}
- if (first_line.contains("Error")) {
- QString text = QString(reply->readLine(1024));
+ if (stream.readLine().contains("Error")) {
+ auto text = stream.readLine(1024);
+
if (text.contains("Too many responses")) {
set_message(
"<h4>" + QString(_("Too many responses from keyserver!")) + "</h4>",
@@ -324,11 +322,14 @@ void KeyServerImportDialog::slot_search_finished() {
} else {
int row = 0;
bool strikeout = false;
- while (reply->canReadLine()) {
- auto line_buff = reply->readLine().trimmed();
- QString decoded =
- QString::fromUtf8(line_buff.constData(), line_buff.size());
- QStringList line = decoded.split(":");
+
+ // read lines until end of steam
+ while (!stream.atEnd()) {
+ QStringList line =
+ QString::fromUtf8(QByteArray::fromPercentEncoding(
+ stream.readLine().trimmed().toUtf8()))
+ .split(":");
+
// TODO: have a look at two following pub lines
if (line[0] == "pub") {
strikeout = false;
@@ -354,7 +355,9 @@ void KeyServerImportDialog::slot_search_finished() {
}
}
- QStringList line2 = QString(reply->readLine()).split(":");
+ QStringList line2 = QString(QByteArray::fromPercentEncoding(
+ stream.readLine().trimmed().toUtf8()))
+ .split(":");
auto* uid = new QTableWidgetItem();
if (line2.size() > 1) {
@@ -400,32 +403,45 @@ void KeyServerImportDialog::slot_search_finished() {
keys_table_->resizeColumnsToContents();
import_button_->setDisabled(keys_table_->size().isEmpty());
}
- reply->deleteLater();
}
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());
+ std::vector<std::string> key_ids;
+ const int row_count = keys_table_->rowCount();
+ for (int i = 0; i < row_count; ++i) {
+ if (keys_table_->item(i, 2)->isSelected()) {
+ QString keyid = keys_table_->item(i, 2)->text();
+ key_ids.push_back(keyid.toStdString());
+ }
}
+ if (!key_ids.empty())
+ SlotImport(key_ids, key_server_combo_box_->currentText().toStdString());
}
void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) {
+ // keyserver host url
std::string target_keyserver;
+
if (key_server_combo_box_ != nullptr) {
target_keyserver = key_server_combo_box_->currentText().toStdString();
}
if (target_keyserver.empty()) {
try {
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ SettingsObject key_server_json("key_server");
+ const auto key_server_list =
+ key_server_json.Check("server_list", nlohmann::json::array());
- target_keyserver = settings.lookup("keyserver.default_server").c_str();
+ int default_key_server_index = key_server_json.Check("default_server", 0);
+ if (default_key_server_index >= key_server_list.size()) {
+ throw std::runtime_error("default_server index out of range");
+ }
+ std::string default_key_server =
+ key_server_list[default_key_server_index].get<std::string>();
- LOG(INFO) << _("Set target Key Server to default Key Server")
- << target_keyserver;
+ target_keyserver = default_key_server;
} catch (...) {
- LOG(ERROR) << _("Cannot read default_keyserver From Settings");
+ LOG(ERROR) << _("Setting Operation Error") << "server_list"
+ << "default_server";
QMessageBox::critical(
nullptr, _("Default Keyserver Not Found"),
_("Cannot read default keyserver from your settings, "
@@ -433,42 +449,31 @@ void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) {
return;
}
}
- 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()));
-}
-
-void KeyServerImportDialog::SlotImport(const QStringList& keyIds,
- const QUrl& keyserverUrl) {
- for (const auto& keyId : keyIds) {
- QUrl req_url(keyserverUrl.scheme() + "://" + keyserverUrl.host() +
- "/pks/lookup?op=get&search=0x" + keyId + "&options=mr");
-
- LOG(INFO) << "request url" << req_url.toString().toStdString();
- auto manager = new QNetworkAccessManager(this);
-
- QNetworkReply* reply = manager->get(QNetworkRequest(req_url));
- connect(reply, &QNetworkReply::finished, this,
- [&, keyId]() { this->slot_import_finished(keyId); });
- LOG(INFO) << "loading start";
- set_loading(true);
- while (reply->isRunning()) QApplication::processEvents();
- set_loading(false);
- LOG(INFO) << "loading done";
+ std::vector<std::string> key_ids;
+ for (const auto& key_id : *keys) {
+ key_ids.push_back(key_id);
}
+ SlotImport(key_ids, target_keyserver);
}
-void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
- LOG(INFO) << _("Called");
+void KeyServerImportDialog::SlotImport(std::vector<std::string> key_ids,
+ std::string keyserver_url) {
+ auto* task = new KeyServerImportTask(keyserver_url, key_ids);
- auto* reply = qobject_cast<QNetworkReply*>(sender());
+ connect(task, &KeyServerImportTask::SignalKeyServerImportResult, this,
+ &KeyServerImportDialog::slot_import_finished);
- QByteArray key = reply->readAll();
+ Thread::TaskRunnerGetter::GetInstance()
+ .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network)
+ ->PostTask(task);
+}
+
+void KeyServerImportDialog::slot_import_finished(
+ QNetworkReply::NetworkError error, QByteArray buffer) {
+ LOG(INFO) << _("Called");
- auto error = reply->error();
if (error != QNetworkReply::NoError) {
- LOG(ERROR) << "Error From Reply" << reply->errorString().toStdString();
+ LOG(ERROR) << "Error From Reply" << buffer.toStdString();
if (!m_automatic_) {
switch (error) {
case QNetworkReply::ContentNotFoundError:
@@ -486,10 +491,8 @@ void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
} else {
switch (error) {
case QNetworkReply::ContentNotFoundError:
- QMessageBox::critical(
- nullptr, _("Public key Not Found"),
- QString(_("Public key fingerprint %1 not found in the Keyserver"))
- .arg(keyid));
+ QMessageBox::critical(nullptr, _("Key Not Found"),
+ QString(_("key not found in the Keyserver")));
break;
case QNetworkReply::TimeoutError:
QMessageBox::critical(nullptr, _("Timeout"), "Connection timeout");
@@ -510,9 +513,8 @@ void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
return;
}
- reply->deleteLater();
-
- this->import_keys(std::make_unique<ByteArray>(key.constData(), key.length()));
+ this->import_keys(
+ std::make_unique<ByteArray>(buffer.constData(), buffer.length()));
if (!m_automatic_) {
set_message(QString("<h4>") + _("Key Imported") + "</h4>", false);
@@ -522,14 +524,17 @@ void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
void KeyServerImportDialog::import_keys(ByteArrayPtr in_data) {
GpgImportInformation result =
GpgKeyImportExporter::GetInstance().ImportKey(std::move(in_data));
+
+ // refresh the key database
emit SignalKeyImported();
+
QWidget* _parent = qobject_cast<QWidget*>(parent());
if (m_automatic_) {
auto dialog = new KeyImportDetailDialog(result, true, _parent);
dialog->show();
this->accept();
} else {
- auto dialog = new KeyImportDetailDialog(result, false, _parent);
+ auto dialog = new KeyImportDetailDialog(result, false, this);
dialog->exec();
}
}
@@ -542,45 +547,4 @@ void KeyServerImportDialog::set_loading(bool status) {
}
}
-KeyServerImportDialog::KeyServerImportDialog(QWidget* parent)
- : QDialog(parent), m_automatic_(true) {
- setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
-
- // Network Waiting
- 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(waiting_bar_);
-
- key_server_combo_box_ = create_comboBox();
-
- this->setLayout(layout);
- this->setWindowTitle(_("Update Keys from Keyserver"));
- this->setFixedSize(240, 42);
- this->setModal(true);
-}
-
-void KeyServerImportDialog::slot_save_window_state() {
- LOG(INFO) << _("Called");
-
- if (m_automatic_) return;
-
- SettingsObject key_server_import_state("key_server_import_state");
-
- // window position and size
- key_server_import_state["window_pos"]["x"] = pos().x();
- key_server_import_state["window_pos"]["y"] = pos().y();
-
- key_server_import_state["window_size"]["width"] = size().width();
- key_server_import_state["window_size"]["height"] = size().height();
- key_server_import_state["window_save"] = true;
-}
-
} // namespace GpgFrontend::UI
diff --git a/src/ui/import_export/KeyServerImportDialog.h b/src/ui/dialog/import_export/KeyServerImportDialog.h
index 37362859..fd912bdd 100644
--- a/src/ui/import_export/KeyServerImportDialog.h
+++ b/src/ui/dialog/import_export/KeyServerImportDialog.h
@@ -29,9 +29,12 @@
#ifndef __KEY_SERVER_IMPORT_DIALOG_H__
#define __KEY_SERVER_IMPORT_DIALOG_H__
+#include <string>
+
#include "KeyImportDetailDialog.h"
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
@@ -40,7 +43,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyServerImportDialog : public QDialog {
+class KeyServerImportDialog : public GeneralDialog {
Q_OBJECT
public:
@@ -74,7 +77,8 @@ class KeyServerImportDialog : public QDialog {
* @param keyIds
* @param keyserverUrl
*/
- void SlotImport(const QStringList& keyIds, const QUrl& keyserverUrl);
+ void SlotImport(std::vector<std::string> key_ids_list,
+ std::string keyserver_url);
signals:
@@ -87,7 +91,7 @@ class KeyServerImportDialog : public QDialog {
private slots:
/**
- * @brief
+ * @brief import key(s) for the key table selection
*
*/
void slot_import();
@@ -96,14 +100,16 @@ class KeyServerImportDialog : public QDialog {
* @brief
*
*/
- void slot_search_finished();
+ void slot_search_finished(QNetworkReply::NetworkError reply,
+ QByteArray buffer);
/**
* @brief
*
* @param keyid
*/
- void slot_import_finished(const QString& keyid);
+ void slot_import_finished(QNetworkReply::NetworkError error,
+ QByteArray buffer);
/**
* @brief
@@ -111,12 +117,6 @@ class KeyServerImportDialog : public QDialog {
*/
void slot_search();
- /**
- * @brief
- *
- */
- void slot_save_window_state();
-
private:
/**
* @brief Create a keys table object
@@ -164,18 +164,17 @@ class KeyServerImportDialog : public QDialog {
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_{}; ///<
+ 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_{}; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp
index a0436a8e..055f2e1f 100644
--- a/src/ui/import_export/KeyUploadDialog.cpp
+++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp
@@ -30,15 +30,16 @@
#include <algorithm>
+#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
-#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids,
QWidget* parent)
- : QDialog(parent), m_keys_(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) {
+ : GeneralDialog(typeid(KeyUploadDialog).name(), parent),
+ m_keys_(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) {
auto* pb = new QProgressBar();
pb->setRange(0, 0);
pb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -109,7 +110,8 @@ void KeyUploadDialog::slot_upload_key_to_server(
// Send Post Data
QNetworkReply* reply = qnam->post(request, postData);
- connect(reply, &QNetworkReply::finished, this, &KeyUploadDialog::slot_upload_finished);
+ connect(reply, &QNetworkReply::finished, this,
+ &KeyUploadDialog::slot_upload_finished);
// Keep Waiting
while (reply->isRunning()) {
diff --git a/src/ui/import_export/KeyUploadDialog.h b/src/ui/dialog/import_export/KeyUploadDialog.h
index 05cba083..d621f33a 100644
--- a/src/ui/import_export/KeyUploadDialog.h
+++ b/src/ui/dialog/import_export/KeyUploadDialog.h
@@ -31,6 +31,7 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -38,7 +39,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyUploadDialog : public QDialog {
+class KeyUploadDialog : public GeneralDialog {
Q_OBJECT
public:
/**
diff --git a/src/ui/key_generate/KeygenDialog.cpp b/src/ui/dialog/key_generate/KeygenDialog.cpp
index d5ca801d..42160ec9 100644
--- a/src/ui/key_generate/KeygenDialog.cpp
+++ b/src/ui/dialog/key_generate/KeygenDialog.cpp
@@ -26,7 +26,7 @@
*
*/
-#include "ui/key_generate/KeygenDialog.h"
+#include "KeygenDialog.h"
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyOpera.h"
@@ -35,7 +35,8 @@
namespace GpgFrontend::UI {
-KeyGenDialog::KeyGenDialog(QWidget* parent) : QDialog(parent) {
+KeyGenDialog::KeyGenDialog(QWidget* parent)
+ : GeneralDialog(typeid(KeyGenDialog).name(), parent) {
button_box_ =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
diff --git a/src/ui/key_generate/KeygenDialog.h b/src/ui/dialog/key_generate/KeygenDialog.h
index 751ebdd8..baf10dbf 100644
--- a/src/ui/key_generate/KeygenDialog.h
+++ b/src/ui/dialog/key_generate/KeygenDialog.h
@@ -30,6 +30,7 @@
#include "core/GpgContext.h"
#include "core/GpgGenKeyInfo.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -37,7 +38,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyGenDialog : public QDialog {
+class KeyGenDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/key_generate/SubkeyGenerateDialog.cpp b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
index 2b9e076d..806c0e50 100644
--- a/src/ui/key_generate/SubkeyGenerateDialog.cpp
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/key_generate/SubkeyGenerateDialog.h"
+#include "SubkeyGenerateDialog.h"
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyGetter.h"
@@ -35,7 +35,8 @@
namespace GpgFrontend::UI {
SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent)
- : QDialog(parent), key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ : GeneralDialog(typeid(SubkeyGenerateDialog).name(), parent),
+ key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
// max expire date time
diff --git a/src/ui/key_generate/SubkeyGenerateDialog.h b/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
index 4ab90ad4..1e6608b2 100644
--- a/src/ui/key_generate/SubkeyGenerateDialog.h
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
@@ -30,13 +30,14 @@
#include "core/GpgContext.h"
#include "core/GpgGenKeyInfo.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
/**
* @brief
*
*/
-class SubkeyGenerateDialog : public QDialog {
+class SubkeyGenerateDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/keypair_details/KeyDetailsDialog.cpp b/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp
index 3b3e8818..9c2f8003 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp
@@ -26,16 +26,16 @@
*
*/
-#include "ui/keypair_details/KeyDetailsDialog.h"
+#include "KeyDetailsDialog.h"
-#include "ui/keypair_details/KeyPairDetailTab.h"
-#include "ui/keypair_details/KeyPairOperaTab.h"
-#include "ui/keypair_details/KeyPairSubkeyTab.h"
-#include "ui/keypair_details/KeyPairUIDTab.h"
+#include "KeyPairDetailTab.h"
+#include "KeyPairOperaTab.h"
+#include "KeyPairSubkeyTab.h"
+#include "KeyPairUIDTab.h"
namespace GpgFrontend::UI {
KeyDetailsDialog::KeyDetailsDialog(const GpgKey& key, QWidget* parent)
- : QDialog(parent) {
+ : GeneralDialog(typeid(KeyDetailsDialog).name(), parent) {
tab_widget_ = new QTabWidget();
tab_widget_->addTab(new KeyPairDetailTab(key.GetId(), tab_widget_),
_("KeyPair"));
diff --git a/src/ui/keypair_details/KeyDetailsDialog.h b/src/ui/dialog/keypair_details/KeyDetailsDialog.h
index e6f4472c..1ddcda00 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.h
+++ b/src/ui/dialog/keypair_details/KeyDetailsDialog.h
@@ -31,10 +31,11 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
-class KeyDetailsDialog : public QDialog {
+class KeyDetailsDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
index 9ff73f9e..18dd1967 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/keypair_details/KeyNewUIDDialog.h"
+#include "KeyNewUIDDialog.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgUIDOperator.h"
@@ -32,7 +32,8 @@
namespace GpgFrontend::UI {
KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent)
- : QDialog(parent), m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ : GeneralDialog(typeid(KeyNewUIDDialog).name(), parent),
+ m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
name_ = new QLineEdit();
name_->setMinimumWidth(240);
email_ = new QLineEdit();
@@ -65,7 +66,8 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent)
this->setAttribute(Qt::WA_DeleteOnClose, true);
this->setModal(true);
- connect(this, &KeyNewUIDDialog::SignalUIDCreated, SignalStation::GetInstance(),
+ connect(this, &KeyNewUIDDialog::SignalUIDCreated,
+ SignalStation::GetInstance(),
&SignalStation::SignalKeyDatabaseRefresh);
}
@@ -84,9 +86,9 @@ void KeyNewUIDDialog::slot_create_new_uid() {
}
auto error_string = error_stream.str();
if (error_string.empty()) {
- if (GpgUIDOperator::GetInstance().AddUID(m_key_, name_->text().toStdString(),
- comment_->text().toStdString(),
- email_->text().toStdString())) {
+ if (GpgUIDOperator::GetInstance().AddUID(
+ m_key_, name_->text().toStdString(), comment_->text().toStdString(),
+ email_->text().toStdString())) {
emit finished(1);
emit SignalUIDCreated();
} else
diff --git a/src/ui/keypair_details/KeyNewUIDDialog.h b/src/ui/dialog/keypair_details/KeyNewUIDDialog.h
index 24f2c6b1..291b59c4 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.h
+++ b/src/ui/dialog/keypair_details/KeyNewUIDDialog.h
@@ -29,9 +29,10 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
-class KeyNewUIDDialog : public QDialog {
+class KeyNewUIDDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
index 76f316e9..4a6e4b52 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/keypair_details/KeyPairDetailTab.h"
+#include "KeyPairDetailTab.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
diff --git a/src/ui/keypair_details/KeyPairDetailTab.h b/src/ui/dialog/keypair_details/KeyPairDetailTab.h
index 9d0d6560..91ccdab8 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairDetailTab.h
@@ -29,9 +29,9 @@
#include "KeySetExpireDateDialog.h"
#include "core/GpgContext.h"
-#include "import_export/KeyServerImportDialog.h"
-#include "import_export/KeyUploadDialog.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/import_export/KeyServerImportDialog.h"
+#include "ui/dialog/import_export/KeyUploadDialog.h"
namespace GpgFrontend::UI {
@@ -60,19 +60,19 @@ class KeyPairDetailTab : public QWidget {
private:
GpgKey key_; ///<
- QGroupBox* owner_box_; ///< Groupbox containing owner information
- QGroupBox* key_box_; ///< Groupbox containing key information
- QGroupBox* fingerprint_box_; ///< Groupbox containing fingerprint information
+ QGroupBox* owner_box_; ///< Groupbox containing owner information
+ QGroupBox* key_box_; ///< Groupbox containing key information
+ QGroupBox* fingerprint_box_; ///< Groupbox containing fingerprint information
QGroupBox* additional_uid_box_; ///< Groupbox containing information about
///< additional uids
- QLabel* name_var_label_; ///< Label containing the keys name
- QLabel* email_var_label_; ///< Label containing the keys email
- QLabel* comment_var_label_; ///< Label containing the keys comment
- QLabel* key_size_var_label_; ///< Label containing the keys key size
- QLabel* expire_var_label_; ///< Label containing the keys expiration date
- QLabel* created_var_label_; ///< Label containing the keys creation date
- QLabel* last_update_var_label_; ///<
+ QLabel* name_var_label_; ///< Label containing the keys name
+ QLabel* email_var_label_; ///< Label containing the keys email
+ QLabel* comment_var_label_; ///< Label containing the keys comment
+ QLabel* key_size_var_label_; ///< Label containing the keys key size
+ QLabel* expire_var_label_; ///< Label containing the keys expiration date
+ QLabel* created_var_label_; ///< Label containing the keys creation date
+ QLabel* last_update_var_label_; ///<
QLabel* algorithm_var_label_; ///< Label containing the keys algorithm
QLabel* key_id_var_label; ///< Label containing the keys keyid
QLabel* fingerprint_var_label_; ///< Label containing the keys fingerprint
diff --git a/src/ui/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
index 4f7cd66f..77eba0bc 100644
--- a/src/ui/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
@@ -26,12 +26,12 @@
#include "KeyPairOperaTab.h"
+#include "KeySetExpireDateDialog.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/function/gpg/GpgKeyOpera.h"
-#include "import_export/KeyUploadDialog.h"
#include "ui/SignalStation.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/keypair_details/KeySetExpireDateDialog.h"
+#include "ui/dialog/import_export/KeyUploadDialog.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/keypair_details/KeyPairOperaTab.h b/src/ui/dialog/keypair_details/KeyPairOperaTab.h
index af6b1eee..af6b1eee 100644
--- a/src/ui/keypair_details/KeyPairOperaTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.h
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
index 46de550c..fe1d0798 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
@@ -26,7 +26,7 @@
*
*/
-#include "ui/keypair_details/KeyPairSubkeyTab.h"
+#include "KeyPairSubkeyTab.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "ui/SignalStation.h"
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.h b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h
index a64d143c..a93ebca5 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h
@@ -32,7 +32,7 @@
#include "KeySetExpireDateDialog.h"
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/key_generate/SubkeyGenerateDialog.h"
+#include "ui/dialog/key_generate/SubkeyGenerateDialog.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
index 4cc835a8..b923dbec 100644
--- a/src/ui/keypair_details/KeyPairUIDTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/keypair_details/KeyPairUIDTab.h"
+#include "KeyPairUIDTab.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyManager.h"
diff --git a/src/ui/keypair_details/KeyPairUIDTab.h b/src/ui/dialog/keypair_details/KeyPairUIDTab.h
index fae8f9f2..fae8f9f2 100644
--- a/src/ui/keypair_details/KeyPairUIDTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairUIDTab.h
diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
index f2ccc240..2c10b895 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
@@ -26,7 +26,7 @@
*
*/
-#include "ui/keypair_details/KeySetExpireDateDialog.h"
+#include "KeySetExpireDateDialog.h"
#include <utility>
@@ -40,7 +40,7 @@ namespace GpgFrontend::UI {
KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id,
QWidget* parent)
- : QDialog(parent),
+ : GeneralDialog(typeid(KeySetExpireDateDialog).name(), parent),
ui_(std::make_shared<Ui_ModifiedExpirationDateTime>()),
m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
init();
@@ -49,7 +49,7 @@ KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id,
KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id,
std::string subkey_fpr,
QWidget* parent)
- : QDialog(parent),
+ : GeneralDialog(typeid(KeySetExpireDateDialog).name(), parent),
ui_(std::make_shared<Ui_ModifiedExpirationDateTime>()),
m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)),
m_subkey_(std::move(subkey_fpr)) {
diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.h b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.h
index 3c0b62f7..3cd6cd01 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.h
+++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.h
@@ -33,12 +33,13 @@
#include "core/model/GpgKey.h"
#include "core/model/GpgSubKey.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
class Ui_ModifiedExpirationDateTime;
namespace GpgFrontend::UI {
-class KeySetExpireDateDialog : public QDialog {
+class KeySetExpireDateDialog : public GeneralDialog {
Q_OBJECT
public:
/**
diff --git a/src/ui/keypair_details/KeyUIDSignDialog.cpp b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
index 2ed45512..0f7de587 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/keypair_details/KeyUIDSignDialog.h"
+#include "KeyUIDSignDialog.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyManager.h"
@@ -34,7 +34,9 @@ namespace GpgFrontend::UI {
KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid,
QWidget* parent)
- : QDialog(parent), m_uids_(std::move(uid)), m_key_(key) {
+ : GeneralDialog(typeid(KeyUIDSignDialog).name(), parent),
+ m_uids_(std::move(uid)),
+ m_key_(key) {
const auto key_id = m_key_.GetId();
m_key_list_ = new KeyList(KeyMenuAbility::NONE, this);
m_key_list_->AddListGroupTab(
diff --git a/src/ui/keypair_details/KeyUIDSignDialog.h b/src/ui/dialog/keypair_details/KeyUIDSignDialog.h
index 7c1cb58c..bfaff6d2 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.h
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.h
@@ -29,11 +29,12 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
-class KeyUIDSignDialog : public QDialog {
+class KeyUIDSignDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/settings/SettingsAdvanced.cpp b/src/ui/dialog/settings/SettingsAdvanced.cpp
index 516d4d02..516d4d02 100644
--- a/src/ui/settings/SettingsAdvanced.cpp
+++ b/src/ui/dialog/settings/SettingsAdvanced.cpp
diff --git a/src/ui/settings/SettingsAdvanced.h b/src/ui/dialog/settings/SettingsAdvanced.h
index c1a3d5a6..c1a3d5a6 100644
--- a/src/ui/settings/SettingsAdvanced.h
+++ b/src/ui/dialog/settings/SettingsAdvanced.h
diff --git a/src/ui/settings/SettingsAppearance.cpp b/src/ui/dialog/settings/SettingsAppearance.cpp
index 7e54c9f8..17471a0d 100644
--- a/src/ui/settings/SettingsAppearance.cpp
+++ b/src/ui/dialog/settings/SettingsAppearance.cpp
@@ -114,11 +114,10 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) {
* appropriately
**********************************/
void AppearanceTab::SetSettings() {
+ SettingsObject general_settings_state("general_settings_state");
- SettingsObject main_windows_state("main_windows_state");
-
- int width = main_windows_state.Check("icon_size").Check("width", 24),
- height = main_windows_state.Check("icon_size").Check("height", 24);
+ int width = general_settings_state.Check("icon_size").Check("width", 24),
+ height = general_settings_state.Check("icon_size").Check("height", 24);
auto icon_size = QSize(width, height);
@@ -136,7 +135,7 @@ void AppearanceTab::SetSettings() {
// icon_style
int s_icon_style =
- main_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
+ general_settings_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
switch (icon_style) {
@@ -153,10 +152,10 @@ void AppearanceTab::SetSettings() {
break;
}
- bool window_save = main_windows_state.Check("window_save", true);
+ bool window_save = general_settings_state.Check("window_save", true);
if (window_save) window_size_check_box_->setCheckState(Qt::Checked);
- auto info_font_size = main_windows_state.Check("info_font_size", 10);
+ auto info_font_size = general_settings_state.Check("font_size", 10);
if (info_font_size < 9 || info_font_size > 18) info_font_size = 10;
info_board_font_size_spin_->setValue(info_font_size);
}
@@ -167,7 +166,7 @@ void AppearanceTab::SetSettings() {
*************************************/
void AppearanceTab::ApplySettings() {
- SettingsObject main_windows_state("main_windows_state");
+ SettingsObject general_settings_state("general_settings_state");
int icon_size = 24;
switch (icon_size_group_->checkedId()) {
@@ -182,8 +181,8 @@ void AppearanceTab::ApplySettings() {
break;
}
- main_windows_state["icon_size"]["width"] = icon_size;
- main_windows_state["icon_size"]["height"] = icon_size;
+ general_settings_state["icon_size"]["width"] = icon_size;
+ general_settings_state["icon_size"]["height"] = icon_size;
auto icon_style = Qt::ToolButtonTextUnderIcon;
switch (icon_style_group_->checkedId()) {
@@ -198,12 +197,11 @@ void AppearanceTab::ApplySettings() {
break;
}
- main_windows_state["icon_style"] = icon_style;
-
- main_windows_state["window_save"] = window_size_check_box_->isChecked();
+ general_settings_state["icon_style"] = icon_style;
- main_windows_state["info_font_size"] = info_board_font_size_spin_->value();
+ general_settings_state["window_save"] = window_size_check_box_->isChecked();
+ general_settings_state["info_font_size"] = info_board_font_size_spin_->value();
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsAppearance.h b/src/ui/dialog/settings/SettingsAppearance.h
index 7110d992..7110d992 100644
--- a/src/ui/settings/SettingsAppearance.h
+++ b/src/ui/dialog/settings/SettingsAppearance.h
diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp
index eefdd3c7..e2677a0f 100644
--- a/src/ui/settings/SettingsDialog.cpp
+++ b/src/ui/dialog/settings/SettingsDialog.cpp
@@ -28,17 +28,18 @@
#include "SettingsDialog.h"
+#include "SettingsAdvanced.h"
+#include "SettingsAppearance.h"
+#include "SettingsGeneral.h"
+#include "SettingsKeyServer.h"
+#include "SettingsNetwork.h"
#include "core/function/GlobalSettingStation.h"
#include "ui/main_window/MainWindow.h"
-#include "ui/settings/SettingsAdvanced.h"
-#include "ui/settings/SettingsAppearance.h"
-#include "ui/settings/SettingsGeneral.h"
-#include "ui/settings/SettingsKeyServer.h"
-#include "ui/settings/SettingsNetwork.h"
namespace GpgFrontend::UI {
-SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) {
+SettingsDialog::SettingsDialog(QWidget* parent)
+ : GeneralDialog(typeid(SettingsDialog).name(), parent) {
tab_widget_ = new QTabWidget();
general_tab_ = new GeneralTab();
appearance_tab_ = new AppearanceTab();
diff --git a/src/ui/settings/SettingsDialog.h b/src/ui/dialog/settings/SettingsDialog.h
index e123cc6c..172370d0 100755..100644
--- a/src/ui/settings/SettingsDialog.h
+++ b/src/ui/dialog/settings/SettingsDialog.h
@@ -30,6 +30,7 @@
#define __SETTINGSDIALOG_H__
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
@@ -43,7 +44,7 @@ class NetworkTab;
* @brief
*
*/
-class SettingsDialog : public QDialog {
+class SettingsDialog : public GeneralDialog {
Q_OBJECT
public:
@@ -54,7 +55,7 @@ class SettingsDialog : public QDialog {
*/
explicit SettingsDialog(QWidget* parent = nullptr);
- GeneralTab* general_tab_; ///<
+ GeneralTab* general_tab_; ///<
AppearanceTab* appearance_tab_; ///<
KeyserverTab* key_server_tab_; ///<
NetworkTab* network_tab_; ///<
diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp
index 3c7bca32..3c7bca32 100644
--- a/src/ui/settings/SettingsGeneral.cpp
+++ b/src/ui/dialog/settings/SettingsGeneral.cpp
diff --git a/src/ui/settings/SettingsGeneral.h b/src/ui/dialog/settings/SettingsGeneral.h
index b3e7d904..b3e7d904 100644
--- a/src/ui/settings/SettingsGeneral.h
+++ b/src/ui/dialog/settings/SettingsGeneral.h
diff --git a/src/ui/settings/SettingsKeyServer.cpp b/src/ui/dialog/settings/SettingsKeyServer.cpp
index 94655871..2c09b66c 100644
--- a/src/ui/settings/SettingsKeyServer.cpp
+++ b/src/ui/dialog/settings/SettingsKeyServer.cpp
@@ -120,23 +120,30 @@ KeyserverTab::KeyserverTab(QWidget* parent)
* appropriately
**********************************/
void KeyserverTab::SetSettings() {
- SettingsObject key_server_json("key_server");
-
- const auto key_server_list =
- key_server_json.Check("server_list", nlohmann::json::array());
+ try {
+ SettingsObject key_server_json("key_server");
- for (const auto& key_server : key_server_list) {
- const auto key_server_str = key_server.get<std::string>();
- this->key_server_str_list_.append(key_server_str.c_str());
- }
+ const auto key_server_list =
+ key_server_json.Check("server_list", nlohmann::json::array());
- int default_key_server_index = key_server_json.Check("default_server", 0);
- std::string default_key_server =
- key_server_list[default_key_server_index].get<std::string>();
+ for (const auto& key_server : key_server_list) {
+ const auto key_server_str = key_server.get<std::string>();
+ this->key_server_str_list_.append(key_server_str.c_str());
+ }
- if (!key_server_str_list_.contains(default_key_server.c_str()))
- key_server_str_list_.append(default_key_server.c_str());
- default_key_server_ = QString::fromStdString(default_key_server);
+ int default_key_server_index = key_server_json.Check("default_server", 0);
+ if (default_key_server_index >= key_server_list.size()) {
+ throw std::runtime_error("default_server index out of range");
+ }
+ std::string default_key_server =
+ key_server_list[default_key_server_index].get<std::string>();
+
+ if (!key_server_str_list_.contains(default_key_server.c_str()))
+ key_server_str_list_.append(default_key_server.c_str());
+ default_key_server_ = QString::fromStdString(default_key_server);
+ } catch (const std::exception& e) {
+ LOG(ERROR) << "Error reading key-server settings: " << e.what();
+ }
}
void KeyserverTab::slot_add_key_server() {
diff --git a/src/ui/settings/SettingsKeyServer.h b/src/ui/dialog/settings/SettingsKeyServer.h
index f983e69b..f983e69b 100644
--- a/src/ui/settings/SettingsKeyServer.h
+++ b/src/ui/dialog/settings/SettingsKeyServer.h
diff --git a/src/ui/settings/SettingsNetwork.cpp b/src/ui/dialog/settings/SettingsNetwork.cpp
index d4edae42..d4edae42 100644
--- a/src/ui/settings/SettingsNetwork.cpp
+++ b/src/ui/dialog/settings/SettingsNetwork.cpp
diff --git a/src/ui/settings/SettingsNetwork.h b/src/ui/dialog/settings/SettingsNetwork.h
index d4c0d00d..d4c0d00d 100644
--- a/src/ui/settings/SettingsNetwork.h
+++ b/src/ui/dialog/settings/SettingsNetwork.h
diff --git a/src/ui/main_window/GeneralMainWindow.cpp b/src/ui/main_window/GeneralMainWindow.cpp
new file mode 100644
index 00000000..7df73aba
--- /dev/null
+++ b/src/ui/main_window/GeneralMainWindow.cpp
@@ -0,0 +1,135 @@
+/**
+ * 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 <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 "GeneralMainWindow.h"
+
+#include <utility>
+
+#include "ui/struct/SettingsObject.h"
+
+GpgFrontend::UI::GeneralMainWindow::GeneralMainWindow(std::string name,
+ QWidget* parent)
+ : name_(std::move(name)), QMainWindow(parent) {
+ slot_restore_settings();
+}
+
+GpgFrontend::UI::GeneralMainWindow::~GeneralMainWindow() = default;
+
+void GpgFrontend::UI::GeneralMainWindow::closeEvent(QCloseEvent* event) {
+ slot_save_settings();
+ QMainWindow::closeEvent(event);
+}
+
+void GpgFrontend::UI::GeneralMainWindow::slot_restore_settings() noexcept {
+ try {
+ LOG(INFO) << name_ << _("Called");
+
+ SettingsObject general_windows_state(name_ + "_state");
+
+ std::string window_state = general_windows_state.Check(
+ "window_state", saveState().toBase64().toStdString());
+
+ // state sets pos & size of dock-widgets
+ this->restoreState(
+ QByteArray::fromBase64(QByteArray::fromStdString(window_state)));
+
+ bool window_save = general_windows_state.Check("window_save", true);
+
+ // Restore window size & location
+ if (window_save) {
+ int x = general_windows_state.Check("window_pos").Check("x", 100),
+ y = general_windows_state.Check("window_pos").Check("y", 100);
+
+ this->move({x, y});
+ pos_ = {x, y};
+
+ int width =
+ general_windows_state.Check("window_size").Check("width", 800),
+ height =
+ general_windows_state.Check("window_size").Check("height", 450);
+
+ this->resize({width, height});
+ size_ = {width, height};
+ }
+
+
+ // appearance
+ SettingsObject general_settings_state("general_settings_state");
+
+ int width = general_settings_state.Check("icon_size").Check("width", 24),
+ height = general_settings_state.Check("icon_size").Check("height", 24);
+ LOG(INFO) << "icon_size" << width << height;
+
+ icon_size_ = {width, height};
+ font_size_ = general_settings_state.Check("font_size", 10);
+
+ this->setIconSize(icon_size_);
+
+ // icon_style
+ int s_icon_style =
+ general_settings_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
+ this->setToolButtonStyle(static_cast<Qt::ToolButtonStyle>(s_icon_style));
+ icon_style_ = toolButtonStyle();
+
+ } catch (...) {
+ LOG(ERROR) << name_ << "error";
+ }
+}
+
+void GpgFrontend::UI::GeneralMainWindow::slot_save_settings() noexcept {
+ try {
+ LOG(INFO) << name_ << _("Called");
+
+ SettingsObject general_windows_state(name_ + "_state");
+
+ // window position and size
+ general_windows_state["window_state"] =
+ saveState().toBase64().toStdString();
+ general_windows_state["window_pos"]["x"] = pos().x();
+ general_windows_state["window_pos"]["y"] = pos().y();
+
+ general_windows_state["window_size"]["width"] = size_.width();
+ general_windows_state["window_size"]["height"] = size_.height();
+ general_windows_state["window_save"] = true;
+
+ SettingsObject general_settings_state("general_settings_state");
+
+ // icon size
+ general_settings_state["icon_size"]["width"] = icon_size_.width();
+ general_settings_state["icon_size"]["height"] = icon_size_.height();
+
+ // font size
+ general_settings_state["font_size"] = font_size_;
+
+ // tool button style
+ general_settings_state["icon_style"] = this->toolButtonStyle();
+
+ } catch (...) {
+ LOG(ERROR) << name_ << "error";
+ }
+}
diff --git a/src/ui/main_window/GeneralMainWindow.h b/src/ui/main_window/GeneralMainWindow.h
new file mode 100644
index 00000000..71327100
--- /dev/null
+++ b/src/ui/main_window/GeneralMainWindow.h
@@ -0,0 +1,81 @@
+/**
+ * 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 <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
+ *
+ */
+
+#ifndef GPGFRONTEND_GENERALMAINWINDOW_H
+#define GPGFRONTEND_GENERALMAINWINDOW_H
+
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+/**
+ *
+ */
+class GeneralMainWindow : public QMainWindow {
+ public:
+ /**
+ *
+ * @param name
+ */
+ explicit GeneralMainWindow(std::string name, QWidget* parent = nullptr);
+
+ /**
+ *
+ */
+ ~GeneralMainWindow() override;
+
+ protected:
+ /**
+ *
+ * @param event
+ */
+ void closeEvent(QCloseEvent* event);
+
+ QSize icon_size_{}; ///<
+ int font_size_{}; ///<
+ Qt::ToolButtonStyle icon_style_; ///<
+
+ private slots:
+ /**
+ *
+ */
+ void slot_restore_settings() noexcept;
+
+ /**
+ *
+ */
+ void slot_save_settings() noexcept;
+
+ private:
+ std::string name_; ///<
+ QPoint pos_; ///<
+ QSize size_; ///<
+};
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_GENERALMAINWINDOW_H
diff --git a/src/ui/KeyMgmt.cpp b/src/ui/main_window/KeyMgmt.cpp
index 30bc8a1b..6dc2b14f 100755..100644
--- a/src/ui/KeyMgmt.cpp
+++ b/src/ui/main_window/KeyMgmt.cpp
@@ -26,24 +26,25 @@
*
*/
-#include "ui/KeyMgmt.h"
+#include "KeyMgmt.h"
#include <utility>
+#include "core/function/GlobalSettingStation.h"
+#include "core/function/KeyPackageOperator.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/function/gpg/GpgKeyOpera.h"
-#include "core/function/KeyPackageOperator.h"
#include "ui/SignalStation.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/import_export/ExportKeyPackageDialog.h"
-#include "ui/key_generate/SubkeyGenerateDialog.h"
+#include "ui/dialog/import_export/ExportKeyPackageDialog.h"
+#include "ui/dialog/key_generate/SubkeyGenerateDialog.h"
#include "ui/main_window/MainWindow.h"
-#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
-KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
+KeyMgmt::KeyMgmt(QWidget* parent)
+ : GeneralMainWindow("key_management", parent) {
/* the list of Keys available*/
key_list_ = new KeyList(KeyMenuAbility::ALL, this);
@@ -105,53 +106,6 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
- try {
- int width = settings.lookup("window.icon_size.width");
- int height = settings.lookup("window.icon_size.height");
-
- this->setIconSize(QSize(width, height));
-
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("icon_size");
- }
-
- // icon_style
- try {
- int s_icon_style = settings.lookup("window.icon_style");
- auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
- this->setToolButtonStyle(icon_style);
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("icon_style");
- }
-
- auto pos = QPoint(50, 50);
- LOG(INFO) << "parent" << parent;
- if (parent) pos += parent->pos();
- LOG(INFO) << "pos default" << pos.x() << pos.y();
- auto size = QSize(900, 600);
-
- try {
- int x, y, width, height;
- x = settings.lookup("window.key_management.position.x");
- y = settings.lookup("window.key_management.position.y");
- width = settings.lookup("window.key_management.size.width");
- height = settings.lookup("window.key_management.size.height");
- pos = QPoint(x, y);
- size = QSize(width, height);
-
- std::string window_state =
- settings.lookup("window.key_management.window_state");
-
- // state sets pos & size of dock-widgets
- this->restoreState(
- QByteArray::fromBase64(QByteArray::fromStdString(window_state)));
-
- } catch (...) {
- LOG(WARNING) << "cannot read pos or size from settings";
- }
-
- this->resize(size);
- this->move(pos);
this->statusBar()->show();
setWindowTitle(_("KeyPair Management"));
@@ -296,7 +250,7 @@ void KeyMgmt::create_tool_bars() {
generateToolButton->setIcon(QIcon(":key_generate.png"));
generateToolButton->setText(_("Generate"));
generateToolButton->setToolTip(_("Generate A New Keypair or Subkey"));
- generateToolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ generateToolButton->setToolButtonStyle(icon_style_);
keyToolBar->addWidget(generateToolButton);
// add button with popup menu for import
@@ -306,7 +260,7 @@ void KeyMgmt::create_tool_bars() {
toolButton->setIcon(QIcon(":key_import.png"));
toolButton->setToolTip(_("Import key"));
toolButton->setText(_("Import Key"));
- toolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ toolButton->setToolButtonStyle(icon_style_);
keyToolBar->addWidget(toolButton);
keyToolBar->addSeparator();
@@ -406,11 +360,6 @@ void KeyMgmt::SlotGenerateKeyDialog() {
keyGenDialog->show();
}
-void KeyMgmt::closeEvent(QCloseEvent* event) {
- SlotSaveWindowState();
- QMainWindow::closeEvent(event);
-}
-
void KeyMgmt::SlotGenerateSubKey() {
auto keys_selected = key_list_->GetSelected();
if (keys_selected->empty()) {
@@ -434,52 +383,6 @@ void KeyMgmt::SlotGenerateSubKey() {
auto dialog = new SubkeyGenerateDialog(key.GetId(), this);
dialog->show();
}
-void KeyMgmt::SlotSaveWindowState() {
- auto& settings =
- GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
-
- if (!settings.exists("window") ||
- settings.lookup("window").getType() != libconfig::Setting::TypeGroup)
- settings.add("window", libconfig::Setting::TypeGroup);
-
- auto& window = settings["window"];
-
- if (!window.exists("key_management") ||
- window.lookup("key_management").getType() !=
- libconfig::Setting::TypeGroup)
- window.add("key_management", libconfig::Setting::TypeGroup);
-
- auto& key_management = window["key_management"];
-
- if (!key_management.exists("position") ||
- key_management.lookup("position").getType() !=
- libconfig::Setting::TypeGroup) {
- auto& position =
- key_management.add("position", libconfig::Setting::TypeGroup);
- position.add("x", libconfig::Setting::TypeInt) = pos().x();
- position.add("y", libconfig::Setting::TypeInt) = pos().y();
- } else {
- key_management["position"]["x"] = pos().x();
- key_management["position"]["y"] = pos().y();
- }
-
- if (!key_management.exists("size") ||
- key_management.lookup("size").getType() !=
- libconfig::Setting::TypeGroup) {
- auto& size = key_management.add("size", libconfig::Setting::TypeGroup);
- size.add("width", libconfig::Setting::TypeInt) = QWidget::width();
- size.add("height", libconfig::Setting::TypeInt) = QWidget::height();
- } else {
- key_management["size"]["width"] = QWidget::width();
- key_management["size"]["height"] = QWidget::height();
- }
-
- if (!key_management.exists("window_state"))
- key_management.add("window_state", libconfig::Setting::TypeString) =
- saveState().toBase64().toStdString();
-
- GlobalSettingStation::GetInstance().SyncSettings();
-}
void KeyMgmt::SlotExportAsOpenSSHFormat() {
ByteArrayPtr key_export_data = nullptr;
@@ -527,7 +430,6 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() {
}
void KeyMgmt::SlotImportKeyPackage() {
-
LOG(INFO) << "Importing key package...";
auto key_package_file_name = QFileDialog::getOpenFileName(
@@ -538,8 +440,7 @@ void KeyMgmt::SlotImportKeyPackage() {
this, _("Import Key Package Passphrase File"), {},
QString(_("Key Package Passphrase File")) + " (*.key);;All Files (*)");
- if(key_package_file_name.isEmpty() || key_file_name.isEmpty())
- return;
+ if (key_package_file_name.isEmpty() || key_file_name.isEmpty()) return;
GpgImportInformation info;
diff --git a/src/ui/KeyMgmt.h b/src/ui/main_window/KeyMgmt.h
index 25ee80c5..2073113a 100755..100644
--- a/src/ui/KeyMgmt.h
+++ b/src/ui/main_window/KeyMgmt.h
@@ -30,10 +30,11 @@
#define __KEYMGMT_H__
#include "ui/GpgFrontendUI.h"
-#include "ui/import_export/KeyImportDetailDialog.h"
-#include "ui/import_export/KeyServerImportDialog.h"
-#include "ui/key_generate/KeygenDialog.h"
-#include "ui/keypair_details/KeyDetailsDialog.h"
+#include "ui/dialog/import_export/KeyImportDetailDialog.h"
+#include "ui/dialog/import_export/KeyServerImportDialog.h"
+#include "ui/dialog/key_generate/KeygenDialog.h"
+#include "ui/dialog/keypair_details/KeyDetailsDialog.h"
+#include "ui/main_window/GeneralMainWindow.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
@@ -42,7 +43,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyMgmt : public QMainWindow {
+class KeyMgmt : public GeneralMainWindow {
Q_OBJECT
public:
@@ -107,12 +108,6 @@ class KeyMgmt : public QMainWindow {
* @brief
*
*/
- void SlotSaveWindowState();
-
- /**
- * @brief
- *
- */
void SlotImportKeyPackage();
signals:
@@ -176,14 +171,6 @@ class KeyMgmt : public QMainWindow {
QAction* close_act_{}; ///<
QAction* show_key_details_act_{}; ///<
KeyServerImportDialog* import_dialog_{}; ///<
-
- protected:
- /**
- * @brief
- *
- * @param event
- */
- void closeEvent(QCloseEvent* event) override;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp
index d04e3dbd..e3e4c0ab 100644
--- a/src/ui/main_window/MainWindow.cpp
+++ b/src/ui/main_window/MainWindow.cpp
@@ -36,7 +36,7 @@
namespace GpgFrontend::UI {
-MainWindow::MainWindow() {
+MainWindow::MainWindow() : GeneralMainWindow("main_window") {
this->setMinimumSize(1200, 700);
this->setWindowTitle(qApp->applicationName());
}
@@ -135,63 +135,14 @@ void MainWindow::restore_settings() {
LOG(INFO) << _("Called");
try {
- LOG(INFO) << "restore settings main_windows_state";
-
- SettingsObject main_windows_state("main_windows_state");
-
- std::string window_state = main_windows_state.Check(
- "window_state", saveState().toBase64().toStdString());
- // state sets pos & size of dock-widgets
- this->restoreState(
- QByteArray::fromBase64(QByteArray::fromStdString(window_state)));
-
- bool window_save = main_windows_state.Check("window_save", true);
-
- // Restore window size & location
- if (window_save) {
- int x = main_windows_state.Check("window_pos").Check("x", 100),
- y = main_windows_state.Check("window_pos").Check("y", 100);
-
- auto pos = QPoint(x, y);
-
- int width = main_windows_state.Check("window_size").Check("width", 800),
- height = main_windows_state.Check("window_size").Check("height", 450);
-
- auto size = QSize(width, height);
- this->resize(size);
- this->move(pos);
- } else {
- this->resize(QSize(800, 450));
- this->move(QPoint(100, 100));
- }
-
- int width = main_windows_state.Check("icon_size").Check("width", 24),
- height = main_windows_state.Check("icon_size").Check("height", 24);
- LOG(INFO) << "icon_size" << width << height;
-
- main_windows_state.Check("info_font_size", 10);
-
- // icon_style
- int s_icon_style =
- main_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
- auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
- this->setToolButtonStyle(icon_style);
- import_button_->setToolButtonStyle(icon_style);
-
- // icons ize
- this->setIconSize(QSize(width, height));
- import_button_->setIconSize(QSize(width, height));
-
LOG(INFO) << "restore settings key_server";
SettingsObject key_server_json("key_server");
-
- if (!key_server_json.contains("server_list")) {
+ if (!key_server_json.contains("server_list") ||
+ key_server_json["server_list"].empty()) {
key_server_json["server_list"] = {"https://keyserver.ubuntu.com",
- "http://keys.gnupg.net",
- "http://pool.sks-keyservers.net"};
+ "https://keys.openpgp.org"};
}
-
if (!key_server_json.contains("default_server")) {
key_server_json["default_server"] = 0;
}
@@ -216,6 +167,9 @@ void MainWindow::restore_settings() {
bool save_key_checked = true;
general.lookupValue("save_key_checked", save_key_checked);
+ // set appearance
+ import_button_->setToolButtonStyle(icon_style_);
+
try {
LOG(INFO) << "restore settings default_key_checked";
@@ -255,16 +209,6 @@ void MainWindow::save_settings() {
auto &settings = GlobalSettingStation::GetInstance().GetUISettings();
try {
- SettingsObject main_windows_state("main_windows_state");
-
- // window position and size
- main_windows_state["window_state"] = saveState().toBase64().toStdString();
- main_windows_state["window_pos"]["x"] = pos().x();
- main_windows_state["window_pos"]["y"] = pos().y();
-
- main_windows_state["window_size"]["width"] = size().width();
- main_windows_state["window_size"]["height"] = size().height();
-
bool save_key_checked = settings.lookup("general.save_key_checked");
// keyid-list of private checked keys
diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h
index a0f1a5d4..b31e2fcb 100644
--- a/src/ui/main_window/MainWindow.h
+++ b/src/ui/main_window/MainWindow.h
@@ -29,17 +29,18 @@
#ifndef __GPGWIN_H__
#define __GPGWIN_H__
+#include "KeyMgmt.h"
#include "core/GpgConstants.h"
#include "core/function/result_analyse/GpgDecryptResultAnalyse.h"
#include "core/function/result_analyse/GpgEncryptResultAnalyse.h"
#include "core/function/result_analyse/GpgSignResultAnalyse.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/KeyMgmt.h"
#include "ui/dialog/WaitingDialog.h"
#include "ui/dialog/Wizard.h"
-#include "ui/help/AboutDialog.h"
-#include "ui/import_export/KeyUploadDialog.h"
-#include "ui/settings/SettingsDialog.h"
+#include "ui/dialog/help/AboutDialog.h"
+#include "ui/dialog/import_export/KeyUploadDialog.h"
+#include "ui/dialog/settings/SettingsDialog.h"
+#include "ui/main_window/GeneralMainWindow.h"
#include "ui/widgets/FindWidget.h"
#include "ui/widgets/InfoBoardWidget.h"
#include "ui/widgets/TextEdit.h"
@@ -49,10 +50,13 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class MainWindow : public QMainWindow {
+class MainWindow : public GeneralMainWindow {
Q_OBJECT
public:
+ /**
+ *
+ */
struct CryptoMenu {
using OperationType = unsigned int;
@@ -383,6 +387,7 @@ class MainWindow : public QMainWindow {
QAction* about_act_{}; ///< Action to open about dialog
QAction* check_update_act_{}; ///< Action to open about dialog
QAction* translate_act_{}; ///< Action to open about dialog
+ QAction* gnupg_act_{}; ///< Action to open about dialog
QAction* open_settings_act_{}; ///< Action to open settings dialog
QAction* show_key_details_act_{}; ///< Action to open key-details dialog
QAction* start_wizard_act_{}; ///< Action to open the wizard
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index 4ab23a22..526c27c0 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -32,8 +32,8 @@
#include "core/function/gpg/GpgFileOpera.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/thread/Task.h"
+#include "dialog/SignersPicker.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/widgets/SignersPicker.h"
namespace GpgFrontend::UI {
@@ -618,6 +618,9 @@ void MainWindow::SlotFileEncryptSign() {
connect(signersPicker, &SignersPicker::finished, &loop, &QEventLoop::quit);
loop.exec();
+ // return when canceled
+ if (!signersPicker->GetStatus()) return;
+
auto signer_key_ids = signersPicker->GetCheckedSigners();
auto p_signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 0ad52248..f715046c 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -26,7 +26,6 @@
*
*/
-#include <cstddef>
#include <memory>
#include <string>
#include <utility>
@@ -34,15 +33,12 @@
#include "MainWindow.h"
#include "core/GpgConstants.h"
#include "core/GpgModel.h"
-#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgBasicOperator.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
-#include "core/model/GpgKey.h"
-#include "core/thread/TaskRunner.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/help/AboutDialog.h"
-#include "ui/widgets/SignersPicker.h"
+#include "ui/dialog/help/AboutDialog.h"
+#include "dialog/SignersPicker.h"
namespace GpgFrontend::UI {
/**
@@ -427,6 +423,9 @@ void MainWindow::slot_encrypt_sign() {
connect(signersPicker, &SignersPicker::finished, &loop, &QEventLoop::quit);
loop.exec();
+ // return when canceled
+ if (!signersPicker->GetStatus()) return;
+
auto signer_key_ids = signersPicker->GetCheckedSigners();
auto signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp
index 9d81b11c..9061349e 100644
--- a/src/ui/main_window/MainWindowSlotUI.cpp
+++ b/src/ui/main_window/MainWindowSlotUI.cpp
@@ -105,17 +105,17 @@ void MainWindow::slot_open_settings_dialog() {
connect(dialog, &SettingsDialog::finished, this, [&]() -> void {
LOG(INFO) << "Setting Dialog Finished";
- SettingsObject main_windows_state("main_windows_state");
+ SettingsObject general_settings_state("general_settings_state");
- int width = main_windows_state.Check("icon_size").Check("width", 24),
- height = main_windows_state.Check("icon_size").Check("height", 24);
+ int width = general_settings_state.Check("icon_size").Check("width", 24),
+ height = general_settings_state.Check("icon_size").Check("height", 24);
LOG(INFO) << "icon_size" << width << height;
- main_windows_state.Check("info_font_size", 10);
+ general_settings_state.Check("info_font_size", 10);
// icon_style
int s_icon_style =
- main_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
+ general_settings_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
this->setToolButtonStyle(icon_style);
import_button_->setToolButtonStyle(icon_style);
diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp
index 7d798c8b..1470b731 100644
--- a/src/ui/main_window/MainWindowUI.cpp
+++ b/src/ui/main_window/MainWindowUI.cpp
@@ -251,11 +251,17 @@ void MainWindow::create_actions() {
connect(about_act_, &QAction::triggered, this,
[=]() { new AboutDialog(0, this); });
+ gnupg_act_ = new QAction(_("GnuPG"), this);
+ gnupg_act_->setIcon(QIcon(":help.png"));
+ gnupg_act_->setToolTip(_("Information about Gnupg"));
+ connect(gnupg_act_, &QAction::triggered, this,
+ [=]() { new AboutDialog(1, this); });
+
translate_act_ = new QAction(_("Translate"), this);
translate_act_->setIcon(QIcon(":help.png"));
translate_act_->setToolTip(_("Information about translation"));
connect(translate_act_, &QAction::triggered, this,
- [=]() { new AboutDialog(1, this); });
+ [=]() { new AboutDialog(2, this); });
/*
* Check Update Menu
@@ -377,6 +383,7 @@ void MainWindow::create_menus() {
help_menu_->addSeparator();
help_menu_->addAction(check_update_act_);
help_menu_->addAction(translate_act_);
+ help_menu_->addAction(gnupg_act_);
help_menu_->addAction(about_act_);
}
diff --git a/src/ui/struct/SettingsObject.h b/src/ui/struct/SettingsObject.h
index 653a543f..d1e85be5 100644
--- a/src/ui/struct/SettingsObject.h
+++ b/src/ui/struct/SettingsObject.h
@@ -69,7 +69,8 @@ class SettingsObject : public nlohmann::json {
* @param default_value
* @return nlohmann::json&
*/
- nlohmann::json& Check(const std::string& key, const nlohmann::json& default_value);
+ nlohmann::json& Check(const std::string& key,
+ const nlohmann::json& default_value);
/**
* @brief
diff --git a/src/ui/thread/KeyServerImportTask.cpp b/src/ui/thread/KeyServerImportTask.cpp
new file mode 100644
index 00000000..bf3e1822
--- /dev/null
+++ b/src/ui/thread/KeyServerImportTask.cpp
@@ -0,0 +1,64 @@
+/**
+ * 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 <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.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#include "ui/thread/KeyServerImportTask.h"
+
+#include <vector>
+
+GpgFrontend::UI::KeyServerImportTask::KeyServerImportTask(
+ std::string keyserver_url, std::vector<std::string> keyids)
+ : keyserver_url_(std::move(keyserver_url)),
+ keyids_(std::move(keyids)),
+ manager_(new QNetworkAccessManager(this)) {}
+
+void GpgFrontend::UI::KeyServerImportTask::run() {
+ SetFinishAfterRun(false);
+
+ QUrl keyserver_url = QUrl(keyserver_url_.c_str());
+ for (const auto& key_id : keyids_) {
+ QUrl req_url(keyserver_url.scheme() + "://" + keyserver_url.host() +
+ "/pks/lookup?op=get&search=0x" + key_id.c_str() +
+ "&options=mr");
+
+ reply_ = manager_->get(QNetworkRequest(req_url));
+
+ connect(reply_, &QNetworkReply::finished, this,
+ &KeyServerImportTask::dealing_reply_from_server);
+ }
+}
+
+void GpgFrontend::UI::KeyServerImportTask::dealing_reply_from_server() {
+ QByteArray buffer;
+ QNetworkReply::NetworkError network_reply = reply_->error();
+ if (network_reply == QNetworkReply::NoError) {
+ buffer = reply_->readAll();
+ }
+ emit SignalKeyServerImportResult(network_reply, buffer);
+
+ if (result_count_++ == keyids_.size() - 1) {
+ emit SignalTaskFinished();
+ }
+} \ No newline at end of file
diff --git a/src/ui/thread/KeyServerImportTask.h b/src/ui/thread/KeyServerImportTask.h
new file mode 100644
index 00000000..7d3b66c6
--- /dev/null
+++ b/src/ui/thread/KeyServerImportTask.h
@@ -0,0 +1,80 @@
+/**
+ * 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 <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.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef GPGFRONTEND_KEYSERVERIMPORTTASK_H
+#define GPGFRONTEND_KEYSERVERIMPORTTASK_H
+
+#include "GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+class KeyServerImportTask : public Thread::Task {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Key Server Search Task object
+ *
+ * @param keyserver_url
+ * @param search_string
+ */
+ KeyServerImportTask(std::string keyserver_url,
+ std::vector<std::string> keyid);
+
+ signals:
+
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void SignalKeyServerImportResult(QNetworkReply::NetworkError reply,
+ QByteArray buffer);
+
+ protected:
+ /**
+ * @brief
+ *
+ */
+ void run() override;
+
+ private slots:
+
+ /**
+ * @brief
+ *
+ */
+ void dealing_reply_from_server();
+
+ private:
+ std::string keyserver_url_; ///<
+ std::vector<std::string> keyids_; ///<
+ int result_count_ = 0;
+
+ QNetworkAccessManager *manager_; ///<
+ QNetworkReply *reply_; ///<
+};
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_KEYSERVERIMPORTTASK_H \ No newline at end of file
diff --git a/src/ui/thread/KeyServerSearchTask.cpp b/src/ui/thread/KeyServerSearchTask.cpp
new file mode 100644
index 00000000..0090e79d
--- /dev/null
+++ b/src/ui/thread/KeyServerSearchTask.cpp
@@ -0,0 +1,59 @@
+/**
+ * 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 <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.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#include "ui/thread/KeyServerSearchTask.h"
+
+#include <utility>
+
+GpgFrontend::UI::KeyServerSearchTask::KeyServerSearchTask(
+ std::string keyserver_url, std::string search_string)
+ : keyserver_url_(std::move(keyserver_url)),
+ search_string_(std::move(search_string)),
+ manager_(new QNetworkAccessManager(this)) {}
+
+void GpgFrontend::UI::KeyServerSearchTask::run() {
+ SetFinishAfterRun(false);
+
+ QUrl url_from_remote =
+ QString::fromStdString(keyserver_url_) +
+ "/pks/lookup?search=" + QString::fromStdString(search_string_) +
+ "&op=index&options=mr";
+
+ reply_ = manager_->get(QNetworkRequest(url_from_remote));
+
+ connect(reply_, &QNetworkReply::finished, this,
+ &KeyServerSearchTask::dealing_reply_from_server);
+}
+
+void GpgFrontend::UI::KeyServerSearchTask::dealing_reply_from_server() {
+ QByteArray buffer;
+ QNetworkReply::NetworkError network_reply = reply_->error();
+ if (network_reply == QNetworkReply::NoError) {
+ buffer = reply_->readAll();
+ }
+ emit SignalKeyServerSearchResult(network_reply, buffer);
+ emit SignalTaskFinished();
+}
diff --git a/src/ui/thread/KeyServerSearchTask.h b/src/ui/thread/KeyServerSearchTask.h
new file mode 100644
index 00000000..3333e949
--- /dev/null
+++ b/src/ui/thread/KeyServerSearchTask.h
@@ -0,0 +1,76 @@
+/**
+ * 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 <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.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef GPGFRONTEND_KEYSERVERSEARCHTASK_H
+#define GPGFRONTEND_KEYSERVERSEARCHTASK_H
+
+#include "GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+class KeyServerSearchTask : public Thread::Task {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Key Server Search Task object
+ *
+ * @param keyserver_url
+ * @param search_string
+ */
+ KeyServerSearchTask(std::string keyserver_url, std::string search_string);
+
+ signals:
+
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void SignalKeyServerSearchResult(QNetworkReply::NetworkError reply,
+ QByteArray buffer);
+
+ protected:
+ /**
+ * @brief
+ *
+ */
+ void run() override;
+
+ private slots:
+
+ void dealing_reply_from_server();
+
+ private:
+ std::string keyserver_url_; ///<
+ std::string search_string_; ///<
+
+ QNetworkAccessManager *manager_; ///<
+ QNetworkReply *reply_; ///<
+};
+
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_KEYSERVERSEARCHTASK_H \ No newline at end of file
diff --git a/src/ui/thread/ListedKeyServerTestTask.h b/src/ui/thread/ListedKeyServerTestTask.h
index 8edaccb0..aa1bac5e 100644
--- a/src/ui/thread/ListedKeyServerTestTask.h
+++ b/src/ui/thread/ListedKeyServerTestTask.h
@@ -27,11 +27,7 @@
#ifndef GPGFRONTEND_LISTEDKEYSERVERTESTTHREAD_H
#define GPGFRONTEND_LISTEDKEYSERVERTESTTHREAD_H
-#include <vector>
-
#include "GpgFrontendUI.h"
-#include "core/thread/Task.h"
-
namespace GpgFrontend::UI {
/**
diff --git a/src/ui/widgets/FilePage.h b/src/ui/widgets/FilePage.h
index cff395a8..8e278de7 100644
--- a/src/ui/widgets/FilePage.h
+++ b/src/ui/widgets/FilePage.h
@@ -29,8 +29,6 @@
#ifndef GPGFRONTEND_FILEPAGE_H
#define GPGFRONTEND_FILEPAGE_H
-
-
#include "ui/GpgFrontendUI.h"
#include "ui/widgets/InfoBoardWidget.h"
diff --git a/src/ui/widgets/FindWidget.cpp b/src/ui/widgets/FindWidget.cpp
index defcf31c..598d8004 100644
--- a/src/ui/widgets/FindWidget.cpp
+++ b/src/ui/widgets/FindWidget.cpp
@@ -49,9 +49,11 @@ FindWidget::FindWidget(QWidget* parent, PlainTextEditorPage* edit)
this->setLayout(notificationWidgetLayout);
connect(find_edit_, &QLineEdit::textEdited, this, &FindWidget::slot_find);
- connect(find_edit_, &QLineEdit::returnPressed, this, &FindWidget::slot_find_next);
+ connect(find_edit_, &QLineEdit::returnPressed, this,
+ &FindWidget::slot_find_next);
connect(nextButton, &QPushButton::clicked, this, &FindWidget::slot_find_next);
- connect(previousButton, &QPushButton::clicked, this, &FindWidget::slot_find_previous);
+ connect(previousButton, &QPushButton::clicked, this,
+ &FindWidget::slot_find_previous);
connect(closeButton, &QPushButton::clicked, this, &FindWidget::slot_close);
// The timer is necessary for setting the focus
diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp
index ec2971cc..264a67d1 100644
--- a/src/ui/widgets/InfoBoardWidget.cpp
+++ b/src/ui/widgets/InfoBoardWidget.cpp
@@ -28,10 +28,10 @@
#include "ui/widgets/InfoBoardWidget.h"
-#include "ui/SignalStation.h"
#include "core/function/GlobalSettingStation.h"
-#include "ui_InfoBoard.h"
+#include "ui/SignalStation.h"
#include "ui/struct/SettingsObject.h"
+#include "ui_InfoBoard.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/widgets/InfoBoardWidget.h b/src/ui/widgets/InfoBoardWidget.h
index 7f456777..47740456 100644
--- a/src/ui/widgets/InfoBoardWidget.h
+++ b/src/ui/widgets/InfoBoardWidget.h
@@ -31,7 +31,7 @@
#include "PlainTextEditorPage.h"
#include "core/function/result_analyse/GpgVerifyResultAnalyse.h"
-#include "ui/details/VerifyDetailsDialog.h"
+#include "ui/dialog/details/VerifyDetailsDialog.h"
class Ui_InfoBoard;
diff --git a/src/ui/widgets/KeyList.h b/src/ui/widgets/KeyList.h
index 60449ad9..f1c88cc6 100644
--- a/src/ui/widgets/KeyList.h
+++ b/src/ui/widgets/KeyList.h
@@ -32,7 +32,7 @@
#include <utility>
#include "core/GpgContext.h"
-#include "ui/import_export/KeyImportDetailDialog.h"
+#include "ui/dialog/import_export/KeyImportDetailDialog.h"
class Ui_KeyList;
diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp
index 4c936f4f..c6c4982c 100644
--- a/src/ui/widgets/VerifyKeyDetailBox.cpp
+++ b/src/ui/widgets/VerifyKeyDetailBox.cpp
@@ -41,7 +41,7 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
case GPG_ERR_NO_PUBKEY: {
this->setTitle("A Error Signature");
auto* importButton = new QPushButton(_("Import from keyserver"));
- connect(importButton,&QPushButton::clicked, this,
+ connect(importButton, &QPushButton::clicked, this,
&VerifyKeyDetailBox::slot_import_form_key_server);
this->setTitle(QString(_("Key not present with id 0x")) + fpr_.c_str());
diff --git a/src/ui/widgets/VerifyKeyDetailBox.h b/src/ui/widgets/VerifyKeyDetailBox.h
index 57f133d5..6ed9fd52 100644
--- a/src/ui/widgets/VerifyKeyDetailBox.h
+++ b/src/ui/widgets/VerifyKeyDetailBox.h
@@ -29,7 +29,7 @@
#ifndef __VERIFYKEYDETAILBOX_H__
#define __VERIFYKEYDETAILBOX_H__
-#include "ui/import_export/KeyServerImportDialog.h"
+#include "ui/dialog/import_export/KeyServerImportDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
diff --git a/third_party/encoding-detect/TextEncodingDetect.cpp b/third_party/encoding-detect/TextEncodingDetect.cpp
deleted file mode 100644
index 22ae5897..00000000
--- a/third_party/encoding-detect/TextEncodingDetect.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-//
-// Copyright 2015-2016 Jonathan Bennett <[email protected]>
-//
-// https://www.autoitscript.com
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-// Includes
-#include "TextEncodingDetect.h"
-
-using namespace AutoIt::Common;
-
-static const unsigned char TextEncodingDetect_UTF16_BOM_LE[] = {
- (unsigned char)(0xFF), (unsigned char)(0xFE)};
-static const unsigned char TextEncodingDetect_UTF16_BOM_BE[] = {
- (unsigned char)(0xFE), (unsigned char)(0xFF)};
-static const unsigned char TextEncodingDetect_UTF8_BOM[] = {
- (unsigned char)(0xEF), (unsigned char)(0xBB), (unsigned char)(0xBF)};
-
-const unsigned char *TextEncodingDetect::utf16_bom_le_ =
- TextEncodingDetect_UTF16_BOM_LE;
-const unsigned char *TextEncodingDetect::utf16_bom_be_ =
- TextEncodingDetect_UTF16_BOM_BE;
-const unsigned char *TextEncodingDetect::utf8_bom_ =
- TextEncodingDetect_UTF8_BOM;
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructor()
-// Default constructor
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::TextEncodingDetect() {
- // By default, assume nulls can't appear in ANSI/ASCII/UTF8 text files
- null_suggests_binary_ = true;
-
- // Set defaults for utf16 detection based the use of odd/even nulls
- utf16_expected_null_percent_ = 70;
- utf16_unexpected_null_percent_ = 10;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Set the percentages used in utf16 detection using nulls.
-///////////////////////////////////////////////////////////////////////////////
-
-void TextEncodingDetect::SetUtf16UnexpectedNullPercent(int percent) {
- if (percent > 0 && percent < 100) utf16_expected_null_percent_ = percent;
-}
-
-void TextEncodingDetect::SetUtf16ExpectedNullPercent(int percent) {
- if (percent > 0 && percent < 100) utf16_unexpected_null_percent_ = percent;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Simple function to return the length of the BOM for a particular encoding
-// mode.
-///////////////////////////////////////////////////////////////////////////////
-
-int TextEncodingDetect::GetBOMLengthFromEncodingMode(Encoding encoding) {
- int length = 0;
-
- if (encoding == UTF16_BE_BOM || encoding == UTF16_LE_BOM)
- length = 2;
- else if (encoding == UTF8_BOM)
- length = 3;
-
- return length;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains a valid BOM and returns the encoding based on it.
-// Returns encoding "None" if there is no BOM.
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::CheckBOM(
- const unsigned char *pBuffer, size_t size) {
- // Check for BOM
- if (size >= 2 && pBuffer[0] == utf16_bom_le_[0] &&
- pBuffer[1] == utf16_bom_le_[1]) {
- return UTF16_LE_BOM;
- } else if (size >= 2 && pBuffer[0] == utf16_bom_be_[0] &&
- pBuffer[1] == utf16_bom_be_[1]) {
- return UTF16_BE_BOM;
- } else if (size >= 3 && pBuffer[0] == utf8_bom_[0] &&
- pBuffer[1] == utf8_bom_[1] && pBuffer[2] == utf8_bom_[2]) {
- return UTF8_BOM;
- } else {
- return None;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains a valid BOM and returns the encoding based on it.
-// If it doesn't contain a BOM it tries to guess what the encoding is or
-// "None" if it just looks like binary data.
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::DetectEncoding(
- const unsigned char *pBuffer, size_t size) const {
- // First check if we have a BOM and return that if so
- Encoding encoding = CheckBOM(pBuffer, size);
- if (encoding != None) return encoding;
-
- // Now check for valid UTF8
- encoding = CheckUTF8(pBuffer, size);
- if (encoding != None) return encoding;
-
- // Now try UTF16
- encoding = CheckUTF16NewlineChars(pBuffer, size);
- if (encoding != None) return encoding;
-
- encoding = CheckUTF16ASCII(pBuffer, size);
- if (encoding != None) return encoding;
-
- // ANSI or None (binary) then
- if (!DoesContainNulls(pBuffer, size))
- return ANSI;
- else {
- // Found a null, return based on the preference in null_suggests_binary_
- if (null_suggests_binary_)
- return None;
- else
- return ANSI;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains valid utf8. Returns:
-// None - not valid utf8
-// UTF8_NOBOM - valid utf8 encodings and multibyte sequences
-// ASCII - Only data in the 0-127 range.
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::CheckUTF8(
- const unsigned char *pBuffer, size_t size) const {
- // UTF8 Valid sequences
- // 0xxxxxxx ASCII
- // 110xxxxx 10xxxxxx 2-byte
- // 1110xxxx 10xxxxxx 10xxxxxx 3-byte
- // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 4-byte
- //
- // Width in UTF8
- // Decimal Width
- // 0-127 1 byte
- // 194-223 2 bytes
- // 224-239 3 bytes
- // 240-244 4 bytes
- //
- // Subsequent chars are in the range 128-191
-
- bool only_saw_ascii_range = true;
- size_t pos = 0;
- int more_chars;
-
- while (pos < size) {
- unsigned char ch = pBuffer[pos++];
-
- if (ch == 0 && null_suggests_binary_) {
- return None;
- } else if (ch <= 127) {
- // 1 byte
- more_chars = 0;
- } else if (ch >= 194 && ch <= 223) {
- // 2 Byte
- more_chars = 1;
- } else if (ch >= 224 && ch <= 239) {
- // 3 Byte
- more_chars = 2;
- } else if (ch >= 240 && ch <= 244) {
- // 4 Byte
- more_chars = 3;
- } else {
- return None; // Not utf8
- }
-
- // Check secondary chars are in range if we are expecting any
- while (more_chars && pos < size) {
- only_saw_ascii_range = false; // Seen non-ascii chars now
-
- ch = pBuffer[pos++];
- if (ch < 128 || ch > 191) return None; // Not utf8
-
- --more_chars;
- }
- }
-
- // If we get to here then only valid UTF-8 sequences have been processed
-
- // If we only saw chars in the range 0-127 then we can't assume UTF8 (the
- // caller will need to decide)
- if (only_saw_ascii_range)
- return ASCII;
- else
- return UTF8_NOBOM;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains text that looks like utf16 by scanning for
-// newline chars that would be present even in non-english text.
-// Returns:
-// None - not valid utf16
-// UTF16_LE_NOBOM - looks like utf16 le
-// UTF16_BE_NOBOM - looks like utf16 be
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::CheckUTF16NewlineChars(
- const unsigned char *pBuffer, size_t size) {
- if (size < 2) return None;
-
- // Reduce size by 1 so we don't need to worry about bounds checking for pairs
- // of bytes
- size--;
-
- int le_control_chars = 0;
- int be_control_chars = 0;
- unsigned char ch1, ch2;
-
- size_t pos = 0;
- while (pos < size) {
- ch1 = pBuffer[pos++];
- ch2 = pBuffer[pos++];
-
- if (ch1 == 0) {
- if (ch2 == 0x0a || ch2 == 0x0d) ++be_control_chars;
- } else if (ch2 == 0) {
- if (ch1 == 0x0a || ch1 == 0x0d) ++le_control_chars;
- }
-
- // If we are getting both LE and BE control chars then this file is not
- // utf16
- if (le_control_chars && be_control_chars) return None;
- }
-
- if (le_control_chars)
- return UTF16_LE_NOBOM;
- else if (be_control_chars)
- return UTF16_BE_NOBOM;
- else
- return None;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains text that looks like utf16. This is done based
-// the use of nulls which in ASCII/script like text can be useful to identify.
-// Returns:
-// None - not valid utf16
-// UTF16_LE_NOBOM - looks like utf16 le
-// UTF16_BE_NOBOM - looks like utf16 be
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::CheckUTF16ASCII(
- const unsigned char *pBuffer, size_t size) const {
- int num_odd_nulls = 0;
- int num_even_nulls = 0;
-
- // Get even nulls
- size_t pos = 0;
- while (pos < size) {
- if (pBuffer[pos] == 0) num_even_nulls++;
-
- pos += 2;
- }
-
- // Get odd nulls
- pos = 1;
- while (pos < size) {
- if (pBuffer[pos] == 0) num_odd_nulls++;
-
- pos += 2;
- }
-
- double even_null_threshold = (num_even_nulls * 2.0) / size;
- double odd_null_threshold = (num_odd_nulls * 2.0) / size;
- double expected_null_threshold = utf16_expected_null_percent_ / 100.0;
- double unexpected_null_threshold = utf16_unexpected_null_percent_ / 100.0;
-
- // Lots of odd nulls, low number of even nulls
- if (even_null_threshold < unexpected_null_threshold &&
- odd_null_threshold > expected_null_threshold)
- return UTF16_LE_NOBOM;
-
- // Lots of even nulls, low number of odd nulls
- if (odd_null_threshold < unexpected_null_threshold &&
- even_null_threshold > expected_null_threshold)
- return UTF16_BE_NOBOM;
-
- // Don't know
- return None;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains any nulls. Used to check for binary vs text data.
-///////////////////////////////////////////////////////////////////////////////
-
-bool TextEncodingDetect::DoesContainNulls(const unsigned char *pBuffer,
- size_t size) {
- size_t pos = 0;
- while (pos < size) {
- if (pBuffer[pos++] == 0) return true;
- }
-
- return false;
-}
diff --git a/third_party/encoding-detect/TextEncodingDetect.h b/third_party/encoding-detect/TextEncodingDetect.h
deleted file mode 100644
index 6d861716..00000000
--- a/third_party/encoding-detect/TextEncodingDetect.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#pragma once
-#ifndef TEXT_ENCODING_DETECT_H_
-#define TEXT_ENCODING_DETECT_H_
-
-//
-// Copyright 2015 Jonathan Bennett <[email protected]>
-//
-// https://www.autoitscript.com
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-// Includes
-#include <stddef.h>
-
-namespace AutoIt::Common {
-class TextEncodingDetect {
- public:
- enum Encoding {
- None, // Unknown or binary
- ANSI, // 0-255
- ASCII, // 0-127
- UTF8_BOM, // UTF8 with BOM
- UTF8_NOBOM, // UTF8 without BOM
- UTF16_LE_BOM, // UTF16 LE with BOM
- UTF16_LE_NOBOM, // UTF16 LE without BOM
- UTF16_BE_BOM, // UTF16-BE with BOM
- UTF16_BE_NOBOM, // UTF16-BE without BOM
- };
-
- TextEncodingDetect();
- ~TextEncodingDetect() = default;
-
- static Encoding CheckBOM(
- const unsigned char *pBuffer,
- size_t size); // Just check if there is a BOM and return
- Encoding DetectEncoding(const unsigned char *pBuffer, size_t size)
- const; // Check BOM and also guess if there is no BOM
- static int GetBOMLengthFromEncodingMode(
- Encoding encoding); // Just return the BOM length of a given mode
-
- void SetNullSuggestsBinary(bool null_suggests_binary) {
- null_suggests_binary_ = null_suggests_binary;
- }
- void SetUtf16UnexpectedNullPercent(int percent);
- void SetUtf16ExpectedNullPercent(int percent);
-
- private:
- TextEncodingDetect(const TextEncodingDetect &);
- const TextEncodingDetect &operator=(const TextEncodingDetect &);
-
- static const unsigned char *utf16_bom_le_;
- static const unsigned char *utf16_bom_be_;
- static const unsigned char *utf8_bom_;
-
- bool null_suggests_binary_;
- int utf16_expected_null_percent_;
- int utf16_unexpected_null_percent_;
-
- Encoding CheckUTF8(const unsigned char *pBuffer,
- size_t size) const; // Check for valid UTF8 with no BOM
- static Encoding CheckUTF16NewlineChars(
- const unsigned char *pBuffer,
- size_t size); // Check for valid UTF16 with no BOM via control chars
- Encoding CheckUTF16ASCII(const unsigned char *pBuffer, size_t size)
- const; // Check for valid UTF16 with no BOM via null distribution
- static bool DoesContainNulls(const unsigned char *pBuffer,
- size_t size); // Check for nulls
-};
-
-} // namespace AutoIt::Common
-
-//////////////////////////////////////////////////////////////////////
-
-#endif
diff --git a/third_party/gpgme b/third_party/gpgme
-Subproject ab1d4ef580794a86da754d516db35091f6997e2
+Subproject cc37447b625b45efb5c94c40461084460f03f24