diff options
author | saturneric <[email protected]> | 2024-01-16 13:35:59 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-16 13:35:59 +0000 |
commit | 620ae9e7c1a8b2db2515c080416cb592066e5fec (patch) | |
tree | 900f3e55118aa2a5049d99dd743d3e595016fc7b /src | |
parent | fix: make task and threading system safer (diff) | |
download | GpgFrontend-620ae9e7c1a8b2db2515c080416cb592066e5fec.tar.gz GpgFrontend-620ae9e7c1a8b2db2515c080416cb592066e5fec.zip |
refactor: remove libgettext from project
Diffstat (limited to 'src')
70 files changed, 1557 insertions, 1805 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cedb2dae..1b06ec33 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,7 +58,7 @@ find_package(OpenSSL REQUIRED) # Introduce Qt # Support Qt version: 6.x -find_package(Qt6 6 COMPONENTS Core Test Widgets PrintSupport Network Core5Compat Concurrent REQUIRED) +find_package(Qt6 6 COMPONENTS Core Test Widgets PrintSupport Network Core5Compat LinguistTools REQUIRED) # Qt configuration set(CMAKE_AUTOMOC ON) @@ -128,50 +128,6 @@ if (BUILD_APPLICATION) endif () endif () -# Get ALL SOURCE FILES -file(GLOB_RECURSE ALL_SOURCE_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/src/*.cpp) - -# i18n -message(STATUS "Build Multiply Languages Support") -# Set Translation Files -find_package(Gettext REQUIRED) -FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) -FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext) - -set(LOCALE_OUTPUT_PATH ${RESOURCE_OUTPUT_DIRECTORY}/locales) - -if (NOT GETTEXT_MSGFMT_EXECUTABLE OR NOT GETTEXT_XGETTEXT_EXECUTABLE) - message(ERROR "msgfmt or xgettext not found. Translations will *not* be installed") -else() - message(STATUS "Setting target translations") - add_custom_target(translations) - set(OUTPUT_POT_PATH ${CMAKE_SOURCE_DIR}/resource/lfs/locale/template/${PROJECT_NAME}.pot) - add_custom_command( - TARGET translations - COMMAND find ${CMAKE_SOURCE_DIR}/src -iname \"*.cpp\" | xargs xgettext --package-name=${PROJECT_NAME} --copyright-holder=Saturneric --package-version=${PROJECT_VERSION} [email protected] --add-comments="/*" --c++ -k_ -o ${OUTPUT_POT_PATH} - ) - - file(GLOB ALL_PO_FILES ${CMAKE_SOURCE_DIR}/resource/lfs/locale/po/*.po) - SET(GMO_FILES) - - foreach (_poFile ${ALL_PO_FILES}) - GET_FILENAME_COMPONENT(_poFileName ${_poFile} NAME) - string(REGEX REPLACE "\\.[^.]*$" "" _langName ${_poFileName}) - message(STATUS "GNU gettext po file ${_langName}") - make_directory(${RESOURCE_OUTPUT_DIRECTORY}/locales) - make_directory(${RESOURCE_OUTPUT_DIRECTORY}/locales/${_langName}/LC_MESSAGES) - add_custom_command( - TARGET translations - COMMAND echo Processing po LANG ${_langName} - ) - add_custom_command( - TARGET translations - COMMAND msgfmt --check --verbose --output-file ${LOCALE_OUTPUT_PATH}/${_langName}/LC_MESSAGES/GpgFrontend.mo ${_poFile} - ) - endforeach () -endif () - - if (BASIC_ENV_CONFIG) # Set Build Information configure_file(${CMAKE_SOURCE_DIR}/src/GpgFrontend.h.in ${CMAKE_SOURCE_DIR}/src/GpgFrontend.h @ONLY) @@ -187,9 +143,6 @@ if (BUILD_APPLICATION) file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/resource/lfs/icons DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/TRANSLATORS DESTINATION ${RESOURCE_OUTPUT_DIRECTORY} FOLLOW_SYMLINK_CHAIN) - if (GPG_STANDALONE_MODE) - file(COPY ${CMAKE_SOURCE_DIR}/resource/gpg1.4 DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) - endif () endif () if (BUILD_APPLICATION) @@ -352,7 +305,6 @@ endif () if (BUILD_APPLICATION) set(RESOURCE_FILES ${CMAKE_SOURCE_DIR}/gpgfrontend.qrc ${APP_ICON_RESOURCE_WINDOWS} ${QON_QM_FILES}) add_custom_target(resources ALL DEPENDS ${RESOURCE_FILES}) - add_dependencies(resources translations) endif () if (BUILD_APPLICATION) @@ -480,14 +432,9 @@ if (BUILD_APPLICATION) target_link_libraries(${AppName} crypto) elseif (APPLE) message(STATUS "Link Application Library For macOS") - target_link_libraries(${AppName} intl) else () message(STATUS "Link Application Library For Linux") target_link_libraries(${AppName} crypto pthread) - # link for freebsd - if(FREEBSD) - target_link_libraries(${AppName} intl) - endif() # issue on filesystem support of gcc if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 9.0) target_link_libraries(${AppName} stdc++fs) @@ -498,6 +445,21 @@ endif () # using c++ standard 17 target_compile_features(${AppName} PUBLIC cxx_std_17) +# build i18n support +set(LOCALE_TS_PATH ${CMAKE_SOURCE_DIR}/resource/lfs/locale/ts) +set(LOCALE_OUTPUT_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/locales) +set(TS_FILES "${LOCALE_TS_PATH}/GpgFrontend.de_DE.ts" + "${LOCALE_TS_PATH}/GpgFrontend.fr_FR.ts" + "${LOCALE_TS_PATH}/GpgFrontend.zh_CN.ts" + "${LOCALE_TS_PATH}/GpgFrontend.zh_TW.ts" + "${LOCALE_TS_PATH}/GpgFrontend.it_IT.ts") +file(GLOB_RECURSE ALL_SOURCE_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/src/*.cpp) +qt_add_translations(${AppName} + RESOURCE_PREFIX "/i18n" + TS_FILES ${TS_FILES} + SOURCES ${ALL_SOURCE_FILES} + INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/src) + # if building linux package if (LINUX AND LINUX_INSTALL_SOFTWARE) include(GNUInstallDirs) diff --git a/src/GpgFrontend.h.in b/src/GpgFrontend.h.in index 29f2ab1c..56173bbd 100644 --- a/src/GpgFrontend.h.in +++ b/src/GpgFrontend.h.in @@ -33,20 +33,6 @@ #include <winsock2.h> #endif -// i18n support -#include <libintl.h> -#define _(String) gettext(String) -#define gettext_noop(String) String -#define N_(String) gettext_noop(String) - -// fix macro bugs in mingw -#ifdef WINDOWS -#include <clocale> -#undef vsnprintf -#undef sprintf -#undef snprintf -#endif - // build info #define PROJECT_NAME "@CMAKE_PROJECT_NAME@" #define OS_PLATFORM "@OS_PLATFORM@" diff --git a/src/cmd.cpp b/src/cmd.cpp index a8a5b9d9..e19ad218 100644 --- a/src/cmd.cpp +++ b/src/cmd.cpp @@ -41,18 +41,21 @@ namespace GpgFrontend { auto PrintVersion() -> int { - std::cout << PROJECT_NAME << " " - << "v" << VERSION_MAJOR << "." << VERSION_MINOR << "." - << VERSION_PATCH << '\n'; - std::cout - << "Copyright (C) 2021 Saturneric <[email protected]>" << '\n' - << _("This is free software; see the source for copying conditions.") - << '\n' - << '\n'; + QTextStream stream(stdin); + stream << PROJECT_NAME << " " + << "v" << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_PATCH + << '\n'; + stream << "Copyright (C) 2021 Saturneric <[email protected]>" << '\n' + << QObject::tr( + "This is free software; see the source for copying conditions.") + << '\n' + << '\n'; - std::cout << _("Build Timestamp: ") << BUILD_TIMESTAMP << '\n' - << _("Build Version: ") << BUILD_VERSION << '\n' - << _("Source Code Version: ") << GIT_VERSION << '\n'; + stream << QObject::tr("Build Timestamp: ") << BUILD_TIMESTAMP << '\n' + << QObject::tr("Build Version: ") << BUILD_VERSION << '\n' + << QObject::tr("Source Code Version: ") << GIT_VERSION << '\n'; + + stream << Qt::endl; return 0; } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 22b2c01b..d51ec6d1 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -48,11 +48,6 @@ if(NOT APPLE) target_link_libraries(gpgfrontend_core PUBLIC mimalloc) endif() -# link third-party libraries -if (NOT LINUX) - target_link_libraries(gpgfrontend_core PUBLIC intl) -endif () - # qt-aes target_sources(gpgfrontend_core PRIVATE ${CMAKE_SOURCE_DIR}/third_party/qt-aes/qaesencryption.cpp) @@ -82,7 +77,7 @@ target_include_directories(gpgfrontend_core PRIVATE ${LibArchive_INCLUDE_DIR}) target_link_libraries(gpgfrontend_core PRIVATE archive) # link Qt core -target_link_libraries(gpgfrontend_core PUBLIC Qt6::Core Qt6::Concurrent) +target_link_libraries(gpgfrontend_core PUBLIC Qt6::Core) # set up pch target_precompile_headers(gpgfrontend_core diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 806e1fe2..74e944f8 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -193,7 +193,7 @@ void InitGpgFrontendCore(CoreInitArgs args) { // initialize library gpgme if (!InitGpgME()) { CoreSignalStation::GetInstance()->SignalBadGnupgEnv( - _("GpgME inilization failed")); + QObject::tr("GpgME inilization failed")); return; } @@ -317,7 +317,7 @@ void InitGpgFrontendCore(CoreInitArgs args) { if (!ctx.Good()) { GF_CORE_LOG_ERROR("default gnupg context init error, abort"); CoreSignalStation::GetInstance()->SignalBadGnupgEnv( - _("GpgME Context inilization failed")); + QObject::tr("GpgME Context inilization failed")); return -1; } Module::UpsertRTValue("core", "env.state.ctx", 1); @@ -326,7 +326,7 @@ void InitGpgFrontendCore(CoreInitArgs args) { if (args.load_default_gpg_context) { if (!GpgKeyGetter::GetInstance().FlushKeyCache()) { CoreSignalStation::GetInstance()->SignalBadGnupgEnv( - _("Gpg Key Detabase inilization failed")); + QObject::tr("Gpg Key Detabase inilization failed")); }; } GF_CORE_LOG_INFO( @@ -380,7 +380,7 @@ void InitGpgFrontendCore(CoreInitArgs args) { "core_init_task"); QObject::connect(task, &Thread::Task::SignalTaskEnd, []() { - + }); // start the thread to check ctx and gnupg state diff --git a/src/core/GpgFrontendCore.h b/src/core/GpgFrontendCore.h index 3aaa8ab4..14b1f878 100644 --- a/src/core/GpgFrontendCore.h +++ b/src/core/GpgFrontendCore.h @@ -33,8 +33,6 @@ // std #include <cstdint> -#include <filesystem> -#include <string> #include <vector> // spdlog library configuration diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp index d24e2894..a25bb52c 100644 --- a/src/core/function/GlobalSettingStation.cpp +++ b/src/core/function/GlobalSettingStation.cpp @@ -182,7 +182,7 @@ class GlobalSettingStation::Impl { app_resource_path_ + "/locales"; ///< Program Data Location #endif - bool portable_mode_ = true; ///< + bool portable_mode_ = false; ///< QString app_portable_config_path_ = working_path_ + "/config.ini"; ///< take effect only in portable mode diff --git a/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp b/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp index e52394b3..5d0ce920 100644 --- a/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp +++ b/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp @@ -38,17 +38,17 @@ GpgFrontend::GpgDecryptResultAnalyse::GpgDecryptResultAnalyse( void GpgFrontend::GpgDecryptResultAnalyse::doAnalyse() { auto *result = result_.GetRaw(); - stream_ << "# " << _("Decrypt Operation") << " "; + stream_ << "# " << tr("Decrypt Operation") << " "; if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR) { - stream_ << "- " << _("Success") << " " << Qt::endl; + stream_ << "- " << tr("Success") << " " << Qt::endl; } else { - stream_ << "- " << _("Failed") << ": " << gpgme_strerror(error_) + stream_ << "- " << tr("Failed") << ": " << gpgme_strerror(error_) << Qt::endl; setStatus(-1); if (result != nullptr && result->unsupported_algorithm != nullptr) { stream_ << Qt::endl; - stream_ << "## " << _("Unsupported Algo") << ": " + stream_ << "## " << tr("Unsupported Algo") << ": " << result->unsupported_algorithm << Qt::endl; } } @@ -56,45 +56,45 @@ void GpgFrontend::GpgDecryptResultAnalyse::doAnalyse() { if (result != nullptr && result->recipients != nullptr) { stream_ << Qt::endl; - stream_ << "## " << _("Gernal State") << ": " << Qt::endl; + stream_ << "## " << tr("Gernal State") << ": " << Qt::endl; if (result->file_name != nullptr) { - stream_ << "- " << _("File Name") << ": " << result->file_name + stream_ << "- " << tr("File Name") << ": " << result->file_name << Qt::endl; } - stream_ << "- " << _("MIME") << ": " - << (result->is_mime == 0 ? _("false") : _("true")) << Qt::endl; + stream_ << "- " << tr("MIME") << ": " + << (result->is_mime == 0 ? tr("false") : tr("true")) << Qt::endl; - stream_ << "- " << _("Message Integrity Protection") << ": " - << (result->legacy_cipher_nomdc == 0 ? _("true") : _("false")) + stream_ << "- " << tr("Message Integrity Protection") << ": " + << (result->legacy_cipher_nomdc == 0 ? tr("true") : tr("false")) << Qt::endl; if (result->legacy_cipher_nomdc == 1) setStatus(0); /// < unsafe situation if (result->symkey_algo != nullptr) { - stream_ << "- " << _("Symmetric Encryption Algorithm") << ": " + stream_ << "- " << tr("Symmetric Encryption Algorithm") << ": " << result->symkey_algo << Qt::endl; } if (result->session_key != nullptr) { - stream_ << "- " << _("Session Key") << ": " << result->session_key + stream_ << "- " << tr("Session Key") << ": " << result->session_key << Qt::endl; } - stream_ << "- " << _("German Encryption Standards") << ": " - << (result->is_de_vs == 0 ? _("false") : _("true")) << Qt::endl; + stream_ << "- " << tr("German Encryption Standards") << ": " + << (result->is_de_vs == 0 ? tr("false") : tr("true")) << Qt::endl; stream_ << Qt::endl << Qt::endl; auto *recipient = result->recipients; auto index = 0; if (recipient != nullptr) { - stream_ << "## " << _("Recipient(s)") << ": " << Qt::endl << Qt::endl; + stream_ << "## " << tr("Recipient(s)") << ": " << Qt::endl << Qt::endl; } while (recipient != nullptr) { // check if (recipient->keyid == nullptr) return; - stream_ << "### " << _("Recipient") << " [" << ++index << "]: "; + stream_ << "### " << tr("Recipient") << " [" << ++index << "]: "; print_recipient(stream_, recipient); stream_ << Qt::endl << "---------------------------------------" << Qt::endl @@ -116,15 +116,15 @@ void GpgFrontend::GpgDecryptResultAnalyse::print_recipient( if (!key.GetComment().isEmpty()) stream << "(" << key.GetComment() << ")"; if (!key.GetEmail().isEmpty()) stream << "<" << key.GetEmail() << ">"; } else { - stream << "<" << _("unknown") << ">"; + stream << "<" << tr("unknown") << ">"; setStatus(0); } stream << Qt::endl; - stream << "- " << _("Key ID") << ": " << recipient->keyid << Qt::endl; - stream << "- " << _("Public Key Algo") << ": " + stream << "- " << tr("Key ID") << ": " << recipient->keyid << Qt::endl; + stream << "- " << tr("Public Key Algo") << ": " << gpgme_pubkey_algo_name(recipient->pubkey_algo) << Qt::endl; - stream << "- " << _("Status") << ": " << gpgme_strerror(recipient->status) + stream << "- " << tr("Status") << ": " << gpgme_strerror(recipient->status) << Qt::endl; } diff --git a/src/core/function/result_analyse/GpgDecryptResultAnalyse.h b/src/core/function/result_analyse/GpgDecryptResultAnalyse.h index 7ff9859f..c795e025 100644 --- a/src/core/function/result_analyse/GpgDecryptResultAnalyse.h +++ b/src/core/function/result_analyse/GpgDecryptResultAnalyse.h @@ -39,6 +39,7 @@ namespace GpgFrontend { */ class GPGFRONTEND_CORE_EXPORT GpgDecryptResultAnalyse : public GpgResultAnalyse { + Q_OBJECT public: /** * @brief Construct a new Decrypt Result Analyse object diff --git a/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp b/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp index 358e0787..a6b18b0a 100644 --- a/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp +++ b/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp @@ -32,17 +32,17 @@ namespace GpgFrontend { -GpgFrontend::GpgEncryptResultAnalyse::GpgEncryptResultAnalyse( - GpgError error, GpgEncryptResult result) +GpgEncryptResultAnalyse::GpgEncryptResultAnalyse(GpgError error, + GpgEncryptResult result) : error_(error), result_(result) {} -void GpgFrontend::GpgEncryptResultAnalyse::doAnalyse() { - stream_ << "# " << _("Encrypt Operation") << " "; +void GpgEncryptResultAnalyse::doAnalyse() { + stream_ << "# " << tr("Encrypt Operation") << " "; if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR) { - stream_ << "- " << _("Success") << " " << Qt::endl; + stream_ << "- " << tr("Success") << " " << Qt::endl; } else { - stream_ << "- " << _("Failed") << ": " << gpgme_strerror(error_) + stream_ << "- " << tr("Failed") << ": " << gpgme_strerror(error_) << Qt::endl; setStatus(-1); } @@ -53,18 +53,18 @@ void GpgFrontend::GpgEncryptResultAnalyse::doAnalyse() { const auto *result = result_.GetRaw(); if (result != nullptr) { - stream_ << "## " << _("Invalid Recipients") << ": " << Qt::endl + stream_ << "## " << tr("Invalid Recipients") << ": " << Qt::endl << Qt::endl; auto *inv_reci = result->invalid_recipients; auto index = 0; while (inv_reci != nullptr) { - stream_ << "### " << _("Recipients") << " " << ++index << ": " + stream_ << "### " << tr("Recipients") << " " << ++index << ": " << Qt::endl; - stream_ << "- " << _("Fingerprint") << ": " << inv_reci->fpr + stream_ << "- " << tr("Fingerprint") << ": " << inv_reci->fpr << Qt::endl; - stream_ << "- " << _("Reason") << ": " + stream_ << "- " << tr("Reason") << ": " << gpgme_strerror(inv_reci->reason) << Qt::endl; stream_ << Qt::endl << Qt::endl; diff --git a/src/core/function/result_analyse/GpgEncryptResultAnalyse.h b/src/core/function/result_analyse/GpgEncryptResultAnalyse.h index 221a4c22..e9594628 100644 --- a/src/core/function/result_analyse/GpgEncryptResultAnalyse.h +++ b/src/core/function/result_analyse/GpgEncryptResultAnalyse.h @@ -38,6 +38,7 @@ namespace GpgFrontend { */ class GPGFRONTEND_CORE_EXPORT GpgEncryptResultAnalyse : public GpgResultAnalyse { + Q_OBJECT public: /** * @brief Construct a new Encrypt Result Analyse object diff --git a/src/core/function/result_analyse/GpgResultAnalyse.h b/src/core/function/result_analyse/GpgResultAnalyse.h index d93a824f..9958b6a2 100644 --- a/src/core/function/result_analyse/GpgResultAnalyse.h +++ b/src/core/function/result_analyse/GpgResultAnalyse.h @@ -33,7 +33,8 @@ namespace GpgFrontend { -class GPGFRONTEND_CORE_EXPORT GpgResultAnalyse { +class GPGFRONTEND_CORE_EXPORT GpgResultAnalyse : public QObject { + Q_OBJECT public: /** * @brief Construct a new Result Analyse object diff --git a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp index a7251923..bf429f38 100644 --- a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp +++ b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp @@ -40,12 +40,13 @@ GpgSignResultAnalyse::GpgSignResultAnalyse(GpgError error, GpgSignResult result) void GpgSignResultAnalyse::doAnalyse() { auto *result = this->result_.GetRaw(); - stream_ << "# " << _("Sign Operation") << " "; + stream_ << "# " << tr("Sign Operation") << " "; if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR) { - stream_ << "- " << _("Success") << " " << Qt::endl; + stream_ << "- " << tr("Success") << " " << Qt::endl; } else { - stream_ << "- " << _("Failed") << " " << gpgme_strerror(error_) << Qt::endl; + stream_ << "- " << tr("Failed") << " " << gpgme_strerror(error_) + << Qt::endl; setStatus(-1); } @@ -56,37 +57,37 @@ void GpgSignResultAnalyse::doAnalyse() { auto index = 0; while (new_sign != nullptr) { - stream_ << "## " << _("New Signature") << " [" << ++index + stream_ << "## " << tr("New Signature") << " [" << ++index << "]: " << Qt::endl; - stream_ << "- " << _("Sign Mode") << ": "; + stream_ << "- " << tr("Sign Mode") << ": "; if (new_sign->type == GPGME_SIG_MODE_NORMAL) { - stream_ << _("Normal"); + stream_ << tr("Normal"); } else if (new_sign->type == GPGME_SIG_MODE_CLEAR) { - stream_ << _("Clear"); + stream_ << tr("Clear"); } else if (new_sign->type == GPGME_SIG_MODE_DETACH) { - stream_ << _("Detach"); + stream_ << tr("Detach"); } stream_ << Qt::endl; auto singer_key = GpgKeyGetter::GetInstance().GetKey(new_sign->fpr); if (singer_key.IsGood()) { - stream_ << "- " << _("Signer") << ": " + stream_ << "- " << tr("Signer") << ": " << singer_key.GetUIDs()->front().GetUID() << Qt::endl; } else { - stream_ << "- " << _("Signer") << ": " + stream_ << "- " << tr("Signer") << ": " << "<unknown>" << Qt::endl; } - stream_ << "- " << _("Public Key Algo") << ": " + stream_ << "- " << tr("Public Key Algo") << ": " << gpgme_pubkey_algo_name(new_sign->pubkey_algo) << Qt::endl; - stream_ << "- " << _("Hash Algo") << ": " + stream_ << "- " << tr("Hash Algo") << ": " << gpgme_hash_algo_name(new_sign->hash_algo) << Qt::endl; - stream_ << "- " << _("Date") << "(" << _("UTC") << ")" + stream_ << "- " << tr("Date") << "(" << tr("UTC") << ")" << ": " << QDateTime::fromSecsSinceEpoch(new_sign->timestamp).toString() << Qt::endl; - stream_ << "- " << _("Date") << "(" << _("Localized") << ")" + stream_ << "- " << tr("Date") << "(" << tr("Localized") << ")" << ": " << GetFormatedDateByTimestamp(new_sign->timestamp) << Qt::endl; @@ -101,17 +102,17 @@ void GpgSignResultAnalyse::doAnalyse() { stream_ << Qt::endl; if (invalid_signer != nullptr) { - stream_ << "## " << _("Invalid Signers") << ": " << Qt::endl; + stream_ << "## " << tr("Invalid Signers") << ": " << Qt::endl; } index = 0; while (invalid_signer != nullptr) { setStatus(0); - stream_ << "### " << _("Signer") << " [" << ++index << "]: " << Qt::endl + stream_ << "### " << tr("Signer") << " [" << ++index << "]: " << Qt::endl << Qt::endl; - stream_ << "- " << _("Fingerprint") << ": " << invalid_signer->fpr + stream_ << "- " << tr("Fingerprint") << ": " << invalid_signer->fpr << Qt::endl; - stream_ << "- " << _("Reason") << ": " + stream_ << "- " << tr("Reason") << ": " << gpgme_strerror(invalid_signer->reason) << Qt::endl; stream_ << "---------------------------------------" << Qt::endl; diff --git a/src/core/function/result_analyse/GpgSignResultAnalyse.h b/src/core/function/result_analyse/GpgSignResultAnalyse.h index 97544e8e..58a20417 100644 --- a/src/core/function/result_analyse/GpgSignResultAnalyse.h +++ b/src/core/function/result_analyse/GpgSignResultAnalyse.h @@ -38,6 +38,7 @@ namespace GpgFrontend { * */ class GPGFRONTEND_CORE_EXPORT GpgSignResultAnalyse : public GpgResultAnalyse { + Q_OBJECT public: /** * @brief Construct a new Sign Result Analyse object diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp index 38d751dd..224aa06b 100644 --- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp +++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp @@ -41,12 +41,12 @@ GpgFrontend::GpgVerifyResultAnalyse::GpgVerifyResultAnalyse( void GpgFrontend::GpgVerifyResultAnalyse::doAnalyse() { auto *result = this->result_.GetRaw(); - stream_ << "# " << _("Verify Operation") << " "; + stream_ << "# " << tr("Verify Operation") << " "; if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR) { - stream_ << " - " << _("Success") << " " << Qt::endl; + stream_ << " - " << tr("Success") << " " << Qt::endl; } else { - stream_ << " - " << _("Failed") << ": " << gpgme_strerror(error_) + stream_ << " - " << tr("Failed") << ": " << gpgme_strerror(error_) << Qt::endl; setStatus(-1); } @@ -55,67 +55,66 @@ void GpgFrontend::GpgVerifyResultAnalyse::doAnalyse() { stream_ << Qt::endl; auto *sign = result->signatures; - stream_ << "-> " << _("Signed On") << "(" << _("UTC") << ")" + stream_ << "-> " << tr("Signed On") << "(" << tr("UTC") << ")" << " " << QDateTime::fromSecsSinceEpoch(sign->timestamp).toString() << Qt::endl; - stream_ << "-> " << _("Signed On") << "(" << _("Localized") << ")" + stream_ << "-> " << tr("Signed On") << "(" << tr("Localized") << ")" << " " << GetFormatedDateByTimestamp(sign->timestamp) << Qt::endl; - stream_ << Qt::endl << "## " << _("Signatures List") << ":" << Qt::endl; + stream_ << Qt::endl << "## " << tr("Signatures List") << ":" << Qt::endl; stream_ << Qt::endl; bool can_continue = true; int count = 1; while ((sign != nullptr) && can_continue) { - stream_ << "### " << QString(_("Signature [%1]:")).arg(count++) - << Qt::endl; - stream_ << "- " << _("Status") << ": "; + stream_ << "### " << tr("Signature [%1]:").arg(count++) << Qt::endl; + stream_ << "- " << tr("Status") << ": "; switch (gpg_err_code(sign->status)) { case GPG_ERR_BAD_SIGNATURE: - stream_ << _("A Bad Signature.") << Qt::endl; + stream_ << tr("A Bad Signature.") << Qt::endl; print_signer(stream_, sign); - stream_ << _("This Signature is invalid.") << Qt::endl; + stream_ << tr("This Signature is invalid.") << Qt::endl; can_continue = false; setStatus(-1); break; case GPG_ERR_NO_ERROR: - stream_ << _("A") << " "; + stream_ << tr("A") << " "; if ((sign->summary & GPGME_SIGSUM_GREEN) != 0) { - stream_ << _("Good") << " "; + stream_ << tr("Good") << " "; } if ((sign->summary & GPGME_SIGSUM_RED) != 0) { - stream_ << _("Bad") << " "; + stream_ << tr("Bad") << " "; } if ((sign->summary & GPGME_SIGSUM_SIG_EXPIRED) != 0) { - stream_ << _("Expired") << " "; + stream_ << tr("Expired") << " "; } if ((sign->summary & GPGME_SIGSUM_KEY_MISSING) != 0) { - stream_ << _("Missing Key's") << " "; + stream_ << tr("Missing Key's") << " "; } if ((sign->summary & GPGME_SIGSUM_KEY_REVOKED) != 0) { - stream_ << _("Revoked Key's") << " "; + stream_ << tr("Revoked Key's") << " "; } if ((sign->summary & GPGME_SIGSUM_KEY_EXPIRED) != 0) { - stream_ << _("Expired Key's") << " "; + stream_ << tr("Expired Key's") << " "; } if ((sign->summary & GPGME_SIGSUM_CRL_MISSING) != 0) { - stream_ << _("Missing CRL's") << " "; + stream_ << tr("Missing CRL's") << " "; } if ((sign->summary & GPGME_SIGSUM_VALID) != 0) { - stream_ << _("Signature Fully Valid.") << Qt::endl; + stream_ << tr("Signature Fully Valid.") << Qt::endl; } else { - stream_ << _("Signature Not Fully Valid.") << Qt::endl; - stream_ << _("(Adjust Trust Level to make it Fully Vaild)") + stream_ << tr("Signature Not Fully Valid.") << Qt::endl; + stream_ << tr("(Adjust Trust Level to make it Fully Vaild)") << Qt::endl; } if ((sign->status & GPGME_SIGSUM_KEY_MISSING) == 0U) { if (!print_signer(stream_, sign)) setStatus(0); } else { - stream_ << _("Key is NOT present with ID 0x") << sign->fpr + stream_ << tr("Key is NOT present with ID 0x") << sign->fpr << Qt::endl; } @@ -123,13 +122,14 @@ void GpgFrontend::GpgVerifyResultAnalyse::doAnalyse() { break; case GPG_ERR_NO_PUBKEY: - stream_ << _("A signature could NOT be verified due to a Missing Key") - << Qt::endl; + stream_ + << tr("A signature could NOT be verified due to a Missing Key") + << Qt::endl; setStatus(-2); break; case GPG_ERR_CERT_REVOKED: - stream_ << _("A signature is valid but the key used to verify the " - "signature has been revoked") + stream_ << tr("A signature is valid but the key used to verify the " + "signature has been revoked") << Qt::endl; if (!print_signer(stream_, sign)) { setStatus(0); @@ -137,30 +137,30 @@ void GpgFrontend::GpgVerifyResultAnalyse::doAnalyse() { setStatus(-1); break; case GPG_ERR_SIG_EXPIRED: - stream_ << _("A signature is valid but expired") << Qt::endl; + stream_ << tr("A signature is valid but expired") << Qt::endl; if (!print_signer(stream_, sign)) { setStatus(0); } setStatus(-1); break; case GPG_ERR_KEY_EXPIRED: - stream_ << _("A signature is valid but the key used to " - "verify the signature has expired.") + stream_ << tr("A signature is valid but the key used to " + "verify the signature has expired.") << Qt::endl; if (!print_signer(stream_, sign)) { setStatus(0); } break; case GPG_ERR_GENERAL: - stream_ << _("There was some other error which prevented " - "the signature verification.") + stream_ << tr("There was some other error which prevented " + "the signature verification.") << Qt::endl; status_ = -1; can_continue = false; break; default: auto fpr = QString(sign->fpr); - stream_ << _("Error for key with fingerprint") << " " + stream_ << tr("Error for key with fingerprint") << " " << GpgFrontend::BeautifyFingerprint(fpr); setStatus(-1); } @@ -171,7 +171,7 @@ void GpgFrontend::GpgVerifyResultAnalyse::doAnalyse() { } else { stream_ << "-> " - << _("Could not find information that can be used for verification.") + << tr("Could not find information that can be used for verification.") << Qt::endl; setStatus(0); return; @@ -185,28 +185,28 @@ auto GpgFrontend::GpgVerifyResultAnalyse::print_signer(QTextStream &stream, auto key = GpgFrontend::GpgKeyGetter::GetInstance().GetKey(sign->fpr); if (!key.IsGood()) { - stream << "- " << _("Signed By") << ": " - << "<" << _("Unknown") << ">" << Qt::endl; + stream << "- " << tr("Signed By") << ": " + << "<" << tr("Unknown") << ">" << Qt::endl; setStatus(0); key_found = false; } else { - stream << "- " << _("Signed By") << ": " << key.GetUIDs()->front().GetUID() + stream << "- " << tr("Signed By") << ": " << key.GetUIDs()->front().GetUID() << Qt::endl; } if (sign->pubkey_algo != 0U) { - stream << "- " << _("Public Key Algo") << ": " + stream << "- " << tr("Public Key Algo") << ": " << gpgme_pubkey_algo_name(sign->pubkey_algo) << Qt::endl; } if (sign->hash_algo != 0U) { - stream << "- " << _("Hash Algo") << ": " + stream << "- " << tr("Hash Algo") << ": " << gpgme_hash_algo_name(sign->hash_algo) << Qt::endl; } if (sign->timestamp != 0U) { - stream << "- " << _("Date") << "(" << _("UTC") << ")" + stream << "- " << tr("Date") << "(" << tr("UTC") << ")" << ": " << QDateTime::fromSecsSinceEpoch(sign->timestamp).toString() << Qt::endl; - stream << "- " << _("Date") << "(" << _("Localized") << ")" + stream << "- " << tr("Date") << "(" << tr("Localized") << ")" << ": " << GetFormatedDateByTimestamp(sign->timestamp) << Qt::endl; } stream << Qt::endl; diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.h b/src/core/function/result_analyse/GpgVerifyResultAnalyse.h index 054083a1..8aa2e41f 100644 --- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.h +++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.h @@ -37,6 +37,7 @@ namespace GpgFrontend { * */ class GPGFRONTEND_CORE_EXPORT GpgVerifyResultAnalyse : public GpgResultAnalyse { + Q_OBJECT public: /** * @brief Construct a new Verify Result Analyse object diff --git a/src/core/model/GpgKey.cpp b/src/core/model/GpgKey.cpp index a53aac5f..ab962b5d 100644 --- a/src/core/model/GpgKey.cpp +++ b/src/core/model/GpgKey.cpp @@ -88,17 +88,17 @@ auto GpgKey::GetProtocol() const -> QString { auto GpgKey::GetOwnerTrust() const -> QString { switch (key_ref_->owner_trust) { case GPGME_VALIDITY_UNKNOWN: - return _("Unknown"); + return tr("Unknown"); case GPGME_VALIDITY_UNDEFINED: - return _("Undefined"); + return tr("Undefined"); case GPGME_VALIDITY_NEVER: - return _("Never"); + return tr("Never"); case GPGME_VALIDITY_MARGINAL: - return _("Marginal"); + return tr("Marginal"); case GPGME_VALIDITY_FULL: - return _("Full"); + return tr("Full"); case GPGME_VALIDITY_ULTIMATE: - return _("Ultimate"); + return tr("Ultimate"); } return "Invalid"; } diff --git a/src/core/model/GpgKey.h b/src/core/model/GpgKey.h index 2e540410..a9b76f7c 100644 --- a/src/core/model/GpgKey.h +++ b/src/core/model/GpgKey.h @@ -40,6 +40,7 @@ namespace GpgFrontend { * */ class GPGFRONTEND_CORE_EXPORT GpgKey { + Q_DECLARE_TR_FUNCTIONS(GpgKey) public: /** * @brief diff --git a/src/core/utils/IOUtils.cpp b/src/core/utils/IOUtils.cpp index 0eefe894..5ca765d9 100644 --- a/src/core/utils/IOUtils.cpp +++ b/src/core/utils/IOUtils.cpp @@ -72,15 +72,16 @@ auto CalculateHash(const QString& file_path) -> QString { QTextStream ss(&buffer); if (info.isFile() && info.isReadable()) { - ss << "[#] " << _("File Hash Information") << Qt::endl; - ss << " " << _("filename") << _(": ") << info.fileName() << Qt::endl; + ss << "[#] " << QObject::tr("File Hash Information") << Qt::endl; + ss << " " << QObject::tr("filename") << QObject::tr(": ") + << info.fileName() << Qt::endl; QFile f(info.filePath()); if (f.open(QFile::ReadOnly)) { // read all data auto buffer = f.readAll(); - ss << " " << _("file size(bytes)") << _(": ") << buffer.size() - << Qt::endl; + ss << " " << QObject::tr("file size(bytes)") << QObject::tr(": ") + << buffer.size() << Qt::endl; // md5 auto hash_md5 = QCryptographicHash(QCryptographicHash::Md5); @@ -88,7 +89,7 @@ auto CalculateHash(const QString& file_path) -> QString { auto md5 = hash_md5.result().toHex(); GF_CORE_LOG_DEBUG("md5 {}", md5); ss << " " - << "md5" << _(": ") << md5 << Qt::endl; + << "md5" << QObject::tr(": ") << md5 << Qt::endl; // sha1 auto hash_sha1 = QCryptographicHash(QCryptographicHash::Sha1); @@ -96,7 +97,7 @@ auto CalculateHash(const QString& file_path) -> QString { auto sha1 = hash_sha1.result().toHex(); GF_CORE_LOG_DEBUG("sha1 {}", sha1); ss << " " - << "sha1" << _(": ") << sha1 << Qt::endl; + << "sha1" << QObject::tr(": ") << sha1 << Qt::endl; // sha1 auto hash_sha256 = QCryptographicHash(QCryptographicHash::Sha256); @@ -104,12 +105,12 @@ auto CalculateHash(const QString& file_path) -> QString { auto sha256 = hash_sha256.result().toHex(); GF_CORE_LOG_DEBUG("sha256 {}", sha256); ss << " " - << "sha256" << _(": ") << sha256 << Qt::endl; + << "sha256" << QObject::tr(": ") << sha256 << Qt::endl; ss << Qt::endl; } } else { - ss << "[#] " << _("Error in Calculating File Hash ") << Qt::endl; + ss << "[#] " << QObject::tr("Error in Calculating File Hash ") << Qt::endl; } return ss.readAll(); @@ -133,20 +134,20 @@ auto TargetFilePreCheck(const QString& path, bool read) if (read) { if (!file_info.exists()) { - return {false, _("target path doesn't exists")}; + return {false, QObject::tr("target path doesn't exists")}; } } else { QFileInfo const path_info(file_info.absolutePath()); if (!path_info.isWritable()) { - return {false, _("do NOT have permission to write path")}; + return {false, QObject::tr("do NOT have permission to write path")}; } } if (read ? !file_info.isReadable() : false) { - return {false, _("do NOT have permission to read/write file")}; + return {false, QObject::tr("do NOT have permission to read/write file")}; } - return {true, _("Success")}; + return {true, QObject::tr("Success")}; } auto GetFullExtension(const QString& path) -> QString { diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp index 0db639f8..8a0c9ca6 100644 --- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp +++ b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp @@ -121,7 +121,7 @@ auto GnuPGInfoGatheringModule::Exec(EventRefrernce event) -> int { c_i_gpgme.name = "gpgme"; c_i_gpgme.desc = "GPG Made Easy"; c_i_gpgme.version = gpgme_version; - c_i_gpgme.path = _("Embedded In"); + c_i_gpgme.path = tr("Embedded In"); c_i_gpgme.binary_checksum = "/"; GpgComponentInfo c_i_gpgconf; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 2c99c5d3..ea4ca076 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -39,8 +39,4 @@ target_link_libraries(gpgfrontend_test PRIVATE gtest) target_link_libraries(gpgfrontend_test PRIVATE gpgfrontend_core) target_link_libraries(gpgfrontend_test PRIVATE spdlog) -if (APPLE) - target_link_libraries(gpgfrontend_test PRIVATE intl) -endif () - add_test(AllTestsInGpgFrontend gpgfrontend_test) diff --git a/src/ui/GpgFrontendApplication.cpp b/src/ui/GpgFrontendApplication.cpp index f7fc5635..1304aad5 100644 --- a/src/ui/GpgFrontendApplication.cpp +++ b/src/ui/GpgFrontendApplication.cpp @@ -37,7 +37,7 @@ namespace GpgFrontend::UI { GpgFrontendApplication::GpgFrontendApplication(int &argc, char *argv[]) : QApplication(argc, argv) { #ifndef MACOS - this->setWindowIcon(QIcon(":gpgfrontend.png")); + this->setWindowIcon(QIcon(":/icons/gpgfrontend.png")); #endif // set the extra information of the build @@ -60,20 +60,21 @@ bool GpgFrontendApplication::notify(QObject *receiver, QEvent *event) { return QApplication::notify(receiver, event); } catch (const std::exception &ex) { GF_UI_LOG_ERROR("exception was caught in notify: {}", ex.what()); - QMessageBox::information(nullptr, _("Standard Exception Thrown"), - _("Oops, an standard exception was thrown " - "during the running of the " - "program. This is not a serious problem, it may " - "be the negligence of the programmer, " - "please report this problem if you can.")); + QMessageBox::information( + nullptr, tr("Standard Exception Thrown"), + tr("Oops, an standard exception was thrown " + "during the running of the " + "program. This is not a serious problem, it may " + "be the negligence of the programmer, " + "please report this problem if you can.")); } catch (...) { GF_UI_LOG_ERROR("unknown exception was caught in notify"); QMessageBox::information( - nullptr, _("Unhandled Exception Thrown"), - _("Oops, an unhandled exception was thrown " - "during the running of the program. This is not a " - "serious problem, it may be the negligence of the programmer, " - "please report this problem if you can.")); + nullptr, tr("Unhandled Exception Thrown"), + tr("Oops, an unhandled exception was thrown " + "during the running of the program. This is not a " + "serious problem, it may be the negligence of the programmer, " + "please report this problem if you can.")); } return -1; #else diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp index cf48e14d..64c316b9 100644 --- a/src/ui/GpgFrontendUIInit.cpp +++ b/src/ui/GpgFrontendUIInit.cpp @@ -49,12 +49,12 @@ void WaitEnvCheckingProcess() { auto* waiting_dialog = new QProgressDialog(); waiting_dialog->setMaximum(0); waiting_dialog->setMinimum(0); - auto* waiting_dialog_label = - new QLabel(QString(_("Loading Gnupg Info...")) + "<br /><br />" + - _("If this process is too slow, please set the key " - "server address appropriately in the gnupg configuration " - "file (depending " - "on the network situation in your country or region).")); + auto* waiting_dialog_label = new QLabel( + QObject::tr("Loading Gnupg Info...") + "<br /><br />" + + QObject::tr("If this process is too slow, please set the key " + "server address appropriately in the gnupg configuration " + "file (depending " + "on the network situation in your country or region).")); waiting_dialog_label->setWordWrap(true); waiting_dialog->setLabel(waiting_dialog_label); waiting_dialog->resize(420, 120); @@ -221,56 +221,23 @@ void InitLocale() { auto settings = GpgFrontend::GlobalSettingStation::GetInstance().GetSettings(); - GF_UI_LOG_INFO("current system locale: {}", setlocale(LC_ALL, nullptr)); + GF_UI_LOG_INFO("current system locale: {}", QLocale().name()); // read from settings file auto lang = settings.value("basic/lang").toString(); - GF_UI_LOG_INFO("current language settings: {}", lang); + GF_UI_LOG_INFO("current custom locale settings: {}", lang); GF_UI_LOG_INFO( "current locales path: {}", GpgFrontend::GlobalSettingStation::GetInstance().GetLocaleDir()); -#ifndef WINDOWS - if (!lang.isEmpty()) { - auto lc = (lang + ".UTF-8").toUtf8(); - - // set LC_ALL - auto* locale_name = std::setlocale(LC_ALL, lc.constData()); - if (locale_name == nullptr) GF_UI_LOG_WARN("set LC_ALL failed, lc: {}", lc); - auto* language = getenv("LANGUAGE"); - // set LANGUAGE - QString language_env = language == nullptr ? "en" : language; - language_env.insert(0, lang + ":"); - GF_UI_LOG_DEBUG("language env: {}", language_env); - if (setenv("LANGUAGE", language_env.toUtf8(), 1) != 0) { - GF_UI_LOG_WARN("set LANGUAGE {} failed", language_env); - }; + auto target_locale = lang.isEmpty() ? QLocale() : QLocale(lang); + auto* translator = new QTranslator(QCoreApplication::instance()); + if (translator->load(target_locale, QLatin1String(PROJECT_NAME), + QLatin1String("."), QLatin1String(":/i18n"), + QLatin1String(".qm"))) { + GF_UI_LOG_INFO("load target translation file done"); + QCoreApplication::installTranslator(translator); } -#else - if (!lang.empty()) { - auto lc = lang.toUtf8(); - - // set LC_ALL - auto* locale_name = setlocale(LC_ALL, lc); - if (locale_name == nullptr) GF_UI_LOG_WARN("set LC_ALL failed, lc: {}", lc); - - auto language = getenv("LANGUAGE"); - // set LANGUAGE - QString language_env = language == nullptr ? "en" : language; - language_env.insert(0, lang + ":"); - language_env.insert(0, "LANGUAGE="); - GF_UI_LOG_DEBUG("language env: {}", language_env); - if (putenv(language_env.toUtf8())) { - GF_UI_LOG_WARN("set LANGUAGE {} failed", language_env); - }; - } -#endif - - bindtextdomain( - PROJECT_NAME, - GpgFrontend::GlobalSettingStation::GetInstance().GetLocaleDir().toUtf8()); - bind_textdomain_codeset(PROJECT_NAME, "utf-8"); - textdomain(PROJECT_NAME); } } // namespace GpgFrontend::UI diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index 69534ca6..8f7b07b4 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -63,7 +63,7 @@ void show_verify_details(QWidget *parent, InfoBoardWidget *info_board, GpgError error, const GpgVerifyResult &verify_result) { // take out result info_board->ResetOptionActionsMenu(); - info_board->AddOptionalAction(_("Show Verify Details"), [=]() { + info_board->AddOptionalAction(QObject::tr("Show Verify Details"), [=]() { VerifyDetailsDialog(parent, error, verify_result); }); } @@ -72,10 +72,11 @@ void import_unknown_key_from_keyserver( QWidget *parent, const GpgVerifyResultAnalyse &verify_res) { QMessageBox::StandardButton reply; reply = QMessageBox::question( - parent, _("Public key not found locally"), - _("There is no target public key content in local for GpgFrontend to " - "gather enough information about this Signature. Do you want to " - "import the public key from Keyserver now?"), + parent, QObject::tr("Public key not found locally"), + QObject::tr( + "There is no target public key content in local for GpgFrontend to " + "gather enough information about this Signature. Do you want to " + "import the public key from Keyserver now?"), QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { auto dialog = KeyServerImportDialog(parent); @@ -181,43 +182,43 @@ CommonUtils::CommonUtils() : QWidget(nullptr) { &UISignalStation::SignalRestartApplication, this, &CommonUtils::SlotRestartApplication); - connect( - this, &CommonUtils::SignalBadGnupgEnv, this, [=](const QString &reason) { - QMessageBox msg_box; - msg_box.setText(_("GnuPG Context Loading Failed")); - msg_box.setInformativeText( - QString(_("Gnupg(gpg) is not installed correctly, please follow " - "<a href='https://www.gpgfrontend.bktus.com/#/" - "faq?id=how-to-deal-with-39env-loading-failed39'>this " - "notes</a> in FAQ to install Gnupg and then open " - "GpgFrontend. <br />" - "Or, you can open GnuPG Controller to set a " - "custom GnuPG which GpgFrontend should use. Then, " - "GpgFrontend will restart. <br /><br />" - "Breif Reason: %1")) - .arg(reason)); - msg_box.setStandardButtons(QMessageBox::Open | QMessageBox::Cancel); - msg_box.setDefaultButton(QMessageBox::Save); - int ret = msg_box.exec(); - - switch (ret) { - case QMessageBox::Open: - (new GnuPGControllerDialog(this))->exec(); - // restart application when loop start - application_need_to_restart_at_once_ = true; - // restart application, core and ui - emit SignalRestartApplication(kDeepRestartCode); - break; - case QMessageBox::Cancel: - // close application - emit SignalRestartApplication(0); - break; - default: - // close application - emit SignalRestartApplication(0); - break; - } - }); + connect(this, &CommonUtils::SignalBadGnupgEnv, this, + [=](const QString &reason) { + QMessageBox msg_box; + msg_box.setText(tr("GnuPG Context Loading Failed")); + msg_box.setInformativeText( + tr("Gnupg(gpg) is not installed correctly, please follow " + "<a href='https://www.gpgfrontend.bktus.com/#/" + "faq?id=how-to-deal-with-39env-loading-failed39'>this " + "notes</a> in FAQ to install Gnupg and then open " + "GpgFrontend. <br />" + "Or, you can open GnuPG Controller to set a " + "custom GnuPG which GpgFrontend should use. Then, " + "GpgFrontend will restart. <br /><br />" + "Breif Reason: %1") + .arg(reason)); + msg_box.setStandardButtons(QMessageBox::Open | QMessageBox::Cancel); + msg_box.setDefaultButton(QMessageBox::Save); + int ret = msg_box.exec(); + + switch (ret) { + case QMessageBox::Open: + (new GnuPGControllerDialog(this))->exec(); + // restart application when loop start + application_need_to_restart_at_once_ = true; + // restart application, core and ui + emit SignalRestartApplication(kDeepRestartCode); + break; + case QMessageBox::Cancel: + // close application + emit SignalRestartApplication(0); + break; + default: + // close application + emit SignalRestartApplication(0); + break; + } + }); } void CommonUtils::WaitForOpera(QWidget *parent, @@ -247,8 +248,8 @@ void CommonUtils::WaitForOpera(QWidget *parent, dialog->close(); dialog->reject(); - QMessageBox::critical(parent, _("Timeout"), - _("Operation has timeout, aborted...")); + QMessageBox::critical(parent, tr("Timeout"), + tr("Operation has timeout, aborted...")); } }); @@ -260,9 +261,8 @@ void CommonUtils::RaiseMessageBox(QWidget *parent, GpgError err) { GpgErrorCode err_code = CheckGpgError2ErrCode(err); if (err_code == GPG_ERR_NO_ERROR) { - QMessageBox::information( - parent, _("Success"), - QString::fromStdString(_("Gpg Operation succeed."))); + QMessageBox::information(parent, tr("Success"), + tr("Gpg Operation succeed.")); } else { RaiseFailureMessageBox(parent, err); } @@ -272,13 +272,12 @@ void CommonUtils::RaiseFailureMessageBox(QWidget *parent, GpgError err) { GpgErrorDesc desc = DescribeGpgErrCode(err); GpgErrorCode err_code = CheckGpgError2ErrCode(err); - QMessageBox::critical( - parent, _("Failure"), - QString(_("Gpg Operation failed.\n\nError code: %1\nSource: " - " %2\nDescription: %3")) - .arg(err_code) - .arg(desc.first) - .arg(desc.second)); + QMessageBox::critical(parent, tr("Failure"), + tr("Gpg Operation failed.\n\nError code: %1\nSource: " + " %2\nDescription: %3") + .arg(err_code) + .arg(desc.first) + .arg(desc.second)); } void CommonUtils::SlotImportKeys(QWidget *parent, const QString &in_buffer) { @@ -290,15 +289,15 @@ void CommonUtils::SlotImportKeys(QWidget *parent, const QString &in_buffer) { } void CommonUtils::SlotImportKeyFromFile(QWidget *parent) { - auto file_name = QFileDialog::getOpenFileName( - this, _("Open Key"), QString(), - QString(_("Key Files")) + " (*.asc *.txt);;" + _("Keyring files") + - " (*.gpg);;All Files (*)"); + auto file_name = QFileDialog::getOpenFileName(this, tr("Open Key"), QString(), + tr("Key Files")) + + " (*.asc *.txt);;" + tr("Keyring files") + + " (*.gpg);;All Files (*)"; if (!file_name.isNull()) { QByteArray key_buffer; if (!ReadFile(file_name, key_buffer)) { - QMessageBox::critical(nullptr, _("File Open Failed"), - _("Failed to open file: ") + file_name); + QMessageBox::critical(nullptr, tr("File Open Failed"), + tr("Failed to open file: ") + file_name); return; } SlotImportKeys(parent, key_buffer); @@ -351,7 +350,7 @@ void CommonUtils::SlotExecuteGpgCommand( const QStringList &arguments, const std::function<void(QProcess *)> &interact_func) { QEventLoop looper; - auto dialog = new WaitingDialog(_("Processing"), nullptr); + auto dialog = new WaitingDialog(tr("Processing"), nullptr); dialog->show(); auto *gpg_process = new QProcess(&looper); gpg_process->setProcessChannelMode(QProcess::MergedChannels); @@ -370,19 +369,19 @@ void CommonUtils::SlotExecuteGpgCommand( connect(gpg_process, &QProcess::errorOccurred, this, [=]() -> void { GF_UI_LOG_ERROR("Error in Process"); dialog->close(); - QMessageBox::critical(nullptr, _("Failure"), - _("Failed to execute command.")); + QMessageBox::critical(nullptr, tr("Failure"), + tr("Failed to execute command.")); }); connect(gpg_process, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this, [=](int, QProcess::ExitStatus status) { dialog->close(); if (status == QProcess::NormalExit) - QMessageBox::information(nullptr, _("Success"), - _("Succeed in executing command.")); + QMessageBox::information(nullptr, tr("Success"), + tr("Succeed in executing command.")); else - QMessageBox::information(nullptr, _("Warning"), - _("Finished executing command.")); + QMessageBox::information(nullptr, tr("Warning"), + tr("Finished executing command.")); }); const auto app_path = Module::RetrieveRTValueTypedOrDefault<>( @@ -402,9 +401,10 @@ void CommonUtils::SlotImportKeyFromKeyServer( auto target_keyserver = KeyServerSO(SettingsObject("key_server")).GetTargetServer(); if (target_keyserver.isEmpty()) { - QMessageBox::critical(nullptr, _("Default Keyserver Not Found"), - _("Cannot read default keyserver from your settings, " - "please set a default keyserver first")); + QMessageBox::critical( + nullptr, tr("Default Keyserver Not Found"), + tr("Cannot read default keyserver from your settings, " + "please set a default keyserver first")); return; } GF_UI_LOG_DEBUG("set target key server to default Key Server: {}", @@ -438,16 +438,16 @@ void CommonUtils::SlotImportKeyFromKeyServer( if (error != QNetworkReply::NoError) { switch (error) { case QNetworkReply::ContentNotFoundError: - status = _("Key Not Found"); + status = tr("Key Not Found"); break; case QNetworkReply::TimeoutError: - status = _("Timeout"); + status = tr("Timeout"); break; case QNetworkReply::HostNotFoundError: - status = _("Key Server Not Found"); + status = tr("Key Server Not Found"); break; default: - status = _("Connection Error"); + status = tr("Connection Error"); } } @@ -458,9 +458,9 @@ void CommonUtils::SlotImportKeyFromKeyServer( GFBuffer(reply->readAll())); if (result->imported == 1) { - status = _("The key has been updated"); + status = tr("The key has been updated"); } else { - status = _("No need to update the key"); + status = tr("No need to update the key"); } callback(key_id, status, current_index, all_index); current_index++; @@ -491,10 +491,10 @@ void CommonUtils::slot_update_key_status() { void CommonUtils::slot_popup_passphrase_input_dialog() { auto *dialog = new QInputDialog(QApplication::activeWindow(), Qt::Dialog); dialog->setModal(true); - dialog->setWindowTitle(_("Password Input Dialog")); + dialog->setWindowTitle(tr("Password Input Dialog")); dialog->setInputMode(QInputDialog::TextInput); dialog->setTextEchoMode(QLineEdit::Password); - dialog->setLabelText(_("Please Input The Password")); + dialog->setLabelText(tr("Please Input The Password")); dialog->resize(500, 80); dialog->exec(); diff --git a/src/ui/dialog/QuitDialog.cpp b/src/ui/dialog/QuitDialog.cpp index c02f5898..6dd5674e 100755 --- a/src/ui/dialog/QuitDialog.cpp +++ b/src/ui/dialog/QuitDialog.cpp @@ -32,7 +32,7 @@ namespace GpgFrontend::UI { QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) : GeneralDialog("quit_dialog", parent) { - setWindowTitle(_("Unsaved Files")); + setWindowTitle(tr("Unsaved Files")); setModal(true); discarded_ = false; @@ -75,15 +75,14 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) /* * Warnbox with icon and text */ - auto pixmap = QPixmap(":error.png"); + auto pixmap = QPixmap(":/icons/error.png"); pixmap = pixmap.scaled(50, 50, Qt::KeepAspectRatio, Qt::SmoothTransformation); auto* warn_icon = new QLabel(); warn_icon->setPixmap(pixmap); - const auto info = - QString(_("%1 files contain unsaved information.<br/>Save the " - "changes before closing?")) - .arg(row); + const auto info = tr("%1 files contain unsaved information.<br/>Save the " + "changes before closing?") + .arg(row); auto* warn_label = new QLabel(info); auto* warn_box_layout = new QHBoxLayout(); warn_box_layout->addWidget(warn_icon); @@ -95,10 +94,10 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) /* * Two labels on top and under the filelist */ - auto* check_label = new QLabel(_("Check the files you want to save:")); + auto* check_label = new QLabel(tr("Check the files you want to save:")); auto* note_label = new QLabel( - "<b>" + QString(_("Note")) + ":</b>" + - _("If you don't save these files, all changes are lost.") + "<br/>"); + "<b>" + tr("Note") + ":</b>" + + tr("If you don't save these files, all changes are lost.") + "<br/>"); /* * Buttonbox diff --git a/src/ui/dialog/SignersPicker.cpp b/src/ui/dialog/SignersPicker.cpp index 3edde0be..378a58c7 100644 --- a/src/ui/dialog/SignersPicker.cpp +++ b/src/ui/dialog/SignersPicker.cpp @@ -35,8 +35,8 @@ namespace GpgFrontend::UI { SignersPicker::SignersPicker(QWidget* parent) : GeneralDialog(typeid(SignersPicker).name(), parent) { - auto* confirm_button = new QPushButton(_("Confirm")); - auto* cancel_button = new QPushButton(_("Cancel")); + auto* confirm_button = new QPushButton(tr("Confirm")); + auto* cancel_button = new QPushButton(tr("Cancel")); connect(confirm_button, &QPushButton::clicked, [=]() { this->accepted_ = true; }); @@ -46,7 +46,7 @@ SignersPicker::SignersPicker(QWidget* parent) /*Setup KeyList*/ key_list_ = new KeyList(0U, this); key_list_->AddListGroupTab( - _("Signers"), "signers", KeyListRow::ONLY_SECRET_KEY, + tr("Signers"), "signers", KeyListRow::ONLY_SECRET_KEY, KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage, [](const GpgKey& key, const KeyTable&) -> bool { return key.IsHasActualSigningCapability(); @@ -54,13 +54,13 @@ SignersPicker::SignersPicker(QWidget* parent) key_list_->SlotRefresh(); auto* vbox2 = new QVBoxLayout(); - vbox2->addWidget(new QLabel(QString(_("Select Signer(s)")) + ": ")); + vbox2->addWidget(new QLabel(tr("Select Signer(s)") + ": ")); vbox2->addWidget(key_list_); vbox2->addWidget(new QLabel( QString( - _("Please select one or more private keys you use for signing.")) + + tr("Please select one or more private keys you use for signing.")) + "\n" + - _("If no key is selected, the default key will be used for signing."))); + tr("If no key is selected, the default key will be used for signing."))); vbox2->addWidget(confirm_button); vbox2->addWidget(cancel_button); vbox2->addStretch(0); @@ -70,7 +70,7 @@ SignersPicker::SignersPicker(QWidget* parent) Qt::CustomizeWindowHint); this->setModal(true); - this->setWindowTitle(_("Signers Picker")); + this->setWindowTitle(tr("Signers Picker")); this->setMinimumWidth(480); movePosition2CenterOfParent(); diff --git a/src/ui/dialog/Wizard.cpp b/src/ui/dialog/Wizard.cpp index dd23fcc0..89ebee27 100644 --- a/src/ui/dialog/Wizard.cpp +++ b/src/ui/dialog/Wizard.cpp @@ -41,12 +41,12 @@ Wizard::Wizard(QWidget* parent) : QWizard(parent) { #ifndef Q_WS_MAC setWizardStyle(ModernStyle); #endif - setWindowTitle(_("First Start Wizard")); + setWindowTitle(tr("First Start Wizard")); // http://www.flickr.com/photos/laureenp/6141822934/ - setPixmap(QWizard::WatermarkPixmap, QPixmap(":/keys2.jpg")); - setPixmap(QWizard::LogoPixmap, QPixmap(":/logo_small.png")); - setPixmap(QWizard::BannerPixmap, QPixmap(":/banner.png")); + setPixmap(QWizard::WatermarkPixmap, QPixmap(":/icons/keys2.jpg")); + setPixmap(QWizard::LogoPixmap, QPixmap(":/icons/logo_small.png")); + setPixmap(QWizard::BannerPixmap, QPixmap(":/icons/banner.png")); int next_page_id = GlobalSettingStation::GetInstance() .GetSettings() @@ -71,19 +71,20 @@ void Wizard::slot_wizard_accepted() { } IntroPage::IntroPage(QWidget* parent) : QWizardPage(parent) { - setTitle(_("Getting Started...")); - setSubTitle(_("... with GpgFrontend")); + setTitle(tr("Getting Started...")); + setSubTitle(tr("... with GpgFrontend")); auto* topLabel = new QLabel( - QString(_("Welcome to use GpgFrontend for decrypting and signing text or " - "file!")) + + QString( + tr("Welcome to use GpgFrontend for decrypting and signing text or " + "file!")) + " <br><br><a href='https://gpgfrontend.bktus.com'>GpgFrontend</a> " + - _("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and " - "Installation-Free OpenPGP Crypto Tool.") + - _("For brief information have a look at the") + + tr("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and " + "Installation-Free OpenPGP Crypto Tool.") + + tr("For brief information have a look at the") + " <a href='https://gpgfrontend.bktus.com/index.html#/overview'>" + - _("Overview") + "</a> (" + - _("by clicking the link, the page will open in the web browser") + + tr("Overview") + "</a> (" + + tr("by clicking the link, the page will open in the web browser") + "). <br>"); topLabel->setTextFormat(Qt::RichText); topLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); @@ -92,8 +93,8 @@ IntroPage::IntroPage(QWidget* parent) : QWizardPage(parent) { // QComboBox for language selection auto* lang_label = - new QLabel(_("If it supports the language currently being used in your " - "system, GpgFrontend will automatically set it.")); + new QLabel(tr("If it supports the language currently being used in your " + "system, GpgFrontend will automatically set it.")); lang_label->setWordWrap(true); // set layout and add widgets @@ -108,60 +109,56 @@ IntroPage::IntroPage(QWidget* parent) : QWizardPage(parent) { int IntroPage::nextId() const { return Wizard::Page_Choose; } ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { - setTitle(_("Choose your action...")); - setSubTitle(_("...by clicking on the appropriate link.")); - - auto* keygenLabel = new QLabel( - QString(_( - "If you have never used GpgFrontend before and also don't own a gpg " - "key yet you " - "may possibly want to read how to")) + - " <a " - "href=\"https://gpgfrontend.bktus.com/index.html#/manual/" + setTitle(tr("Choose your action...")); + setSubTitle(tr("...by clicking on the appropriate link.")); + + auto* keygen_label = new QLabel( + tr("If you have never used GpgFrontend before and also don't own a gpg " + "key yet you may possibly want to read how to") + + " <a href=\"https://gpgfrontend.bktus.com/index.html#/manual/" "generate-key\">" + - _("Generate Key") + "</a><hr>"); - keygenLabel->setTextFormat(Qt::RichText); - keygenLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - keygenLabel->setOpenExternalLinks(true); - keygenLabel->setWordWrap(true); - - auto* encrDecyTextLabel = new QLabel( - QString(_( - "If you want to learn how to encrypt, decrypt, sign and verify text, " - "you can read ")) + + tr("Generate Key") + "</a><hr>"); + keygen_label->setTextFormat(Qt::RichText); + keygen_label->setTextInteractionFlags(Qt::TextBrowserInteraction); + keygen_label->setOpenExternalLinks(true); + keygen_label->setWordWrap(true); + + auto* encr_decy_text_label = new QLabel( + tr("If you want to learn how to encrypt, decrypt, sign and verify text, " + "you can read ") + "<a " "href=\"https://gpgfrontend.bktus.com/index.html#/manual/" "encrypt-decrypt-text\">" + - _("Encrypt & Decrypt Text") + "</a> " + _("or") + + tr("Encrypt & Decrypt Text") + "</a> " + tr("or") + " <a " "href=\"https://gpgfrontend.bktus.com/index.html#/manual/" "sign-verify-text\">" + - _("Sign & Verify Text") + "</a><hr>"); + tr("Sign & Verify Text") + "</a><hr>"); - encrDecyTextLabel->setTextFormat(Qt::RichText); - encrDecyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - encrDecyTextLabel->setOpenExternalLinks(true); - encrDecyTextLabel->setWordWrap(true); + encr_decy_text_label->setTextFormat(Qt::RichText); + encr_decy_text_label->setTextInteractionFlags(Qt::TextBrowserInteraction); + encr_decy_text_label->setOpenExternalLinks(true); + encr_decy_text_label->setWordWrap(true); - auto* signVerifyTextLabel = - new QLabel(QString(_("If you want to operate file, you can read ")) + + auto* sign_verify_text_label = + new QLabel(tr("If you want to operate file, you can read ") + "<a " "href=\"https://gpgfrontend.bktus.com/index.html#/manual/" "encrypt-decrypt-file\">" + - _("Encrypt & Sign File") + "</a> " + _("or") + + tr("Encrypt & Sign File") + "</a> " + tr("or") + " <a " "href=\"https://gpgfrontend.bktus.com/index.html#/manual/" "sign-verify-file\">" + - _("Sign & Verify File") + "</a><hr>"); - signVerifyTextLabel->setTextFormat(Qt::RichText); - signVerifyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - signVerifyTextLabel->setOpenExternalLinks(true); - signVerifyTextLabel->setWordWrap(true); + tr("Sign & Verify File") + "</a><hr>"); + sign_verify_text_label->setTextFormat(Qt::RichText); + sign_verify_text_label->setTextInteractionFlags(Qt::TextBrowserInteraction); + sign_verify_text_label->setOpenExternalLinks(true); + sign_verify_text_label->setWordWrap(true); auto* layout = new QVBoxLayout(); - layout->addWidget(keygenLabel); - layout->addWidget(encrDecyTextLabel); - layout->addWidget(signVerifyTextLabel); + layout->addWidget(keygen_label); + layout->addWidget(encr_decy_text_label); + layout->addWidget(sign_verify_text_label); setLayout(layout); next_page_ = Wizard::Page_Conclusion; } @@ -178,33 +175,33 @@ void ChoosePage::slot_jump_page(const QString& page) { } KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { - setTitle(_("Create a keypair...")); - setSubTitle(_("...for decrypting and signing messages")); - auto* topLabel = new QLabel( - _("You should create a new keypair." - "The pair consists of a public and a private key.<br>" - "Other users can use the public key to encrypt messages for you " - "and verify messages signed by you." - "You can use the private key to decrypt and sign messages.<br>" - "For more information have a look at the offline tutorial (which then " - "is shown in the main window):")); - topLabel->setWordWrap(true); - auto* linkLabel = new QLabel( + setTitle(tr("Create a keypair...")); + setSubTitle(tr("...for decrypting and signing messages")); + auto* top_label = new QLabel( + tr("You should create a new keypair." + "The pair consists of a public and a private key.<br>" + "Other users can use the public key to encrypt messages for you " + "and verify messages signed by you." + "You can use the private key to decrypt and sign messages.<br>" + "For more information have a look at the offline tutorial (which then " + "is shown in the main window):")); + top_label->setWordWrap(true); + auto* link_label = new QLabel( "<a href=" "docu_keygen.html#content" ">" + - QString(_("Offline tutorial")) + "</a>"); + tr("Offline tutorial") + "</a>"); - auto* createKeyButtonBox = new QWidget(this); - auto* createKeyButtonBoxLayout = new QHBoxLayout(createKeyButtonBox); - auto* createKeyButton = new QPushButton(_("Create New Key")); - createKeyButtonBoxLayout->addWidget(createKeyButton); - createKeyButtonBoxLayout->addStretch(1); + auto* create_key_button_box = new QWidget(this); + auto* create_key_button_box_layout = new QHBoxLayout(create_key_button_box); + auto* create_key_button = new QPushButton(tr("Create New Key")); + create_key_button_box_layout->addWidget(create_key_button); + create_key_button_box_layout->addStretch(1); auto* layout = new QVBoxLayout(); - layout->addWidget(topLabel); - layout->addWidget(linkLabel); - layout->addWidget(createKeyButtonBox); - connect(createKeyButton, &QPushButton::clicked, this, + layout->addWidget(top_label); + layout->addWidget(link_label); + layout->addWidget(create_key_button_box); + connect(create_key_button, &QPushButton::clicked, this, &KeyGenPage::slot_generate_key_dialog); setLayout(layout); @@ -218,17 +215,17 @@ void KeyGenPage::slot_generate_key_dialog() { } ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { - setTitle(_("Ready.")); - setSubTitle(_("Have fun with GpgFrontend!")); + setTitle(tr("Ready.")); + setSubTitle(tr("Have fun with GpgFrontend!")); auto* bottomLabel = new QLabel( - QString(_("You are ready to use GpgFrontend now.<br><br>")) + + tr("You are ready to use GpgFrontend now.<br><br>") + "<a " "href=\"https://saturneric.github.io/GpgFrontend/index.html#/" "overview\">" + - _("The Online Document") + "</a>" + - _(" will get you started with GpgFrontend. Anytime you encounter " - "problems, please try to find help from the documentation") + + tr("The Online Document") + "</a>" + + tr(" will get you started with GpgFrontend. Anytime you encounter " + "problems, please try to find help from the documentation") + "<br>"); bottomLabel->setTextFormat(Qt::RichText); @@ -236,10 +233,10 @@ ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { bottomLabel->setOpenExternalLinks(true); bottomLabel->setWordWrap(true); - open_help_check_box_ = new QCheckBox(_("Open offline help.")); + open_help_check_box_ = new QCheckBox(tr("Open offline help.")); open_help_check_box_->setChecked(true); - dont_show_wizard_checkbox_ = new QCheckBox(_("Dont show the wizard again.")); + dont_show_wizard_checkbox_ = new QCheckBox(tr("Dont show the wizard again.")); dont_show_wizard_checkbox_->setChecked(true); registerField("showWizard", dont_show_wizard_checkbox_); diff --git a/src/ui/dialog/details/VerifyDetailsDialog.cpp b/src/ui/dialog/details/VerifyDetailsDialog.cpp index ba23b2c6..cea34607 100644 --- a/src/ui/dialog/details/VerifyDetailsDialog.cpp +++ b/src/ui/dialog/details/VerifyDetailsDialog.cpp @@ -35,7 +35,7 @@ namespace GpgFrontend::UI { VerifyDetailsDialog::VerifyDetailsDialog(QWidget* parent, GpgError error, GpgVerifyResult result) : QDialog(parent), m_result_(result), error_(error) { - this->setWindowTitle(_("Signatures Details")); + this->setWindowTitle(tr("Signatures Details")); main_layout_ = new QHBoxLayout(); this->setLayout(main_layout_); @@ -58,7 +58,7 @@ void VerifyDetailsDialog::slot_refresh() { auto signatures = m_result_.GetSignature(); if (signatures.empty()) { - m_vbox_layout->addWidget(new QLabel(_("No valid input found"))); + m_vbox_layout->addWidget(new QLabel(tr("No valid input found"))); m_vbox_layout->addWidget(button_box_); return; } @@ -68,16 +68,16 @@ void VerifyDetailsDialog::slot_refresh() { // Set the title widget depending on sign status if (gpg_err_code(signatures[0].GetStatus()) == GPG_ERR_BAD_SIGNATURE) { - m_vbox_layout->addWidget(new QLabel(_("Error Validating signature"))); + m_vbox_layout->addWidget(new QLabel(tr("Error Validating signature"))); } else if (input_signature_ != nullptr) { - const auto info = QString(_("File was signed on %1")) - .arg(QLocale::system().toString(timestamp)) + - "<br/>" + _("It Contains") + ": " + "<br/><br/>"; + const auto info = + tr("File was signed on %1").arg(QLocale::system().toString(timestamp)) + + "<br/>" + tr("It Contains") + ": " + "<br/><br/>"; m_vbox_layout->addWidget(new QLabel(info)); } else { const auto info = - QString(_("Signed on %1")).arg(QLocale::system().toString(timestamp)) + - "<br/>" + _("It Contains") + ": " + "<br/><br/>"; + tr("Signed on %1").arg(QLocale::system().toString(timestamp)) + + "<br/>" + tr("It Contains") + ": " + "<br/><br/>"; m_vbox_layout->addWidget(new QLabel(info)); } // Add information box for every single key diff --git a/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp b/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp index 43dbcf1e..fbf018ca 100644 --- a/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp +++ b/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp @@ -42,26 +42,26 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) ui_(GpgFrontend::SecureCreateSharedObject<Ui_GnuPGControllerDialog>()) { ui_->setupUi(this); - ui_->generalBox->setTitle(_("General")); - ui_->keyDatabaseGroupBox->setTitle(_("Key Database")); - ui_->advanceGroupBox->setTitle(_("Advanced")); + ui_->generalBox->setTitle(tr("General")); + ui_->keyDatabaseGroupBox->setTitle(tr("Key Database")); + ui_->advanceGroupBox->setTitle(tr("Advanced")); - ui_->asciiModeCheckBox->setText(_("No ASCII Mode")); + ui_->asciiModeCheckBox->setText(tr("No ASCII Mode")); ui_->usePinentryAsPasswordInputDialogCheckBox->setText( - _("Use Pinentry as Password Input Dialog")); - ui_->useCustomGnuPGInstallPathCheckBox->setText(_("Use Custom GnuPG")); - ui_->useCustomGnuPGInstallPathButton->setText(_("Select GnuPG Path")); + tr("Use Pinentry as Password Input Dialog")); + ui_->useCustomGnuPGInstallPathCheckBox->setText(tr("Use Custom GnuPG")); + ui_->useCustomGnuPGInstallPathButton->setText(tr("Select GnuPG Path")); ui_->keyDatabseUseCustomCheckBox->setText( - _("Use Custom GnuPG Key Database Path")); + tr("Use Custom GnuPG Key Database Path")); ui_->customKeyDatabasePathSelectButton->setText( - _("Select Key Database Path")); + tr("Select Key Database Path")); // tips ui_->customGnuPGPathTipsLabel->setText( - _("Tips: please select a directroy where \"gpgconf\" is located in.")); + tr("Tips: please select a directroy where \"gpgconf\" is located in.")); ui_->restartTipsLabel->setText( - _("Tips: notice that modify any of these settings will cause an " - "Application restart.")); + tr("Tips: notice that modify any of these settings will cause an " + "Application restart.")); // announce main window connect(this, &GnuPGControllerDialog::SignalRestartNeeded, @@ -92,7 +92,7 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) [=]() { QString selected_custom_key_database_path = QFileDialog::getExistingDirectory( - this, _("Open Directory"), {}, + this, tr("Open Directory"), {}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); GF_UI_LOG_DEBUG("key databse path selected: {}", @@ -123,7 +123,7 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) ui_->useCustomGnuPGInstallPathButton, &QPushButton::clicked, this, [=]() { QString selected_custom_gnupg_install_path = QFileDialog::getExistingDirectory( - this, _("Open Directory"), {}, + this, tr("Open Directory"), {}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); GF_UI_LOG_DEBUG("gnupg install path selected: {}", @@ -169,7 +169,7 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) connect(this, &QDialog::finished, this, &GnuPGControllerDialog::deleteLater); #endif - setWindowTitle(_("GnuPG Controller")); + setWindowTitle(tr("GnuPG Controller")); set_settings(); } @@ -328,23 +328,23 @@ void GnuPGControllerDialog::slot_set_restart_needed(int mode) { bool GnuPGControllerDialog::check_custom_gnupg_path(QString path) { if (path.isEmpty()) { - QMessageBox::critical(this, _("Illegal GnuPG Path"), - _("Target GnuPG Path is empty.")); + QMessageBox::critical(this, tr("Illegal GnuPG Path"), + tr("Target GnuPG Path is empty.")); return false; } QFileInfo dir_info(path); if (!dir_info.exists() || !dir_info.isReadable() || !dir_info.isDir()) { QMessageBox::critical( - this, _("Illegal GnuPG Path"), - _("Target GnuPG Path is not an exists readable directory.")); + this, tr("Illegal GnuPG Path"), + tr("Target GnuPG Path is not an exists readable directory.")); return false; } QDir dir(path); if (!dir.isAbsolute()) { - QMessageBox::critical(this, _("Illegal GnuPG Path"), - _("Target GnuPG Path is not an absolute path.")); + QMessageBox::critical(this, tr("Illegal GnuPG Path"), + tr("Target GnuPG Path is not an absolute path.")); } #ifdef WINDOWS QFileInfo gpgconf_info(path + "/gpgconf.exe"); @@ -355,8 +355,8 @@ bool GnuPGControllerDialog::check_custom_gnupg_path(QString path) { if (!gpgconf_info.exists() || !gpgconf_info.isExecutable() || !gpgconf_info.isFile()) { QMessageBox::critical( - this, _("Illegal GnuPG Path"), - _("Target GnuPG Path contains no \"gpgconf\" executable.")); + this, tr("Illegal GnuPG Path"), + tr("Target GnuPG Path contains no \"gpgconf\" executable.")); return false; } @@ -366,16 +366,16 @@ bool GnuPGControllerDialog::check_custom_gnupg_path(QString path) { auto GnuPGControllerDialog::check_custom_gnupg_key_database_path(QString path) -> bool { if (path.isEmpty()) { - QMessageBox::critical(this, _("Illegal GnuPG Key Database Path"), - _("Target GnuPG Key Database Path is empty.")); + QMessageBox::critical(this, tr("Illegal GnuPG Key Database Path"), + tr("Target GnuPG Key Database Path is empty.")); return false; } QFileInfo dir_info(path); if (!dir_info.exists() || !dir_info.isReadable() || !dir_info.isDir()) { - QMessageBox::critical(this, _("Illegal GnuPG Key Database Path"), - _("Target GnuPG Key Database Path is not an " - "exists readable directory.")); + QMessageBox::critical(this, tr("Illegal GnuPG Key Database Path"), + tr("Target GnuPG Key Database Path is not an " + "exists readable directory.")); return false; } diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 6f8dedc2..54deed22 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -31,11 +31,9 @@ #include <openssl/opensslv.h> #include <any> -#include <string> #include "GpgFrontendBuildInfo.h" #include "core/function/GlobalSettingStation.h" -#include "core/module/Module.h" #include "core/module/ModuleManager.h" #include "ui/dialog/help/GnupgTab.h" @@ -43,7 +41,7 @@ namespace GpgFrontend::UI { AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) : GeneralDialog(typeid(AboutDialog).name(), parent) { - this->setWindowTitle(QString(_("About")) + " " + qApp->applicationName()); + this->setWindowTitle(tr("About") + " " + qApp->applicationName()); auto* tab_widget = new QTabWidget; auto* info_tab = new InfoTab(); @@ -51,10 +49,10 @@ AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) auto* translators_tab = new TranslatorsTab(); update_tab_ = new UpdateTab(); - 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")); + tab_widget->addTab(info_tab, tr("About GpgFrontend")); + tab_widget->addTab(gnupg_tab, tr("GnuPG")); + tab_widget->addTab(translators_tab, tr("Translators")); + tab_widget->addTab(update_tab_, tr("Update")); connect(tab_widget, &QTabWidget::currentChanged, this, [&](int index) { GF_UI_LOG_DEBUG("current index: {}", index); }); @@ -83,26 +81,26 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { "core", "gpgme.version", QString{"2.0.0"}); GF_UI_LOG_DEBUG("got gpgme version from rt: {}", gpgme_version); - auto* pixmap = new QPixmap(":gpgfrontend-logo.png"); + auto* pixmap = new QPixmap(":/icons/gpgfrontend-logo.png"); auto* text = new QString( "<center><h2>" + qApp->applicationName() + "</h2></center>" + "<center><b>" + qApp->applicationVersion() + "</b></center>" + "<center>" + GIT_VERSION + "</center>" + "<br><center>" + - _("GpgFrontend is an easy-to-use, compact, cross-platform, " - "and installation-free GnuPG Frontend." - "It visualizes most of the common operations of GnuPG." - "GpgFrontend is licensed under the GPLv3") + + tr("GpgFrontend is an easy-to-use, compact, cross-platform, " + "and installation-free GnuPG Frontend." + "It visualizes most of the common operations of GnuPG." + "GpgFrontend is licensed under the GPLv3") + "<br><br>" "<b>" + - _("Developer:") + "</b><br>" + "Saturneric" + "<br><br>" + - _("If you have any questions or suggestions, raise an issue at") + + tr("Developer:") + "</b><br>" + "Saturneric" + "<br><br>" + + tr("If you have any questions or suggestions, raise an issue at") + "<br/>" " <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> " + - _("or send a mail to my mailing list at") + " <a " + + tr("or send a mail to my mailing list at") + " <a " + "href=\"mailto:[email protected]\">[email protected]</a>." + "<br><br> " + - _("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + - " " + _("and") + " " + "GPGME" + " " + gpgme_version + "<br>" + - _("Built at") + " " + BUILD_TIMESTAMP + "</center>"); + tr("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + + " " + tr("and") + " " + "GPGME" + " " + gpgme_version + "<br>" + + tr("Built at") + " " + BUILD_TIMESTAMP + "</center>"); auto* layout = new QGridLayout(); auto* pixmap_label = new QLabel(); @@ -139,9 +137,9 @@ TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { main_layout->addStretch(); auto* notice_label = new QLabel( - _("If you think there are any problems with the translation, why not " - "participate in the translation work? If you want to participate, " - "please read the document or contact me via email."), + tr("If you think there are any problems with the translation, why not " + "participate in the translation work? If you want to participate, " + "please read the document or contact me via email."), this); notice_label->setWordWrap(true); main_layout->addWidget(notice_label); @@ -150,7 +148,7 @@ TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { } UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { - auto* pixmap = new QPixmap(":gpgfrontend-logo.png"); + auto* pixmap = new QPixmap(":/icons/gpgfrontend-logo.png"); auto* layout = new QGridLayout(); auto* pixmap_label = new QLabel(); pixmap_label->setPixmap(*pixmap); @@ -162,17 +160,17 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { auto* tips_label = new QLabel(); tips_label->setText( "<center>" + - QString(_("It is recommended that you always check the version " - "of GpgFrontend and upgrade to the latest version.")) + + tr("It is recommended that you always check the version " + "of GpgFrontend and upgrade to the latest version.") + "</center><center>" + - _("New versions not only represent new features, but " - "also often represent functional and security fixes.") + + tr("New versions not only represent new features, but " + "also often represent functional and security fixes.") + "</center>"); tips_label->setWordWrap(true); current_version_label_ = new QLabel(); - current_version_label_->setText("<center>" + QString(_("Current Version")) + - _(": ") + "<b>" + current_version_ + + current_version_label_->setText("<center>" + tr("Current Version") + + tr(": ") + "<b>" + current_version_ + "</b></center>"); current_version_label_->setWordWrap(true); @@ -254,41 +252,41 @@ void UpdateTab::slot_show_version_status() { "version.latest_version", QString{}); latest_version_label_->setText("<center><b>" + - QString(_("Latest Version From Github")) + - ": " + latest_version + "</b></center>"); + tr("Latest Version From Github") + ": " + + latest_version + "</b></center>"); if (is_need_upgrade) { upgrade_label_->setText( "<center>" + - QString(_("The current version is less than the latest version on " - "github.")) + - "</center><center>" + _("Please click") + + tr("The current version is less than the latest version on " + "github.") + + "</center><center>" + tr("Please click") + " <a " "href=\"https://www.gpgfrontend.bktus.com/#/downloads\">" + - _("Here") + "</a> " + _("to download the latest stable version.") + + tr("Here") + "</a> " + tr("to download the latest stable version.") + "</center>"); upgrade_label_->show(); } else if (is_current_a_withdrawn_version) { upgrade_label_->setText( "<center>" + - QString(_("This version has serious problems and has been withdrawn. " - "Please stop using it immediately.")) + - "</center><center>" + _("Please click") + + tr("This version has serious problems and has been withdrawn. " + "Please stop using it immediately.") + + "</center><center>" + tr("Please click") + " <a " "href=\"https://github.com/saturneric/GpgFrontend/releases\">" + - _("Here") + "</a> " + _("to download the latest stable version.") + + tr("Here") + "</a> " + tr("to download the latest stable version.") + "</center>"); upgrade_label_->show(); } else if (!is_current_version_released) { upgrade_label_->setText( "<center>" + - QString(_("This version has not been released yet, it may be a beta " - "version. If you are not a tester and care about version " - "stability, please do not use this version.")) + - "</center><center>" + _("Please click") + + tr("This version has not been released yet, it may be a beta " + "version. If you are not a tester and care about version " + "stability, please do not use this version.") + + "</center><center>" + tr("Please click") + " <a " "href=\"https://www.gpgfrontend.bktus.com/#/downloads\">" + - _("Here") + "</a> " + _("to download the latest stable version.") + + tr("Here") + "</a> " + tr("to download the latest stable version.") + "</center>"); upgrade_label_->show(); } diff --git a/src/ui/dialog/help/GnupgTab.cpp b/src/ui/dialog/help/GnupgTab.cpp index 660732ac..28f1acfe 100644 --- a/src/ui/dialog/help/GnupgTab.cpp +++ b/src/ui/dialog/help/GnupgTab.cpp @@ -41,11 +41,11 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent) ui_->setupUi(this); QStringList components_column_titles; - components_column_titles << _("Name") << _("Description") << _("Version") - << _("Checksum") << _("Binary Path"); + components_column_titles << tr("Name") << tr("Description") << tr("Version") + << tr("Checksum") << tr("Binary Path"); - ui_->tabWidget->setTabText(0, _("Components")); - ui_->tabWidget->setTabText(1, _("Configurations")); + ui_->tabWidget->setTabText(0, tr("Components")); + ui_->tabWidget->setTabText(1, tr("Configurations")); ui_->componentDetailsTable->setColumnCount(components_column_titles.length()); ui_->componentDetailsTable->setHorizontalHeaderLabels( @@ -55,9 +55,9 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent) QAbstractItemView::SelectRows); QStringList configurations_column_titles; - configurations_column_titles << _("Component") << _("Group") << _("Key") - << _("Description") << _("Default Value") - << _("Value"); + configurations_column_titles << tr("Component") << tr("Group") << tr("Key") + << tr("Description") << tr("Default Value") + << tr("Value"); ui_->configurationDetailsTable->setColumnCount( configurations_column_titles.length()); diff --git a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp index 2883d486..7c740063 100644 --- a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp +++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp @@ -49,8 +49,9 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( connect(ui_->setOutputPathButton, &QPushButton::clicked, this, [=]() { auto file_name = QFileDialog::getSaveFileName( - this, _("Export Key Package"), ui_->nameValueLabel->text() + ".gfepack", - QString(_("Key Package")) + " (*.gfepack);;All Files (*)"); + this, tr("Export Key Package"), + ui_->nameValueLabel->text() + ".gfepack", + tr("Key Package") + " (*.gfepack);;All Files (*)"); // check path if (file_name.isEmpty()) return; @@ -60,17 +61,17 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( connect(ui_->generatePassphraseButton, &QPushButton::clicked, this, [=]() { auto file_name = QFileDialog::getSaveFileName( - this, _("Export Key Package Passphrase"), + this, tr("Export Key Package Passphrase"), ui_->nameValueLabel->text() + ".key", - QString(_("Key File")) + " (*.key);;All Files (*)"); + tr("Key File") + " (*.key);;All Files (*)"); // check path if (file_name.isEmpty()) return; if (!KeyPackageOperator::GeneratePassphrase(file_name, passphrase_)) { QMessageBox::critical( - this, _("Error"), - _("An error occurred while generating the passphrase file.")); + this, tr("Error"), + tr("An error occurred while generating the passphrase file.")); return; } ui_->passphraseValueLabel->setText(file_name); @@ -79,17 +80,17 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( connect(ui_->button_box_, &QDialogButtonBox::accepted, this, [=]() { if (ui_->outputPathLabel->text().isEmpty()) { QMessageBox::critical( - this, _("Forbidden"), - _("Please select an output path before exporting.")); + this, tr("Forbidden"), + tr("Please select an output path before exporting.")); return; } if (ui_->passphraseValueLabel->text().isEmpty()) { QMessageBox::critical( - this, _("Forbidden"), - _("Please generate a password to protect your key before exporting, " - "it is very important. Don't forget to back up your password in a " - "safe place.")); + this, tr("Forbidden"), + tr("Please generate a password to protect your key before exporting, " + "it is very important. Don't forget to back up your password in a " + "safe place.")); return; } @@ -102,13 +103,13 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( keys->erase(keys_new_end, keys->end()); if (keys->empty()) { - QMessageBox::critical(this, _("Error"), - _("No key is suitable to export.")); + QMessageBox::critical(this, tr("Error"), + tr("No key is suitable to export.")); return; } CommonUtils::WaitForOpera( - this, _("Generating"), [this, keys](const OperaWaitingHd& op_hd) { + this, tr("Generating"), [this, keys](const OperaWaitingHd& op_hd) { KeyPackageOperator::GenerateKeyPackage( ui_->outputPathLabel->text(), ui_->nameValueLabel->text(), *keys, passphrase_, ui_->includeSecretKeyCheckBox->isChecked(), @@ -118,24 +119,25 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( if (err >= 0) { QMessageBox::information( - this, _("Success"), + this, tr("Success"), QString( - _("The Key Package has been successfully generated " - "and has been protected by encryption " - "algorithms(AES-256-ECB). You can safely transfer " - "your Key Package.")) + + tr("The Key Package has been successfully generated " + "and has been protected by encryption " + "algorithms(AES-256-ECB). You can safely transfer " + "your Key Package.")) + "<br /><br />" + "<b>" + - _("But the key file cannot be leaked under any " - "circumstances. Please delete the Key Package and " - "key file as soon as possible after completing the " - "transfer " - "operation.") + + tr("But the key file cannot be leaked under any " + "circumstances. Please delete the Key Package and " + "key file as soon as possible after completing " + "the " + "transfer " + "operation.") + "</b>"); accept(); } else { QMessageBox::critical( - this, _("Error"), - _("An error occurred while exporting the key package.")); + this, tr("Error"), + tr("An error occurred while exporting the key package.")); } }); }); @@ -144,21 +146,21 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( connect(ui_->button_box_, &QDialogButtonBox::rejected, this, [=]() { this->close(); }); - ui_->nameLabel->setText(_("Key Package Name")); - ui_->selectOutputPathLabel->setText(_("Output Path")); - ui_->passphraseLabel->setText(_("Passphrase")); + ui_->nameLabel->setText(tr("Key Package Name")); + ui_->selectOutputPathLabel->setText(tr("Output Path")); + ui_->passphraseLabel->setText(tr("Passphrase")); ui_->tipsLabel->setText( - _("Tips: You can use Key Package to safely and conveniently transfer " - "your public and private keys between devices.")); - ui_->generatePassphraseButton->setText(_("Generate and Save Passphrase")); - ui_->gnerateNameButton->setText(_("Generate Key Package Name")); - ui_->setOutputPathButton->setText(_("Select Output Path")); + tr("Tips: You can use Key Package to safely and conveniently transfer " + "your public and private keys between devices.")); + ui_->generatePassphraseButton->setText(tr("Generate and Save Passphrase")); + ui_->gnerateNameButton->setText(tr("Generate Key Package Name")); + ui_->setOutputPathButton->setText(tr("Select Output Path")); ui_->includeSecretKeyCheckBox->setText( - _("Include secret key (Think twice before acting)")); + tr("Include secret key (Think twice before acting)")); ui_->noPublicKeyCheckBox->setText( - _("Exclude keys that do not have a private key")); + tr("Exclude keys that do not have a private key")); setAttribute(Qt::WA_DeleteOnClose); - setWindowTitle(_("Export As Key Package")); + setWindowTitle(tr("Export As Key Package")); } diff --git a/src/ui/dialog/import_export/KeyImportDetailDialog.cpp b/src/ui/dialog/import_export/KeyImportDetailDialog.cpp index 7d1303ec..720fa883 100644 --- a/src/ui/dialog/import_export/KeyImportDetailDialog.cpp +++ b/src/ui/dialog/import_export/KeyImportDetailDialog.cpp @@ -39,8 +39,8 @@ KeyImportDetailDialog::KeyImportDetailDialog( m_result_(std::move(result)) { // If no key for import found, just show a message if (m_result_->considered == 0) { - QMessageBox::information(parent, _("Key Import Details"), - _("No keys found to import")); + QMessageBox::information(parent, tr("Key Import Details"), + tr("No keys found to import")); emit finished(0); this->close(); this->deleteLater(); @@ -55,7 +55,7 @@ KeyImportDetailDialog::KeyImportDetailDialog( mv_box->addWidget(button_box_); this->setLayout(mv_box); - this->setWindowTitle(_("Key Import Details")); + this->setWindowTitle(tr("Key Import Details")); this->setMinimumSize(QSize(600, 300)); this->adjustSize(); @@ -69,52 +69,51 @@ KeyImportDetailDialog::KeyImportDetailDialog( void KeyImportDetailDialog::create_general_info_box() { // GridBox for general import information - general_info_box_ = new QGroupBox(_("General key info")); + general_info_box_ = new QGroupBox(tr("General key info")); auto* general_info_box_layout = new QGridLayout(general_info_box_); - general_info_box_layout->addWidget( - new QLabel(QString(_("Considered")) + ": "), 1, 0); + general_info_box_layout->addWidget(new QLabel(tr("Considered") + ": "), 1, 0); general_info_box_layout->addWidget( new QLabel(QString::number(m_result_->considered)), 1, 1); int row = 2; if (m_result_->unchanged != 0) { general_info_box_layout->addWidget( - new QLabel(QString(_("Public unchanged")) + ": "), row, 0); + new QLabel(tr("Public unchanged") + ": "), row, 0); general_info_box_layout->addWidget( new QLabel(QString::number(m_result_->unchanged)), row, 1); row++; } if (m_result_->imported != 0) { - general_info_box_layout->addWidget( - new QLabel(QString(_("Imported")) + ": "), row, 0); + general_info_box_layout->addWidget(new QLabel(tr("Imported") + ": "), row, + 0); general_info_box_layout->addWidget( new QLabel(QString::number(m_result_->imported)), row, 1); row++; } if (m_result_->not_imported != 0) { - general_info_box_layout->addWidget( - new QLabel(QString(_("Not Imported")) + ": "), row, 0); + general_info_box_layout->addWidget(new QLabel(tr("Not Imported") + ": "), + row, 0); general_info_box_layout->addWidget( new QLabel(QString::number(m_result_->not_imported)), row, 1); row++; } if (m_result_->secret_read != 0) { - general_info_box_layout->addWidget( - new QLabel(QString(_("Private Read")) + ": "), row, 0); + general_info_box_layout->addWidget(new QLabel(tr("Private Read") + ": "), + row, 0); general_info_box_layout->addWidget( new QLabel(QString::number(m_result_->secret_read)), row, 1); row++; } if (m_result_->secret_imported != 0) { general_info_box_layout->addWidget( - new QLabel(QString(_("Private Imported")) + ": "), row, 0); + new QLabel(tr("Private Imported") + ": "), row, 0); general_info_box_layout->addWidget( new QLabel(QString::number(m_result_->secret_imported)), row, 1); row++; } if (m_result_->secret_unchanged != 0) { general_info_box_layout->addWidget( - new QLabel(QString(_("Private Unchanged")) + ": "), row, 0); + new QLabel(tr("Private Unchanged") + ": "), row, 0); general_info_box_layout->addWidget( new QLabel(QString::number(m_result_->secret_unchanged)), row, 1); } @@ -129,7 +128,8 @@ void KeyImportDetailDialog::create_keys_table() { keys_table_->setSelectionMode(QAbstractItemView::NoSelection); QStringList header_labels; - header_labels << _("Name") << _("Email") << _("Status") << _("Fingerprint"); + header_labels << tr("Name") << tr("Email") << tr("Status") + << tr("Fingerprint"); keys_table_->verticalHeader()->hide(); keys_table_->setHorizontalHeaderLabels(header_labels); @@ -155,27 +155,27 @@ QString KeyImportDetailDialog::get_status_string(int key_status) { QString status_string; // keystatus is greater than 15, if key is private if (key_status > 15) { - status_string.append(_("Private")); + status_string.append(tr("Private")); key_status = key_status - 16; } else { - status_string.append(_("Public")); + status_string.append(tr("Public")); } if (key_status == 0) { - status_string.append(", " + QString(_("Unchanged"))); + status_string.append(", " + tr("Unchanged")); } else { if (key_status == 1) { - status_string.append(", " + QString(_("New Key"))); + status_string.append(", " + tr("New Key")); } else { if (key_status > 7) { - status_string.append(", " + QString(_("New Subkey"))); + status_string.append(", " + tr("New Subkey")); return status_string; } if (key_status > 3) { - status_string.append(", " + QString(_("New Signature"))); + status_string.append(", " + tr("New Signature")); return status_string; } if (key_status > 1) { - status_string.append(", " + QString(_("New UID"))); + status_string.append(", " + tr("New UID")); return status_string; } } diff --git a/src/ui/dialog/import_export/KeyServerImportDialog.cpp b/src/ui/dialog/import_export/KeyServerImportDialog.cpp index 7cafaaca..49438c44 100644 --- a/src/ui/dialog/import_export/KeyServerImportDialog.cpp +++ b/src/ui/dialog/import_export/KeyServerImportDialog.cpp @@ -55,23 +55,23 @@ KeyServerImportDialog::KeyServerImportDialog(QWidget* parent) } // Buttons - close_button_ = new QPushButton(_("Close")); + close_button_ = new QPushButton(tr("Close")); connect(close_button_, &QPushButton::clicked, this, &KeyServerImportDialog::close); - import_button_ = new QPushButton(_("Import ALL")); + import_button_ = new QPushButton(tr("Import ALL")); connect(import_button_, &QPushButton::clicked, this, &KeyServerImportDialog::slot_import); import_button_->setDisabled(true); - search_button_ = new QPushButton(_("Search")); + search_button_ = new QPushButton(tr("Search")); connect(search_button_, &QPushButton::clicked, this, &KeyServerImportDialog::slot_search); // Line edits for search string - search_label_ = new QLabel(QString(_("Search String")) + _(": ")); + search_label_ = new QLabel(tr("Search String") + tr(": ")); search_line_edit_ = new QLineEdit(); // combobox for keyserver list - key_server_label_ = new QLabel(QString(_("Key Server")) + _(": ")); + key_server_label_ = new QLabel(tr("Key Server") + tr(": ")); key_server_combo_box_ = create_combo_box(); // table containing the keys found @@ -112,7 +112,7 @@ KeyServerImportDialog::KeyServerImportDialog(QWidget* parent) main_layout->addLayout(buttons_layout, 6, 0, 1, 3); this->setLayout(main_layout); - this->setWindowTitle(_("Import Keys from Keyserver")); + this->setWindowTitle(tr("Import Keys from Keyserver")); this->setModal(true); movePosition2CenterOfParent(); @@ -152,7 +152,7 @@ void KeyServerImportDialog::create_keys_table() { keys_table_->setSelectionMode(QAbstractItemView::SingleSelection); QStringList labels; - labels << _("UID") << _("Creation date") << _("KeyID") << _("Tag"); + labels << tr("UID") << tr("Creation date") << tr("KeyID") << tr("Tag"); keys_table_->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::ResizeToContents); keys_table_->setHorizontalHeaderLabels(labels); @@ -165,17 +165,17 @@ void KeyServerImportDialog::create_keys_table() { void KeyServerImportDialog::set_message(const QString& text, bool error) { message_->setText(text); if (error) { - icon_->setPixmap( - QPixmap(":error.png").scaled(QSize(24, 24), Qt::KeepAspectRatio)); + icon_->setPixmap(QPixmap(":/icons/error.png") + .scaled(QSize(24, 24), Qt::KeepAspectRatio)); } else { icon_->setPixmap( - QPixmap(":info.png").scaled(QSize(24, 24), Qt::KeepAspectRatio)); + QPixmap(":/icons/info.png").scaled(QSize(24, 24), Qt::KeepAspectRatio)); } } void KeyServerImportDialog::slot_search() { if (search_line_edit_->text().isEmpty()) { - set_message("<h4>" + QString(_("Text is empty.")) + "</h4>", false); + set_message("<h4>" + tr("Text is empty.") + "</h4>", false); return; } @@ -222,16 +222,16 @@ void KeyServerImportDialog::slot_search_finished( switch (error) { case QNetworkReply::ContentNotFoundError: - set_message(_("Not Key Found"), true); + set_message(tr("Not Key Found"), true); break; case QNetworkReply::TimeoutError: - set_message(_("Timeout"), true); + set_message(tr("Timeout"), true); break; case QNetworkReply::HostNotFoundError: - set_message(_("Key Server Not Found"), true); + set_message(tr("Key Server Not Found"), true); break; default: - set_message(_("Connection Error"), true); + set_message(tr("Connection Error"), true); } return; } @@ -240,36 +240,32 @@ void KeyServerImportDialog::slot_search_finished( auto text = stream.readLine(1024); if (text.contains("Too many responses")) { - set_message( - "<h4>" + QString(_("Too many responses from keyserver!")) + "</h4>", - true); + set_message("<h4>" + tr("Too many responses from keyserver!") + "</h4>", + true); return; } else if (text.contains("No keys found")) { // if string looks like hex string, search again with 0x prepended QRegExp rx("[0-9A-Fa-f]*"); QString query = search_line_edit_->text(); if (rx.exactMatch(query)) { - set_message( - "<h4>" + - QString(_("No keys found, input may be kexId, retrying search " - "with 0x.")) + - "</h4>", - true); + set_message("<h4>" + + tr("No keys found, input may be kexId, retrying search " + "with 0x.") + + "</h4>", + true); search_line_edit_->setText(query.prepend("0x")); this->slot_search(); return; } set_message( - "<h4>" + QString(_("No keys found containing the search string!")) + - "</h4>", + "<h4>" + tr("No keys found containing the search string!") + "</h4>", true); return; } else if (text.contains("Insufficiently specific words")) { - set_message("<h4>" + - QString(_("Insufficiently specific search string!")) + - "</h4>", - true); + set_message( + "<h4>" + tr("Insufficiently specific search string!") + "</h4>", + true); return; } else { set_message(text, true); @@ -302,12 +298,10 @@ void KeyServerImportDialog::slot_search_finished( new QTableWidgetItem(QString("expired"))); } if (flags.contains("r")) { - keys_table_->setItem(row, 3, - new QTableWidgetItem(QString(_("revoked")))); + keys_table_->setItem(row, 3, new QTableWidgetItem(tr("revoked"))); } if (flags.contains("d")) { - keys_table_->setItem(row, 3, - new QTableWidgetItem(QString(_("disabled")))); + keys_table_->setItem(row, 3, new QTableWidgetItem(tr("disabled"))); } } @@ -352,8 +346,7 @@ void KeyServerImportDialog::slot_search_finished( } set_message( QString("<h4>") + - QString(_("%1 keys found. Double click a key to import it.")) - .arg(row) + + tr("%1 keys found. Double click a key to import it.").arg(row) + "</h4>", false); } @@ -419,7 +412,7 @@ void KeyServerImportDialog::slot_import_finished( return; } - set_message(_("Key Imported"), false); + set_message(tr("Key Imported"), false); // refresh the key database emit SignalKeyImported(); @@ -430,7 +423,7 @@ void KeyServerImportDialog::slot_import_finished( void KeyServerImportDialog::set_loading(bool status) { waiting_bar_->setVisible(status); - if (status) set_message(_("Processing ..."), false); + if (status) set_message(tr("Processing ..."), false); } } // namespace GpgFrontend::UI diff --git a/src/ui/dialog/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp index 3fdbc629..da0ea9f4 100644 --- a/src/ui/dialog/import_export/KeyUploadDialog.cpp +++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp @@ -57,7 +57,7 @@ KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids, this->setLayout(layout); this->setModal(true); - this->setWindowTitle(_("Uploading Public Key")); + this->setWindowTitle(tr("Uploading Public Key")); this->setFixedSize(240, 42); this->setPosCenterOfScreen(); } @@ -136,22 +136,22 @@ void KeyUploadDialog::slot_upload_finished() { QString message; switch (error) { case QNetworkReply::ContentNotFoundError: - message = _("Key Not Found"); + message = tr("Key Not Found"); break; case QNetworkReply::TimeoutError: - message = _("Timeout"); + message = tr("Timeout"); break; case QNetworkReply::HostNotFoundError: - message = _("Key Server Not Found"); + message = tr("Key Server Not Found"); break; default: - message = _("Connection Error"); + message = tr("Connection Error"); } QMessageBox::critical(this, "Upload Failed", message); return; } - QMessageBox::information(this, _("Upload Success"), - _("Upload Public Key Successfully")); + QMessageBox::information(this, tr("Upload Success"), + tr("Upload Public Key Successfully")); GF_UI_LOG_DEBUG("success while contacting keyserver!"); reply->deleteLater(); diff --git a/src/ui/dialog/key_generate/KeygenDialog.cpp b/src/ui/dialog/key_generate/KeygenDialog.cpp index 29ea74b6..ad9c7a54 100644 --- a/src/ui/dialog/key_generate/KeygenDialog.cpp +++ b/src/ui/dialog/key_generate/KeygenDialog.cpp @@ -64,7 +64,7 @@ KeyGenDialog::KeyGenDialog(QWidget* parent) generate_key_dialog(); - this->setWindowTitle(_("Generate Key")); + this->setWindowTitle(tr("Generate Key")); this->setAttribute(Qt::WA_DeleteOnClose); this->setModal(true); } @@ -91,18 +91,19 @@ void KeyGenDialog::generate_key_dialog() { } void KeyGenDialog::slot_key_gen_accept() { - std::stringstream error_stream; + QString buffer; + QTextStream error_stream(&buffer); /** * check for errors in keygen dialog input */ if ((name_edit_->text()).size() < 5) { - error_stream << " " << _("Name must contain at least five characters.") + error_stream << " " << tr("Name must contain at least five characters.") << '\n'; } if (email_edit_->text().isEmpty() || !check_email_address(email_edit_->text())) { - error_stream << " " << _("Please give a email address.") << '\n'; + error_stream << " " << tr("Please give a email address.") << '\n'; } /** @@ -110,12 +111,11 @@ void KeyGenDialog::slot_key_gen_accept() { * in the future) */ if (date_edit_->dateTime() > max_date_time_) { - error_stream << " " << _("Expiration time too long.") << '\n'; + error_stream << " " << tr("Expiration time too long.") << '\n'; } - auto err_string = error_stream.str(); - - if (err_string.empty()) { + auto err_string = error_stream.readAll(); + if (err_string.isEmpty()) { /** * create the string for key generation */ @@ -143,7 +143,7 @@ void KeyGenDialog::slot_key_gen_accept() { } CommonUtils::WaitForOpera( - this, _("Generating"), + this, tr("Generating"), [this, gen_key_info = this->gen_key_info_](const OperaWaitingHd& hd) { GpgKeyOpera::GetInstance().GenerateKeyWithSubkey( gen_key_info, gen_subkey_info_, @@ -171,7 +171,7 @@ void KeyGenDialog::slot_key_gen_accept() { QPalette error = error_label_->palette(); error.setColor(QPalette::Window, "#ff8080"); error_label_->setPalette(error); - error_label_->setText(err_string.c_str()); + error_label_->setText(err_string); this->show(); } @@ -183,18 +183,18 @@ QGroupBox* KeyGenDialog::create_key_usage_group_box() { auto* group_box = new QGroupBox(this); auto* grid = new QGridLayout(this); - group_box->setTitle(_("Key Usage")); + group_box->setTitle(tr("Key Usage")); - auto* encrypt = new QCheckBox(_("Encryption"), group_box); + auto* encrypt = new QCheckBox(tr("Encryption"), group_box); encrypt->setTristate(false); - auto* sign = new QCheckBox(_("Signing"), group_box); + auto* sign = new QCheckBox(tr("Signing"), group_box); sign->setTristate(false); - auto* cert = new QCheckBox(_("Certification"), group_box); + auto* cert = new QCheckBox(tr("Certification"), group_box); cert->setTristate(false); - auto* auth = new QCheckBox(_("Authentication"), group_box); + auto* auth = new QCheckBox(tr("Authentication"), group_box); auth->setTristate(false); key_usage_check_boxes_.push_back(encrypt); @@ -406,14 +406,14 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() { auto* vbox1 = new QGridLayout; - vbox1->addWidget(new QLabel(QString(_("Name")) + ": "), 0, 0); - vbox1->addWidget(new QLabel(QString(_("Email Address")) + ": "), 1, 0); - vbox1->addWidget(new QLabel(QString(_("Comment")) + ": "), 2, 0); - vbox1->addWidget(new QLabel(QString(_("Expiration Date")) + ": "), 3, 0); - vbox1->addWidget(new QLabel(QString(_("Never Expire")) + ": "), 3, 3); - vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 4, 0); - vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 5, 0); - vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase"))), 6, 0); + vbox1->addWidget(new QLabel(tr("Name") + ": "), 0, 0); + vbox1->addWidget(new QLabel(tr("Email Address") + ": "), 1, 0); + vbox1->addWidget(new QLabel(tr("Comment") + ": "), 2, 0); + vbox1->addWidget(new QLabel(tr("Expiration Date") + ": "), 3, 0); + vbox1->addWidget(new QLabel(tr("Never Expire") + ": "), 3, 3); + vbox1->addWidget(new QLabel(tr("KeySize (in Bit)") + ": "), 4, 0); + vbox1->addWidget(new QLabel(tr("Key Type") + ": "), 5, 0); + vbox1->addWidget(new QLabel(tr("Non Pass Phrase")), 6, 0); vbox1->addWidget(name_edit_, 0, 1, 1, 3); vbox1->addWidget(email_edit_, 1, 1, 1, 3); @@ -426,7 +426,7 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() { auto* basic_info_group_box = new QGroupBox(); basic_info_group_box->setLayout(vbox1); - basic_info_group_box->setTitle(_("Basic Information")); + basic_info_group_box->setTitle(tr("Basic Information")); return basic_info_group_box; } diff --git a/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp index 1036f9fa..0867354b 100644 --- a/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp +++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp @@ -62,9 +62,9 @@ SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent) group_grid->addWidget(create_basic_info_group_box(), 0, 0); group_grid->addWidget(key_usage_group_box_, 1, 0); - auto* tipps_label = new QLabel( - QString(_("Tipps: if the key pair has a passphrase, the subkey's " - "passphrase must be equal to it."))); + auto* tipps_label = + new QLabel(tr("Tipps: if the key pair has a passphrase, the subkey's " + "passphrase must be equal to it.")); tipps_label->setWordWrap(true); group_grid->addWidget(tipps_label); @@ -76,7 +76,7 @@ SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent) vbox2->addWidget(error_label_); vbox2->addWidget(button_box_); - this->setWindowTitle(_("Generate New Subkey")); + this->setWindowTitle(tr("Generate New Subkey")); this->setLayout(vbox2); this->setAttribute(Qt::WA_DeleteOnClose); this->setModal(true); @@ -89,18 +89,18 @@ QGroupBox* SubkeyGenerateDialog::create_key_usage_group_box() { auto* group_box = new QGroupBox(this); auto* grid = new QGridLayout(this); - group_box->setTitle(_("Key Usage")); + group_box->setTitle(tr("Key Usage")); - auto* encrypt = new QCheckBox(_("Encryption"), group_box); + auto* encrypt = new QCheckBox(tr("Encryption"), group_box); encrypt->setTristate(false); - auto* sign = new QCheckBox(_("Signing"), group_box); + auto* sign = new QCheckBox(tr("Signing"), group_box); sign->setTristate(false); - auto* cert = new QCheckBox(_("Certification"), group_box); + auto* cert = new QCheckBox(tr("Certification"), group_box); cert->setTristate(false); - auto* auth = new QCheckBox(_("Authentication"), group_box); + auto* auth = new QCheckBox(tr("Authentication"), group_box); auth->setTristate(false); key_usage_check_boxes_.push_back(encrypt); @@ -144,11 +144,11 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() { auto* vbox1 = new QGridLayout; - vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 0, 0); - vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 1, 0); - vbox1->addWidget(new QLabel(QString(_("Expiration Date")) + ": "), 2, 0); - vbox1->addWidget(new QLabel(QString(_("Never Expire"))), 2, 3); - vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase"))), 3, 0); + vbox1->addWidget(new QLabel(tr("Key Type") + ": "), 0, 0); + vbox1->addWidget(new QLabel(tr("KeySize (in Bit)") + ": "), 1, 0); + vbox1->addWidget(new QLabel(tr("Expiration Date") + ": "), 2, 0); + vbox1->addWidget(new QLabel(tr("Never Expire")), 2, 3); + vbox1->addWidget(new QLabel(tr("Non Pass Phrase")), 3, 0); vbox1->addWidget(key_type_combo_box_, 0, 1); vbox1->addWidget(key_size_spin_box_, 1, 1); @@ -158,7 +158,7 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() { auto* basic_info_group_box = new QGroupBox(); basic_info_group_box->setLayout(vbox1); - basic_info_group_box->setTitle(_("Basic Information")); + basic_info_group_box->setTitle(tr("Basic Information")); return basic_info_group_box; } @@ -263,19 +263,20 @@ void SubkeyGenerateDialog::refresh_widgets_state() { } void SubkeyGenerateDialog::slot_key_gen_accept() { - std::stringstream err_stream; + QString buffer; + QTextStream err_stream(&buffer); /** * primary keys should have a reasonable expiration date (no more than 2 years * in the future) */ if (date_edit_->dateTime() > QDateTime::currentDateTime().addYears(2)) { - err_stream << " " << _("Expiration time no more than 2 years.") << " "; + err_stream << " " << tr("Expiration time no more than 2 years.") << " "; } - auto err_string = err_stream.str(); + auto err_string = err_stream.readAll(); - if (err_string.empty()) { + if (err_string.isEmpty()) { gen_key_info_->SetKeyLength(key_size_spin_box_->value()); if (expire_check_box_->checkState() != 0U) { @@ -285,7 +286,7 @@ void SubkeyGenerateDialog::slot_key_gen_accept() { } CommonUtils::WaitForOpera( - this, _("Generating"), + this, tr("Generating"), [this, key = this->key_, gen_key_info = this->gen_key_info_](const OperaWaitingHd& hd) { GpgKeyOpera::GetInstance().GenerateSubkey( @@ -311,7 +312,7 @@ void SubkeyGenerateDialog::slot_key_gen_accept() { QPalette error = error_label_->palette(); error.setColor(QPalette::Window, "#ff8080"); error_label_->setPalette(error); - error_label_->setText(err_string.c_str()); + error_label_->setText(err_string); this->show(); } diff --git a/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp b/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp index 012d2a24..6908592b 100644 --- a/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp +++ b/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp @@ -39,12 +39,12 @@ KeyDetailsDialog::KeyDetailsDialog(const GpgKey& key, QWidget* parent) : GeneralDialog(typeid(KeyDetailsDialog).name(), parent) { tab_widget_ = new QTabWidget(); tab_widget_->addTab(new KeyPairDetailTab(key.GetId(), tab_widget_), - _("KeyPair")); - tab_widget_->addTab(new KeyPairUIDTab(key.GetId(), tab_widget_), _("UIDs")); + tr("KeyPair")); + tab_widget_->addTab(new KeyPairUIDTab(key.GetId(), tab_widget_), tr("UIDs")); tab_widget_->addTab(new KeyPairSubkeyTab(key.GetId(), tab_widget_), - _("Subkeys")); + tr("Subkeys")); tab_widget_->addTab(new KeyPairOperaTab(key.GetId(), tab_widget_), - _("Operations")); + tr("Operations")); auto* main_layout = new QVBoxLayout; main_layout->addWidget(tab_widget_); @@ -54,7 +54,7 @@ KeyDetailsDialog::KeyDetailsDialog(const GpgKey& key, QWidget* parent) #endif this->setAttribute(Qt::WA_DeleteOnClose, true); this->setLayout(main_layout); - this->setWindowTitle(_("Key Details")); + this->setWindowTitle(tr("Key Details")); this->setModal(true); this->show(); diff --git a/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp index a548c18d..cd3c0f29 100644 --- a/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp +++ b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp @@ -47,9 +47,9 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) error_label_ = new QLabel(); auto gridLayout = new QGridLayout(); - gridLayout->addWidget(new QLabel(_("Name")), 0, 0); - gridLayout->addWidget(new QLabel(_("Email")), 1, 0); - gridLayout->addWidget(new QLabel(_("Comment")), 2, 0); + gridLayout->addWidget(new QLabel(tr("Name")), 0, 0); + gridLayout->addWidget(new QLabel(tr("Email")), 1, 0); + gridLayout->addWidget(new QLabel(tr("Comment")), 2, 0); gridLayout->addWidget(name_, 0, 1); gridLayout->addWidget(email_, 1, 1); @@ -57,7 +57,7 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) gridLayout->addWidget(create_button_, 3, 0, 1, 2); gridLayout->addWidget( - new QLabel(_("Notice: The New UID Created will be set as Primary.")), 4, + new QLabel(tr("Notice: The New UID Created will be set as Primary.")), 4, 0, 1, 2); gridLayout->addWidget(error_label_, 5, 0, 1, 2); @@ -65,7 +65,7 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) &KeyNewUIDDialog::slot_create_new_uid); this->setLayout(gridLayout); - this->setWindowTitle(_("Create New UID")); + this->setWindowTitle(tr("Create New UID")); this->setAttribute(Qt::WA_DeleteOnClose, true); this->setModal(true); @@ -75,20 +75,21 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) } void KeyNewUIDDialog::slot_create_new_uid() { - std::stringstream error_stream; + QString buffer; + QTextStream error_stream(&buffer); /** * check for errors in keygen dialog input */ if ((name_->text()).size() < 5) { - error_stream << " " << _("Name must contain at least five characters.") - << std::endl; + error_stream << " " << tr("Name must contain at least five characters.") + << Qt::endl; } if (email_->text().isEmpty() || !check_email_address(email_->text())) { - error_stream << " " << _("Please give a email address.") << std::endl; + error_stream << " " << tr("Please give a email address.") << Qt::endl; } - auto error_string = error_stream.str(); - if (error_string.empty()) { + auto error_string = error_stream.readAll(); + if (error_string.isEmpty()) { if (GpgUIDOperator::GetInstance().AddUID( m_key_, name_->text(), comment_->text(), email_->text())) { emit finished(1); @@ -105,7 +106,7 @@ void KeyNewUIDDialog::slot_create_new_uid() { QPalette error = error_label_->palette(); error.setColor(QPalette::Window, "#ff8080"); error_label_->setPalette(error); - error_label_->setText(error_string.c_str()); + error_label_->setText(error_string); this->show(); } diff --git a/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp index 5863dfe9..a91b5fd4 100644 --- a/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp +++ b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp @@ -37,10 +37,10 @@ namespace GpgFrontend::UI { KeyPairDetailTab::KeyPairDetailTab(const QString& key_id, QWidget* parent) : QWidget(parent), key_(GpgKeyGetter::GetInstance().GetKey(key_id)) { - owner_box_ = new QGroupBox(_("Owner")); - key_box_ = new QGroupBox(_("Primary Key")); - fingerprint_box_ = new QGroupBox(_("Fingerprint")); - additional_uid_box_ = new QGroupBox(_("Additional UIDs")); + owner_box_ = new QGroupBox(tr("Owner")); + key_box_ = new QGroupBox(tr("Primary Key")); + fingerprint_box_ = new QGroupBox(tr("Fingerprint")); + additional_uid_box_ = new QGroupBox(tr("Additional UIDs")); name_var_label_ = new QLabel(); name_var_label_->setTextInteractionFlags(Qt::TextSelectableByMouse); @@ -67,27 +67,23 @@ KeyPairDetailTab::KeyPairDetailTab(const QString& key_id, QWidget* parent) auto* vbox_kd = new QGridLayout(); auto* vbox_od = new QGridLayout(); - vbox_od->addWidget(new QLabel(QString(_("Name")) + ": "), 0, 0); - vbox_od->addWidget(new QLabel(QString(_("Email Address")) + ": "), 1, 0); - vbox_od->addWidget(new QLabel(QString(_("Comment")) + ": "), 2, 0); + vbox_od->addWidget(new QLabel(tr("Name") + ": "), 0, 0); + vbox_od->addWidget(new QLabel(tr("Email Address") + ": "), 1, 0); + vbox_od->addWidget(new QLabel(tr("Comment") + ": "), 2, 0); vbox_od->addWidget(name_var_label_, 0, 1); vbox_od->addWidget(email_var_label_, 1, 1); vbox_od->addWidget(comment_var_label_, 2, 1); - vbox_kd->addWidget(new QLabel(QString(_("Key ID")) + ": "), 0, 0); - vbox_kd->addWidget(new QLabel(QString(_("Algorithm")) + ": "), 1, 0); - vbox_kd->addWidget(new QLabel(QString(_("Key Size")) + ": "), 2, 0); - vbox_kd->addWidget(new QLabel(QString(_("Nominal Usage")) + ": "), 3, 0); - vbox_kd->addWidget(new QLabel(QString(_("Actual Usage")) + ": "), 4, 0); - vbox_kd->addWidget(new QLabel(QString(_("Owner Trust Level")) + ": "), 5, 0); - vbox_kd->addWidget(new QLabel(QString(_("Create Date (Local Time)")) + ": "), - 6, 0); - vbox_kd->addWidget(new QLabel(QString(_("Expires on (Local Time)")) + ": "), - 7, 0); - vbox_kd->addWidget(new QLabel(QString(_("Last Update (Local Time)")) + ": "), - 8, 0); - vbox_kd->addWidget(new QLabel(QString(_("Primary Key Existence")) + ": "), 9, - 0); + vbox_kd->addWidget(new QLabel(tr("Key ID") + ": "), 0, 0); + vbox_kd->addWidget(new QLabel(tr("Algorithm") + ": "), 1, 0); + vbox_kd->addWidget(new QLabel(tr("Key Size") + ": "), 2, 0); + vbox_kd->addWidget(new QLabel(tr("Nominal Usage") + ": "), 3, 0); + vbox_kd->addWidget(new QLabel(tr("Actual Usage") + ": "), 4, 0); + vbox_kd->addWidget(new QLabel(tr("Owner Trust Level") + ": "), 5, 0); + vbox_kd->addWidget(new QLabel(tr("Create Date (Local Time)") + ": "), 6, 0); + vbox_kd->addWidget(new QLabel(tr("Expires on (Local Time)") + ": "), 7, 0); + vbox_kd->addWidget(new QLabel(tr("Last Update (Local Time)") + ": "), 8, 0); + vbox_kd->addWidget(new QLabel(tr("Primary Key Existence") + ": "), 9, 0); key_id_var_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); vbox_kd->addWidget(key_id_var_label, 0, 1, 1, 1); @@ -101,7 +97,7 @@ KeyPairDetailTab::KeyPairDetailTab(const QString& key_id, QWidget* parent) vbox_kd->addWidget(last_update_var_label_, 8, 1, 1, 2); vbox_kd->addWidget(primary_key_exist_var_label_, 9, 1, 1, 2); - auto* copy_key_id_button = new QPushButton(_("Copy")); + auto* copy_key_id_button = new QPushButton(tr("Copy")); copy_key_id_button->setFlat(true); copy_key_id_button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); vbox_kd->addWidget(copy_key_id_button, 0, 2); @@ -126,9 +122,9 @@ KeyPairDetailTab::KeyPairDetailTab(const QString& key_id, QWidget* parent) hbox_fp->addStretch(); hbox_fp->addWidget(fingerprint_var_label_); - auto* copy_fingerprint_button = new QPushButton(_("Copy")); + auto* copy_fingerprint_button = new QPushButton(tr("Copy")); copy_fingerprint_button->setFlat(true); - copy_fingerprint_button->setToolTip(_("copy fingerprint to clipboard")); + copy_fingerprint_button->setToolTip(tr("copy fingerprint to clipboard")); connect(copy_fingerprint_button, &QPushButton::clicked, this, &KeyPairDetailTab::slot_copy_fingerprint); @@ -140,7 +136,7 @@ KeyPairDetailTab::KeyPairDetailTab(const QString& key_id, QWidget* parent) mvbox->addStretch(); auto* expBox = new QHBoxLayout(); - QPixmap pixmap(":warning.png"); + QPixmap pixmap(":/icons/warning.png"); exp_label_ = new QLabel(); icon_label_ = new QLabel(); @@ -174,7 +170,7 @@ void KeyPairDetailTab::slot_copy_fingerprint() { void KeyPairDetailTab::slot_refresh_key_info() { // Show the situation that primary key not exists. primary_key_exist_var_label_->setText( - key_.IsHasMasterKey() ? _("Exists") : _("Not Exists")); + key_.IsHasMasterKey() ? tr("Exists") : tr("Not Exists")); if (!key_.IsHasMasterKey()) { auto palette_expired = primary_key_exist_var_label_->palette(); palette_expired.setColor(primary_key_exist_var_label_->foregroundRole(), @@ -207,11 +203,11 @@ void KeyPairDetailTab::slot_refresh_key_info() { QTextStream usage_steam(&buffer); if (key_.IsHasCertificationCapability()) { - usage_steam << _("Certificate") << " "; + usage_steam << tr("Certificate") << " "; } - if (key_.IsHasEncryptionCapability()) usage_steam << _("Encrypt") << " "; - if (key_.IsHasSigningCapability()) usage_steam << _("Sign") << " "; - if (key_.IsHasAuthenticationCapability()) usage_steam << _("Auth") << " "; + if (key_.IsHasEncryptionCapability()) usage_steam << tr("Encrypt") << " "; + if (key_.IsHasSigningCapability()) usage_steam << tr("Sign") << " "; + if (key_.IsHasAuthenticationCapability()) usage_steam << tr("Auth") << " "; usage_var_label_->setText(usage_steam.readAll()); @@ -219,16 +215,16 @@ void KeyPairDetailTab::slot_refresh_key_info() { QTextStream actual_usage_steam(&buffer_2); if (key_.IsHasActualCertificationCapability()) { - actual_usage_steam << _("Certificate") << " "; + actual_usage_steam << tr("Certificate") << " "; } if (key_.IsHasActualEncryptionCapability()) { - actual_usage_steam << _("Encrypt") << " "; + actual_usage_steam << tr("Encrypt") << " "; } if (key_.IsHasActualSigningCapability()) { - actual_usage_steam << _("Sign") << " "; + actual_usage_steam << tr("Sign") << " "; } if (key_.IsHasActualAuthenticationCapability()) { - actual_usage_steam << _("Auth") << " "; + actual_usage_steam << tr("Auth") << " "; } actual_usage_var_label_->setText(actual_usage_steam.readAll()); @@ -243,7 +239,7 @@ void KeyPairDetailTab::slot_refresh_key_info() { key_size_val = QString::number(key_.GetPrimaryKeyLength()); if (key_.GetExpireTime().toSecsSinceEpoch() == 0) { - expire_var_label_->setText(_("Never Expire")); + expire_var_label_->setText(tr("Never Expire")); } else { expire_var_label_->setText( QLocale::system().toString((key_.GetExpireTime()))); @@ -254,7 +250,7 @@ void KeyPairDetailTab::slot_refresh_key_info() { created_var_label_->setText(QLocale::system().toString(key_.GetCreateTime())); if (key_.GetLastUpdateTime().toSecsSinceEpoch() == 0) { - last_update_var_label_->setText(_("No Data")); + last_update_var_label_->setText(tr("No Data")); } else { last_update_var_label_->setText( QLocale::system().toString(key_.GetLastUpdateTime())); @@ -270,12 +266,12 @@ void KeyPairDetailTab::slot_refresh_key_info() { if (key_.IsExpired()) { icon_label_->show(); exp_label_->show(); - exp_label_->setText(_("Warning: The primary key has expired.")); + exp_label_->setText(tr("Warning: The primary key has expired.")); } if (key_.IsRevoked()) { icon_label_->show(); exp_label_->show(); - exp_label_->setText(_("Warning: The primary key has been revoked.")); + exp_label_->setText(tr("Warning: The primary key has been revoked.")); } } diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp index e024b8f0..5b0f4642 100644 --- a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp +++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp @@ -48,29 +48,29 @@ KeyPairOperaTab::KeyPairOperaTab(const QString& key_id, QWidget* parent) CreateOperaMenu(); auto* m_vbox = new QVBoxLayout(this); - auto* opera_key_box = new QGroupBox(_("General Operations")); + auto* opera_key_box = new QGroupBox(tr("General Operations")); auto* vbox_p_k = new QVBoxLayout(); auto* export_h_box_layout = new QHBoxLayout(); vbox_p_k->addLayout(export_h_box_layout); - auto* export_public_button = new QPushButton(_("Export Public Key")); + auto* export_public_button = new QPushButton(tr("Export Public Key")); export_h_box_layout->addWidget(export_public_button); connect(export_public_button, &QPushButton::clicked, this, &KeyPairOperaTab::slot_export_public_key); if (m_key_.IsPrivateKey()) { - auto* export_private_button = new QPushButton(_("Export Private Key")); + auto* export_private_button = new QPushButton(tr("Export Private Key")); export_private_button->setStyleSheet("text-align:center;"); export_private_button->setMenu(secret_key_export_opera_menu_); export_h_box_layout->addWidget(export_private_button); if (m_key_.IsHasMasterKey()) { auto* edit_expires_button = - new QPushButton(_("Modify Expiration Datetime (Primary Key)")); + new QPushButton(tr("Modify Expiration Datetime (Primary Key)")); connect(edit_expires_button, &QPushButton::clicked, this, &KeyPairOperaTab::slot_modify_edit_datetime); - auto* edit_password_button = new QPushButton(_("Modify Password")); + auto* edit_password_button = new QPushButton(tr("Modify Password")); connect(edit_password_button, &QPushButton::clicked, this, &KeyPairOperaTab::slot_modify_password); @@ -89,7 +89,7 @@ KeyPairOperaTab::KeyPairOperaTab(const QString& key_id, QWidget* parent) settings.value("network/forbid_all_gnupg_connection").toBool(); auto* key_server_opera_button = - new QPushButton(_("Key Server Operation (Pubkey)")); + new QPushButton(tr("Key Server Operation (Pubkey)")); key_server_opera_button->setStyleSheet("text-align:center;"); key_server_opera_button->setMenu(key_server_opera_menu_); key_server_opera_button->setDisabled(forbid_all_gnupg_connection); @@ -97,18 +97,18 @@ KeyPairOperaTab::KeyPairOperaTab(const QString& key_id, QWidget* parent) if (m_key_.IsPrivateKey() && m_key_.IsHasMasterKey()) { auto* revoke_cert_gen_button = - new QPushButton(_("Generate Revoke Certificate")); + new QPushButton(tr("Generate Revoke Certificate")); connect(revoke_cert_gen_button, &QPushButton::clicked, this, &KeyPairOperaTab::slot_gen_revoke_cert); advance_h_box_layout->addWidget(revoke_cert_gen_button); } - auto* modify_tofu_button = new QPushButton(_("Modify TOFU Policy")); + auto* modify_tofu_button = new QPushButton(tr("Modify TOFU Policy")); connect(modify_tofu_button, &QPushButton::clicked, this, &KeyPairOperaTab::slot_modify_tofu_policy); auto* set_owner_trust_level_button = - new QPushButton(_("Set Owner Trust Level")); + new QPushButton(tr("Set Owner Trust Level")); connect(set_owner_trust_level_button, &QPushButton::clicked, this, &KeyPairOperaTab::slot_set_owner_trust_level); @@ -131,14 +131,16 @@ KeyPairOperaTab::KeyPairOperaTab(const QString& key_id, QWidget* parent) void KeyPairOperaTab::CreateOperaMenu() { key_server_opera_menu_ = new QMenu(this); - auto* upload_key_pair = new QAction(_("Upload Key Pair to Key Server"), this); + auto* upload_key_pair = + new QAction(tr("Upload Key Pair to Key Server"), this); connect(upload_key_pair, &QAction::triggered, this, &KeyPairOperaTab::slot_upload_key_to_server); if (!(m_key_.IsPrivateKey() && m_key_.IsHasMasterKey())) { upload_key_pair->setDisabled(true); } - auto* update_key_pair = new QAction(_("Sync Key Pair From Key Server"), this); + auto* update_key_pair = + new QAction(tr("Sync Key Pair From Key Server"), this); connect(update_key_pair, &QAction::triggered, this, &KeyPairOperaTab::slot_update_key_from_server); @@ -152,13 +154,14 @@ void KeyPairOperaTab::CreateOperaMenu() { secret_key_export_opera_menu_ = new QMenu(this); - auto* export_full_secret_key = new QAction(_("Export Full Secret Key"), this); + auto* export_full_secret_key = + new QAction(tr("Export Full Secret Key"), this); connect(export_full_secret_key, &QAction::triggered, this, &KeyPairOperaTab::slot_export_private_key); if (!m_key_.IsPrivateKey()) export_full_secret_key->setDisabled(true); auto* export_shortest_secret_key = - new QAction(_("Export Shortest Secret Key"), this); + new QAction(tr("Export Shortest Secret Key"), this); connect(export_shortest_secret_key, &QAction::triggered, this, &KeyPairOperaTab::slot_export_short_private_key); @@ -185,15 +188,14 @@ void KeyPairOperaTab::slot_export_public_key() { std::replace(file_string.begin(), file_string.end(), ' ', '_'); auto file_name = QFileDialog::getSaveFileName( - this, _("Export Key To File"), file_string, - QString(_("Key Files")) + " (*.asc *.txt);;All Files (*)"); + this, tr("Export Key To File"), file_string, + tr("Key Files") + " (*.asc *.txt);;All Files (*)"); if (file_name.isEmpty()) return; if (!WriteFileGFBuffer(file_name, gf_buffer)) { - QMessageBox::critical( - this, _("Export Error"), - QString(_("Couldn't open %1 for writing")).arg(file_name)); + QMessageBox::critical(this, tr("Export Error"), + tr("Couldn't open %1 for writing").arg(file_name)); return; } } @@ -201,15 +203,15 @@ void KeyPairOperaTab::slot_export_public_key() { void KeyPairOperaTab::slot_export_short_private_key() { // Show a information box with explanation about private key int ret = QMessageBox::information( - this, _("Exporting short private Key"), - "<h3>" + QString(_("You are about to export your")) + - "<font color=\"red\">" + _(" PRIVATE KEY ") + "</font>!</h3>\n" + - _("This is NOT your Public Key, so DON'T give it away.") + "<br />" + - _("Do you REALLY want to export your PRIVATE KEY in a Minimum " - "Size?") + + this, tr("Exporting short private Key"), + "<h3>" + tr("You are about to export your") + "<font color=\"red\">" + + tr(" PRIVATE KEY ") + "</font>!</h3>\n" + + tr("This is NOT your Public Key, so DON'T give it away.") + "<br />" + + tr("Do you REALLY want to export your PRIVATE KEY in a Minimum " + "Size?") + "<br />" + - _("For OpenPGP keys it removes all signatures except for the latest " - "self-signatures."), + tr("For OpenPGP keys it removes all signatures except for the latest " + "self-signatures."), QMessageBox::Cancel | QMessageBox::Ok); // export key, if ok was clicked @@ -232,15 +234,14 @@ void KeyPairOperaTab::slot_export_short_private_key() { std::replace(file_string.begin(), file_string.end(), ' ', '_'); auto file_name = QFileDialog::getSaveFileName( - this, _("Export Key To File"), file_string, - QString(_("Key Files")) + " (*.asc *.txt);;All Files (*)"); + this, tr("Export Key To File"), file_string, + tr("Key Files") + " (*.asc *.txt);;All Files (*)"); if (file_name.isEmpty()) return; if (!WriteFileGFBuffer(file_name, gf_buffer)) { - QMessageBox::critical( - this, _("Export Error"), - QString(_("Couldn't open %1 for writing")).arg(file_name)); + QMessageBox::critical(this, tr("Export Error"), + tr("Couldn't open %1 for writing").arg(file_name)); return; } } @@ -249,11 +250,11 @@ void KeyPairOperaTab::slot_export_short_private_key() { void KeyPairOperaTab::slot_export_private_key() { // Show a information box with explanation about private key int ret = QMessageBox::information( - this, _("Exporting private Key"), - "<h3>" + QString(_("You are about to export your")) + - "<font color=\"red\">" + _(" PRIVATE KEY ") + "</font>!</h3>\n" + - _("This is NOT your Public Key, so DON'T give it away.") + "<br />" + - _("Do you REALLY want to export your PRIVATE KEY?"), + this, tr("Exporting private Key"), + "<h3>" + tr("You are about to export your") + "<font color=\"red\">" + + tr(" PRIVATE KEY ") + "</font>!</h3>\n" + + tr("This is NOT your Public Key, so DON'T give it away.") + "<br />" + + tr("Do you REALLY want to export your PRIVATE KEY?"), QMessageBox::Cancel | QMessageBox::Ok); // export key, if ok was clicked @@ -276,15 +277,14 @@ void KeyPairOperaTab::slot_export_private_key() { std::replace(file_string.begin(), file_string.end(), ' ', '_'); auto file_name = QFileDialog::getSaveFileName( - this, _("Export Key To File"), file_string, - QString(_("Key Files")) + " (*.asc *.txt);;All Files (*)"); + this, tr("Export Key To File"), file_string, + tr("Key Files") + " (*.asc *.txt);;All Files (*)"); if (file_name.isEmpty()) return; if (!WriteFileGFBuffer(file_name, gf_buffer)) { - QMessageBox::critical( - this, _("Export Error"), - QString(_("Couldn't open %1 for writing")).arg(file_name)); + QMessageBox::critical(this, tr("Export Error"), + tr("Couldn't open %1 for writing").arg(file_name)); return; } } @@ -312,7 +312,7 @@ void KeyPairOperaTab::slot_update_key_from_server() { } void KeyPairOperaTab::slot_gen_revoke_cert() { - auto literal = QString("%1 (*.rev)").arg(_("Revocation Certificates")); + auto literal = QString("%1 (*.rev)").arg(tr("Revocation Certificates")); QString m_output_file_name; #ifndef WINDOWS @@ -323,7 +323,7 @@ void KeyPairOperaTab::slot_gen_revoke_cert() { m_key_.GetId() + ").rev"; #endif - QFileDialog dialog(this, _("Generate revocation certificate"), file_string, + QFileDialog dialog(this, tr("Generate revocation certificate"), file_string, literal); dialog.setDefaultSuffix(".rev"); dialog.setAcceptMode(QFileDialog::AcceptSave); @@ -344,31 +344,31 @@ void KeyPairOperaTab::slot_modify_password() { void KeyPairOperaTab::slot_modify_tofu_policy() { QStringList items; - items << _("Policy Auto") << _("Policy Good") << _("Policy Bad") - << _("Policy Ask") << _("Policy Unknown"); + items << tr("Policy Auto") << tr("Policy Good") << tr("Policy Bad") + << tr("Policy Ask") << tr("Policy Unknown"); bool ok; QString item = QInputDialog::getItem( - this, _("Modify TOFU Policy(Default is Auto)"), - _("Policy for the Key Pair:"), items, 0, false, &ok); + this, tr("Modify TOFU Policy(Default is Auto)"), + tr("Policy for the Key Pair:"), items, 0, false, &ok); if (ok && !item.isEmpty()) { GF_UI_LOG_DEBUG("selected policy: {}", item.toStdString()); gpgme_tofu_policy_t tofu_policy = GPGME_TOFU_POLICY_AUTO; - if (item == _("Policy Auto")) { + if (item == tr("Policy Auto")) { tofu_policy = GPGME_TOFU_POLICY_AUTO; - } else if (item == _("Policy Good")) { + } else if (item == tr("Policy Good")) { tofu_policy = GPGME_TOFU_POLICY_GOOD; - } else if (item == _("Policy Bad")) { + } else if (item == tr("Policy Bad")) { tofu_policy = GPGME_TOFU_POLICY_BAD; - } else if (item == _("Policy Ask")) { + } else if (item == tr("Policy Ask")) { tofu_policy = GPGME_TOFU_POLICY_ASK; - } else if (item == _("Policy Unknown")) { + } else if (item == tr("Policy Unknown")) { tofu_policy = GPGME_TOFU_POLICY_UNKNOWN; } auto err = GpgKeyOpera::GetInstance().ModifyTOFUPolicy(m_key_, tofu_policy); if (CheckGpgError(err) != GPG_ERR_NO_ERROR) { - QMessageBox::critical(this, _("Not Successful"), - QString(_("Modify TOFU policy not successfully."))); + QMessageBox::critical(this, tr("Not Successful"), + tr("Modify TOFU policy not successfully.")); } } } diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp index 71d2d9fe..3f973fae 100644 --- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp +++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp @@ -40,12 +40,12 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const QString& key_id, QWidget* parent) create_subkey_list(); create_subkey_opera_menu(); - list_box_ = new QGroupBox(_("Subkey List")); - detail_box_ = new QGroupBox(_("Detail of Selected Subkey")); + list_box_ = new QGroupBox(tr("Subkey List")); + detail_box_ = new QGroupBox(tr("Detail of Selected Subkey")); auto* uid_buttons_layout = new QGridLayout(); - auto* add_subkey_button = new QPushButton(_("Generate A New Subkey")); + auto* add_subkey_button = new QPushButton(tr("Generate A New Subkey")); if (!key_.IsPrivateKey() || !key_.IsHasMasterKey()) { add_subkey_button->setDisabled(true); setHidden(add_subkey_button); @@ -62,23 +62,18 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const QString& key_id, QWidget* parent) auto* subkey_detail_layout = new QGridLayout(); - subkey_detail_layout->addWidget(new QLabel(QString(_("Key ID")) + ": "), 0, - 0); - subkey_detail_layout->addWidget(new QLabel(QString(_("Algorithm")) + ": "), 1, - 0); - subkey_detail_layout->addWidget(new QLabel(QString(_("Key Size")) + ": "), 2, - 0); - subkey_detail_layout->addWidget(new QLabel(QString(_("Usage")) + ": "), 3, 0); + subkey_detail_layout->addWidget(new QLabel(tr("Key ID") + ": "), 0, 0); + subkey_detail_layout->addWidget(new QLabel(tr("Algorithm") + ": "), 1, 0); + subkey_detail_layout->addWidget(new QLabel(tr("Key Size") + ": "), 2, 0); + subkey_detail_layout->addWidget(new QLabel(tr("Usage") + ": "), 3, 0); subkey_detail_layout->addWidget( - new QLabel(QString(_("Expires On (Local Time)")) + ": "), 4, 0); + new QLabel(tr("Expires On (Local Time)") + ": "), 4, 0); subkey_detail_layout->addWidget( - new QLabel(QString(_("Create Date (Local Time)")) + ": "), 5, 0); - subkey_detail_layout->addWidget(new QLabel(QString(_("Existence")) + ": "), 6, + new QLabel(tr("Create Date (Local Time)") + ": "), 5, 0); + subkey_detail_layout->addWidget(new QLabel(tr("Existence") + ": "), 6, 0); + subkey_detail_layout->addWidget(new QLabel(tr("Key in Smart Card") + ": "), 7, 0); - subkey_detail_layout->addWidget( - new QLabel(QString(_("Key in Smart Card")) + ": "), 7, 0); - subkey_detail_layout->addWidget(new QLabel(QString(_("Fingerprint")) + ": "), - 8, 0); + subkey_detail_layout->addWidget(new QLabel(tr("Fingerprint") + ": "), 8, 0); key_id_var_label_ = new QLabel(this); key_size_var_label_ = new QLabel(this); @@ -100,7 +95,7 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const QString& key_id, QWidget* parent) subkey_detail_layout->addWidget(card_key_label_, 7, 1, 1, 2); subkey_detail_layout->addWidget(fingerprint_var_label_, 8, 1, 1, 2); - auto* copy_key_id_button = new QPushButton(_("Copy")); + auto* copy_key_id_button = new QPushButton(tr("Copy")); copy_key_id_button->setFlat(true); subkey_detail_layout->addWidget(copy_key_id_button, 0, 2); connect(copy_key_id_button, &QPushButton::clicked, this, [=]() { @@ -157,8 +152,8 @@ void KeyPairSubkeyTab::create_subkey_list() { subkey_list_->setAlternatingRowColors(true); QStringList labels; - labels << _("Subkey ID") << _("Key Size") << _("Algo") << _("Create Date") - << _("Expire Date"); + labels << tr("Subkey ID") << tr("Key Size") << tr("Algo") << tr("Create Date") + << tr("Expire Date"); subkey_list_->setHorizontalHeaderLabels(labels); subkey_list_->horizontalHeader()->setStretchLastSection(false); @@ -200,7 +195,7 @@ void KeyPairSubkeyTab::slot_refresh_subkey_list() { auto* tmp4 = new QTableWidgetItem(subkeys.GetExpireTime().toSecsSinceEpoch() == 0 - ? _("Never Expire") + ? tr("Never Expire") : subkeys.GetExpireTime().toString()); tmp4->setTextAlignment(Qt::AlignCenter); subkey_list_->setItem(row, 4, tmp4); @@ -229,7 +224,7 @@ void KeyPairSubkeyTab::slot_add_subkey() { } void KeyPairSubkeyTab::slot_refresh_subkey_detail() { - auto& subkey = get_selected_subkey(); + const auto& subkey = get_selected_subkey(); key_id_var_label_->setText(subkey.GetID()); key_size_var_label_->setText(QString::number(subkey.GetKeyLength())); @@ -237,7 +232,7 @@ void KeyPairSubkeyTab::slot_refresh_subkey_detail() { time_t subkey_time_t = subkey.GetExpireTime().toSecsSinceEpoch(); expire_var_label_->setText( - subkey_time_t == 0 ? _("Never Expires") + subkey_time_t == 0 ? tr("Never Expires") : QLocale::system().toString(subkey.GetExpireTime())); if (subkey_time_t != 0 && @@ -255,23 +250,24 @@ void KeyPairSubkeyTab::slot_refresh_subkey_detail() { created_var_label_->setText( QLocale::system().toString(subkey.GetCreateTime())); - std::stringstream usage_steam; + QString buffer; + QTextStream usage_steam(&buffer); if (subkey.IsHasCertificationCapability()) { - usage_steam << _("Certificate") << " "; + usage_steam << tr("Certificate") << " "; } - if (subkey.IsHasEncryptionCapability()) usage_steam << _("Encrypt") << " "; - if (subkey.IsHasSigningCapability()) usage_steam << _("Sign") << " "; - if (subkey.IsHasAuthenticationCapability()) usage_steam << _("Auth") << " "; + if (subkey.IsHasEncryptionCapability()) usage_steam << tr("Encrypt") << " "; + if (subkey.IsHasSigningCapability()) usage_steam << tr("Sign") << " "; + if (subkey.IsHasAuthenticationCapability()) usage_steam << tr("Auth") << " "; - usage_var_label_->setText(usage_steam.str().c_str()); + usage_var_label_->setText(usage_steam.readAll()); // Show the situation that secret key not exists. - master_key_exist_var_label_->setText(subkey.IsSecretKey() ? _("Exists") - : _("Not Exists")); + master_key_exist_var_label_->setText(subkey.IsSecretKey() ? tr("Exists") + : tr("Not Exists")); // Show the situation if key in a smart card. - card_key_label_->setText(subkey.IsCardKey() ? _("Yes") : _("No")); + card_key_label_->setText(subkey.IsCardKey() ? tr("Yes") : tr("No")); if (!subkey.IsSecretKey()) { auto palette_expired = master_key_exist_var_label_->palette(); @@ -300,7 +296,7 @@ void KeyPairSubkeyTab::slot_refresh_subkey_detail() { void KeyPairSubkeyTab::create_subkey_opera_menu() { subkey_opera_menu_ = new QMenu(this); - auto* edit_subkey_act = new QAction(_("Edit Expire Date")); + auto* edit_subkey_act = new QAction(tr("Edit Expire Date")); connect(edit_subkey_act, &QAction::triggered, this, &KeyPairSubkeyTab::slot_edit_subkey); diff --git a/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp index 00310c34..fe2f5f02 100644 --- a/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp +++ b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp @@ -47,8 +47,8 @@ KeyPairUIDTab::KeyPairUIDTab(const QString& key_id, QWidget* parent) auto* uid_buttons_layout = new QGridLayout(); - auto* add_uid_button = new QPushButton(_("New UID")); - auto* manage_uid_button = new QPushButton(_("UID Management")); + auto* add_uid_button = new QPushButton(tr("New UID")); + auto* manage_uid_button = new QPushButton(tr("UID Management")); if (m_key_.IsHasMasterKey()) { manage_uid_button->setMenu(manage_selected_uid_menu_); @@ -67,12 +67,12 @@ KeyPairUIDTab::KeyPairUIDTab(const QString& key_id, QWidget* parent) auto* uid_group_box = new QGroupBox(); uid_group_box->setLayout(grid_layout); - uid_group_box->setTitle(_("UIDs")); + uid_group_box->setTitle(tr("UIDs")); auto* tofu_group_box = new QGroupBox(); auto* tofu_vbox_layout = new QVBoxLayout(); tofu_group_box->setLayout(tofu_vbox_layout); - tofu_group_box->setTitle(_("TOFU")); + tofu_group_box->setTitle(tr("TOFU")); #if !defined(RELEASE) tofu_tabs_ = new QTabWidget(this); tofu_vbox_layout->addWidget(tofu_tabs_); @@ -84,7 +84,7 @@ KeyPairUIDTab::KeyPairUIDTab(const QString& key_id, QWidget* parent) auto* sign_group_box = new QGroupBox(); sign_group_box->setLayout(sign_grid_layout); - sign_group_box->setTitle(_("Signature of Selected UID")); + sign_group_box->setTitle(tr("Signature of Selected UID")); auto* vbox_layout = new QVBoxLayout(); vbox_layout->addWidget(uid_group_box); @@ -137,7 +137,7 @@ void KeyPairUIDTab::create_uid_list() { uid_list_->setAlternatingRowColors(true); QStringList labels; - labels << _("Select") << _("Name") << _("Email") << _("Comment"); + labels << tr("Select") << tr("Name") << tr("Email") << tr("Comment"); uid_list_->setHorizontalHeaderLabels(labels); uid_list_->horizontalHeader()->setStretchLastSection(true); } @@ -160,8 +160,8 @@ void KeyPairUIDTab::create_sign_list() { sig_list_->setAlternatingRowColors(true); QStringList labels; - labels << _("Key ID") << _("Name") << _("Email") << _("Create Date") - << _("Expired Date"); + labels << tr("Key ID") << tr("Name") << tr("Email") << tr("Create Date") + << tr("Expired Date"); sig_list_->setHorizontalHeaderLabels(labels); sig_list_->horizontalHeader()->setStretchLastSection(false); } @@ -237,7 +237,7 @@ void KeyPairUIDTab::slot_refresh_tofu_info() { int index = 1; for (const auto& tofu_info : *tofu_infos) { tofu_tabs_->addTab(new TOFUInfoPage(tofu_info, this), - QString(_("TOFU %1")).arg(index++)); + tr("TOFU %1").arg(index++)); } } } @@ -285,7 +285,7 @@ void KeyPairUIDTab::slot_refresh_sig_list() { auto* tmp5 = new QTableWidgetItem( sig.GetExpireTime().toSecsSinceEpoch() == 0 - ? _("Never Expires") + ? tr("Never Expires") : QLocale::system().toString(sig.GetExpireTime())); tmp5->setTextAlignment(Qt::AlignCenter); sig_list_->setItem(sig_row, 4, tmp5); @@ -302,8 +302,8 @@ void KeyPairUIDTab::slot_add_sign() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, _("Invalid Operation"), - _("Please select one or more UIDs before doing this operation.")); + nullptr, tr("Invalid Operation"), + tr("Please select one or more UIDs before doing this operation.")); return; } @@ -325,10 +325,10 @@ auto KeyPairUIDTab::get_uid_checked() -> UIDArgsListPtr { void KeyPairUIDTab::create_manage_uid_menu() { manage_selected_uid_menu_ = new QMenu(this); - auto* sign_uid_act = new QAction(_("Sign Selected UID(s)"), this); + auto* sign_uid_act = new QAction(tr("Sign Selected UID(s)"), this); connect(sign_uid_act, &QAction::triggered, this, &KeyPairUIDTab::slot_add_sign); - auto* del_uid_act = new QAction(_("Delete Selected UID(s)"), this); + auto* del_uid_act = new QAction(tr("Delete Selected UID(s)"), this); connect(del_uid_act, &QAction::triggered, this, &KeyPairUIDTab::slot_del_uid); if (m_key_.IsHasMasterKey()) { @@ -348,11 +348,11 @@ void KeyPairUIDTab::slot_add_uid() { void KeyPairUIDTab::slot_add_uid_result(int result) { if (result == 1) { - QMessageBox::information(nullptr, _("Successful Operation"), - _("Successfully added a new UID.")); + QMessageBox::information(nullptr, tr("Successful Operation"), + tr("Successfully added a new UID.")); } else if (result == -1) { - QMessageBox::critical(nullptr, _("Operation Failed"), - _("An error occurred during the operation.")); + QMessageBox::critical(nullptr, tr("Operation Failed"), + tr("An error occurred during the operation.")); } } @@ -361,8 +361,8 @@ void KeyPairUIDTab::slot_del_uid() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, _("Invalid Operation"), - _("Please select one or more UIDs before doing this operation.")); + nullptr, tr("Invalid Operation"), + tr("Please select one or more UIDs before doing this operation.")); return; } @@ -373,12 +373,12 @@ void KeyPairUIDTab::slot_del_uid() { } int ret = QMessageBox::warning( - this, _("Deleting UIDs"), + this, tr("Deleting UIDs"), "<b>" + QString( - _("Are you sure that you want to delete the following UIDs?")) + + tr("Are you sure that you want to delete the following UIDs?")) + "</b><br/><br/>" + keynames + +"<br/>" + - _("The action can not be undone."), + tr("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { @@ -386,9 +386,8 @@ void KeyPairUIDTab::slot_del_uid() { GF_UI_LOG_DEBUG("uid: {}", uid); if (!GpgUIDOperator::GetInstance().RevUID(m_key_, uid)) { QMessageBox::critical( - nullptr, _("Operation Failed"), - QString(_("An error occurred during the delete %1 operation.")) - .arg(uid)); + nullptr, tr("Operation Failed"), + tr("An error occurred during the delete %1 operation.").arg(uid)); } } emit SignalUpdateUIDInfo(); @@ -412,18 +411,17 @@ void KeyPairUIDTab::slot_set_primary_uid() { keynames.append("<br/>"); int ret = QMessageBox::warning( - this, _("Set Primary UID"), - "<b>" + - QString(_("Are you sure that you want to set the Primary UID to?")) + + this, tr("Set Primary UID"), + "<b>" + tr("Are you sure that you want to set the Primary UID to?") + "</b><br/><br/>" + keynames + +"<br/>" + - _("The action can not be undone."), + tr("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { if (!GpgUIDOperator::GetInstance().SetPrimaryUID(m_key_, selected_uids->front())) { - QMessageBox::critical(nullptr, _("Operation Failed"), - _("An error occurred during the operation.")); + QMessageBox::critical(nullptr, tr("Operation Failed"), + tr("An error occurred during the operation.")); } else { emit SignalUpdateUIDInfo(); } @@ -454,13 +452,13 @@ auto KeyPairUIDTab::get_sign_selected() -> SignIdArgsListPtr { void KeyPairUIDTab::create_uid_popup_menu() { uid_popup_menu_ = new QMenu(this); - auto* ser_primary_uid_act = new QAction(_("Set As Primary"), this); + auto* ser_primary_uid_act = new QAction(tr("Set As Primary"), this); connect(ser_primary_uid_act, &QAction::triggered, this, &KeyPairUIDTab::slot_set_primary_uid); - auto* sign_uid_act = new QAction(_("Sign UID"), this); + auto* sign_uid_act = new QAction(tr("Sign UID"), this); connect(sign_uid_act, &QAction::triggered, this, &KeyPairUIDTab::slot_add_sign_single); - auto* del_uid_act = new QAction(_("Delete UID"), this); + auto* del_uid_act = new QAction(tr("Delete UID"), this); connect(del_uid_act, &QAction::triggered, this, &KeyPairUIDTab::slot_del_uid_single); @@ -483,8 +481,8 @@ void KeyPairUIDTab::slot_add_sign_single() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, _("Invalid Operation"), - _("Please select one UID before doing this operation.")); + nullptr, tr("Invalid Operation"), + tr("Please select one UID before doing this operation.")); return; } @@ -497,8 +495,8 @@ void KeyPairUIDTab::slot_del_uid_single() { auto selected_uids = get_uid_selected(); if (selected_uids->empty()) { QMessageBox::information( - nullptr, _("Invalid Operation"), - _("Please select one UID before doing this operation.")); + nullptr, tr("Invalid Operation"), + tr("Please select one UID before doing this operation.")); return; } @@ -508,18 +506,18 @@ void KeyPairUIDTab::slot_del_uid_single() { keynames.append("<br/>"); int ret = QMessageBox::warning( - this, _("Deleting UID"), + this, tr("Deleting UID"), "<b>" + QString( - _("Are you sure that you want to delete the following uid?")) + + tr("Are you sure that you want to delete the following uid?")) + "</b><br/><br/>" + keynames + +"<br/>" + - _("The action can not be undone."), + tr("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { if (!GpgUIDOperator::GetInstance().RevUID(m_key_, selected_uids->front())) { - QMessageBox::critical(nullptr, _("Operation Failed"), - _("An error occurred during the operation.")); + QMessageBox::critical(nullptr, tr("Operation Failed"), + tr("An error occurred during the operation.")); } else { emit SignalUpdateUIDInfo(); } @@ -529,7 +527,7 @@ void KeyPairUIDTab::slot_del_uid_single() { void KeyPairUIDTab::create_sign_popup_menu() { sign_popup_menu_ = new QMenu(this); - auto* del_sign_act = new QAction(_("Delete(Revoke) Key Signature"), this); + auto* del_sign_act = new QAction(tr("Delete(Revoke) Key Signature"), this); connect(del_sign_act, &QAction::triggered, this, &KeyPairUIDTab::slot_del_sign); @@ -540,8 +538,8 @@ void KeyPairUIDTab::slot_del_sign() { auto selected_signs = get_sign_selected(); if (selected_signs->empty()) { QMessageBox::information( - nullptr, _("Invalid Operation"), - _("Please select one Key Signature before doing this operation.")); + nullptr, tr("Invalid Operation"), + tr("Please select one Key Signature before doing this operation.")); return; } @@ -549,9 +547,9 @@ void KeyPairUIDTab::slot_del_sign() { .GetKey(selected_signs->front().first) .IsGood()) { QMessageBox::critical( - nullptr, _("Invalid Operation"), - _("To delete the signature, you need to have its corresponding public " - "key in the local database.")); + nullptr, tr("Invalid Operation"), + tr("To delete the signature, you need to have its corresponding public " + "key in the local database.")); return; } @@ -560,19 +558,18 @@ void KeyPairUIDTab::slot_del_sign() { keynames.append(selected_signs->front().second); keynames.append("<br/>"); - int ret = - QMessageBox::warning(this, _("Deleting Key Signature"), - "<b>" + - QString(_("Are you sure that you want to delete " - "the following signature?")) + - "</b><br/><br/>" + keynames + +"<br/>" + - _("The action can not be undone."), - QMessageBox::No | QMessageBox::Yes); + int ret = QMessageBox::warning(this, tr("Deleting Key Signature"), + "<b>" + + tr("Are you sure that you want to delete " + "the following signature?") + + "</b><br/><br/>" + keynames + +"<br/>" + + tr("The action can not be undone."), + QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { if (!GpgKeyManager::GetInstance().RevSign(m_key_, selected_signs)) { - QMessageBox::critical(nullptr, _("Operation Failed"), - _("An error occurred during the operation.")); + QMessageBox::critical(nullptr, tr("Operation Failed"), + tr("An error occurred during the operation.")); } } } diff --git a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp index 8ccc8045..a2870965 100644 --- a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp +++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp @@ -78,8 +78,8 @@ void KeySetExpireDateDialog::slot_confirm() { auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent())); msg_box->setAttribute(Qt::WA_DeleteOnClose); msg_box->setStandardButtons(QMessageBox::Ok); - msg_box->setWindowTitle(_("Success")); - msg_box->setText(_("The expire date of the key pair has been updated.")); + msg_box->setWindowTitle(tr("Success")); + msg_box->setText(tr("The expire date of the key pair has been updated.")); msg_box->setModal(true); msg_box->open(); @@ -88,8 +88,8 @@ void KeySetExpireDateDialog::slot_confirm() { this->close(); } else { QMessageBox::critical( - this, _("Failure"), - _("Failed to update the expire date of the key pair.")); + this, tr("Failure"), + tr("Failed to update the expire date of the key pair.")); } } @@ -126,13 +126,13 @@ void KeySetExpireDateDialog::init() { UISignalStation::GetInstance(), &UISignalStation::SignalKeyDatabaseRefresh); - ui_->titleLabel->setText(_("Modified Expiration Date (Local Time)")); - ui_->label->setText( - _("Tips: For the sake of security, the key is valid for up to two years. " - "If you are an expert user, please unlock it for a longer time in the " - "settings.")); - ui_->noExpirationCheckBox->setText(_("No Expiration")); - this->setWindowTitle(_("Modified Expiration Date")); + ui_->titleLabel->setText(tr("Modified Expiration Date (Local Time)")); + ui_->label->setText(tr( + "Tips: For the sake of security, the key is valid for up to two years. " + "If you are an expert user, please unlock it for a longer time in the " + "settings.")); + ui_->noExpirationCheckBox->setText(tr("No Expiration")); + this->setWindowTitle(tr("Modified Expiration Date")); } void KeySetExpireDateDialog::slot_non_expired_checked(int state) { diff --git a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp index 55cafe55..ba12f232 100644 --- a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp +++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp @@ -43,7 +43,7 @@ KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid, const auto key_id = m_key_.GetId(); m_key_list_ = new KeyList(KeyMenuAbility::NONE, this); m_key_list_->AddListGroupTab( - _("Signers"), "signers", KeyListRow::ONLY_SECRET_KEY, + tr("Signers"), "signers", KeyListRow::ONLY_SECRET_KEY, KeyListColumn::NAME | KeyListColumn::EmailAddress, [key_id](const GpgKey& key, const KeyTable&) -> bool { return !(key.IsDisabled() || !key.IsHasCertificationCapability() || @@ -83,7 +83,7 @@ KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid, layout->addWidget(m_key_list_, 0, 0); layout->addWidget(sign_key_button_, 2, 0, Qt::AlignRight); - timeLayout->addWidget(new QLabel(_("Expire Date")), 0, 0); + timeLayout->addWidget(new QLabel(tr("Expire Date")), 0, 0); timeLayout->addWidget(expires_edit_, 0, 1); timeLayout->addWidget(non_expire_check_, 0, 2); layout->addLayout(timeLayout, 1, 0); @@ -93,7 +93,7 @@ KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid, this->setLayout(layout); this->setModal(true); - this->setWindowTitle(_("Sign For Key's UID(s)")); + this->setWindowTitle(tr("Sign For Key's UID(s)")); this->adjustSize(); setAttribute(Qt::WA_DeleteOnClose, true); @@ -117,13 +117,14 @@ void KeyUIDSignDialog::slot_sign_key(bool clicked) { // Sign For mKey if (!GpgKeyManager::GetInstance().SignKey(m_key_, *keys, uid, expires)) { QMessageBox::critical( - nullptr, _("Unsuccessful Operation"), - QString(_("Signature operation failed for UID %1")).arg(uid)); + nullptr, tr("Unsuccessful Operation"), + tr("Signature operation failed for UID %1").arg(uid)); } } - QMessageBox::information(nullptr, _("Operation Complete"), - _("The signature operation of the UID is complete")); + QMessageBox::information( + nullptr, tr("Operation Complete"), + tr("The signature operation of the UID is complete")); this->close(); emit SignalKeyUIDSignUpdate(); } diff --git a/src/ui/dialog/settings/SettingsAppearance.cpp b/src/ui/dialog/settings/SettingsAppearance.cpp index b1843388..d4f97c4c 100644 --- a/src/ui/dialog/settings/SettingsAppearance.cpp +++ b/src/ui/dialog/settings/SettingsAppearance.cpp @@ -39,26 +39,26 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent), ui_(SecureCreateSharedObject<Ui_AppearanceSettings>()) { ui_->setupUi(this); - ui_->iconSizeBox->setTitle(_("Icon Size")); - ui_->smallRadioButton->setText(_("small")); - ui_->mediumRadioButton->setText(_("medium")); - ui_->largeRadioButton->setText(_("large")); + ui_->iconSizeBox->setTitle(tr("Icon Size")); + ui_->smallRadioButton->setText(tr("small")); + ui_->mediumRadioButton->setText(tr("medium")); + ui_->largeRadioButton->setText(tr("large")); - ui_->iconStyleBox->setTitle(_("Icon Style")); - ui_->justTextRadioButton->setText(_("just text")); - ui_->justIconRadioButton->setText(_("just icons")); - ui_->textAndIconsRadioButton->setText(_("text and icons")); + ui_->iconStyleBox->setTitle(tr("Icon Style")); + ui_->justTextRadioButton->setText(tr("just text")); + ui_->justIconRadioButton->setText(tr("just icons")); + ui_->textAndIconsRadioButton->setText(tr("text and icons")); - ui_->windowStateBox->setTitle(_("Window State")); + ui_->windowStateBox->setTitle(tr("Window State")); ui_->windowStateCheckBox->setText( - _("Save window size and position on exit.")); + tr("Save window size and position on exit.")); - ui_->textEditorBox->setTitle(_("Text Editor")); - ui_->fontSizeTextEditorLabel->setText(_("Font Size in Text Editor")); + ui_->textEditorBox->setTitle(tr("Text Editor")); + ui_->fontSizeTextEditorLabel->setText(tr("Font Size in Text Editor")); - ui_->informationBoardBox->setTitle(_("Information Board")); + ui_->informationBoardBox->setTitle(tr("Information Board")); ui_->fontSizeInformationBoardLabel->setText( - _("Font Size in Information Board")); + tr("Font Size in Information Board")); icon_size_group_ = new QButtonGroup(this); icon_size_group_->addButton(ui_->smallRadioButton, 1); diff --git a/src/ui/dialog/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp index 834f1096..a1ac1885 100644 --- a/src/ui/dialog/settings/SettingsDialog.cpp +++ b/src/ui/dialog/settings/SettingsDialog.cpp @@ -51,10 +51,10 @@ SettingsDialog::SettingsDialog(QWidget* parent) main_layout->addWidget(tab_widget_); main_layout->stretch(0); - tab_widget_->addTab(general_tab_, _("General")); - tab_widget_->addTab(appearance_tab_, _("Appearance")); - tab_widget_->addTab(key_server_tab_, _("Key Server")); - tab_widget_->addTab(network_tab_, _("Network")); + tab_widget_->addTab(general_tab_, tr("General")); + tab_widget_->addTab(appearance_tab_, tr("Appearance")); + tab_widget_->addTab(key_server_tab_, tr("Key Server")); + tab_widget_->addTab(network_tab_, tr("Network")); #ifndef MACOS button_box_ = @@ -65,11 +65,11 @@ SettingsDialog::SettingsDialog(QWidget* parent) &SettingsDialog::reject); mainLayout->addWidget(button_box_); mainLayout->stretch(0); - setWindowTitle(_("Settings")); + setWindowTitle(tr("Settings")); #else connect(this, &QDialog::finished, this, &SettingsDialog::SlotAccept); connect(this, &QDialog::finished, this, &SettingsDialog::deleteLater); - setWindowTitle(_("Preference")); + setWindowTitle(tr("Preference")); #endif setLayout(main_layout); @@ -125,23 +125,22 @@ void SettingsDialog::SlotAccept() { auto SettingsDialog::ListLanguages() -> QHash<QString, QString> { QHash<QString, QString> languages; - languages.insert(QString(), _("System Default")); + languages.insert(QString(), tr("System Default")); - auto locale_path = GlobalSettingStation::GetInstance().GetLocaleDir(); + QStringList filenames = QDir(QLatin1String(":/i18n")).entryList(); + for (const auto& file : filenames) { + GF_UI_LOG_DEBUG("get locale from locale directory: {}", file.toStdString()); - auto locale_dir = QDir(locale_path); - QStringList file_names = locale_dir.entryList(QStringList("*")); - - for (const auto& locale : file_names) { - GF_UI_LOG_DEBUG("get locale from locale directory: {}", - locale.toStdString()); - if (locale == "." || locale == "..") continue; + auto start = file.indexOf('.') + 1; + auto end = file.lastIndexOf('.'); + if (start < 0 || end < 0 || start >= end) continue; + auto locale = file.mid(start, end - start); QLocale const q_locale(locale); if (q_locale.nativeTerritoryName().isEmpty()) continue; auto language = q_locale.nativeLanguageName() + " (" + locale + ")"; - languages.insert(locale, language); + languages.insert(q_locale.name(), language); } return languages; } diff --git a/src/ui/dialog/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp index 4c9c0368..44c66e10 100644 --- a/src/ui/dialog/settings/SettingsGeneral.cpp +++ b/src/ui/dialog/settings/SettingsGeneral.cpp @@ -40,30 +40,30 @@ GeneralTab::GeneralTab(QWidget* parent) ui_(GpgFrontend::SecureCreateSharedObject<Ui_GeneralSettings>()) { ui_->setupUi(this); - ui_->cacheBox->setTitle(_("Cache")); + ui_->cacheBox->setTitle(tr("Cache")); ui_->clearGpgPasswordCacheCheckBox->setText( - _("Clear gpg password cache when closing GpgFrontend.")); + tr("Clear gpg password cache when closing GpgFrontend.")); ui_->restoreTextEditorPageCheckBox->setText( - _("Automatically restore unsaved Text Editor pages after an application " - "crash.")); + tr("Automatically restore unsaved Text Editor pages after an application " + "crash.")); - ui_->importConfirmationBox->setTitle(_("Operation")); + ui_->importConfirmationBox->setTitle(tr("Operation")); ui_->longerKeyExpirationDateCheckBox->setText( - _("Enable to use longer key expiration date.")); + tr("Enable to use longer key expiration date.")); ui_->importConfirmationCheckBox->setText( - _("Import files dropped on the Key List without confirmation.")); + tr("Import files dropped on the Key List without confirmation.")); - ui_->langBox->setTitle(_("Language")); + ui_->langBox->setTitle(tr("Language")); ui_->langNoteLabel->setText( - "<b>" + QString(_("NOTE")) + _(": ") + "</b>" + - _("GpgFrontend will restart automatically if you change the language!")); + "<b>" + tr("NOTE") + tr(": ") + "</b>" + + tr("GpgFrontend will restart automatically if you change the language!")); - ui_->dataBox->setTitle(_("Data")); + ui_->dataBox->setTitle(tr("Data")); ui_->clearAllLogFilesButton->setText( - QString(_("Clear All Log (Total Size: %1)")) % - GlobalSettingStation::GetInstance().GetLogFilesSize()); + tr("Clear All Log (Total Size: %1)") + .arg(GlobalSettingStation::GetInstance().GetLogFilesSize())); ui_->clearAllDataObjectsButton->setText( - QString(_("Clear All Data Objects (Total Size: %1)")) + tr("Clear All Data Objects (Total Size: %1)") .arg(GlobalSettingStation::GetInstance().GetDataObjectsFilesSize())); lang_ = SettingsDialog::ListLanguages(); @@ -76,22 +76,21 @@ GeneralTab::GeneralTab(QWidget* parent) connect(ui_->clearAllLogFilesButton, &QPushButton::clicked, this, [=]() { GlobalSettingStation::GetInstance().ClearAllLogFiles(); ui_->clearAllLogFilesButton->setText( - QString(_("Clear All Log (Total Size: %1)")) + tr("Clear All Log (Total Size: %1)") .arg(GlobalSettingStation::GetInstance().GetLogFilesSize())); }); connect(ui_->clearAllDataObjectsButton, &QPushButton::clicked, this, [=]() { QMessageBox::StandardButton reply; reply = QMessageBox::question( - this, _("Confirm"), - _("Are you sure you want to clear all data objects?\nThis will result " - "in " - "loss of all cached form positions, statuses, key servers, etc."), + this, tr("Confirm"), + tr("Are you sure you want to clear all data objects?\nThis will result " + "in loss of all cached form positions, statuses, key servers, etc."), QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { GlobalSettingStation::GetInstance().ClearAllDataObjects(); ui_->clearAllDataObjectsButton->setText( - QString(_("Clear All Data Objects (Total Size: %1)")) + tr("Clear All Data Objects (Total Size: %1)") .arg(GlobalSettingStation::GetInstance() .GetDataObjectsFilesSize())); } diff --git a/src/ui/dialog/settings/SettingsKeyServer.cpp b/src/ui/dialog/settings/SettingsKeyServer.cpp index d51ba1af..5613ed45 100644 --- a/src/ui/dialog/settings/SettingsKeyServer.cpp +++ b/src/ui/dialog/settings/SettingsKeyServer.cpp @@ -52,25 +52,25 @@ KeyserverTab::KeyserverTab(QWidget* parent) connect(ui_->testKeyServerButton, &QPushButton::clicked, this, &KeyserverTab::slot_test_listed_key_server); - ui_->keyServerListGroupBox->setTitle(_("Keyserver List")); - ui_->operationsGroupBox->setTitle(_("Operations")); + ui_->keyServerListGroupBox->setTitle(tr("Keyserver List")); + ui_->operationsGroupBox->setTitle(tr("Operations")); - ui_->keyServerListTable->horizontalHeaderItem(0)->setText(_("Default")); + ui_->keyServerListTable->horizontalHeaderItem(0)->setText(tr("Default")); ui_->keyServerListTable->horizontalHeaderItem(1)->setText( - _("Keyserver Address")); - ui_->keyServerListTable->horizontalHeaderItem(2)->setText(_("Security")); - ui_->keyServerListTable->horizontalHeaderItem(3)->setText(_("Available")); + tr("Keyserver Address")); + ui_->keyServerListTable->horizontalHeaderItem(2)->setText(tr("Security")); + ui_->keyServerListTable->horizontalHeaderItem(3)->setText(tr("Available")); - ui_->addKeyServerPushButton->setText(_("Add")); - ui_->testKeyServerButton->setText(_("Test Listed Keyserver")); + ui_->addKeyServerPushButton->setText(tr("Add")); + ui_->testKeyServerButton->setText(tr("Test Listed Keyserver")); ui_->tipsLabel->setText( - _("Tips: Please Double-click table item to edit it.")); - ui_->actionDelete_Selected_Key_Server->setText(_("Delete Selected")); + tr("Tips: Please Double-click table item to edit it.")); + ui_->actionDelete_Selected_Key_Server->setText(tr("Delete Selected")); ui_->actionDelete_Selected_Key_Server->setToolTip( - _("Delete Selected Key Server")); - ui_->actionSet_As_Default->setText(_("Set As Default")); - ui_->actionSet_As_Default->setToolTip(_("Set As Default")); + tr("Delete Selected Key Server")); + ui_->actionSet_As_Default->setText(tr("Set As Default")); + ui_->actionSet_As_Default->setToolTip(tr("Set As Default")); popup_menu_ = new QMenu(this); popup_menu_->addAction(ui_->actionSet_As_Default); @@ -140,21 +140,21 @@ void KeyserverTab::slot_add_key_server() { ; } else if (target_url.startsWith("http://")) { QMessageBox::warning( - this, _("Insecure keyserver address"), - _("For security reasons, using HTTP as the communication protocol " - "with " - "the key server is not recommended. It is recommended to use " - "HTTPS.")); + this, tr("Insecure keyserver address"), + tr("For security reasons, using HTTP as the communication protocol " + "with " + "the key server is not recommended. It is recommended to use " + "HTTPS.")); } key_server_str_list_.append(ui_->addKeyServerEdit->text()); } else { auto ret = QMessageBox::warning( - this, _("Warning"), - _("You may not use HTTPS or HTTP as the protocol for communicating " - "with the key server, which may not be wrong. But please check the " - "address you entered again to make sure it is correct. Are you " - "sure " - "that want to add it into the keyserver list?"), + this, tr("Warning"), + tr("You may not use HTTPS or HTTP as the protocol for communicating " + "with the key server, which may not be wrong. But please check the " + "address you entered again to make sure it is correct. Are you " + "sure " + "that want to add it into the keyserver list?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -197,13 +197,13 @@ void KeyserverTab::slot_refresh_table() { tmp2->setTextAlignment(Qt::AlignCenter); ui_->keyServerListTable->setItem(index, 1, tmp2); - auto* tmp3 = new QTableWidgetItem(server.startsWith("https") ? _("true") - : _("false")); + auto* tmp3 = new QTableWidgetItem(server.startsWith("https") ? tr("true") + : tr("false")); tmp3->setTextAlignment(Qt::AlignCenter); ui_->keyServerListTable->setItem(index, 2, tmp3); tmp3->setFlags(tmp3->flags() ^ Qt::ItemIsEditable); - auto* tmp4 = new QTableWidgetItem(_("unknown")); + auto* tmp4 = new QTableWidgetItem(tr("unknown")); tmp4->setTextAlignment(Qt::AlignCenter); ui_->keyServerListTable->setItem(index, 3, tmp4); tmp4->setFlags(tmp3->flags() ^ Qt::ItemIsEditable); @@ -217,7 +217,7 @@ void KeyserverTab::slot_refresh_table() { } void KeyserverTab::slot_test_listed_key_server() { - auto timeout = QInputDialog::getInt(this, _("Set TCP Timeout"), + auto timeout = QInputDialog::getInt(this, tr("Set TCP Timeout"), tr("timeout(ms): "), 2500, 200, 16000); QStringList urls; @@ -242,10 +242,10 @@ void KeyserverTab::slot_test_listed_key_server() { const auto status = result[i]; auto* status_iem = ui_->keyServerListTable->item(i, 3); if (status == ListedKeyServerTestTask::kTEST_RESULT_TYPE_SUCCESS) { - status_iem->setText(_("Reachable")); + status_iem->setText(tr("Reachable")); status_iem->setForeground(QBrush(QColor::fromRgb(0, 255, 0))); } else { - status_iem->setText(_("Not Reachable")); + status_iem->setText(tr("Not Reachable")); status_iem->setForeground(QBrush(QColor::fromRgb(255, 0, 0))); } } @@ -256,11 +256,11 @@ void KeyserverTab::slot_test_listed_key_server() { auto* waiting_dialog = new QProgressDialog(this); waiting_dialog->setMaximum(0); waiting_dialog->setMinimum(0); - auto* waiting_dialog_label = - new QLabel(QString(_("Test Key Server Connection...")) + "<br /><br />" + - _("This test only tests the network connectivity of the key " - "server. Passing the test does not mean that the key server " - "is functionally available.")); + auto* waiting_dialog_label = new QLabel( + tr("Test Key Server Connection...") + "<br /><br />" + + tr("This test only tests the network connectivity of the key " + "server. Passing the test does not mean that the key server " + "is functionally available.")); waiting_dialog_label->setWordWrap(true); waiting_dialog->setLabel(waiting_dialog_label); waiting_dialog->resize(420, 120); diff --git a/src/ui/dialog/settings/SettingsNetwork.cpp b/src/ui/dialog/settings/SettingsNetwork.cpp index ac6160e8..c7e1e9f6 100644 --- a/src/ui/dialog/settings/SettingsNetwork.cpp +++ b/src/ui/dialog/settings/SettingsNetwork.cpp @@ -68,31 +68,31 @@ GpgFrontend::UI::NetworkTab::NetworkTab(QWidget *parent) connect(ui_->checkProxyConnectionButton, &QPushButton::clicked, this, &NetworkTab::slot_test_proxy_connection_result); - ui_->proxyGroupBox->setTitle(_("Proxy")); - ui_->capabilityGroupBox->setTitle(_("Network Ability")); - ui_->operationsGroupBox->setTitle(_("Operations")); + ui_->proxyGroupBox->setTitle(tr("Proxy")); + ui_->capabilityGroupBox->setTitle(tr("Network Ability")); + ui_->operationsGroupBox->setTitle(tr("Operations")); - ui_->enableProxyCheckBox->setText(_("Enable Proxy")); - ui_->proxyServerPortLabel->setText(_("Port")); + ui_->enableProxyCheckBox->setText(tr("Enable Proxy")); + ui_->proxyServerPortLabel->setText(tr("Port")); - ui_->proxyServerAddressLabel->setText(_("Host Address")); - ui_->proxyServerPortLabel->setText(_("Port")); - ui_->proxyTypeLabel->setText(_("Proxy Type")); - ui_->usernameLabel->setText(_("Username")); - ui_->passwordLabel->setText(_("Password")); + ui_->proxyServerAddressLabel->setText(tr("Host Address")); + ui_->proxyServerPortLabel->setText(tr("Port")); + ui_->proxyTypeLabel->setText(tr("Proxy Type")); + ui_->usernameLabel->setText(tr("Username")); + ui_->passwordLabel->setText(tr("Password")); ui_->checkProxyConnectionButton->setText( - _("Apply Proxy Settings and Check Proxy Connection")); + tr("Apply Proxy Settings and Check Proxy Connection")); ui_->forbidALLGnuPGNetworkConnectionCheckBox->setText( - _("Forbid all GnuPG network connection.")); + tr("Forbid all GnuPG network connection.")); ui_->prohibitUpdateCheck->setText( - _("Prohibit checking for version updates when the program starts.")); + tr("Prohibit checking for version updates when the program starts.")); ui_->autoImportMissingKeyCheckBox->setText( - _("Automatically import a missing key for signature verification.")); + tr("Automatically import a missing key for signature verification.")); ui_->networkAbilityTipsLabel->setText( - _("Tips: These Option Changes take effect only after the " - "application restart.")); + tr("Tips: These Option Changes take effect only after the " + "application restart.")); SetSettings(); } @@ -167,7 +167,7 @@ void GpgFrontend::UI::NetworkTab::slot_test_proxy_connection_result() { apply_proxy_settings(); bool ok; - auto url = QInputDialog::getText(this, _("Test Server Url Accessibility"), + auto url = QInputDialog::getText(this, tr("Test Server Url Accessibility"), tr("Server Url"), QLineEdit::Normal, "https://", &ok); if (ok && !url.isEmpty()) { @@ -177,14 +177,15 @@ void GpgFrontend::UI::NetworkTab::slot_test_proxy_connection_result() { SignalProxyConnectionTestResult, this, [=](const QString &result) { if (result == "Reachable") { - QMessageBox::information(this, _("Success"), - _("Successfully connect to the target " - "server through the proxy server.")); + QMessageBox::information( + this, tr("Success"), + tr("Successfully connect to the target " + "server through the proxy server.")); } else { QMessageBox::critical( - this, _("Failed"), - _("Unable to connect to the target server through the " - "proxy server. Proxy settings may be invalid.")); + this, tr("Failed"), + tr("Unable to connect to the target server through the " + "proxy server. Proxy settings may be invalid.")); } }); @@ -193,9 +194,10 @@ void GpgFrontend::UI::NetworkTab::slot_test_proxy_connection_result() { waiting_dialog->setMaximum(0); waiting_dialog->setMinimum(0); auto waiting_dialog_label = new QLabel( - QString(_("Test Proxy Server Connection...")) + "<br /><br />" + - _("Is using your proxy settings to access the url. Note that this test " - "operation will apply your proxy settings to the entire software.")); + tr("Test Proxy Server Connection...") + "<br /><br />" + + tr("Is using your proxy settings to access the url. Note that this " + "test " + "operation will apply your proxy settings to the entire software.")); waiting_dialog_label->setWordWrap(true); waiting_dialog->setLabel(waiting_dialog_label); waiting_dialog->resize(420, 120); diff --git a/src/ui/function/ArchiveDirectory.cpp b/src/ui/function/ArchiveDirectory.cpp deleted file mode 100644 index f0151705..00000000 --- a/src/ui/function/ArchiveDirectory.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (C) 2021 Saturneric <[email protected]> - * - * 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 "ArchiveDirectory.h" - -#include "core/function/ArchiveFileOperator.h" - -namespace GpgFrontend::UI { - -auto PathPreCheck(QWidget* parent, const std::filesystem::path& path) -> bool { - QFileInfo const file_info(path); - QFileInfo const path_info(file_info.absolutePath()); - - if (!path_info.exists()) { - QMessageBox::critical( - parent, _("Error"), - QString(_("The path %1 does not exist.")).arg(path.c_str())); - return false; - } - - if (!path_info.isDir()) { - QMessageBox::critical( - parent, _("Error"), - QString(_("The path %1 is not a directory.")).arg(path.c_str())); - return false; - } - - if (!file_info.isReadable()) { - QMessageBox::critical(parent, _("Error"), - _("No permission to read this file.")); - return false; - } - return true; -} - -ArchiveDirectory::ArchiveDirectory(QWidget* parent) : QWidget(parent) {} - -auto ArchiveDirectory::Exec(const std::filesystem::path& target_directory) - -> std::tuple<bool, GFBuffer> { - if (!PathPreCheck(this, target_directory)) { - return {false, {}}; - } - - try { - auto base_path = target_directory.parent_path(); - auto target_path = target_directory; - target_path = target_path.replace_extension(""); - - GF_UI_LOG_DEBUG("archive directory, base path: {}, target path: {}", - base_path.string(), target_path.string()); - - // ArchiveFileOperator::CreateArchive(base_path, target_path, 0, ); - - } catch (...) { - GF_UI_LOG_ERROR("archive caught exception error"); - return {false, {}}; - } - return {true, {}}; -} - -} // namespace GpgFrontend::UI
\ No newline at end of file diff --git a/src/ui/function/ArchiveDirectory.h b/src/ui/function/ArchiveDirectory.h deleted file mode 100644 index 8b21c7e1..00000000 --- a/src/ui/function/ArchiveDirectory.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (C) 2021 Saturneric <[email protected]> - * - * 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 - * - */ - -#pragma once - -#include "core/model/GFBuffer.h" -#include "ui/GpgFrontendUI.h" - -namespace GpgFrontend::UI { -class ArchiveDirectory : public QWidget { - Q_OBJECT - public: - /** - * @brief Construct a new Raise Pinentry object - * - * @param parent - */ - explicit ArchiveDirectory(QWidget* parent); - - /** - * @brief - * - * @return int - */ - auto Exec(const std::filesystem::path& target_directory) - -> std::tuple<bool, GFBuffer>; -}; -} // namespace GpgFrontend::UI
\ No newline at end of file diff --git a/src/ui/function/RaisePinentry.cpp b/src/ui/function/RaisePinentry.cpp index 8d4c51c4..762977b7 100644 --- a/src/ui/function/RaisePinentry.cpp +++ b/src/ui/function/RaisePinentry.cpp @@ -60,16 +60,16 @@ auto RaisePinentry::Exec() -> int { bool ask_for_new = context_->GetPassphraseInfo().isEmpty() && context_->GetUidsInfo().isEmpty(); - auto* pinentry = new PinEntryDialog( - FindTopMostWindow(this), 0, 15, true, ask_for_new, - ask_for_new ? QString(_("Repeat PIN:")) : QString(), - QString(_("Show passphrase")), QString(_("Hide passphrase"))); + auto* pinentry = + new PinEntryDialog(FindTopMostWindow(this), 0, 15, true, ask_for_new, + ask_for_new ? tr("Repeat PIN:") : QString(), + tr("Show passphrase"), tr("Hide passphrase")); if (context_->IsPreWasBad()) { - pinentry->setError(QString(_("Given PIN was wrong. Please retry."))); + pinentry->setError(tr("Given PIN was wrong. Please retry.")); } - pinentry->setPrompt(QString(_("PIN:"))); + pinentry->setPrompt(tr("PIN:")); if (!context_->GetUidsInfo().isEmpty()) { pinentry->setDescription(QString("Please provide PIN of Key:\n%1\n") @@ -79,20 +79,19 @@ auto RaisePinentry::Exec() -> int { struct pinentry pinentry_info; pinentry->setPinentryInfo(pinentry_info); - pinentry->setRepeatErrorText( - QString::fromStdString(_("Passphrases do not match"))); + pinentry->setRepeatErrorText(tr("Passphrases do not match")); pinentry->setGenpinLabel(QString("BBBBBBBBB")); pinentry->setGenpinTT(QString("AAAAAAAA")); - pinentry->setCapsLockHint(QString(_("Caps Lock is on"))); + pinentry->setCapsLockHint(tr("Caps Lock is on")); pinentry->setFormattedPassphrase({false, QString()}); pinentry->setConstraintsOptions({false, QString(), QString(), QString()}); - pinentry->setWindowTitle(_("Buddled Pinentry")); + pinentry->setWindowTitle(tr("Buddled Pinentry")); /* If we reuse the same dialog window. */ pinentry->setPin(QString()); - pinentry->setOkText(_("Confirm")); - pinentry->setCancelText(_("Cancel")); + pinentry->setOkText(tr("Confirm")); + pinentry->setCancelText(tr("Cancel")); GF_UI_LOG_DEBUG("buddled pinentry is ready to start..."); connect(pinentry, &PinEntryDialog::finished, this, diff --git a/src/ui/function/SetOwnerTrustLevel.cpp b/src/ui/function/SetOwnerTrustLevel.cpp index 91917961..360abfce 100644 --- a/src/ui/function/SetOwnerTrustLevel.cpp +++ b/src/ui/function/SetOwnerTrustLevel.cpp @@ -46,41 +46,42 @@ auto SetOwnerTrustLevel::Exec(const QString& key_id) -> bool { QStringList items; - items << _("Unknown") << _("Undefined") << _("Never") << _("Marginal") - << _("Full") << _("Ultimate"); + items << tr("Unknown") << tr("Undefined") << tr("Never") << tr("Marginal") + << tr("Full") << tr("Ultimate"); bool ok; - QString item = QInputDialog::getItem(this, _("Modify Owner Trust Level"), - _("Trust for the Key Pair:"), items, + QString item = QInputDialog::getItem(this, tr("Modify Owner Trust Level"), + tr("Trust for the Key Pair:"), items, key.GetOwnerTrustLevel(), false, &ok); if (ok && !item.isEmpty()) { GF_UI_LOG_DEBUG("selected owner trust policy: {}", item.toStdString()); int trust_level = 0; // Unknown Level - if (item == _("Ultimate")) { + if (item == tr("Ultimate")) { trust_level = 5; - } else if (item == _("Full")) { + } else if (item == tr("Full")) { trust_level = 4; - } else if (item == _("Marginal")) { + } else if (item == tr("Marginal")) { trust_level = 3; - } else if (item == _("Never")) { + } else if (item == tr("Never")) { trust_level = 2; - } else if (item == _("Undefined")) { + } else if (item == tr("Undefined")) { trust_level = 1; } if (trust_level == 0) { QMessageBox::warning( - this, _("Warning"), - QString(_("Owner Trust Level cannot set to Unknown level, automately " - "changing it into Undefined level."))); + this, tr("Warning"), + QString( + tr("Owner Trust Level cannot set to Unknown level, automately " + "changing it into Undefined level."))); trust_level = 1; } bool status = GpgKeyManager::GetInstance().SetOwnerTrustLevel(key, trust_level); if (!status) { - QMessageBox::critical(this, _("Failed"), - QString(_("Modify Owner Trust Level failed."))); + QMessageBox::critical(this, tr("Failed"), + tr("Modify Owner Trust Level failed.")); return false; } diff --git a/src/ui/main_window/KeyMgmt.cpp b/src/ui/main_window/KeyMgmt.cpp index dacf996e..0ff9ced6 100644 --- a/src/ui/main_window/KeyMgmt.cpp +++ b/src/ui/main_window/KeyMgmt.cpp @@ -50,10 +50,12 @@ KeyMgmt::KeyMgmt(QWidget* parent) /* the list of Keys available*/ key_list_ = new KeyList(KeyMenuAbility::ALL, this); - key_list_->AddListGroupTab(_("All"), "all", KeyListRow::SECRET_OR_PUBLIC_KEY); + key_list_->AddListGroupTab(tr("All"), "all", + KeyListRow::SECRET_OR_PUBLIC_KEY); key_list_->AddListGroupTab( - _("Only Public Key"), "only_public_key", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("Only Public Key"), "only_public_key", + KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -62,7 +64,8 @@ KeyMgmt::KeyMgmt(QWidget* parent) }); key_list_->AddListGroupTab( - _("Has Private Key"), "has_private_key", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("Has Private Key"), "has_private_key", + KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -71,7 +74,7 @@ KeyMgmt::KeyMgmt(QWidget* parent) }); key_list_->AddListGroupTab( - _("No Primary Key"), "no_primary_key", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("No Primary Key"), "no_primary_key", KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -80,7 +83,7 @@ KeyMgmt::KeyMgmt(QWidget* parent) }); key_list_->AddListGroupTab( - _("Revoked"), "revoked", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("Revoked"), "revoked", KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -88,7 +91,7 @@ KeyMgmt::KeyMgmt(QWidget* parent) }); key_list_->AddListGroupTab( - _("Expired"), "expired", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("Expired"), "expired", KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -113,7 +116,7 @@ KeyMgmt::KeyMgmt(QWidget* parent) this->statusBar()->show(); - setWindowTitle(_("KeyPair Management")); + setWindowTitle(tr("KeyPair Management")); key_list_->AddMenuAction(generate_subkey_act_); key_list_->AddMenuAction(delete_selected_keys_act_); @@ -133,43 +136,44 @@ KeyMgmt::KeyMgmt(QWidget* parent) } void KeyMgmt::create_actions() { - open_key_file_act_ = new QAction(_("Open"), this); - open_key_file_act_->setShortcut(QKeySequence(_("Ctrl+O"))); - open_key_file_act_->setToolTip(_("Open Key File")); + open_key_file_act_ = new QAction(tr("Open"), this); + open_key_file_act_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_O)); + open_key_file_act_->setToolTip(tr("Open Key File")); connect(open_key_file_act_, &QAction::triggered, this, [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); }); - close_act_ = new QAction(_("Close"), this); - close_act_->setShortcut(QKeySequence(_("Ctrl+Q"))); - close_act_->setIcon(QIcon(":exit.png")); - close_act_->setToolTip(_("Close")); + close_act_ = new QAction(tr("Close"), this); + close_act_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); + close_act_->setIcon(QIcon(":/icons/exit.png")); + close_act_->setToolTip(tr("Close")); connect(close_act_, &QAction::triggered, this, &KeyMgmt::close); - generate_key_pair_act_ = new QAction(_("New Keypair"), this); - generate_key_pair_act_->setShortcut(QKeySequence(_("Ctrl+N"))); - generate_key_pair_act_->setIcon(QIcon(":key_generate.png")); - generate_key_pair_act_->setToolTip(_("Generate KeyPair")); + generate_key_pair_act_ = new QAction(tr("New Keypair"), this); + generate_key_pair_act_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N)); + generate_key_pair_act_->setIcon(QIcon(":/icons/key_generate.png")); + generate_key_pair_act_->setToolTip(tr("Generate KeyPair")); connect(generate_key_pair_act_, &QAction::triggered, this, &KeyMgmt::SlotGenerateKeyDialog); - generate_subkey_act_ = new QAction(_("New Subkey"), this); - generate_subkey_act_->setShortcut(QKeySequence(_("Ctrl+Shift+N"))); - generate_subkey_act_->setIcon(QIcon(":key_generate.png")); - generate_subkey_act_->setToolTip(_("Generate Subkey For Selected KeyPair")); + generate_subkey_act_ = new QAction(tr("New Subkey"), this); + generate_subkey_act_->setShortcut( + QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_N)); + generate_subkey_act_->setIcon(QIcon(":/icons/key_generate.png")); + generate_subkey_act_->setToolTip(tr("Generate Subkey For Selected KeyPair")); connect(generate_subkey_act_, &QAction::triggered, this, &KeyMgmt::SlotGenerateSubKey); - import_key_from_file_act_ = new QAction(_("File"), this); - import_key_from_file_act_->setIcon(QIcon(":import_key_from_file.png")); - import_key_from_file_act_->setToolTip(_("Import New Key From File")); + import_key_from_file_act_ = new QAction(tr("File"), this); + import_key_from_file_act_->setIcon(QIcon(":/icons/import_key_from_file.png")); + import_key_from_file_act_->setToolTip(tr("Import New Key From File")); connect(import_key_from_file_act_, &QAction::triggered, this, [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); }); - import_key_from_clipboard_act_ = new QAction(_("Clipboard"), this); + import_key_from_clipboard_act_ = new QAction(tr("Clipboard"), this); import_key_from_clipboard_act_->setIcon( - QIcon(":import_key_from_clipboard.png")); + QIcon(":/icons/import_key_from_clipboard.png")); import_key_from_clipboard_act_->setToolTip( - _("Import New Key From Clipboard")); + tr("Import New Key From Clipboard")); connect(import_key_from_clipboard_act_, &QAction::triggered, this, [&]() { CommonUtils::GetInstance()->SlotImportKeyFromClipboard(this); }); @@ -180,62 +184,63 @@ void KeyMgmt::create_actions() { .value("network/forbid_all_gnupg_connection", false) .toBool(); - import_key_from_key_server_act_ = new QAction(_("Keyserver"), this); + import_key_from_key_server_act_ = new QAction(tr("Keyserver"), this); import_key_from_key_server_act_->setIcon( - QIcon(":import_key_from_server.png")); + QIcon(":/icons/import_key_from_server.png")); import_key_from_key_server_act_->setToolTip( - _("Import New Key From Keyserver")); + tr("Import New Key From Keyserver")); import_key_from_key_server_act_->setDisabled(forbid_all_gnupg_connection); connect(import_key_from_key_server_act_, &QAction::triggered, this, [this]() { CommonUtils::GetInstance()->SlotImportKeyFromKeyServer(this); }); - import_keys_from_key_package_act_ = new QAction(_("Key Package"), this); - import_keys_from_key_package_act_->setIcon(QIcon(":key_package.png")); + import_keys_from_key_package_act_ = new QAction(tr("Key Package"), this); + import_keys_from_key_package_act_->setIcon(QIcon(":/icons/key_package.png")); import_keys_from_key_package_act_->setToolTip( - _("Import Key(s) From a Key Package")); + tr("Import Key(s) From a Key Package")); connect(import_keys_from_key_package_act_, &QAction::triggered, this, &KeyMgmt::SlotImportKeyPackage); - export_key_to_clipboard_act_ = new QAction(_("Export To Clipboard"), this); - export_key_to_clipboard_act_->setIcon(QIcon(":export_key_to_clipboard.png")); + export_key_to_clipboard_act_ = new QAction(tr("Export To Clipboard"), this); + export_key_to_clipboard_act_->setIcon( + QIcon(":/icons/export_key_to_clipboard.png")); export_key_to_clipboard_act_->setToolTip( - _("Export Checked Key(s) To Clipboard")); + tr("Export Checked Key(s) To Clipboard")); connect(export_key_to_clipboard_act_, &QAction::triggered, this, &KeyMgmt::SlotExportKeyToClipboard); - export_key_to_file_act_ = new QAction(_("Export As Key Package"), this); - export_key_to_file_act_->setIcon(QIcon(":key_package.png")); + export_key_to_file_act_ = new QAction(tr("Export As Key Package"), this); + export_key_to_file_act_->setIcon(QIcon(":/icons/key_package.png")); export_key_to_file_act_->setToolTip( - _("Export Checked Key(s) To a Key Package")); + tr("Export Checked Key(s) To a Key Package")); connect(export_key_to_file_act_, &QAction::triggered, this, &KeyMgmt::SlotExportKeyToKeyPackage); - export_key_as_open_ssh_format_ = new QAction(_("Export As OpenSSH"), this); - export_key_as_open_ssh_format_->setIcon(QIcon(":ssh-key.png")); + export_key_as_open_ssh_format_ = new QAction(tr("Export As OpenSSH"), this); + export_key_as_open_ssh_format_->setIcon(QIcon(":/icons/ssh-key.png")); export_key_as_open_ssh_format_->setToolTip( - _("Export Checked Key As OpenSSH Format to File")); + tr("Export Checked Key As OpenSSH Format to File")); connect(export_key_as_open_ssh_format_, &QAction::triggered, this, &KeyMgmt::SlotExportAsOpenSSHFormat); - delete_selected_keys_act_ = new QAction(_("Delete Selected Key(s)"), this); - delete_selected_keys_act_->setToolTip(_("Delete the Selected keys")); + delete_selected_keys_act_ = new QAction(tr("Delete Selected Key(s)"), this); + delete_selected_keys_act_->setToolTip(tr("Delete the Selected keys")); connect(delete_selected_keys_act_, &QAction::triggered, this, &KeyMgmt::SlotDeleteSelectedKeys); - delete_checked_keys_act_ = new QAction(_("Delete Checked Key(s)"), this); - delete_checked_keys_act_->setToolTip(_("Delete the Checked keys")); - delete_checked_keys_act_->setIcon(QIcon(":button_delete.png")); + delete_checked_keys_act_ = new QAction(tr("Delete Checked Key(s)"), this); + delete_checked_keys_act_->setToolTip(tr("Delete the Checked keys")); + delete_checked_keys_act_->setIcon(QIcon(":/icons/button_delete.png")); connect(delete_checked_keys_act_, &QAction::triggered, this, &KeyMgmt::SlotDeleteCheckedKeys); - show_key_details_act_ = new QAction(_("Show Key Details"), this); - show_key_details_act_->setToolTip(_("Show Details for this Key")); + show_key_details_act_ = new QAction(tr("Show Key Details"), this); + show_key_details_act_->setToolTip(tr("Show Details for this Key")); connect(show_key_details_act_, &QAction::triggered, this, &KeyMgmt::SlotShowKeyDetails); - set_owner_trust_of_key_act_ = new QAction(_("Set Owner Trust Level"), this); - set_owner_trust_of_key_act_->setToolTip(_("Set Owner Trust Level")); + set_owner_trust_of_key_act_ = new QAction(tr("Set Owner Trust Level"), this); + set_owner_trust_of_key_act_->setToolTip(tr("Set Owner Trust Level")); set_owner_trust_of_key_act_->setData(QVariant("set_owner_trust_level")); connect(set_owner_trust_of_key_act_, &QAction::triggered, this, [this]() { auto keys_selected = key_list_->GetSelected(); @@ -248,22 +253,22 @@ void KeyMgmt::create_actions() { } void KeyMgmt::create_menus() { - file_menu_ = menuBar()->addMenu(_("File")); + file_menu_ = menuBar()->addMenu(tr("File")); file_menu_->addAction(open_key_file_act_); file_menu_->addAction(close_act_); - key_menu_ = menuBar()->addMenu(_("Key")); - generate_key_menu_ = key_menu_->addMenu(_("Generate Key")); + key_menu_ = menuBar()->addMenu(tr("Key")); + generate_key_menu_ = key_menu_->addMenu(tr("Generate Key")); generate_key_menu_->addAction(generate_key_pair_act_); generate_key_menu_->addAction(generate_subkey_act_); - import_key_menu_ = key_menu_->addMenu(_("Import Key")); + import_key_menu_ = key_menu_->addMenu(tr("Import Key")); import_key_menu_->addAction(import_key_from_file_act_); import_key_menu_->addAction(import_key_from_clipboard_act_); import_key_menu_->addAction(import_key_from_key_server_act_); import_key_menu_->addAction(import_keys_from_key_package_act_); - export_key_menu_ = key_menu_->addMenu(_("Export Key")); + export_key_menu_ = key_menu_->addMenu(tr("Export Key")); export_key_menu_->addAction(export_key_to_file_act_); export_key_menu_->addAction(export_key_to_clipboard_act_); export_key_menu_->addAction(export_key_as_open_ssh_format_); @@ -272,7 +277,7 @@ void KeyMgmt::create_menus() { } void KeyMgmt::create_tool_bars() { - QToolBar* key_tool_bar = addToolBar(_("Key")); + QToolBar* key_tool_bar = addToolBar(tr("Key")); key_tool_bar->setObjectName("keytoolbar"); // genrate key pair @@ -283,18 +288,18 @@ void KeyMgmt::create_tool_bars() { auto* import_tool_button = new QToolButton(this); import_tool_button->setMenu(import_key_menu_); import_tool_button->setPopupMode(QToolButton::InstantPopup); - import_tool_button->setIcon(QIcon(":key_import.png")); - import_tool_button->setToolTip(_("Import key")); - import_tool_button->setText(_("Import Key")); + import_tool_button->setIcon(QIcon(":/icons/key_import.png")); + import_tool_button->setToolTip(tr("Import key")); + import_tool_button->setText(tr("Import Key")); import_tool_button->setToolButtonStyle(icon_style_); key_tool_bar->addWidget(import_tool_button); auto* export_tool_button = new QToolButton(this); export_tool_button->setMenu(export_key_menu_); export_tool_button->setPopupMode(QToolButton::InstantPopup); - export_tool_button->setIcon(QIcon(":key_export.png")); - export_tool_button->setToolTip(_("Export key")); - export_tool_button->setText(_("Export Key")); + export_tool_button->setIcon(QIcon(":/icons/key_export.png")); + export_tool_button->setToolTip(tr("Export key")); + export_tool_button->setText(tr("Export Key")); export_tool_button->setToolButtonStyle(icon_style_); key_tool_bar->addWidget(export_tool_button); @@ -327,12 +332,12 @@ void KeyMgmt::delete_keys_with_warning(KeyIdArgsListPtr uidList) { } int const ret = QMessageBox::warning( - this, _("Deleting Keys"), + this, tr("Deleting Keys"), "<b>" + QString( - _("Are you sure that you want to delete the following keys?")) + + tr("Are you sure that you want to delete the following keys?")) + "</b><br/><br/>" + keynames + +"<br/>" + - _("The action can not be undone."), + tr("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { @@ -348,7 +353,7 @@ void KeyMgmt::SlotShowKeyDetails() { auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front()); if (!key.IsGood()) { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); return; } @@ -359,21 +364,21 @@ void KeyMgmt::SlotExportKeyToKeyPackage() { auto keys_checked = key_list_->GetChecked(); if (keys_checked->empty()) { QMessageBox::critical( - this, _("Forbidden"), - _("Please check some keys before doing this operation.")); + this, tr("Forbidden"), + tr("Please check some keys before doing this operation.")); return; } auto* dialog = new ExportKeyPackageDialog(std::move(keys_checked), this); dialog->exec(); - emit SignalStatusBarChanged(QString(_("key(s) exported"))); + emit SignalStatusBarChanged(tr("key(s) exported")); } void KeyMgmt::SlotExportKeyToClipboard() { auto keys_checked = key_list_->GetChecked(); if (keys_checked->empty()) { QMessageBox::critical( - this, _("Forbidden"), - _("Please check some keys before doing this operation.")); + this, tr("Forbidden"), + tr("Please check some keys before doing this operation.")); return; } @@ -389,7 +394,7 @@ void KeyMgmt::SlotExportKeyToClipboard() { } else { auto keys = GpgKeyGetter::GetInstance().GetKeys(keys_checked); CommonUtils::WaitForOpera( - this, _("Exporting"), [=](const OperaWaitingHd& op_hd) { + this, tr("Exporting"), [=](const OperaWaitingHd& op_hd) { GpgKeyImportExporter::GetInstance().ExportKeys( *keys, false, true, false, false, [=](GpgError err, const DataObjectPtr& data_obj) { @@ -422,19 +427,19 @@ void KeyMgmt::SlotGenerateSubKey() { auto keys_selected = key_list_->GetSelected(); if (keys_selected->empty()) { QMessageBox::information( - this, _("Invalid Operation"), - _("Please select one KeyPair before doing this operation.")); + this, tr("Invalid Operation"), + tr("Please select one KeyPair before doing this operation.")); return; } const auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front()); if (!key.IsGood()) { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); return; } if (!key.IsPrivateKey()) { - QMessageBox::critical(this, _("Invalid Operation"), - _("If a key pair does not have a private key then " - "it will not be able to generate sub-keys.")); + QMessageBox::critical(this, tr("Invalid Operation"), + tr("If a key pair does not have a private key then " + "it will not be able to generate sub-keys.")); return; } @@ -446,20 +451,20 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() { auto keys_checked = key_list_->GetChecked(); if (keys_checked->empty()) { QMessageBox::critical( - this, _("Forbidden"), - _("Please check a key before performing this operation.")); + this, tr("Forbidden"), + tr("Please check a key before performing this operation.")); return; } if (keys_checked->size() > 1) { - QMessageBox::critical(this, _("Forbidden"), - _("This operation accepts just a single key.")); + QMessageBox::critical(this, tr("Forbidden"), + tr("This operation accepts just a single key.")); return; } auto keys = GpgKeyGetter::GetInstance().GetKeys(keys_checked); CommonUtils::WaitForOpera( - this, _("Exporting"), [this, keys](const OperaWaitingHd& op_hd) { + this, tr("Exporting"), [this, keys](const OperaWaitingHd& op_hd) { GpgKeyImportExporter::GetInstance().ExportKeys( *keys, false, true, false, true, [=](GpgError err, const DataObjectPtr& data_obj) { @@ -483,20 +488,20 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() { if (gf_buffer.Empty()) { QMessageBox::critical( - this, _("Error"), - _("This key may not be able to export as OpenSSH format. " - "Please check the key-size of the subkey(s) used to " - "sign.")); + this, tr("Error"), + tr("This key may not be able to export as OpenSSH format. " + "Please check the key-size of the subkey(s) used to " + "sign.")); return; } QString const file_name = QFileDialog::getSaveFileName( - this, _("Export OpenSSH Key To File"), "authorized_keys", - QString(_("OpenSSH Public Key Files")) + "All Files (*)"); + this, tr("Export OpenSSH Key To File"), "authorized_keys", + tr("OpenSSH Public Key Files") + "All Files (*)"); if (!file_name.isEmpty()) { WriteFileGFBuffer(file_name, gf_buffer); - emit SignalStatusBarChanged(QString(_("key(s) exported"))); + emit SignalStatusBarChanged(tr("key(s) exported")); } }); }); @@ -506,12 +511,12 @@ void KeyMgmt::SlotImportKeyPackage() { GF_UI_LOG_INFO("Importing key package..."); auto key_package_file_name = QFileDialog::getOpenFileName( - this, _("Import Key Package"), {}, - QString(_("Key Package")) + " (*.gfepack);;All Files (*)"); + this, tr("Import Key Package"), {}, + tr("Key Package") + " (*.gfepack);;All Files (*)"); auto key_file_name = QFileDialog::getOpenFileName( - this, _("Import Key Package Passphrase File"), {}, - QString(_("Key Package Passphrase File")) + " (*.key);;All Files (*)"); + this, tr("Import Key Package Passphrase File"), {}, + tr("Key Package Passphrase File") + " (*.key);;All Files (*)"); if (key_package_file_name.isEmpty() || key_file_name.isEmpty()) return; @@ -521,14 +526,14 @@ void KeyMgmt::SlotImportKeyPackage() { key_package_file_name, key_file_name); if (success) { - emit SignalStatusBarChanged(QString(_("key(s) imported"))); + emit SignalStatusBarChanged(tr("key(s) imported")); emit SignalKeyStatusUpdated(); auto* dialog = new KeyImportDetailDialog(info, this); dialog->exec(); } else { - QMessageBox::critical(this, _("Error"), - _("An error occur in importing key package.")); + QMessageBox::critical(this, tr("Error"), + tr("An error occur in importing key package.")); } } diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index cdeb597a..31d53bd1 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -162,9 +162,10 @@ void MainWindow::Init() noexcept { if (show_wizard) slot_start_wizard(); } catch (...) { - GF_UI_LOG_ERROR(_("Critical error occur while loading GpgFrontend.")); - QMessageBox::critical(nullptr, _("Loading Failed"), - _("Critical error occur while loading GpgFrontend.")); + GF_UI_LOG_ERROR(tr("Critical error occur while loading GpgFrontend.")); + QMessageBox::critical( + nullptr, tr("Loading Failed"), + tr("Critical error occur while loading GpgFrontend.")); QCoreApplication::quit(); exit(0); } diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp index 80390b13..3b28e41b 100644 --- a/src/ui/main_window/MainWindowFileSlotFunction.cpp +++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp @@ -44,9 +44,9 @@ namespace GpgFrontend::UI { void MainWindow::SlotFileEncrypt(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")) - .arg(QFileInfo(path).fileName())); + QMessageBox::critical( + this, tr("Error"), + tr("Cannot read from file: %1").arg(QFileInfo(path).fileName())); return; } @@ -59,10 +59,10 @@ void MainWindow::SlotFileEncrypt(const QString& path) { SetExtensionOfOutputFile(path, kENCRYPT, !non_ascii_when_export); if (QFile::exists(out_path)) { - auto out_file_name = QString(_("The target file %1 already exists, " - "do you need to overwrite it?")) + auto out_file_name = tr("The target file %1 already exists, " + "do you need to overwrite it?") .arg(out_path); - auto ret = QMessageBox::warning(this, _("Warning"), out_file_name, + auto ret = QMessageBox::warning(this, tr("Warning"), out_file_name, QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -70,8 +70,8 @@ void MainWindow::SlotFileEncrypt(const QString& path) { check_result = TargetFilePreCheck(out_path, false); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot write to file: %1")).arg(out_path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot write to file: %1").arg(out_path)); return; } @@ -80,14 +80,14 @@ void MainWindow::SlotFileEncrypt(const QString& path) { if (key_ids->empty()) { // Symmetric Encrypt auto ret = QMessageBox::information( - this, _("Symmetric Encryption"), - _("No Key Selected. Do you want to encrypt with a " - "symmetric cipher using a passphrase?"), + this, tr("Symmetric Encryption"), + tr("No Key Selected. Do you want to encrypt with a " + "symmetric cipher using a passphrase?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; CommonUtils::WaitForOpera( - this, _("Symmetrically Encrypting"), [=](const OperaWaitingHd& op_hd) { + this, tr("Symmetrically Encrypting"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().EncryptFileSymmetric( path, !non_ascii_when_export, out_path, [=](GpgError err, const DataObjectPtr& data_obj) { @@ -119,16 +119,16 @@ void MainWindow::SlotFileEncrypt(const QString& path) { if (!key_can_encrypt) { QMessageBox::critical( - nullptr, _("Invalid KeyPair"), - QString(_("The selected keypair cannot be used for encryption.")) + - "<br/><br/>" + _("For example the Following Key:") + " <br/>" + + nullptr, tr("Invalid KeyPair"), + tr("The selected keypair cannot be used for encryption.") + + "<br/><br/>" + tr("For example the Following Key:") + " <br/>" + key.GetUIDs()->front().GetUID()); return; } } CommonUtils::WaitForOpera( - this, _("Encrypting"), [=](const OperaWaitingHd& op_hd) { + this, tr("Encrypting"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().EncryptFile( {p_keys->begin(), p_keys->end()}, path, !non_ascii_when_export, out_path, [=](GpgError err, const DataObjectPtr& data_obj) { @@ -152,9 +152,9 @@ void MainWindow::SlotFileEncrypt(const QString& path) { void MainWindow::SlotDirectoryEncrypt(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")) - .arg(QFileInfo(path).fileName())); + QMessageBox::critical( + this, tr("Error"), + tr("Cannot read from file: %1").arg(QFileInfo(path).fileName())); return; } @@ -167,10 +167,10 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) { !non_ascii_when_export); if (QFile::exists(out_path)) { - auto out_file_name = QString(_("The target file %1 already exists, " - "do you need to overwrite it?")) + auto out_file_name = tr("The target file %1 already exists, " + "do you need to overwrite it?") .arg(out_path); - auto ret = QMessageBox::warning(this, _("Warning"), out_file_name, + auto ret = QMessageBox::warning(this, tr("Warning"), out_file_name, QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -178,8 +178,8 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) { check_result = TargetFilePreCheck(out_path, false); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot write to file: %1")).arg(out_path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot write to file: %1").arg(out_path)); return; } @@ -188,14 +188,14 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) { // symmetric encrypt if (key_ids->empty()) { auto ret = QMessageBox::information( - this, _("Symmetric Encryption"), - _("No Key Selected. Do you want to encrypt with a " - "symmetric cipher using a passphrase?"), + this, tr("Symmetric Encryption"), + tr("No Key Selected. Do you want to encrypt with a " + "symmetric cipher using a passphrase?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; CommonUtils::WaitForOpera( - this, _("Archiving & Symmetrically Encrypting"), + this, tr("Archiving & Symmetrically Encrypting"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().EncryptDerectorySymmetric( path, !non_ascii_when_export, out_path, @@ -228,16 +228,16 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) { if (!key_can_encrypt) { QMessageBox::critical( - nullptr, _("Invalid KeyPair"), - QString(_("The selected keypair cannot be used for encryption.")) + - "<br/><br/>" + _("For example the Following Key:") + " <br/>" + + nullptr, tr("Invalid KeyPair"), + tr("The selected keypair cannot be used for encryption.") + + "<br/><br/>" + tr("For example the Following Key:") + " <br/>" + key.GetUIDs()->front().GetUID()); return; } } CommonUtils::WaitForOpera( - this, _("Archiving & Encrypting"), [=](const OperaWaitingHd& op_hd) { + this, tr("Archiving & Encrypting"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().EncryptDirectory( {p_keys->begin(), p_keys->end()}, path, !non_ascii_when_export, out_path, [=](GpgError err, const DataObjectPtr& data_obj) { @@ -261,17 +261,17 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) { void MainWindow::SlotFileDecrypt(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")) - .arg(QFileInfo(path).fileName())); + QMessageBox::critical( + this, tr("Error"), + tr("Cannot read from file: %1").arg(QFileInfo(path).fileName())); return; } auto out_path = SetExtensionOfOutputFile(path, kDECRYPT, true); if (QFileInfo(out_path).exists()) { auto ret = QMessageBox::warning( - this, _("Warning"), - _("The target file already exists, do you need to overwrite it?"), + this, tr("Warning"), + tr("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -279,13 +279,13 @@ void MainWindow::SlotFileDecrypt(const QString& path) { check_result = TargetFilePreCheck(out_path, false); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot write to file: %1")).arg(out_path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot write to file: %1").arg(out_path)); return; } CommonUtils::WaitForOpera( - this, _("Decrypting"), [=](const OperaWaitingHd& op_hd) { + this, tr("Decrypting"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().DecryptFile( path, out_path, [=](GpgError err, const DataObjectPtr& data_obj) { // stop waiting @@ -308,16 +308,16 @@ void MainWindow::SlotFileDecrypt(const QString& path) { void MainWindow::SlotArchiveDecrypt(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")).arg(path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot read from file: %1").arg(path)); return; } auto out_path = SetExtensionOfOutputFileForArchive(path, kDECRYPT, true); if (QFileInfo(out_path).exists()) { auto ret = QMessageBox::warning( - this, _("Warning"), - _("The target file already exists, do you need to overwrite it?"), + this, tr("Warning"), + tr("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -325,13 +325,13 @@ void MainWindow::SlotArchiveDecrypt(const QString& path) { check_result = TargetFilePreCheck(out_path, false); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot write to file: %1")).arg(out_path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot write to file: %1").arg(out_path)); return; } CommonUtils::WaitForOpera( - this, _("Decrypting & Extrating"), [=](const OperaWaitingHd& op_hd) { + this, tr("Decrypting & Extrating"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().DecryptArchive( path, out_path, [=](GpgError err, const DataObjectPtr& data_obj) { // stop waiting @@ -354,9 +354,9 @@ void MainWindow::SlotArchiveDecrypt(const QString& path) { void MainWindow::SlotFileSign(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")) - .arg(QFileInfo(path).fileName())); + QMessageBox::critical( + this, tr("Error"), + tr("Cannot read from file: %1").arg(QFileInfo(path).fileName())); return; } @@ -365,18 +365,18 @@ void MainWindow::SlotFileSign(const QString& path) { if (keys->empty()) { QMessageBox::critical( - this, _("No Key Checked"), - _("Please check the key in the key toolbox on the right.")); + this, tr("No Key Checked"), + tr("Please check the key in the key toolbox on the right.")); return; } for (const auto& key : *keys) { if (!key.IsHasActualSigningCapability()) { QMessageBox::information( - this, _("Invalid Operation"), - QString(_("The selected key contains a key that does not actually " - "have a sign usage.")) + - "<br/><br/>" + _("for example the Following Key:") + " <br/>" + + this, tr("Invalid Operation"), + tr("The selected key contains a key that does not actually " + "have a sign usage.") + + "<br/><br/>" + tr("for example the Following Key:") + " <br/>" + key.GetUIDs()->front().GetUID()); return; } @@ -391,18 +391,17 @@ void MainWindow::SlotFileSign(const QString& path) { SetExtensionOfOutputFile(path, kSIGN, !non_ascii_when_export); if (QFileInfo(sig_file_path).exists()) { - auto ret = - QMessageBox::warning(this, _("Warning"), - QString(_("The signature file \"%1\" exists, " - "do you need to overwrite it?")) - .arg(sig_file_path), - QMessageBox::Ok | QMessageBox::Cancel); + auto ret = QMessageBox::warning(this, tr("Warning"), + tr("The signature file \"%1\" exists, " + "do you need to overwrite it?") + .arg(sig_file_path), + QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; } CommonUtils::WaitForOpera( - this, _("Signing"), [=](const OperaWaitingHd& op_hd) { + this, tr("Signing"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().SignFile( {keys->begin(), keys->end()}, path, !non_ascii_when_export, sig_file_path, [=](GpgError err, const DataObjectPtr& data_obj) { @@ -426,9 +425,9 @@ void MainWindow::SlotFileSign(const QString& path) { void MainWindow::SlotFileVerify(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")) - .arg(QFileInfo(path).fileName())); + QMessageBox::critical( + this, tr("Error"), + tr("Cannot read from file: %1").arg(QFileInfo(path).fileName())); return; } @@ -448,10 +447,10 @@ void MainWindow::SlotFileVerify(const QString& path) { if (!prossible_singleton_target && !data_file_info.exists()) { bool ok; QString const text = QInputDialog::getText( - this, _("File to be Verified"), - _("Please provide An ABSOLUTE Path \n" - "If Data And Signature is COMBINED within a single file, " - "KEEP THIS EMPTY: "), + this, tr("File to be Verified"), + tr("Please provide An ABSOLUTE Path \n" + "If Data And Signature is COMBINED within a single file, " + "KEEP THIS EMPTY: "), QLineEdit::Normal, data_file_path, &ok); if (!ok) return; @@ -462,9 +461,9 @@ void MainWindow::SlotFileVerify(const QString& path) { if (!data_file_info.isFile() || (!sign_file_path.isEmpty() && !QFileInfo(sign_file_path).isFile())) { QMessageBox::critical( - this, _("Error"), - _("Please select the appropriate origin file or signature file. " - "Ensure that both are in this directory.")); + this, tr("Error"), + tr("Please select the appropriate origin file or signature file. " + "Ensure that both are in this directory.")); return; } @@ -472,7 +471,7 @@ void MainWindow::SlotFileVerify(const QString& path) { GF_UI_LOG_DEBUG("verification signature file path: {}", sign_file_path); CommonUtils::WaitForOpera( - this, _("Verifying"), [=](const OperaWaitingHd& op_hd) { + this, tr("Verifying"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().VerifyFile( data_file_path, sign_file_path, [=](GpgError err, const DataObjectPtr& data_obj) { @@ -503,8 +502,8 @@ void MainWindow::SlotFileVerify(const QString& path) { void MainWindow::SlotFileEncryptSign(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")).arg(path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot read from file: %1").arg(path)); return; } @@ -514,8 +513,8 @@ void MainWindow::SlotFileEncryptSign(const QString& path) { if (p_keys->empty()) { QMessageBox::critical( - this, _("No Key Checked"), - _("Please check the key in the key toolbox on the right.")); + this, tr("No Key Checked"), + tr("Please check the key in the key toolbox on the right.")); return; } @@ -525,9 +524,9 @@ void MainWindow::SlotFileEncryptSign(const QString& path) { if (!key_can_encrypt) { QMessageBox::critical( - nullptr, _("Invalid KeyPair"), - QString(_("The selected keypair cannot be used for encryption.")) + - "<br/><br/>" + _("For example the Following Key:") + " <br/>" + + nullptr, tr("Invalid KeyPair"), + tr("The selected keypair cannot be used for encryption.") + + "<br/><br/>" + tr("For example the Following Key:") + " <br/>" + key.GetUIDs()->front().GetUID()); return; } @@ -543,15 +542,15 @@ void MainWindow::SlotFileEncryptSign(const QString& path) { check_result = TargetFilePreCheck(out_path, false); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot write to file: %1")).arg(out_path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot write to file: %1").arg(out_path)); return; } if (QFile::exists(out_path)) { auto ret = QMessageBox::warning( - this, _("Warning"), - _("The target file already exists, do you need to overwrite it?"), + this, tr("Warning"), + tr("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -569,7 +568,7 @@ void MainWindow::SlotFileEncryptSign(const QString& path) { auto p_signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids); CommonUtils::WaitForOpera( - this, _("Encrypting and Signing"), [=](const OperaWaitingHd& op_hd) { + this, tr("Encrypting and Signing"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().EncryptSignFile( {p_keys->begin(), p_keys->end()}, {p_signer_keys->begin(), p_signer_keys->end()}, path, @@ -604,8 +603,8 @@ void MainWindow::SlotFileEncryptSign(const QString& path) { void MainWindow::SlotDirectoryEncryptSign(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")).arg(path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot read from file: %1").arg(path)); return; } @@ -615,8 +614,8 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) { if (p_keys->empty()) { QMessageBox::critical( - this, _("No Key Checked"), - _("Please check the key in the key toolbox on the right.")); + this, tr("No Key Checked"), + tr("Please check the key in the key toolbox on the right.")); return; } @@ -626,9 +625,9 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) { if (!key_can_encrypt) { QMessageBox::critical( - nullptr, _("Invalid KeyPair"), - QString(_("The selected keypair cannot be used for encryption.")) + - "<br/><br/>" + _("For example the Following Key:") + " <br/>" + + nullptr, tr("Invalid KeyPair"), + tr("The selected keypair cannot be used for encryption.") + + "<br/><br/>" + tr("For example the Following Key:") + " <br/>" + key.GetUIDs()->front().GetUID()); return; } @@ -644,15 +643,15 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) { check_result = TargetFilePreCheck(out_path, false); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot write to file: %1")).arg(out_path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot write to file: %1").arg(out_path)); return; } if (QFile::exists(out_path)) { auto ret = QMessageBox::warning( - this, _("Warning"), - _("The target file already exists, do you need to overwrite it?"), + this, tr("Warning"), + tr("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -670,7 +669,7 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) { auto p_signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids); CommonUtils::WaitForOpera( - this, _("Archiving & Encrypting & Signing"), + this, tr("Archiving & Encrypting & Signing"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().EncryptSignDirectory( {p_keys->begin(), p_keys->end()}, @@ -706,8 +705,8 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) { void MainWindow::SlotFileDecryptVerify(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")).arg(path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot read from file: %1").arg(path)); return; } @@ -715,24 +714,23 @@ void MainWindow::SlotFileDecryptVerify(const QString& path) { check_result = TargetFilePreCheck(out_path, false); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot write to file: %1")).arg(out_path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot write to file: %1").arg(out_path)); return; } if (QFile::exists(out_path)) { - auto ret = - QMessageBox::warning(this, _("Warning"), - QString(_("The output file %1 already exists, do " - "you need to overwrite it?")) - .arg(out_path), - QMessageBox::Ok | QMessageBox::Cancel); + auto ret = QMessageBox::warning(this, tr("Warning"), + tr("The output file %1 already exists, do " + "you need to overwrite it?") + .arg(out_path), + QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; } CommonUtils::WaitForOpera( - this, _("Decrypting and Verifying"), [=](const OperaWaitingHd& op_hd) { + this, tr("Decrypting and Verifying"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().DecryptVerifyFile( path, out_path, [=](GpgError err, const DataObjectPtr& data_obj) { // stop waiting @@ -771,8 +769,8 @@ void MainWindow::SlotFileDecryptVerify(const QString& path) { void MainWindow::SlotArchiveDecryptVerify(const QString& path) { auto check_result = TargetFilePreCheck(path, true); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot read from file: %1")).arg(path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot read from file: %1").arg(path)); return; } @@ -781,24 +779,23 @@ void MainWindow::SlotArchiveDecryptVerify(const QString& path) { check_result = TargetFilePreCheck(out_path, false); if (!std::get<0>(check_result)) { - QMessageBox::critical(this, _("Error"), - QString(_("Cannot write to file: %1")).arg(out_path)); + QMessageBox::critical(this, tr("Error"), + tr("Cannot write to file: %1").arg(out_path)); return; } if (QFile::exists(out_path)) { - auto ret = - QMessageBox::warning(this, _("Warning"), - QString(_("The output file %1 already exists, do " - "you need to overwrite it?")) - .arg(out_path), - QMessageBox::Ok | QMessageBox::Cancel); + auto ret = QMessageBox::warning(this, tr("Warning"), + tr("The output file %1 already exists, do " + "you need to overwrite it?") + .arg(out_path), + QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; } CommonUtils::WaitForOpera( - this, _("Decrypting & Verifying & Extracting"), + this, tr("Decrypting & Verifying & Extracting"), [=](const OperaWaitingHd& op_hd) { GpgFileOpera::GetInstance().DecryptVerifyArchive( path, out_path, [=](GpgError err, const DataObjectPtr& data_obj) { diff --git a/src/ui/main_window/MainWindowGpgOperaFunction.cpp b/src/ui/main_window/MainWindowGpgOperaFunction.cpp index cf7e2d68..c9e09bf2 100644 --- a/src/ui/main_window/MainWindowGpgOperaFunction.cpp +++ b/src/ui/main_window/MainWindowGpgOperaFunction.cpp @@ -35,7 +35,6 @@ #include "core/function/result_analyse/GpgVerifyResultAnalyse.h" #include "core/model/DataObject.h" #include "core/model/GpgEncryptResult.h" -#include "core/utils/CommonUtils.h" #include "core/utils/GpgUtils.h" #include "ui/UserInterfaceUtils.h" #include "ui/dialog/SignersPicker.h" @@ -50,16 +49,16 @@ void MainWindow::SlotEncrypt() { if (key_ids->empty()) { // Symmetric Encrypt auto ret = QMessageBox::information( - this, _("Symmetric Encryption"), - _("No Key Checked. Do you want to encrypt with a " - "symmetric cipher using a passphrase?"), + this, tr("Symmetric Encryption"), + tr("No Key Checked. Do you want to encrypt with a " + "symmetric cipher using a passphrase?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; auto buffer = GFBuffer(edit_->CurTextPage()->GetTextPage()->toPlainText()); CommonUtils::WaitForOpera( - this, _("Symmetrically Encrypting"), + this, tr("Symmetrically Encrypting"), [this, buffer](const OperaWaitingHd& op_hd) { GpgFrontend::GpgBasicOperator::GetInstance().EncryptSymmetric( buffer, true, @@ -93,11 +92,10 @@ void MainWindow::SlotEncrypt() { for (const auto& key : *keys) { if (!key.IsHasActualEncryptionCapability()) { QMessageBox::information( - this, _("Invalid Operation"), - QString( - _("The selected key contains a key that does not actually have a " - "encrypt usage.")) + - "<br/><br/>" + _("For example the Following Key:") + " <br/>" + + this, tr("Invalid Operation"), + tr("The selected key contains a key that does not actually have a " + "encrypt usage.") + + "<br/><br/>" + tr("For example the Following Key:") + " <br/>" + key.GetUIDs()->front().GetUID()); return; } @@ -105,7 +103,8 @@ void MainWindow::SlotEncrypt() { auto buffer = GFBuffer(edit_->CurTextPage()->GetTextPage()->toPlainText()); CommonUtils::WaitForOpera( - this, _("Encrypting"), [this, keys, buffer](const OperaWaitingHd& op_hd) { + this, tr("Encrypting"), + [this, keys, buffer](const OperaWaitingHd& op_hd) { GpgFrontend::GpgBasicOperator::GetInstance().Encrypt( {keys->begin(), keys->end()}, buffer, true, [this, op_hd](GpgError err, const DataObjectPtr& data_obj) { @@ -138,8 +137,8 @@ void MainWindow::SlotSign() { auto key_ids = m_key_list_->GetPrivateChecked(); if (key_ids->empty()) { QMessageBox::critical( - this, _("No Key Checked"), - _("Please check the key in the key toolbox on the right.")); + this, tr("No Key Checked"), + tr("Please check the key in the key toolbox on the right.")); return; } @@ -147,11 +146,10 @@ void MainWindow::SlotSign() { for (const auto& key : *keys) { if (!key.IsHasActualSigningCapability()) { QMessageBox::information( - this, _("Invalid Operation"), - QString( - _("The selected key contains a key that does not actually have a " - "signature usage.")) + - "<br/><br/>" + _("For example the Following Key:") + "<br/>" + + this, tr("Invalid Operation"), + tr("The selected key contains a key that does not actually have a " + "signature usage.") + + "<br/><br/>" + tr("For example the Following Key:") + "<br/>" + key.GetUIDs()->front().GetUID()); return; } @@ -160,7 +158,7 @@ void MainWindow::SlotSign() { // set input buffer auto buffer = GFBuffer(edit_->CurTextPage()->GetTextPage()->toPlainText()); CommonUtils::WaitForOpera( - this, _("Signing"), [this, keys, buffer](const OperaWaitingHd& hd) { + this, tr("Signing"), [this, keys, buffer](const OperaWaitingHd& hd) { GpgFrontend::GpgBasicOperator::GetInstance().Sign( {keys->begin(), keys->end()}, buffer, GPGME_SIG_MODE_CLEAR, true, [this, hd](GpgError err, const DataObjectPtr& data_obj) { @@ -192,7 +190,7 @@ void MainWindow::SlotDecrypt() { auto buffer = GFBuffer(edit_->CurTextPage()->GetTextPage()->toPlainText()); CommonUtils::WaitForOpera( - this, _("Decrypting"), [this, buffer](const OperaWaitingHd& hd) { + this, tr("Decrypting"), [this, buffer](const OperaWaitingHd& hd) { GpgFrontend::GpgBasicOperator::GetInstance().Decrypt( buffer, [this, hd](GpgError err, const DataObjectPtr& data_obj) { // stop waiting @@ -225,7 +223,7 @@ void MainWindow::SlotVerify() { auto buffer = GFBuffer(edit_->CurTextPage()->GetTextPage()->toPlainText()); CommonUtils::WaitForOpera( - this, _("Verifying"), [this, buffer](const OperaWaitingHd& hd) { + this, tr("Verifying"), [this, buffer](const OperaWaitingHd& hd) { GpgFrontend::GpgBasicOperator::GetInstance().Verify( buffer, GFBuffer(), [this, hd](GpgError err, const DataObjectPtr& data_obj) { @@ -252,8 +250,8 @@ void MainWindow::SlotEncryptSign() { if (key_ids->empty()) { QMessageBox::critical( - this, _("No Key Checked"), - _("Please check some key in the key toolbox on the right.")); + this, tr("No Key Checked"), + tr("Please check some key in the key toolbox on the right.")); return; } @@ -264,9 +262,9 @@ void MainWindow::SlotEncryptSign() { if (!key_can_encrypt) { QMessageBox::critical( - this, _("Invalid KeyPair"), - QString(_("The selected keypair cannot be used for encryption.")) + - "<br/><br/>" + _("For example the Following Key:") + " <br/>" + + this, tr("Invalid KeyPair"), + tr("The selected keypair cannot be used for encryption.") + + "<br/><br/>" + tr("For example the Following Key:") + " <br/>" + key.GetUIDs()->front().GetUID()); return; } @@ -295,7 +293,7 @@ void MainWindow::SlotEncryptSign() { auto buffer = GFBuffer(edit_->CurTextPage()->GetTextPage()->toPlainText()); CommonUtils::WaitForOpera( - this, _("Encrypting and Signing"), + this, tr("Encrypting and Signing"), [this, keys, signer_keys, buffer](const OperaWaitingHd& hd) { GpgFrontend::GpgBasicOperator::GetInstance().EncryptSign( {keys->begin(), keys->end()}, @@ -341,7 +339,7 @@ void MainWindow::SlotDecryptVerify() { auto buffer = GFBuffer(edit_->CurTextPage()->GetTextPage()->toPlainText()); CommonUtils::WaitForOpera( - this, _("Decrypting and Verifying"), + this, tr("Decrypting and Verifying"), [this, buffer](const OperaWaitingHd& hd) { GpgFrontend::GpgBasicOperator::GetInstance().DecryptVerify( buffer, [this, hd](GpgError err, const DataObjectPtr& data_obj) { diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp index 37f49b0d..fe9aa0df 100644 --- a/src/ui/main_window/MainWindowSlotFunction.cpp +++ b/src/ui/main_window/MainWindowSlotFunction.cpp @@ -93,12 +93,12 @@ void MainWindow::slot_append_keys_create_datetime() { auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); if (!key.IsGood()) { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); return; } auto create_datetime_format_str_local = - QLocale::system().toString(key.GetCreateTime()) + _(" (Local Time) ") + + QLocale::system().toString(key.GetCreateTime()) + tr(" (Local Time) ") + "\n"; edit_->SlotAppendText2CurTextPage(create_datetime_format_str_local); } @@ -113,7 +113,7 @@ void MainWindow::slot_append_keys_expire_datetime() { auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); if (!key.IsGood()) { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); return; } @@ -129,7 +129,7 @@ void MainWindow::slot_append_keys_fingerprint() { auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); if (!key.IsGood()) { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); return; } @@ -145,7 +145,7 @@ void MainWindow::slot_copy_mail_address_to_clipboard() { auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); if (!key.IsGood()) { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); return; } QClipboard* cb = QApplication::clipboard(); @@ -158,7 +158,7 @@ void MainWindow::slot_copy_default_uid_to_clipboard() { auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); if (!key.IsGood()) { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); return; } QClipboard* cb = QApplication::clipboard(); @@ -171,7 +171,7 @@ void MainWindow::slot_copy_key_id_to_clipboard() { auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); if (!key.IsGood()) { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); return; } QClipboard* cb = QApplication::clipboard(); @@ -186,7 +186,7 @@ void MainWindow::slot_show_key_details() { if (key.IsGood()) { new KeyDetailsDialog(key, this); } else { - QMessageBox::critical(this, _("Error"), _("Key Not Found.")); + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); } } @@ -238,17 +238,18 @@ void MainWindow::upload_key_to_server() { void MainWindow::SlotOpenFile(const QString& path) { QFileInfo const info(path); if (!info.isFile() || !info.isReadable()) { - QMessageBox::critical(this, _("Error"), - _("Cannot open this file. Please make sure that this " - "is a regular file and it's readable.")); + QMessageBox::critical( + this, tr("Error"), + tr("Cannot open this file. Please make sure that this " + "is a regular file and it's readable.")); return; } if (info.size() > static_cast<qint64>(1024 * 1024)) { QMessageBox::critical( - this, _("Error"), - _("Cannot open this file. The file is TOO LARGE (>1MB) for " - "GpgFrontend Text Editor.")); + this, tr("Error"), + tr("Cannot open this file. The file is TOO LARGE (>1MB) for " + "GpgFrontend Text Editor.")); return; } @@ -286,16 +287,14 @@ void MainWindow::slot_version_upgrade_nofity() { "version.latest_version", QString{}); GF_UI_LOG_DEBUG( - "got version info from rt, need upgrade: {}, with drawn: {}, current " - "version " - "released: {}", + "got version info from rt, need upgrade: {}, with drawn: {}, " + "current version released: {}", is_need_upgrade, is_current_a_withdrawn_version, is_current_version_released); if (is_need_upgrade) { statusBar()->showMessage( - QString(_("GpgFrontend Upgradeable (New Version: %1).")) - .arg(latest_version), + tr("GpgFrontend Upgradeable (New Version: %1).").arg(latest_version), 30000); auto* update_button = new QPushButton("Update GpgFrontend", this); connect(update_button, &QPushButton::clicked, [=]() { @@ -305,20 +304,19 @@ void MainWindow::slot_version_upgrade_nofity() { statusBar()->addPermanentWidget(update_button, 0); } else if (is_current_a_withdrawn_version) { QMessageBox::warning( - this, _("Withdrawn Version"), - QString( - _("This version(%1) may have been withdrawn by the developer due " - "to serious problems. Please stop using this version " - "immediately and use the latest stable version.")) + this, tr("Withdrawn Version"), + + tr("This version(%1) may have been withdrawn by the developer due " + "to serious problems. Please stop using this version " + "immediately and use the latest stable version.") .arg(latest_version) + "<br/>" + - QString(_("You can download the latest stable version(%1) on " - "Github Releases " - "Page.<br/>")) + tr("You can download the latest stable version(%1) on " + "Github Releases Page.<br/>") .arg(latest_version)); } else if (!is_current_version_released) { statusBar()->showMessage( - QString(_("This maybe a BETA Version (Latest Stable Version: %1).")) + tr("This maybe a BETA Version (Latest Stable Version: %1).") .arg(latest_version), 30000); } diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp index 3bc2ba23..f62f6d9f 100644 --- a/src/ui/main_window/MainWindowUI.cpp +++ b/src/ui/main_window/MainWindowUI.cpp @@ -42,127 +42,127 @@ namespace GpgFrontend::UI { void MainWindow::create_actions() { /* Main Menu */ - new_tab_act_ = new QAction(_("New"), this); - new_tab_act_->setIcon(QIcon(":misc_doc.png")); + new_tab_act_ = new QAction(tr("New"), this); + new_tab_act_->setIcon(QIcon(":/icons/misc_doc.png")); QList<QKeySequence> new_tab_act_shortcut_list; new_tab_act_shortcut_list.append(QKeySequence(Qt::CTRL | Qt::Key_N)); new_tab_act_shortcut_list.append(QKeySequence(Qt::CTRL | Qt::Key_T)); new_tab_act_->setShortcuts(new_tab_act_shortcut_list); - new_tab_act_->setToolTip(_("Open a new file")); + new_tab_act_->setToolTip(tr("Open a new file")); connect(new_tab_act_, &QAction::triggered, edit_, &TextEdit::SlotNewTab); - open_act_ = new QAction(_("Open..."), this); - open_act_->setIcon(QIcon(":fileopen.png")); + open_act_ = new QAction(tr("Open..."), this); + open_act_->setIcon(QIcon(":/icons/fileopen.png")); open_act_->setShortcut(QKeySequence::Open); - open_act_->setToolTip(_("Open an existing file")); + open_act_->setToolTip(tr("Open an existing file")); connect(open_act_, &QAction::triggered, edit_, &TextEdit::SlotOpen); - browser_act_ = new QAction(_("File Browser"), this); - browser_act_->setIcon(QIcon(":file-browser.png")); + browser_act_ = new QAction(tr("File Browser"), this); + browser_act_->setIcon(QIcon(":/icons/file-browser.png")); browser_act_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_B)); - browser_act_->setToolTip(_("Open a file browser")); + browser_act_->setToolTip(tr("Open a file browser")); connect(browser_act_, &QAction::triggered, this, &MainWindow::slot_open_file_tab); - save_act_ = new QAction(_("Save File"), this); - save_act_->setIcon(QIcon(":filesave.png")); + save_act_ = new QAction(tr("Save File"), this); + save_act_->setIcon(QIcon(":/icons/filesave.png")); save_act_->setShortcut(QKeySequence::Save); - save_act_->setToolTip(_("Save the current File")); + save_act_->setToolTip(tr("Save the current File")); connect(save_act_, &QAction::triggered, edit_, &TextEdit::SlotSave); - save_as_act_ = new QAction(QString(_("Save As")) + "...", this); - save_as_act_->setIcon(QIcon(":filesaveas.png")); + save_as_act_ = new QAction(tr("Save As") + "...", this); + save_as_act_->setIcon(QIcon(":/icons/filesaveas.png")); save_as_act_->setShortcut(QKeySequence::SaveAs); - save_as_act_->setToolTip(_("Save the current File as...")); + save_as_act_->setToolTip(tr("Save the current File as...")); connect(save_as_act_, &QAction::triggered, edit_, &TextEdit::SlotSaveAs); - print_act_ = new QAction(_("Print"), this); - print_act_->setIcon(QIcon(":fileprint.png")); + print_act_ = new QAction(tr("Print"), this); + print_act_->setIcon(QIcon(":/icons/fileprint.png")); print_act_->setShortcut(QKeySequence::Print); - print_act_->setToolTip(_("Print Document")); + print_act_->setToolTip(tr("Print Document")); connect(print_act_, &QAction::triggered, edit_, &TextEdit::SlotPrint); - close_tab_act_ = new QAction(_("Close"), this); + close_tab_act_ = new QAction(tr("Close"), this); close_tab_act_->setShortcut(QKeySequence::Close); - close_tab_act_->setToolTip(_("Close file")); + close_tab_act_->setToolTip(tr("Close file")); connect(close_tab_act_, &QAction::triggered, edit_, &TextEdit::SlotCloseTab); - quit_act_ = new QAction(_("Quit"), this); + quit_act_ = new QAction(tr("Quit"), this); quit_act_->setShortcut(QKeySequence::Quit); - quit_act_->setIcon(QIcon(":exit.png")); - quit_act_->setToolTip(_("Quit Program")); + quit_act_->setIcon(QIcon(":/icons/exit.png")); + quit_act_->setToolTip(tr("Quit Program")); connect(quit_act_, &QAction::triggered, this, &MainWindow::close); /* Edit Menu */ - undo_act_ = new QAction(_("Undo"), this); + undo_act_ = new QAction(tr("Undo"), this); undo_act_->setShortcut(QKeySequence::Undo); - undo_act_->setToolTip(_("Undo Last Edit Action")); + undo_act_->setToolTip(tr("Undo Last Edit Action")); connect(undo_act_, &QAction::triggered, edit_, &TextEdit::SlotUndo); - redo_act_ = new QAction(_("Redo"), this); + redo_act_ = new QAction(tr("Redo"), this); redo_act_->setShortcut(QKeySequence::Redo); - redo_act_->setToolTip(_("Redo Last Edit Action")); + redo_act_->setToolTip(tr("Redo Last Edit Action")); connect(redo_act_, &QAction::triggered, edit_, &TextEdit::SlotRedo); - zoom_in_act_ = new QAction(_("Zoom In"), this); + zoom_in_act_ = new QAction(tr("Zoom In"), this); zoom_in_act_->setShortcut(QKeySequence::ZoomIn); connect(zoom_in_act_, &QAction::triggered, edit_, &TextEdit::SlotZoomIn); - zoom_out_act_ = new QAction(_("Zoom Out"), this); + zoom_out_act_ = new QAction(tr("Zoom Out"), this); zoom_out_act_->setShortcut(QKeySequence::ZoomOut); connect(zoom_out_act_, &QAction::triggered, edit_, &TextEdit::SlotZoomOut); - paste_act_ = new QAction(_("Paste"), this); - paste_act_->setIcon(QIcon(":button_paste.png")); + paste_act_ = new QAction(tr("Paste"), this); + paste_act_->setIcon(QIcon(":/icons/button_paste.png")); paste_act_->setShortcut(QKeySequence::Paste); - paste_act_->setToolTip(_("Paste Text From Clipboard")); + paste_act_->setToolTip(tr("Paste Text From Clipboard")); connect(paste_act_, &QAction::triggered, edit_, &TextEdit::SlotPaste); - cut_act_ = new QAction(_("Cut"), this); - cut_act_->setIcon(QIcon(":button_cut.png")); + cut_act_ = new QAction(tr("Cut"), this); + cut_act_->setIcon(QIcon(":/icons/button_cut.png")); cut_act_->setShortcut(QKeySequence::Cut); cut_act_->setToolTip( - _("Cut the current selection's contents to the " - "clipboard")); + tr("Cut the current selection's contents to the " + "clipboard")); connect(cut_act_, &QAction::triggered, edit_, &TextEdit::SlotCut); - copy_act_ = new QAction(_("Copy"), this); - copy_act_->setIcon(QIcon(":button_copy.png")); + copy_act_ = new QAction(tr("Copy"), this); + copy_act_->setIcon(QIcon(":/icons/button_copy.png")); copy_act_->setShortcut(QKeySequence::Copy); copy_act_->setToolTip( - _("Copy the current selection's contents to the " - "clipboard")); + tr("Copy the current selection's contents to the " + "clipboard")); connect(copy_act_, &QAction::triggered, edit_, &TextEdit::SlotCopy); - quote_act_ = new QAction(_("Quote"), this); - quote_act_->setIcon(QIcon(":quote.png")); - quote_act_->setToolTip(_("Quote whole text")); + quote_act_ = new QAction(tr("Quote"), this); + quote_act_->setIcon(QIcon(":/icons/quote.png")); + quote_act_->setToolTip(tr("Quote whole text")); connect(quote_act_, &QAction::triggered, edit_, &TextEdit::SlotQuote); - select_all_act_ = new QAction(_("Select All"), this); - select_all_act_->setIcon(QIcon(":edit.png")); + select_all_act_ = new QAction(tr("Select All"), this); + select_all_act_->setIcon(QIcon(":/icons/edit.png")); select_all_act_->setShortcut(QKeySequence::SelectAll); - select_all_act_->setToolTip(_("Select the whole text")); + select_all_act_->setToolTip(tr("Select the whole text")); connect(select_all_act_, &QAction::triggered, edit_, &TextEdit::SlotSelectAll); - find_act_ = new QAction(_("Find"), this); + find_act_ = new QAction(tr("Find"), this); find_act_->setShortcut(QKeySequence::Find); - find_act_->setToolTip(_("Find a word")); + find_act_->setToolTip(tr("Find a word")); connect(find_act_, &QAction::triggered, this, &MainWindow::slot_find); - clean_double_line_breaks_act_ = new QAction(_("Remove spacing"), this); + clean_double_line_breaks_act_ = new QAction(tr("Remove spacing"), this); clean_double_line_breaks_act_->setIcon( - QIcon(":format-line-spacing-triple.png")); + QIcon(":/icons/format-line-spacing-triple.png")); // cleanDoubleLineBreaksAct->setShortcut(QKeySequence::SelectAll); clean_double_line_breaks_act_->setToolTip( - _("Remove double linebreaks, e.g. in pasted text from Web Mailer")); + tr("Remove double linebreaks, e.g. in pasted text from Web Mailer")); connect(clean_double_line_breaks_act_, &QAction::triggered, this, &MainWindow::slot_clean_double_line_breaks); - open_settings_act_ = new QAction(_("Settings"), this); - open_settings_act_->setToolTip(_("Open settings dialog")); + open_settings_act_ = new QAction(tr("Settings"), this); + open_settings_act_->setToolTip(tr("Open settings dialog")); open_settings_act_->setMenuRole(QAction::PreferencesRole); open_settings_act_->setShortcut(QKeySequence::Preferences); connect(open_settings_act_, &QAction::triggered, this, @@ -170,11 +170,11 @@ void MainWindow::create_actions() { /* Crypt Menu */ - encrypt_act_ = new QAction(_("Encrypt"), this); - encrypt_act_->setIcon(QIcon(":encrypted.png")); + encrypt_act_ = new QAction(tr("Encrypt"), this); + encrypt_act_->setIcon(QIcon(":/icons/encrypted.png")); encrypt_act_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_E)); - encrypt_act_->setToolTip(_("Encrypt Message")); + encrypt_act_->setToolTip(tr("Encrypt Message")); connect(encrypt_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); @@ -192,12 +192,12 @@ void MainWindow::create_actions() { } }); - encrypt_sign_act_ = new QAction(_("Encrypt Sign"), this); - encrypt_sign_act_->setIcon(QIcon(":encrypted_signed.png")); + encrypt_sign_act_ = new QAction(tr("Encrypt Sign"), this); + encrypt_sign_act_->setIcon(QIcon(":/icons/encrypted_signed.png")); encrypt_sign_act_->setShortcut( QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_E)); - encrypt_sign_act_->setToolTip(_("Encrypt and Sign Message")); + encrypt_sign_act_->setToolTip(tr("Encrypt and Sign Message")); connect(encrypt_sign_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); @@ -215,10 +215,10 @@ void MainWindow::create_actions() { } }); - decrypt_act_ = new QAction(_("Decrypt"), this); - decrypt_act_->setIcon(QIcon(":decrypted.png")); + decrypt_act_ = new QAction(tr("Decrypt"), this); + decrypt_act_->setIcon(QIcon(":/icons/decrypted.png")); decrypt_act_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D)); - decrypt_act_->setToolTip(_("Decrypt Message")); + decrypt_act_->setToolTip(tr("Decrypt Message")); connect(decrypt_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); @@ -240,11 +240,11 @@ void MainWindow::create_actions() { } }); - decrypt_verify_act_ = new QAction(_("Decrypt Verify"), this); - decrypt_verify_act_->setIcon(QIcon(":decrypted_verified.png")); + decrypt_verify_act_ = new QAction(tr("Decrypt Verify"), this); + decrypt_verify_act_->setIcon(QIcon(":/icons/decrypted_verified.png")); decrypt_verify_act_->setShortcut( QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_D)); - decrypt_verify_act_->setToolTip(_("Decrypt and Verify Message")); + decrypt_verify_act_->setToolTip(tr("Decrypt and Verify Message")); connect(decrypt_verify_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); @@ -266,10 +266,10 @@ void MainWindow::create_actions() { } }); - sign_act_ = new QAction(_("Sign"), this); - sign_act_->setIcon(QIcon(":signature.png")); + sign_act_ = new QAction(tr("Sign"), this); + sign_act_->setIcon(QIcon(":/icons/signature.png")); sign_act_->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_I)); - sign_act_->setToolTip(_("Sign Message")); + sign_act_->setToolTip(tr("Sign Message")); connect(sign_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); @@ -281,10 +281,10 @@ void MainWindow::create_actions() { if (edit_->SlotCurPageTextEdit() != nullptr) this->SlotSign(); }); - verify_act_ = new QAction(_("Verify"), this); - verify_act_->setIcon(QIcon(":verify.png")); + verify_act_ = new QAction(tr("Verify"), this); + verify_act_->setIcon(QIcon(":/icons/verify.png")); verify_act_->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_V)); - verify_act_->setToolTip(_("Verify Message")); + verify_act_->setToolTip(tr("Verify Message")); connect(verify_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); @@ -299,17 +299,17 @@ void MainWindow::create_actions() { /* Key Menu */ - import_key_from_file_act_ = new QAction(_("File"), this); - import_key_from_file_act_->setIcon(QIcon(":import_key_from_file.png")); - import_key_from_file_act_->setToolTip(_("Import New Key From File")); + import_key_from_file_act_ = new QAction(tr("File"), this); + import_key_from_file_act_->setIcon(QIcon(":/icons/import_key_from_file.png")); + import_key_from_file_act_->setToolTip(tr("Import New Key From File")); connect(import_key_from_file_act_, &QAction::triggered, this, [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); }); - import_key_from_clipboard_act_ = new QAction(_("Clipboard"), this); + import_key_from_clipboard_act_ = new QAction(tr("Clipboard"), this); import_key_from_clipboard_act_->setIcon( - QIcon(":import_key_from_clipboard.png")); + QIcon(":/icons/import_key_from_clipboard.png")); import_key_from_clipboard_act_->setToolTip( - _("Import New Key From Clipboard")); + tr("Import New Key From Clipboard")); connect(import_key_from_clipboard_act_, &QAction::triggered, this, [&]() { CommonUtils::GetInstance()->SlotImportKeyFromClipboard(this); }); @@ -320,59 +320,60 @@ void MainWindow::create_actions() { .value("network/forbid_all_gnupg_connection", false) .toBool(); - import_key_from_key_server_act_ = new QAction(_("Keyserver"), this); + import_key_from_key_server_act_ = new QAction(tr("Keyserver"), this); import_key_from_key_server_act_->setIcon( - QIcon(":import_key_from_server.png")); + QIcon(":/icons/import_key_from_server.png")); import_key_from_key_server_act_->setToolTip( - _("Import New Key From Keyserver")); + tr("Import New Key From Keyserver")); import_key_from_key_server_act_->setDisabled(forbid_all_gnupg_connection); connect(import_key_from_key_server_act_, &QAction::triggered, this, [&]() { CommonUtils::GetInstance()->SlotImportKeyFromKeyServer(this); }); - import_key_from_edit_act_ = new QAction(_("Editor"), this); - import_key_from_edit_act_->setIcon(QIcon(":txt.png")); - import_key_from_edit_act_->setToolTip(_("Import New Key From Editor")); + import_key_from_edit_act_ = new QAction(tr("Editor"), this); + import_key_from_edit_act_->setIcon(QIcon(":/icons/txt.png")); + import_key_from_edit_act_->setToolTip(tr("Import New Key From Editor")); connect(import_key_from_edit_act_, &QAction::triggered, this, &MainWindow::slot_import_key_from_edit); - open_key_management_act_ = new QAction(_("Manage Keys"), this); - open_key_management_act_->setIcon(QIcon(":keymgmt.png")); - open_key_management_act_->setToolTip(_("Open Key Management")); + open_key_management_act_ = new QAction(tr("Manage Keys"), this); + open_key_management_act_->setIcon(QIcon(":/icons/keymgmt.png")); + open_key_management_act_->setToolTip(tr("Open Key Management")); connect(open_key_management_act_, &QAction::triggered, this, &MainWindow::slot_open_key_management); - clean_gpg_password_cache_act_ = new QAction(_("Clear Password Cache"), this); - clean_gpg_password_cache_act_->setIcon(QIcon(":configure.png")); - clean_gpg_password_cache_act_->setToolTip(_("Clear Password Cache of GnuPG")); + clean_gpg_password_cache_act_ = new QAction(tr("Clear Password Cache"), this); + clean_gpg_password_cache_act_->setIcon(QIcon(":/icons/configure.png")); + clean_gpg_password_cache_act_->setToolTip( + tr("Clear Password Cache of GnuPG")); connect(clean_gpg_password_cache_act_, &QAction::triggered, this, [=]() { if (GpgFrontend::GpgAdvancedOperator::ClearGpgPasswordCache()) { - QMessageBox::information(this, _("Successful Operation"), - _("Clear password cache successfully")); + QMessageBox::information(this, tr("Successful Operation"), + tr("Clear password cache successfully")); } else { - QMessageBox::critical(this, _("Failed Operation"), - _("Failed to clear password cache of GnuPG")); + QMessageBox::critical(this, tr("Failed Operation"), + tr("Failed to clear password cache of GnuPG")); } }); - reload_components_act_ = new QAction(_("Reload All Components"), this); - reload_components_act_->setIcon(QIcon(":configure.png")); - reload_components_act_->setToolTip(_("Reload All GnuPG's Components")); + reload_components_act_ = new QAction(tr("Reload All Components"), this); + reload_components_act_->setIcon(QIcon(":/icons/configure.png")); + reload_components_act_->setToolTip(tr("Reload All GnuPG's Components")); connect(reload_components_act_, &QAction::triggered, this, [=]() { if (GpgFrontend::GpgAdvancedOperator::ReloadGpgComponents()) { QMessageBox::information( - this, _("Successful Operation"), - _("Reload all the GnuPG's components successfully")); + this, tr("Successful Operation"), + tr("Reload all the GnuPG's components successfully")); } else { QMessageBox::critical( - this, _("Failed Operation"), - _("Failed to reload all or one of the GnuPG's component(s)")); + this, tr("Failed Operation"), + tr("Failed to reload all or one of the GnuPG's component(s)")); } }); - restart_components_act_ = new QAction(_("Restart All Components"), this); - restart_components_act_->setIcon(QIcon(":configure.png")); - restart_components_act_->setToolTip(_("Restart All GnuPG's Components")); + restart_components_act_ = new QAction(tr("Restart All Components"), this); + restart_components_act_->setIcon(QIcon(":/icons/configure.png")); + restart_components_act_->setToolTip(tr("Restart All GnuPG's Components")); connect(restart_components_act_, &QAction::triggered, this, [=]() { GpgFrontend::GpgAdvancedOperator::RestartGpgComponents(); Module::ListenRTPublishEvent( @@ -381,127 +382,127 @@ void MainWindow::create_actions() { bool success_state = std::any_cast<bool>(value); if (success_state) { QMessageBox::information( - this, _("Successful Operation"), - _("Restart all the GnuPG's components successfully")); + this, tr("Successful Operation"), + tr("Restart all the GnuPG's components successfully")); } else { QMessageBox::critical( - this, _("Failed Operation"), - _("Failed to restart all or one of the GnuPG's component(s)")); + this, tr("Failed Operation"), + tr("Failed to restart all or one of the GnuPG's component(s)")); } }); }); - gnupg_controller_open_act_ = new QAction(_("Open GnuPG Controller"), this); - gnupg_controller_open_act_->setIcon(QIcon(":configure.png")); - gnupg_controller_open_act_->setToolTip(_("Open GnuPG Controller Dialog")); + gnupg_controller_open_act_ = new QAction(tr("Open GnuPG Controller"), this); + gnupg_controller_open_act_->setIcon(QIcon(":/icons/configure.png")); + gnupg_controller_open_act_->setToolTip(tr("Open GnuPG Controller Dialog")); connect(gnupg_controller_open_act_, &QAction::triggered, this, [this]() { (new GnuPGControllerDialog(this))->exec(); }); /* * About Menu */ - about_act_ = new QAction(_("About"), this); - about_act_->setIcon(QIcon(":help.png")); - about_act_->setToolTip(_("Show the application's About box")); + about_act_ = new QAction(tr("About"), this); + about_act_->setIcon(QIcon(":/icons/help.png")); + about_act_->setToolTip(tr("Show the application's About box")); about_act_->setMenuRole(QAction::AboutRole); 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")); + gnupg_act_ = new QAction(tr("GnuPG"), this); + gnupg_act_->setIcon(QIcon("/icons/:help.png")); + gnupg_act_->setToolTip(tr("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")); + translate_act_ = new QAction(tr("Translate"), this); + translate_act_->setIcon(QIcon(":/icons/help.png")); + translate_act_->setToolTip(tr("Information about translation")); connect(translate_act_, &QAction::triggered, this, [=]() { new AboutDialog(2, this); }); /* * Check Update Menu */ - check_update_act_ = new QAction(_("Check for Updates"), this); - check_update_act_->setIcon(QIcon(":help.png")); - check_update_act_->setToolTip(_("Check for updates")); + check_update_act_ = new QAction(tr("Check for Updates"), this); + check_update_act_->setIcon(QIcon(":/icons/help.png")); + check_update_act_->setToolTip(tr("Check for updates")); connect(check_update_act_, &QAction::triggered, this, [=]() { new AboutDialog(3, this); }); - start_wizard_act_ = new QAction(_("Open Wizard"), this); - start_wizard_act_->setToolTip(_("Open the wizard")); + start_wizard_act_ = new QAction(tr("Open Wizard"), this); + start_wizard_act_->setToolTip(tr("Open the wizard")); connect(start_wizard_act_, &QAction::triggered, this, &MainWindow::slot_start_wizard); append_selected_keys_act_ = - new QAction(_("Append Public Key to Editor"), this); + new QAction(tr("Append Public Key to Editor"), this); append_selected_keys_act_->setToolTip( - _("Append selected Keypair's Public Key to Editor")); + tr("Append selected Keypair's Public Key to Editor")); connect(append_selected_keys_act_, &QAction::triggered, this, &MainWindow::slot_append_selected_keys); append_key_create_date_to_editor_act_ = - new QAction(_("Append Create DateTime to Editor"), this); + new QAction(tr("Append Create DateTime to Editor"), this); append_key_create_date_to_editor_act_->setToolTip( - _("Append selected Key's creation date and time to Editor")); + tr("Append selected Key's creation date and time to Editor")); connect(append_key_create_date_to_editor_act_, &QAction::triggered, this, &MainWindow::slot_append_keys_create_datetime); append_key_expire_date_to_editor_act_ = - new QAction(_("Append Expire DateTime to Editor"), this); + new QAction(tr("Append Expire DateTime to Editor"), this); append_key_expire_date_to_editor_act_->setToolTip( - _("Append selected Key's expiration date and time to Editor")); + tr("Append selected Key's expiration date and time to Editor")); connect(append_key_expire_date_to_editor_act_, &QAction::triggered, this, &MainWindow::slot_append_keys_expire_datetime); append_key_fingerprint_to_editor_act_ = - new QAction(_("Append Fingerprint to Editor"), this); + new QAction(tr("Append Fingerprint to Editor"), this); append_key_expire_date_to_editor_act_->setToolTip( - _("Append selected Key's Fingerprint to Editor")); + tr("Append selected Key's Fingerprint to Editor")); connect(append_key_fingerprint_to_editor_act_, &QAction::triggered, this, &MainWindow::slot_append_keys_fingerprint); - copy_mail_address_to_clipboard_act_ = new QAction(_("Copy Email"), this); + copy_mail_address_to_clipboard_act_ = new QAction(tr("Copy Email"), this); copy_mail_address_to_clipboard_act_->setToolTip( - _("Copy selected Keypair's to clipboard")); + tr("Copy selected Keypair's to clipboard")); connect(copy_mail_address_to_clipboard_act_, &QAction::triggered, this, &MainWindow::slot_copy_mail_address_to_clipboard); copy_key_default_uid_to_clipboard_act_ = - new QAction(_("Copy Default UID"), this); + new QAction(tr("Copy Default UID"), this); copy_key_default_uid_to_clipboard_act_->setToolTip( - _("Copy selected Keypair's default UID to clipboard")); + tr("Copy selected Keypair's default UID to clipboard")); connect(copy_key_default_uid_to_clipboard_act_, &QAction::triggered, this, &MainWindow::slot_copy_default_uid_to_clipboard); - copy_key_id_to_clipboard_act_ = new QAction(_("Copy Key ID"), this); + copy_key_id_to_clipboard_act_ = new QAction(tr("Copy Key ID"), this); copy_key_id_to_clipboard_act_->setToolTip( - _("Copy selected Keypair's ID to clipboard")); + tr("Copy selected Keypair's ID to clipboard")); connect(copy_key_id_to_clipboard_act_, &QAction::triggered, this, &MainWindow::slot_copy_key_id_to_clipboard); - show_key_details_act_ = new QAction(_("Show Key Details"), this); - show_key_details_act_->setToolTip(_("Show Details for this Key")); + show_key_details_act_ = new QAction(tr("Show Key Details"), this); + show_key_details_act_->setToolTip(tr("Show Details for this Key")); connect(show_key_details_act_, &QAction::triggered, this, &MainWindow::slot_show_key_details); - add_key_2_favourtie_act_ = new QAction(_("Add To Favourite"), this); - add_key_2_favourtie_act_->setToolTip(_("Add this key to Favourite Table")); + add_key_2_favourtie_act_ = new QAction(tr("Add To Favourite"), this); + add_key_2_favourtie_act_->setToolTip(tr("Add this key to Favourite Table")); add_key_2_favourtie_act_->setData(QVariant("add_key_2_favourite_action")); connect(add_key_2_favourtie_act_, &QAction::triggered, this, &MainWindow::slot_add_key_2_favourite); remove_key_from_favourtie_act_ = - new QAction(_("Remove From Favourite"), this); + new QAction(tr("Remove From Favourite"), this); remove_key_from_favourtie_act_->setToolTip( - _("Remove this key from Favourite Table")); + tr("Remove this key from Favourite Table")); remove_key_from_favourtie_act_->setData( QVariant("remove_key_from_favourtie_action")); connect(remove_key_from_favourtie_act_, &QAction::triggered, this, &MainWindow::slot_remove_key_from_favourite); - set_owner_trust_of_key_act_ = new QAction(_("Set Owner Trust Level"), this); - set_owner_trust_of_key_act_->setToolTip(_("Set Owner Trust Level")); + set_owner_trust_of_key_act_ = new QAction(tr("Set Owner Trust Level"), this); + set_owner_trust_of_key_act_->setToolTip(tr("Set Owner Trust Level")); set_owner_trust_of_key_act_->setData(QVariant("set_owner_trust_level")); connect(set_owner_trust_of_key_act_, &QAction::triggered, this, &MainWindow::slot_set_owner_trust_level_of_key); @@ -520,17 +521,17 @@ void MainWindow::create_actions() { &TextEdit::SlotSwitchTabDown); this->addAction(switch_tab_down_act_); - cut_pgp_header_act_ = new QAction(_("Remove PGP Header"), this); + cut_pgp_header_act_ = new QAction(tr("Remove PGP Header"), this); connect(cut_pgp_header_act_, &QAction::triggered, this, &MainWindow::slot_cut_pgp_header); - add_pgp_header_act_ = new QAction(_("Add PGP Header"), this); + add_pgp_header_act_ = new QAction(tr("Add PGP Header"), this); connect(add_pgp_header_act_, &QAction::triggered, this, &MainWindow::slot_add_pgp_header); } void MainWindow::create_menus() { - file_menu_ = menuBar()->addMenu(_("File")); + file_menu_ = menuBar()->addMenu(tr("File")); file_menu_->addAction(new_tab_act_); file_menu_->addAction(browser_act_); file_menu_->addAction(open_act_); @@ -543,7 +544,7 @@ void MainWindow::create_menus() { file_menu_->addAction(close_tab_act_); file_menu_->addAction(quit_act_); - edit_menu_ = menuBar()->addMenu(_("Edit")); + edit_menu_ = menuBar()->addMenu(tr("Edit")); edit_menu_->addAction(undo_act_); edit_menu_->addAction(redo_act_); edit_menu_->addSeparator(); @@ -561,7 +562,7 @@ void MainWindow::create_menus() { edit_menu_->addSeparator(); edit_menu_->addAction(open_settings_act_); - crypt_menu_ = menuBar()->addMenu(_("Crypt")); + crypt_menu_ = menuBar()->addMenu(tr("Crypt")); crypt_menu_->addAction(encrypt_act_); crypt_menu_->addAction(encrypt_sign_act_); crypt_menu_->addAction(decrypt_act_); @@ -571,16 +572,16 @@ void MainWindow::create_menus() { crypt_menu_->addAction(verify_act_); crypt_menu_->addSeparator(); - key_menu_ = menuBar()->addMenu(_("Keys")); - import_key_menu_ = key_menu_->addMenu(_("Import Key")); - import_key_menu_->setIcon(QIcon(":key_import.png")); + key_menu_ = menuBar()->addMenu(tr("Keys")); + import_key_menu_ = key_menu_->addMenu(tr("Import Key")); + import_key_menu_->setIcon(QIcon(":/icons/key_import.png")); import_key_menu_->addAction(import_key_from_file_act_); import_key_menu_->addAction(import_key_from_edit_act_); import_key_menu_->addAction(import_key_from_clipboard_act_); import_key_menu_->addAction(import_key_from_key_server_act_); key_menu_->addAction(open_key_management_act_); - gpg_menu_ = menuBar()->addMenu(_("GnuPG")); + gpg_menu_ = menuBar()->addMenu(tr("GnuPG")); gpg_menu_->addAction(clean_gpg_password_cache_act_); gpg_menu_->addSeparator(); gpg_menu_->addAction(reload_components_act_); @@ -588,13 +589,13 @@ void MainWindow::create_menus() { gpg_menu_->addSeparator(); gpg_menu_->addAction(gnupg_controller_open_act_); - steganography_menu_ = menuBar()->addMenu(_("Steganography")); + steganography_menu_ = menuBar()->addMenu(tr("Steganography")); steganography_menu_->addAction(cut_pgp_header_act_); steganography_menu_->addAction(add_pgp_header_act_); - view_menu_ = menuBar()->addMenu(_("View")); + view_menu_ = menuBar()->addMenu(tr("View")); - help_menu_ = menuBar()->addMenu(_("Help")); + help_menu_ = menuBar()->addMenu(tr("Help")); help_menu_->addAction(start_wizard_act_); help_menu_->addSeparator(); help_menu_->addAction(check_update_act_); @@ -604,14 +605,14 @@ void MainWindow::create_menus() { } void MainWindow::create_tool_bars() { - file_tool_bar_ = addToolBar(_("File")); + file_tool_bar_ = addToolBar(tr("File")); file_tool_bar_->setObjectName("fileToolBar"); file_tool_bar_->addAction(new_tab_act_); file_tool_bar_->addAction(open_act_); file_tool_bar_->addAction(browser_act_); view_menu_->addAction(file_tool_bar_->toggleViewAction()); - crypt_tool_bar_ = addToolBar(_("Operations")); + crypt_tool_bar_ = addToolBar(tr("Operations")); crypt_tool_bar_->setObjectName("cryptToolBar"); crypt_tool_bar_->addAction(encrypt_act_); crypt_tool_bar_->addAction(encrypt_sign_act_); @@ -621,12 +622,12 @@ void MainWindow::create_tool_bars() { crypt_tool_bar_->addAction(verify_act_); view_menu_->addAction(crypt_tool_bar_->toggleViewAction()); - key_tool_bar_ = addToolBar(_("Key")); + key_tool_bar_ = addToolBar(tr("Key")); key_tool_bar_->setObjectName("keyToolBar"); key_tool_bar_->addAction(open_key_management_act_); view_menu_->addAction(key_tool_bar_->toggleViewAction()); - edit_tool_bar_ = addToolBar(_("Edit")); + edit_tool_bar_ = addToolBar(tr("Edit")); edit_tool_bar_->setObjectName("editToolBar"); edit_tool_bar_->addAction(copy_act_); edit_tool_bar_->addAction(paste_act_); @@ -634,7 +635,7 @@ void MainWindow::create_tool_bars() { edit_tool_bar_->hide(); view_menu_->addAction(edit_tool_bar_->toggleViewAction()); - special_edit_tool_bar_ = addToolBar(_("Special Edit")); + special_edit_tool_bar_ = addToolBar(tr("Special Edit")); special_edit_tool_bar_->setObjectName("specialEditToolBar"); special_edit_tool_bar_->addAction(quote_act_); special_edit_tool_bar_->addAction(clean_double_line_breaks_act_); @@ -645,9 +646,9 @@ void MainWindow::create_tool_bars() { import_button_ = new QToolButton(); import_button_->setMenu(import_key_menu_); import_button_->setPopupMode(QToolButton::InstantPopup); - import_button_->setIcon(QIcon(":key_import.png")); - import_button_->setToolTip(_("Import key from...")); - import_button_->setText(_("Import key")); + import_button_->setIcon(QIcon(":/icons/key_import.png")); + import_button_->setToolTip(tr("Import key from...")); + import_button_->setText(tr("Import key")); key_tool_bar_->addWidget(import_button_); } @@ -657,20 +658,20 @@ void MainWindow::create_status_bar() { // QPixmap* pixmap; // icon which should be shown if there are files in attachments-folder - // pixmap = new QPixmap(":statusbar_icon.png"); + // pixmap = new QPixmap(":/icons/statusbar_icon.png"); // statusBarIcon = new QLabel(); // statusBar()->addWidget(statusBarIcon); // // statusBarIcon->setPixmap(*pixmap); // statusBar()->insertPermanentWidget(0, statusBarIcon, 0); - statusBar()->showMessage(_("Ready"), 2000); + statusBar()->showMessage(tr("Ready"), 2000); status_bar_box->setLayout(status_bar_box_layout); } void MainWindow::create_dock_windows() { /* KeyList-Dock window */ - key_list_dock_ = new QDockWidget(_("Key ToolBox"), this); + key_list_dock_ = new QDockWidget(tr("Key ToolBox"), this); key_list_dock_->setObjectName("EncryptDock"); key_list_dock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -678,7 +679,7 @@ void MainWindow::create_dock_windows() { addDockWidget(Qt::RightDockWidgetArea, key_list_dock_); m_key_list_->AddListGroupTab( - _("Default"), "default", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("Default"), "default", KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -686,7 +687,7 @@ void MainWindow::create_dock_windows() { }); m_key_list_->AddListGroupTab( - _("Favourite"), "favourite", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("Favourite"), "favourite", KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -694,7 +695,8 @@ void MainWindow::create_dock_windows() { }); m_key_list_->AddListGroupTab( - _("Only Public Key"), "only_public_key", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("Only Public Key"), "only_public_key", + KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -703,7 +705,8 @@ void MainWindow::create_dock_windows() { }); m_key_list_->AddListGroupTab( - _("Has Private Key"), "has_private_key", KeyListRow::SECRET_OR_PUBLIC_KEY, + tr("Has Private Key"), "has_private_key", + KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage | KeyListColumn::Validity, [](const GpgKey& key, const KeyTable&) -> bool { @@ -716,7 +719,7 @@ void MainWindow::create_dock_windows() { key_list_dock_->setWidget(m_key_list_); view_menu_->addAction(key_list_dock_->toggleViewAction()); - info_board_dock_ = new QDockWidget(_("Information Board"), this); + info_board_dock_ = new QDockWidget(tr("Information Board"), this); info_board_dock_->setObjectName("Information Board"); info_board_dock_->setAllowedAreas(Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, info_board_dock_); diff --git a/src/ui/thread/KeyServerImportTask.cpp b/src/ui/thread/KeyServerImportTask.cpp index 89f0f45a..63cabbcd 100644 --- a/src/ui/thread/KeyServerImportTask.cpp +++ b/src/ui/thread/KeyServerImportTask.cpp @@ -71,23 +71,22 @@ void GpgFrontend::UI::KeyServerImportTask::dealing_reply_from_server() { QString err_msg; switch (network_reply) { case QNetworkReply::ContentNotFoundError: - err_msg = QString(_("Key not found in the Keyserver.")); + err_msg = tr("Key not found in the Keyserver."); break; case QNetworkReply::TimeoutError: - err_msg = QString(_("Network connection timeout.")); + err_msg = tr("Network connection timeout."); break; case QNetworkReply::HostNotFoundError: - err_msg = - QString(_("Cannot resolve the address of target key server.")); + err_msg = tr("Cannot resolve the address of target key server."); break; default: - err_msg = QString(_("General connection error occurred.")); + err_msg = tr("General connection error occurred."); } emit SignalKeyServerImportResult(false, err_msg, buffer, nullptr); } auto info = GpgKeyImportExporter::GetInstance().ImportKey(GFBuffer(buffer)); - emit SignalKeyServerImportResult(true, _("Success"), buffer, info); + emit SignalKeyServerImportResult(true, tr("Success"), buffer, info); if (static_cast<size_t>(result_count_++) == keyids_.size() - 1) { emit SignalTaskShouldEnd(0); diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index 08534dcb..b32cb175 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -65,13 +65,13 @@ FilePage::FilePage(QWidget* parent, const QString& target_path) ui_->pathEdit->setCompleter(path_edit_completer_); option_popup_menu_ = new QMenu(this); - auto* show_hidden_act = new QAction(_("Show Hidden File"), this); + auto* show_hidden_act = new QAction(tr("Show Hidden File"), this); show_hidden_act->setCheckable(true); connect(show_hidden_act, &QAction::triggered, file_tree_view_, &FileTreeView::SlotShowHiddenFile); option_popup_menu_->addAction(show_hidden_act); - auto* show_system_act = new QAction(_("Show System File"), this); + auto* show_system_act = new QAction(tr("Show System File"), this); show_system_act->setCheckable(true); connect(show_system_act, &QAction::triggered, file_tree_view_, &FileTreeView::SlotShowSystemFile); diff --git a/src/ui/widgets/FileTreeView.cpp b/src/ui/widgets/FileTreeView.cpp index ef0fbf48..f3556dc9 100644 --- a/src/ui/widgets/FileTreeView.cpp +++ b/src/ui/widgets/FileTreeView.cpp @@ -81,8 +81,8 @@ void FileTreeView::SlotGoPath(const std::filesystem::path& target_path) { } } else { QMessageBox::critical( - this, _("Error"), - _("The path is not exists, unprivileged or unreachable.")); + this, tr("Error"), + tr("The path is not exists, unprivileged or unreachable.")); } emit SignalPathChanged(QString::fromStdString(current_path_.u8string())); } @@ -94,8 +94,8 @@ void FileTreeView::slot_file_tree_view_item_double_clicked( if (file_info.isReadable()) { emit SignalOpenFile(file_info.absoluteFilePath()); } else { - QMessageBox::critical(this, _("Error"), - _("The file is unprivileged or unreachable.")); + QMessageBox::critical(this, tr("Error"), + tr("The file is unprivileged or unreachable.")); } } else { SlotGoPath(file_info.filesystemAbsoluteFilePath()); @@ -155,8 +155,8 @@ auto FileTreeView::SlotDeleteSelectedItem() -> void { QModelIndex const index = this->currentIndex(); QVariant const data = this->model()->data(index); - auto ret = QMessageBox::warning(this, _("Warning"), - _("Are you sure you want to delete it?"), + auto ret = QMessageBox::warning(this, tr("Warning"), + tr("Are you sure you want to delete it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -164,8 +164,8 @@ auto FileTreeView::SlotDeleteSelectedItem() -> void { GF_UI_LOG_DEBUG("delete item: {}", data.toString().toStdString()); if (!dir_model_->remove(index)) { - QMessageBox::critical(this, _("Error"), - _("Unable to delete the file or folder.")); + QMessageBox::critical(this, tr("Error"), + tr("Unable to delete the file or folder.")); } } @@ -174,9 +174,9 @@ void FileTreeView::SlotMkdir() { QString new_dir_name; bool ok; - new_dir_name = - QInputDialog::getText(this, _("Make New Directory"), _("Directory Name"), - QLineEdit::Normal, new_dir_name, &ok); + new_dir_name = QInputDialog::getText(this, tr("Make New Directory"), + tr("Directory Name"), QLineEdit::Normal, + new_dir_name, &ok); if (ok && !new_dir_name.isEmpty()) { dir_model_->mkdir(index, new_dir_name); } @@ -187,9 +187,9 @@ void FileTreeView::SlotMkdirBelowAtSelectedItem() { QString new_dir_name; bool ok; - new_dir_name = - QInputDialog::getText(this, _("Make New Directory"), _("Directory Name"), - QLineEdit::Normal, new_dir_name, &ok); + new_dir_name = QInputDialog::getText(this, tr("Make New Directory"), + tr("Directory Name"), QLineEdit::Normal, + new_dir_name, &ok); if (ok && !new_dir_name.isEmpty()) { dir_model_->mkdir(index, new_dir_name); } @@ -205,9 +205,9 @@ void FileTreeView::SlotTouch() { QString new_file_name; bool ok; - new_file_name = QInputDialog::getText(this, _("Create Empty File"), - _("Filename (you can given extension)"), - QLineEdit::Normal, new_file_name, &ok); + new_file_name = QInputDialog::getText( + this, tr("Create Empty File"), tr("Filename (you can given extension)"), + QLineEdit::Normal, new_file_name, &ok); if (ok && !new_file_name.isEmpty()) { #ifdef WINDOWS auto file_path = root_path / new_file_name.toStdU16String(); @@ -216,7 +216,8 @@ void FileTreeView::SlotTouch() { #endif QFile new_file(file_path.u8string().c_str()); if (!new_file.open(QIODevice::WriteOnly | QIODevice::NewOnly)) { - QMessageBox::critical(this, _("Error"), _("Unable to create the file.")); + QMessageBox::critical(this, tr("Error"), + tr("Unable to create the file.")); } new_file.close(); } @@ -227,9 +228,9 @@ void FileTreeView::SlotTouchBelowAtSelectedItem() { QString new_file_name; bool ok; - new_file_name = QInputDialog::getText(this, _("Create Empty File"), - _("Filename (you can given extension)"), - QLineEdit::Normal, new_file_name, &ok); + new_file_name = QInputDialog::getText( + this, tr("Create Empty File"), tr("Filename (you can given extension)"), + QLineEdit::Normal, new_file_name, &ok); if (ok && !new_file_name.isEmpty()) { #ifdef WINDOWS auto file_path = root_path / new_file_name.toStdU16String(); @@ -238,7 +239,8 @@ void FileTreeView::SlotTouchBelowAtSelectedItem() { #endif QFile new_file(file_path.u8string().c_str()); if (!new_file.open(QIODevice::WriteOnly | QIODevice::NewOnly)) { - QMessageBox::critical(this, _("Error"), _("Unable to create the file.")); + QMessageBox::critical(this, tr("Error"), + tr("Unable to create the file.")); } new_file.close(); } @@ -272,7 +274,7 @@ void FileTreeView::SlotOpenSelectedItemBySystemApplication() { void FileTreeView::SlotRenameSelectedItem() { bool ok; auto text = QInputDialog::getText( - this, _("Rename"), _("New Filename"), QLineEdit::Normal, + this, tr("Rename"), tr("New Filename"), QLineEdit::Normal, QString::fromStdString(selected_path_.filename().u8string()), &ok); if (ok && !text.isEmpty()) { try { @@ -289,8 +291,8 @@ void FileTreeView::SlotRenameSelectedItem() { } catch (...) { GF_UI_LOG_ERROR("file tree view rename error: {}", selected_path_.u8string()); - QMessageBox::critical(this, _("Error"), - _("Unable to rename the file or folder.")); + QMessageBox::critical(this, tr("Error"), + tr("Unable to rename the file or folder.")); } } } @@ -303,50 +305,50 @@ void FileTreeView::slot_create_popup_menu() { popup_menu_ = new QMenu(); action_open_file_ = new QAction(this); - action_open_file_->setText(_("Open")); + action_open_file_->setText(tr("Open")); connect(action_open_file_, &QAction::triggered, this, [this](bool) { emit SignalOpenFile(QString::fromStdString(GetSelectedPath())); }); action_rename_file_ = new QAction(this); - action_rename_file_->setText(_("Rename")); + action_rename_file_->setText(tr("Rename")); connect(action_rename_file_, &QAction::triggered, this, &FileTreeView::SlotRenameSelectedItem); action_delete_file_ = new QAction(this); - action_delete_file_->setText(_("Delete")); + action_delete_file_->setText(tr("Delete")); connect(action_delete_file_, &QAction::triggered, this, &FileTreeView::SlotDeleteSelectedItem); action_calculate_hash_ = new QAction(this); - action_calculate_hash_->setText(_("Calculate Hash")); + action_calculate_hash_->setText(tr("Calculate Hash")); connect(action_calculate_hash_, &QAction::triggered, this, &FileTreeView::slot_calculate_hash); action_make_directory_ = new QAction(this); - action_make_directory_->setText(_("Directory")); + action_make_directory_->setText(tr("Directory")); connect(action_make_directory_, &QAction::triggered, this, &FileTreeView::SlotMkdirBelowAtSelectedItem); action_create_empty_file_ = new QAction(this); - action_create_empty_file_->setText(_("File")); + action_create_empty_file_->setText(tr("File")); connect(action_create_empty_file_, &QAction::triggered, this, &FileTreeView::SlotTouchBelowAtSelectedItem); action_compress_files_ = new QAction(this); - action_compress_files_->setText(_("Compress...")); + action_compress_files_->setText(tr("Compress...")); action_compress_files_->setVisible(false); connect(action_compress_files_, &QAction::triggered, this, &FileTreeView::slot_compress_files); auto* action_open_with_system_default_application = new QAction(this); action_open_with_system_default_application->setText( - _("Open with Default System Application")); + tr("Open with Default System Application")); connect(action_open_with_system_default_application, &QAction::triggered, this, &FileTreeView::SlotOpenSelectedItemBySystemApplication); auto* new_item_action_menu = new QMenu(this); - new_item_action_menu->setTitle(_("New")); + new_item_action_menu->setTitle(tr("New")); new_item_action_menu->addAction(action_create_empty_file_); new_item_action_menu->addAction(action_make_directory_); diff --git a/src/ui/widgets/FindWidget.cpp b/src/ui/widgets/FindWidget.cpp index b8af254a..7cc569e4 100644 --- a/src/ui/widgets/FindWidget.cpp +++ b/src/ui/widgets/FindWidget.cpp @@ -33,28 +33,31 @@ namespace GpgFrontend::UI { FindWidget::FindWidget(QWidget* parent, PlainTextEditorPage* edit) : QWidget(parent), m_text_page_(edit) { find_edit_ = new QLineEdit(this); - auto* closeButton = new QPushButton( + auto* close_button = new QPushButton( this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), QString(), this); - auto* nextButton = new QPushButton(QIcon(":button_next.png"), QString()); - auto* previousButton = new QPushButton(QIcon(":button_previous.png"), ""); - - auto* notificationWidgetLayout = new QHBoxLayout(this); - notificationWidgetLayout->setContentsMargins(10, 0, 0, 0); - notificationWidgetLayout->addWidget(new QLabel(QString(_("Find")) + ": ")); - notificationWidgetLayout->addWidget(find_edit_, 2); - notificationWidgetLayout->addWidget(nextButton); - notificationWidgetLayout->addWidget(previousButton); - notificationWidgetLayout->addWidget(closeButton); - - this->setLayout(notificationWidgetLayout); + auto* next_button = + new QPushButton(QIcon(":/icons/button_next.png"), QString()); + auto* previous_button = + new QPushButton(QIcon(":/icons/button_previous.png"), ""); + + auto* notification_widget_layout = new QHBoxLayout(this); + notification_widget_layout->setContentsMargins(10, 0, 0, 0); + notification_widget_layout->addWidget(new QLabel(tr("Find") + ": ")); + notification_widget_layout->addWidget(find_edit_, 2); + notification_widget_layout->addWidget(next_button); + notification_widget_layout->addWidget(previous_button); + notification_widget_layout->addWidget(close_button); + + this->setLayout(notification_widget_layout); connect(find_edit_, &QLineEdit::textEdited, this, &FindWidget::slot_find); connect(find_edit_, &QLineEdit::returnPressed, this, &FindWidget::slot_find_next); - connect(nextButton, &QPushButton::clicked, this, &FindWidget::slot_find_next); - connect(previousButton, &QPushButton::clicked, this, + connect(next_button, &QPushButton::clicked, this, + &FindWidget::slot_find_next); + connect(previous_button, &QPushButton::clicked, this, &FindWidget::slot_find_previous); - connect(closeButton, &QPushButton::clicked, this, &FindWidget::slot_close); + connect(close_button, &QPushButton::clicked, this, &FindWidget::slot_close); // The timer is necessary for setting the focus QTimer::singleShot(0, find_edit_, SLOT(setFocus())); @@ -63,17 +66,17 @@ FindWidget::FindWidget(QWidget* parent, PlainTextEditorPage* edit) void FindWidget::set_background() { // auto cursor = m_text_page_->GetTextPage()->textCursor(); // if match is found set background of QLineEdit to white, otherwise to red - QPalette bgPalette(find_edit_->palette()); + QPalette bg_palette(find_edit_->palette()); if (!find_edit_->text().isEmpty() && m_text_page_->GetTextPage() ->document() ->find(find_edit_->text()) .position() < 0) { - bgPalette.setColor(QPalette::Base, "#ececba"); + bg_palette.setColor(QPalette::Base, "#ececba"); } else { - bgPalette.setColor(QPalette::Base, Qt::white); + bg_palette.setColor(QPalette::Base, Qt::white); } - find_edit_->setPalette(bgPalette); + find_edit_->setPalette(bg_palette); } void FindWidget::slot_find_next() { diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp index bf3dba18..fdec1e50 100644 --- a/src/ui/widgets/InfoBoardWidget.cpp +++ b/src/ui/widgets/InfoBoardWidget.cpp @@ -42,9 +42,9 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent) ui_->setupUi(this); ui_->actionButtonLayout->addStretch(); - ui_->copyToolButton->setToolTip(_("Copy")); - ui_->saveToolButton->setToolTip(_("Save File")); - ui_->clearToolButton->setToolTip(_("Clear")); + ui_->copyToolButton->setToolTip(tr("Copy")); + ui_->saveToolButton->setToolTip(tr("Save File")); + ui_->clearToolButton->setToolTip(tr("Clear")); connect(ui_->copyToolButton, &QToolButton::clicked, this, &InfoBoardWidget::slot_copy); @@ -164,7 +164,7 @@ void InfoBoardWidget::slot_copy() { void InfoBoardWidget::slot_save() { auto file_path = QFileDialog::getSaveFileName( - this, _("Save Information Board's Content"), {}, tr("Text (*.txt)")); + this, tr("Save Information Board's Content"), {}, tr("Text (*.txt)")); GF_UI_LOG_DEBUG("file path: {}", file_path.toStdString()); if (file_path.isEmpty()) return; @@ -173,8 +173,8 @@ void InfoBoardWidget::slot_save() { file.write(ui_->infoBoard->toPlainText().toUtf8()); } else { QMessageBox::critical( - this, _("Error"), - _("The file path is not exists, unprivileged or unreachable.")); + this, tr("Error"), + tr("The file path is not exists, unprivileged or unreachable.")); } file.close(); } diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 700772e4..a3eb85ea 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -96,19 +96,19 @@ void KeyList::init() { setAcceptDrops(true); - ui_->refreshKeyListButton->setText(_("Refresh")); + ui_->refreshKeyListButton->setText(tr("Refresh")); ui_->refreshKeyListButton->setToolTip( - _("Refresh the key list to synchronize changes.")); - ui_->syncButton->setText(_("Sync Public Key")); + tr("Refresh the key list to synchronize changes.")); + ui_->syncButton->setText(tr("Sync Public Key")); ui_->syncButton->setToolTip( - _("Sync public key with your default keyserver.")); - ui_->uncheckButton->setText(_("Uncheck ALL")); + tr("Sync public key with your default keyserver.")); + ui_->uncheckButton->setText(tr("Uncheck ALL")); ui_->uncheckButton->setToolTip( - _("Cancel all checked items in the current tab at once.")); - ui_->checkALLButton->setText(_("Check ALL")); + tr("Cancel all checked items in the current tab at once.")); + ui_->checkALLButton->setText(tr("Check ALL")); ui_->checkALLButton->setToolTip( - _("Check all items in the current tab at once")); - ui_->searchBarEdit->setPlaceholderText(_("Search for keys...")); + tr("Check all items in the current tab at once")); + ui_->searchBarEdit->setPlaceholderText(tr("Search for keys...")); } void KeyList::AddListGroupTab(const QString& name, const QString& id, @@ -164,8 +164,8 @@ void KeyList::AddListGroupTab(const QString& name, const QString& id, } QStringList labels; - labels << _("Select") << _("Type") << _("Name") << _("Email Address") - << _("Usage") << _("Trust") << _("Finger Print"); + labels << tr("Select") << tr("Type") << tr("Name") << tr("Email Address") + << tr("Usage") << tr("Trust") << tr("Finger Print"); key_list->setHorizontalHeaderLabels(labels); key_list->horizontalHeader()->setStretchLastSection(false); @@ -180,7 +180,7 @@ void KeyList::SlotRefresh() { ui_->refreshKeyListButton->setDisabled(true); ui_->syncButton->setDisabled(true); - emit SignalRefreshStatusBar(_("Refreshing Key List..."), 3000); + emit SignalRefreshStatusBar(tr("Refreshing Key List..."), 3000); this->buffered_keys_list_ = GpgKeyGetter::GetInstance().FetchKey(); this->slot_refresh_ui(); } @@ -348,16 +348,13 @@ void KeyList::AddMenuAction(QAction* act) { popup_menu_->addAction(act); } void KeyList::dropEvent(QDropEvent* event) { auto* dialog = new QDialog(); - dialog->setWindowTitle(_("Import Keys")); + dialog->setWindowTitle(tr("Import Keys")); QLabel* label; - label = - new QLabel(QString(_("You've dropped something on the table.")) + "\n " + - _("GpgFrontend " - "will now try to import key(s).") + - "\n"); + label = new QLabel(tr("You've dropped something on the table.") + "\n " + + tr("GpgFrontend will now try to import key(s).") + "\n"); // "always import keys"-CheckBox - auto* check_box = new QCheckBox(_("Always import without bothering.")); + auto* check_box = new QCheckBox(tr("Always import without bothering.")); bool confirm_import_keys = GlobalSettingStation::GetInstance() .GetSettings() @@ -452,7 +449,7 @@ void KeyList::slot_refresh_ui() { GpgKeyGetter::GetInstance().GetKeysCopy(buffered_keys_list_)); } } - emit SignalRefreshStatusBar(_("Key List Refreshed."), 1000); + emit SignalRefreshStatusBar(tr("Key List Refreshed."), 1000); ui_->refreshKeyListButton->setDisabled(false); ui_->syncButton->setDisabled(false); } @@ -473,7 +470,7 @@ void KeyList::slot_sync_with_key_server() { ui_->refreshKeyListButton->setDisabled(true); ui_->syncButton->setDisabled(true); - emit SignalRefreshStatusBar(_("Syncing Key List..."), 3000); + emit SignalRefreshStatusBar(tr("Syncing Key List..."), 3000); CommonUtils::SlotImportKeyFromKeyServer( key_ids, [=](const QString& key_id, const QString& status, size_t current_index, size_t all_index) { @@ -481,7 +478,7 @@ void KeyList::slot_sync_with_key_server() { current_index, all_index); auto key = GpgKeyGetter::GetInstance().GetKey(key_id); - auto status_str = QString(_("Sync [%1/%2] %3 %4")) + auto status_str = tr("Sync [%1/%2] %3 %4") .arg(current_index) .arg(all_index) .arg(key.GetUIDs()->front().GetUID()) @@ -491,7 +488,7 @@ void KeyList::slot_sync_with_key_server() { if (current_index == all_index) { ui_->syncButton->setDisabled(false); ui_->refreshKeyListButton->setDisabled(false); - emit SignalRefreshStatusBar(_("Key List Sync Done."), 3000); + emit SignalRefreshStatusBar(tr("Key List Sync Done."), 3000); emit this->SignalRefreshDatabase(); } }); diff --git a/src/ui/widgets/PlainTextEditorPage.cpp b/src/ui/widgets/PlainTextEditorPage.cpp index 6bd5ba74..7d951006 100644 --- a/src/ui/widgets/PlainTextEditorPage.cpp +++ b/src/ui/widgets/PlainTextEditorPage.cpp @@ -51,7 +51,7 @@ PlainTextEditorPage::PlainTextEditorPage(QString file_path, QWidget *parent) this->setAttribute(Qt::WA_DeleteOnClose); - this->ui_->characterLabel->setText(_("0 character")); + this->ui_->characterLabel->setText(tr("0 character")); this->ui_->lfLabel->setHidden(true); this->ui_->encodingLabel->setText("Unicode"); @@ -60,7 +60,7 @@ PlainTextEditorPage::PlainTextEditorPage(QString file_path, QWidget *parent) if (!read_done_) return; auto text = ui_->textPage->document()->toPlainText(); - auto str = QString(_("%1 character(s)")).arg(text.size()); + auto str = tr("%1 character(s)").arg(text.size()); this->ui_->characterLabel->setText(str); }); @@ -69,7 +69,7 @@ PlainTextEditorPage::PlainTextEditorPage(QString file_path, QWidget *parent) ui_->loadingLabel->setHidden(true); } else { read_done_ = false; - ui_->loadingLabel->setText(_("Loading...")); + ui_->loadingLabel->setText(tr("Loading...")); ui_->loadingLabel->setHidden(false); } } @@ -83,8 +83,8 @@ QPlainTextEdit *PlainTextEditorPage::GetTextPage() { return ui_->textPage; } void PlainTextEditorPage::NotifyFileSaved() { this->is_crlf_ = false; - this->ui_->lfLabel->setText(_("lf")); - this->ui_->encodingLabel->setText(_("UTF-8")); + this->ui_->lfLabel->setText(tr("lf")); + this->ui_->encodingLabel->setText(tr("UTF-8")); } void PlainTextEditorPage::SetFilePath(const QString &filePath) { @@ -195,7 +195,7 @@ void PlainTextEditorPage::slot_insert_text(QByteArray bytes_data) { this->GetTextPage()->insertPlainText(bytes_data); auto text = this->GetTextPage()->toPlainText(); - auto str = QString(_("%1 character(s)")).arg(text.size()); + auto str = tr("%1 character(s)").arg(text.size()); this->ui_->characterLabel->setText(str); QTimer::singleShot(25, this, &PlainTextEditorPage::SignalUIBytesDisplayed); diff --git a/src/ui/widgets/TOFUInfoPage.cpp b/src/ui/widgets/TOFUInfoPage.cpp index 502fed44..39cf8921 100644 --- a/src/ui/widgets/TOFUInfoPage.cpp +++ b/src/ui/widgets/TOFUInfoPage.cpp @@ -33,15 +33,14 @@ GpgFrontend::UI::TOFUInfoPage::TOFUInfoPage( : QWidget(parent) { auto grid_layout = new QGridLayout(); - grid_layout->addWidget(new QLabel(QString(_("Key ID")) + ": "), 0, 0); - grid_layout->addWidget(new QLabel(QString(_("Algorithm")) + ": "), 1, 0); - grid_layout->addWidget(new QLabel(QString(_("Key Size")) + ": "), 2, 0); - grid_layout->addWidget(new QLabel(QString(_("Nominal Usage")) + ": "), 3, 0); - grid_layout->addWidget(new QLabel(QString(_("Actual Usage")) + ": "), 4, 0); - grid_layout->addWidget(new QLabel(QString(_("Expires on")) + ": "), 5, 0); - grid_layout->addWidget(new QLabel(QString(_("Last Update")) + ": "), 6, 0); - grid_layout->addWidget(new QLabel(QString(_("Secret Key Existence")) + ": "), - 7, 0); + grid_layout->addWidget(new QLabel(tr("Key ID") + ": "), 0, 0); + grid_layout->addWidget(new QLabel(tr("Algorithm") + ": "), 1, 0); + grid_layout->addWidget(new QLabel(tr("Key Size") + ": "), 2, 0); + grid_layout->addWidget(new QLabel(tr("Nominal Usage") + ": "), 3, 0); + grid_layout->addWidget(new QLabel(tr("Actual Usage") + ": "), 4, 0); + grid_layout->addWidget(new QLabel(tr("Expires on") + ": "), 5, 0); + grid_layout->addWidget(new QLabel(tr("Last Update") + ": "), 6, 0); + grid_layout->addWidget(new QLabel(tr("Secret Key Existence") + ": "), 7, 0); setLayout(grid_layout); } diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp index 1812dd23..59890465 100644 --- a/src/ui/widgets/TextEdit.cpp +++ b/src/ui/widgets/TextEdit.cpp @@ -59,11 +59,11 @@ TextEdit::TextEdit(QWidget* parent) : QWidget(parent) { } void TextEdit::SlotNewTab() { - QString header = _("untitled") + QString::number(++count_page_) + ".txt"; + QString header = tr("untitled") + QString::number(++count_page_) + ".txt"; auto* page = new PlainTextEditorPage(); auto index = tab_widget_->addTab(page, header); - tab_widget_->setTabIcon(index, QIcon(":file.png")); + tab_widget_->setTabIcon(index, QIcon(":/icons/file.png")); tab_widget_->setCurrentIndex(tab_widget_->count() - 1); page->GetTextPage()->setFocus(); connect(page->GetTextPage()->document(), &QTextDocument::modificationChanged, @@ -73,7 +73,7 @@ void TextEdit::SlotNewTab() { } void TextEdit::SlotNewTabWithContent(QString title, const QString& content) { - QString header = _("untitled") + QString::number(++count_page_) + ".txt"; + QString header = tr("untitled") + QString::number(++count_page_) + ".txt"; if (!title.isEmpty()) { // modify title if (!title.isEmpty() && title[0] == '*') { @@ -85,7 +85,7 @@ void TextEdit::SlotNewTabWithContent(QString title, const QString& content) { auto* page = new PlainTextEditorPage(); auto index = tab_widget_->addTab(page, header); - tab_widget_->setTabIcon(index, QIcon(":file.png")); + tab_widget_->setTabIcon(index, QIcon(":/icons/file.png")); tab_widget_->setCurrentIndex(tab_widget_->count() - 1); page->GetTextPage()->setFocus(); connect(page->GetTextPage()->document(), &QTextDocument::modificationChanged, @@ -105,13 +105,13 @@ void TextEdit::slotNewHelpTab(const QString& title, const QString& path) const { void TextEdit::SlotNewFileTab() { auto const target_dir = QFileDialog::getExistingDirectory( - this, _("Open Directory"), QDir::home().path(), + this, tr("Open Directory"), QDir::home().path(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if (target_dir.isEmpty()) return; auto* page = new FilePage(qobject_cast<QWidget*>(parent()), target_dir); auto index = tab_widget_->addTab(page, QString()); - tab_widget_->setTabIcon(index, QIcon(":file-browser.png")); + tab_widget_->setTabIcon(index, QIcon(":/icons/file-browser.png")); tab_widget_->setCurrentIndex(tab_widget_->count() - 1); connect(page, &FilePage::SignalPathChanged, this, &TextEdit::slot_file_page_path_changed); @@ -134,16 +134,15 @@ void TextEdit::SlotOpenFile(const QString& path) { QApplication::setOverrideCursor(Qt::WaitCursor); auto index = tab_widget_->addTab(page, stripped_name(path)); - tab_widget_->setTabIcon(index, QIcon(":file.png")); + tab_widget_->setTabIcon(index, QIcon(":/icons/file.png")); tab_widget_->setCurrentIndex(tab_widget_->count() - 1); QApplication::restoreOverrideCursor(); page->GetTextPage()->setFocus(); page->ReadFile(); } else { - QMessageBox::warning(this, _("Warning"), - QString(_("Cannot read file %1:\n%2.")) - .arg(path) - .arg(file.errorString())); + QMessageBox::warning( + this, tr("Warning"), + tr("Cannot read file %1:\n%2.").arg(path).arg(file.errorString())); } file.close(); @@ -151,7 +150,7 @@ void TextEdit::SlotOpenFile(const QString& path) { void TextEdit::SlotOpen() { QStringList file_names = - QFileDialog::getOpenFileNames(this, _("Open file"), QDir::currentPath()); + QFileDialog::getOpenFileNames(this, tr("Open file"), QDir::currentPath()); for (const auto& file_name : file_names) { if (!file_name.isEmpty()) { SlotOpenFile(file_name); @@ -201,10 +200,9 @@ bool TextEdit::save_file(const QString& fileName) { file.close(); return true; } - QMessageBox::warning(this, _("Warning"), - QString(_("Cannot read file %1:\n%2.")) - .arg(fileName) - .arg(file.errorString())); + QMessageBox::warning( + this, tr("Warning"), + tr("Cannot read file %1:\n%2.").arg(fileName).arg(file.errorString())); return false; } @@ -221,7 +219,7 @@ auto TextEdit::SlotSaveAs() -> bool { path = tab_widget_->tabText(tab_widget_->currentIndex()).remove(0, 2); } - return save_file(QFileDialog::getSaveFileName(this, _("Save file"), path)); + return save_file(QFileDialog::getSaveFileName(this, tr("Save file"), path)); } void TextEdit::SlotCloseTab() { @@ -282,13 +280,13 @@ bool TextEdit::maybe_save_current_tab(bool askToSave) { const QString& file_path = page->GetFilePath(); if (askToSave) { result = QMessageBox::warning( - this, _("Unsaved document"), - QString(_("The document \"%1\" has been modified. Do you want to " - "save your changes?")) + this, tr("Unsaved document"), + tr("The document \"%1\" has been modified. Do you want to " + "save your changes?") .arg(doc_name) + - "<br/><b>" + _("Note:") + "</b>" + - _("If you don't save these files, all changes are " - "lost.") + + "<br/><b>" + tr("Note:") + "</b>" + + tr("If you don't save these files, all changes are " + "lost.") + "<br/>", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); } @@ -421,10 +419,9 @@ void TextEdit::SlotFillTextEditWithText(const QString& text) const { void TextEdit::LoadFile(const QString& fileName) { QFile file(fileName); if (!file.open(QFile::ReadOnly | QFile::Text)) { - QMessageBox::warning(this, _("Warning"), - QString(_("Cannot read file %1:\n%2.")) - .arg(fileName) - .arg(file.errorString())); + QMessageBox::warning( + this, tr("Warning"), + tr("Cannot read file %1:\n%2.").arg(fileName).arg(file.errorString())); return; } QTextStream in(&file); @@ -434,7 +431,7 @@ void TextEdit::LoadFile(const QString& fileName) { SlotCurPageTextEdit()->SetFilePath(fileName); tab_widget_->setTabText(tab_widget_->currentIndex(), stripped_name(fileName)); file.close(); - // statusBar()->showMessage(_("File loaded"), 2000); + // statusBar()->showMessage(tr("File loaded"), 2000); } QString TextEdit::stripped_name(const QString& full_file_name) { @@ -460,10 +457,10 @@ void TextEdit::SlotPrint() { if (document != nullptr) { document->print(&printer); } else { - QMessageBox::warning(this, _("Warning"), _("No document to print")); + QMessageBox::warning(this, tr("Warning"), tr("No document to print")); } - // statusBar()->showMessage(_("Ready"), 2000); + // statusBar()->showMessage(tr("Ready"), 2000); #endif } diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp index db81ffa8..c2dd74d3 100644 --- a/src/ui/widgets/VerifyKeyDetailBox.cpp +++ b/src/ui/widgets/VerifyKeyDetailBox.cpp @@ -50,18 +50,18 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature, .value("network/forbid_all_gnupg_connection", false) .toBool(); - auto* import_button = new QPushButton(_("Import from keyserver")); + auto* import_button = new QPushButton(tr("Import from keyserver")); import_button->setDisabled(forbid_all_gnupg_connection); connect(import_button, &QPushButton::clicked, this, &VerifyKeyDetailBox::slot_import_form_key_server); - this->setTitle(QString(_("Key not present with id 0x")) + fpr_); + this->setTitle(tr("Key not present with id 0x") + fpr_); auto* grid = new QGridLayout(); - grid->addWidget(new QLabel(QString(_("Status")) + _(":")), 0, 0); - // grid->addWidget(new QLabel(_("Fingerprint:")), 1, 0); - grid->addWidget(new QLabel(_("Key not present in key list")), 0, 1); + grid->addWidget(new QLabel(tr("Status") + tr(":")), 0, 0); + // grid->addWidget(new QLabel(tr("Fingerprint:")), 1, 0); + grid->addWidget(new QLabel(tr("Key not present in key list")), 0, 1); // grid->addWidget(new QLabel(signature->fpr), 1, 1); grid->addWidget(import_button, 2, 0, 2, 1); @@ -69,14 +69,14 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature, break; } case GPG_ERR_NO_ERROR: { - this->setTitle(QString(_("A Signature")) + ":"); + this->setTitle(tr("A Signature") + ":"); auto* gird = create_key_info_grid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); if (!signature.GetFingerprint().isEmpty()) { - vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + vbox->addWidget(new QLabel(tr("Fingerprint") + ": " + signature.GetFingerprint())); } } @@ -84,15 +84,14 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature, } case GPG_ERR_CERT_REVOKED: { this->setTitle("An Error Signature"); - vbox->addWidget( - new QLabel(QString(_("Status")) + ":" + _("Cert Revoked"))); + vbox->addWidget(new QLabel(tr("Status") + ":" + tr("Cert Revoked"))); auto* gird = create_key_info_grid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); if (!signature.GetFingerprint().isEmpty()) { - vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + vbox->addWidget(new QLabel(tr("Fingerprint") + ": " + signature.GetFingerprint())); } } @@ -100,15 +99,14 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature, } case GPG_ERR_SIG_EXPIRED: { this->setTitle("An Error Signature"); - vbox->addWidget( - new QLabel(QString(_("Status")) + ":" + _("Signature Expired"))); + vbox->addWidget(new QLabel(tr("Status") + ":" + tr("Signature Expired"))); auto* gird = create_key_info_grid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); if (!signature.GetFingerprint().isEmpty()) { - vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + vbox->addWidget(new QLabel(tr("Fingerprint") + ": " + signature.GetFingerprint())); } } @@ -116,17 +114,15 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature, } case GPG_ERR_KEY_EXPIRED: { this->setTitle("An Error Signature"); - vbox->addWidget( - new QLabel(QString(_("Status")) + ":" + _("Key Expired"))); - vbox->addWidget( - new QLabel(QString(_("Status")) + ":" + _("Key Expired"))); + vbox->addWidget(new QLabel(tr("Status") + ":" + tr("Key Expired"))); + vbox->addWidget(new QLabel(tr("Status") + ":" + tr("Key Expired"))); auto* gird = create_key_info_grid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); if (!signature.GetFingerprint().isEmpty()) { - vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + vbox->addWidget(new QLabel(tr("Fingerprint") + ": " + signature.GetFingerprint())); } } @@ -134,15 +130,14 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature, } case GPG_ERR_GENERAL: { this->setTitle("An Error Signature"); - vbox->addWidget( - new QLabel(QString(_("Status")) + ":" + _("General Error"))); + vbox->addWidget(new QLabel(tr("Status") + ":" + tr("General Error"))); auto* gird = create_key_info_grid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); if (!signature.GetFingerprint().isEmpty()) { - vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + vbox->addWidget(new QLabel(tr("Fingerprint") + ": " + signature.GetFingerprint())); } } @@ -150,14 +145,14 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature, } default: { this->setTitle("An Error Signature"); - this->setTitle(QString(_("Status")) + ":" + _("Unknown Error ")); + this->setTitle(tr("Status") + ":" + tr("Unknown Error ")); auto* gird = create_key_info_grid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); if (!signature.GetFingerprint().isEmpty()) { - vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + vbox->addWidget(new QLabel(tr("Fingerprint") + ": " + signature.GetFingerprint())); } } @@ -180,45 +175,45 @@ auto VerifyKeyDetailBox::create_key_info_grid(const GpgSignature& signature) auto key = GpgKeyGetter::GetInstance().GetKey(fpr_); if (!key.IsGood()) return nullptr; - grid->addWidget(new QLabel(QString(_("Signer Name")) + ":"), 0, 0); - grid->addWidget(new QLabel(QString(_("Signer Email")) + ":"), 1, 0); - grid->addWidget(new QLabel(QString(_("Key's Fingerprint")) + ":"), 2, 0); - grid->addWidget(new QLabel(QString(_("Valid")) + ":"), 3, 0); - grid->addWidget(new QLabel(QString(_("Flags")) + ":"), 4, 0); + grid->addWidget(new QLabel(tr("Signer Name") + ":"), 0, 0); + grid->addWidget(new QLabel(tr("Signer Email") + ":"), 1, 0); + grid->addWidget(new QLabel(tr("Key's Fingerprint") + ":"), 2, 0); + grid->addWidget(new QLabel(tr("Valid") + ":"), 3, 0); + grid->addWidget(new QLabel(tr("Flags") + ":"), 4, 0); grid->addWidget(new QLabel(key.GetName()), 0, 1); grid->addWidget(new QLabel(key.GetEmail()), 1, 1); grid->addWidget(new QLabel(BeautifyFingerprint(fpr_)), 2, 1); if ((signature.GetSummary() & GPGME_SIGSUM_VALID) != 0U) { - grid->addWidget(new QLabel(_("Fully Valid")), 3, 1); + grid->addWidget(new QLabel(tr("Fully Valid")), 3, 1); } else { - grid->addWidget(new QLabel(_("NOT Fully Valid")), 3, 1); + grid->addWidget(new QLabel(tr("NOT Fully Valid")), 3, 1); } QString buffer; QTextStream text_stream(&buffer); if ((signature.GetSummary() & GPGME_SIGSUM_GREEN) != 0U) { - text_stream << _("Good") << " "; + text_stream << tr("Good") << " "; } if ((signature.GetSummary() & GPGME_SIGSUM_RED) != 0U) { - text_stream << _("Bad") << " "; + text_stream << tr("Bad") << " "; } if ((signature.GetSummary() & GPGME_SIGSUM_SIG_EXPIRED) != 0U) { - text_stream << _("Expired") << " "; + text_stream << tr("Expired") << " "; } if ((signature.GetSummary() & GPGME_SIGSUM_KEY_MISSING) != 0U) { - text_stream << _("Missing Key") << " "; + text_stream << tr("Missing Key") << " "; } if ((signature.GetSummary() & GPGME_SIGSUM_KEY_REVOKED) != 0U) { - text_stream << _("Revoked Key") << " "; + text_stream << tr("Revoked Key") << " "; } if ((signature.GetSummary() & GPGME_SIGSUM_KEY_EXPIRED) != 0U) { - text_stream << _("Expired Key") << " "; + text_stream << tr("Expired Key") << " "; } if ((signature.GetSummary() & GPGME_SIGSUM_CRL_MISSING) != 0U) { - text_stream << _("Missing CRL") << " "; + text_stream << tr("Missing CRL") << " "; } grid->addWidget(new QLabel(text_stream.readAll()), 4, 1); |