diff options
author | saturneric <[email protected]> | 2025-04-18 17:35:45 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2025-04-18 17:35:45 +0000 |
commit | d115562e6cb231356ef87a2ab86f4da1159a9e41 (patch) | |
tree | c079dd49cf0a991b17cb96ad4f05d558567908c0 /src | |
parent | feat: add more basic env checks at init (diff) | |
download | GpgFrontend-d115562e6cb231356ef87a2ab86f4da1159a9e41.tar.gz GpgFrontend-d115562e6cb231356ef87a2ab86f4da1159a9e41.zip |
fix: issues found on macos
Diffstat (limited to 'src')
-rw-r--r-- | src/core/GpgCoreInit.cpp | 11 | ||||
-rw-r--r-- | src/core/function/gpg/GpgContext.cpp | 4 | ||||
-rw-r--r-- | src/core/utils/GpgUtils.cpp | 2 | ||||
-rw-r--r-- | src/ui/UserInterfaceUtils.cpp | 7 | ||||
-rw-r--r-- | src/ui/dialog/controller/GnuPGControllerDialog.cpp | 3 | ||||
-rw-r--r-- | src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp | 1 | ||||
-rw-r--r-- | src/ui/dialog/keypair_details/KeyPairSubkeyTab.h | 100 | ||||
-rw-r--r-- | src/ui/main_window/MainWindow.cpp | 19 |
8 files changed, 75 insertions, 72 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 1735c316..561c3e24 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -429,10 +429,6 @@ void EnsureGpgAgentConfHasPinentry(GpgContext& ctx) { } config_file.close(); LOG_D() << "updated gpg-agent.conf with pinentry:" << pinentry_path; - - // reload configure - GpgAdvancedOperator::GetInstance(ctx.GetChannel()) - .ReloadAllGpgComponents(); } else { LOG_W() << "failed to write to gpg-agent.conf"; } @@ -612,7 +608,8 @@ auto InitGpgFrontendCore(CoreInitArgs args) -> int { return -1; } -#if defined(__linux__) +#if !(defined(_WIN32) || defined(WIN32)) + // auto config pinentry-program EnsureGpgAgentConfHasPinentry(default_ctx); #endif @@ -669,6 +666,10 @@ auto InitGpgFrontendCore(CoreInitArgs args) -> int { EnsureGpgAgentConfHasPinentry(ctx); #endif +#if defined(__APPLE__) && defined(__MACH__) + EnsureGpgAgentConfHasPinentry(ctx); +#endif + if (!GpgKeyGetter::GetInstance(ctx.GetChannel()).FlushKeyCache()) { LOG_E() << "gpgme context init key cache failed, index:" << channel_index; diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp index de450356..ca00c452 100644 --- a/src/core/function/gpg/GpgContext.cpp +++ b/src/core/function/gpg/GpgContext.cpp @@ -43,7 +43,7 @@ #include "core/utils/GpgUtils.h" #include "core/utils/MemoryUtils.h" -#ifdef _WIN32 +#if defined(_WIN32) || defined(WIN32) #include <windows.h> #endif @@ -408,7 +408,7 @@ class GpgContext::Impl { auto configuration_name = info_split_list[0].trimmed(); auto configuration_value = info_split_list[1].trimmed(); -#ifdef __MINGW32__ +#if defined(_WIN32) || defined(WIN32) // replace some special substrings on windows // platform configuration_value.replace("%3a", ":"); diff --git a/src/core/utils/GpgUtils.cpp b/src/core/utils/GpgUtils.cpp index 8b2abeb7..d8f147bb 100644 --- a/src/core/utils/GpgUtils.cpp +++ b/src/core/utils/GpgUtils.cpp @@ -462,6 +462,8 @@ auto GPGFRONTEND_CORE_EXPORT DecidePinentry() -> QString { QStringList preferred_list = {"pinentry-gnome3", "pinentry-qt" "pinentry-gtk2"}; +#elif defined(__APPLE__) && defined(__MACH__) + QStringList preferred_list = {"pinentry-mac", "pinentry-qt"}; #else QStringList preferred_list = {"pinentry-qt"}; #endif diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index b5747b9f..dbc3f7e3 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -169,10 +169,9 @@ void CommonUtils::RaiseMessageBox(QWidget *parent, GpgError err) { void CommonUtils::RaiseMessageBoxNotSupported(QWidget *parent) { QMessageBox::warning( - parent, QObject::tr("Operation Not Supported"), - QObject::tr( - "The current GnuPG version is too low and does not support this " - "operation. Please upgrade your GnuPG version to continue.")); + parent, tr("Operation Not Supported"), + tr("The current GnuPG version is too low and does not support this " + "operation. Please upgrade your GnuPG version to continue.")); } void CommonUtils::RaiseFailureMessageBox(QWidget *parent, GpgError err, diff --git a/src/ui/dialog/controller/GnuPGControllerDialog.cpp b/src/ui/dialog/controller/GnuPGControllerDialog.cpp index 5dacae65..3f21b57b 100644 --- a/src/ui/dialog/controller/GnuPGControllerDialog.cpp +++ b/src/ui/dialog/controller/GnuPGControllerDialog.cpp @@ -333,7 +333,8 @@ auto GnuPGControllerDialog::check_custom_gnupg_path(QString path) -> bool { QMessageBox::critical(this, tr("Illegal GnuPG Path"), tr("Target GnuPG Path is not an absolute path.")); } -#ifdef __MINGW32__ + +#if defined(_WIN32) || defined(WIN32) QFileInfo const gpgconf_info(path + "/gpgconf.exe"); #else QFileInfo const gpgconf_info(path + "/gpgconf"); diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp index b8942b94..64e4d029 100644 --- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp +++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp @@ -31,7 +31,6 @@ #include "core/function/gpg/GpgKeyGetter.h" #include "core/function/gpg/GpgKeyImportExporter.h" #include "core/function/gpg/GpgKeyManager.h" -#include "core/function/gpg/GpgKeyOpera.h" #include "core/utils/CommonUtils.h" #include "core/utils/GpgUtils.h" #include "core/utils/IOUtils.h" diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h index 3d9eeb50..c7d7a08a 100644 --- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h +++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h @@ -47,55 +47,13 @@ class KeyPairSubkeyTab : public QWidget { */ KeyPairSubkeyTab(int channel, GpgKeyPtr key, QWidget* parent); - private: - /** - * @brief Create a subkey list object - * - */ - void create_subkey_list(); - - /** - * @brief Create a subkey opera menu object - * - */ - void create_subkey_opera_menu(); - + protected: /** - * @brief Get the selected subkey object + * @brief * - * @return const GpgSubKey& + * @param event */ - auto get_selected_subkey() -> const GpgSubKey&; - - int current_gpg_context_channel_; - GpgKeyPtr key_; ///< - QTableWidget* subkey_list_{}; ///< - QContainer<GpgSubKey> buffered_subkeys_; ///< - - QGroupBox* list_box_; ///< - QGroupBox* detail_box_; ///< - - QMenu* subkey_opera_menu_{}; ///< - - QLabel* key_type_var_label_; - QLabel* key_size_var_label_; ///< Label containing the keys key size - QLabel* expire_var_label_; ///< Label containing the keys expiration date - QLabel* revoke_var_label_; - QLabel* created_var_label_; ///< Label containing the keys creation date - QLabel* algorithm_var_label_; ///< Label containing the keys algorithm - QLabel* algorithm_detail_var_label_; ///< - QLabel* key_id_var_label_; ///< Label containing the keys keyid - QLabel* fingerprint_var_label_; ///< Label containing the keys fingerprint - QLabel* usage_var_label_; ///< - QLabel* master_key_exist_var_label_; ///< - QLabel* card_key_label_; ///< - - QPushButton* export_subkey_button_; - QAction* export_subkey_act_; - - QAction* edit_subkey_act_; - QAction* delete_subkey_act_; - QAction* revoke_subkey_act_; + void contextMenuEvent(QContextMenuEvent* event) override; private slots: @@ -161,13 +119,55 @@ class KeyPairSubkeyTab : public QWidget { */ void SignalKeyDatabaseRefresh(); - protected: + private: + int current_gpg_context_channel_; + GpgKeyPtr key_; ///< + QTableWidget* subkey_list_{}; ///< + QContainer<GpgSubKey> buffered_subkeys_; ///< + + QGroupBox* list_box_; ///< + QGroupBox* detail_box_; ///< + + QMenu* subkey_opera_menu_{}; ///< + + QLabel* key_type_var_label_; + QLabel* key_size_var_label_; ///< Label containing the keys key size + QLabel* expire_var_label_; ///< Label containing the keys expiration date + QLabel* revoke_var_label_; + QLabel* created_var_label_; ///< Label containing the keys creation date + QLabel* algorithm_var_label_; ///< Label containing the keys algorithm + QLabel* algorithm_detail_var_label_; ///< + QLabel* key_id_var_label_; ///< Label containing the keys keyid + QLabel* fingerprint_var_label_; ///< Label containing the keys fingerprint + QLabel* usage_var_label_; ///< + QLabel* master_key_exist_var_label_; ///< + QLabel* card_key_label_; ///< + + QPushButton* export_subkey_button_; + QAction* export_subkey_act_; + + QAction* edit_subkey_act_; + QAction* delete_subkey_act_; + QAction* revoke_subkey_act_; + /** - * @brief + * @brief Create a subkey list object * - * @param event */ - void contextMenuEvent(QContextMenuEvent* event) override; + void create_subkey_list(); + + /** + * @brief Create a subkey opera menu object + * + */ + void create_subkey_opera_menu(); + + /** + * @brief Get the selected subkey object + * + * @return const GpgSubKey& + */ + auto get_selected_subkey() -> const GpgSubKey&; }; } // namespace GpgFrontend::UI diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index 4b5c71f5..8c8fd55e 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -117,19 +117,20 @@ void MainWindow::Init() noexcept { &UISignalStation::SignalMainWindowOpenFile, this, &MainWindow::SlotOpenFile); -#if defined(__linux__) +#if !(defined(_WIN32) || defined(WIN32)) connect(this, &MainWindow::SignalLoaded, this, [=]() { QTimer::singleShot(3000, [self = QPointer<MainWindow>(this)]() { if (self != nullptr && DecidePinentry().isEmpty() && !IsFlatpakENV()) { QMessageBox::warning( - self, QObject::tr("Pinentry Not Found"), - QObject::tr( - "No suitable pinentry program was found on your system.\n\n" - "Please install 'pinentry-qt' or another compatible pinentry " - "(e.g., pinentry-gnome3, pinentry-gtk2).\n\n" - "Without it, GnuPG cannot prompt for passwords.\n\n" - "Once you have installed it, please restart GpgFrontend. " - "The configuration file will be updated automatically.")); + self, tr("GUI Pinentry Not Found"), + tr("No suitable *graphical* Pinentry program was found on your " + "system.\n\n" + "Please install a GUI-based Pinentry (e.g., 'pinentry-qt', " + "'pinentry-gnome3', or 'pinentry-mac' on macOS).\n\n" + "Without a GUI Pinentry, GnuPG cannot prompt you for " + "passwords or passphrases.\n\n" + "After installing it, please restart GpgFrontend. The " + "configuration file will be updated automatically.")); } }); }); |