diff options
author | Saturneric <[email protected]> | 2021-12-01 17:25:46 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-12-01 17:53:09 +0000 |
commit | 1ae8663decb3163b92d32b80cefb46eb678a5af6 (patch) | |
tree | 8e8cb58cacfe12827438b0524917cb0926f926cb /src | |
parent | Add & Modified (diff) | |
download | GpgFrontend-1ae8663decb3163b92d32b80cefb46eb678a5af6.tar.gz GpgFrontend-1ae8663decb3163b92d32b80cefb46eb678a5af6.zip |
Add i18n Support
1. Remove Qt Linguist.
2. Add GNU gettext libraries.
3. Modified source codes to meet with i18n support.
Diffstat (limited to 'src')
153 files changed, 2459 insertions, 2411 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 13e48933..4e9428fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,18 +54,40 @@ endif () # Get ALL SOURCE FILES file(GLOB_RECURSE ALL_SOURCE_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/src/*.cpp) +# i18n if (MULTI_LANG_SUPPORT) # Set Translation Files - set(QT_TS_FILES - gpgfrontend_en_us.ts gpgfrontend_zh_cn.ts - gpgfrontend_fr.ts gpgfrontend_ru.ts gpgfrontend_es.ts) - list(TRANSFORM QT_TS_FILES PREPEND ${CMAKE_SOURCE_DIR}/resource/ts/) - message(STATUS "QT_TS_FILES ${QT_TS_FILES}") - set(QT_QM_FILES_OUTPUT_DIR ${RESOURCE_OUTPUT_DIRECTORY}/ts) - set_source_files_properties(${QT_TS_FILES} PROPERTIES OUTPUT_LOCATION ${QT_QM_FILES_OUTPUT_DIR}) - QT5_create_translation(QON_QM_FILES ${CMAKE_SOURCE_DIR} ${QT_TS_FILES}) - message(STATUS "QON_QM_FILES ${QON_QM_FILES}") - add_custom_target(translations DEPENDS ${QON_QM_FILES}) + find_package(Gettext REQUIRED) + FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) + FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext) + if (NOT GETTEXT_MSGFMT_EXECUTABLE OR NOT GETTEXT_XGETTEXT_EXECUTABLE) + message(ERROR "msgfmt or xgettext not found. Translations will *not* be installed") + else (NOT GETTEXT_MSGFMT_EXECUTABLE) + message(STATUS "Setting target translations") + add_custom_target(translations) + set(OUTPUT_POT_PATH ${CMAKE_SOURCE_DIR}/resource/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/locale/po/*.po) + SET(GMO_FILES) + message(STATUS "ALL_PO_FILES ${ALL_PO_FILES}") + + foreach (_poFile ${ALL_PO_FILES}) + GET_FILENAME_COMPONENT(_poFileName ${_poFile} NAME) + string(REGEX REPLACE "\\.[^.]*$" "" _langName ${_poFileName}) + message(STATUS "_poFileName ${_langName}") + make_directory(${CMAKE_SOURCE_DIR}/resource/locale/out/${_langName}/LC_MESSAGES) + add_custom_command( + TARGET translations + COMMAND msgfmt --check --verbose --output-file ${CMAKE_SOURCE_DIR}/resource/locale/out/${_langName}/LC_MESSAGES/GpgFrontend.mo ${_poFile} + ) + endforeach () + + + endif () endif () if (BASIC_ENV_CONFIG) @@ -79,6 +101,10 @@ if (APPLICATION_BUILD) file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/resource/conf DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) + if (MULTI_LANG_SUPPORT) + make_directory(${RESOURCE_OUTPUT_DIRECTORY}/locales) + file(COPY ${CMAKE_SOURCE_DIR}/resource/locale/out/ DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/locales FOLLOW_SYMLINK_CHAIN) + endif () endif () if (APPLICATION_BUILD) @@ -185,7 +211,7 @@ if (APPLICATION_BUILD) ${QT_DEPENDENCY_LIBS} crypto ssl) else () - message(STATUS "Link Application Static Library For UNIX") + message(STATUS "Link Application Static Library For UNIX ") target_link_libraries(${AppName} ${GPGFRONTEND_LIBS} ${QT_DEPENDENCY_LIBS} diff --git a/src/GpgFrontend.h.in b/src/GpgFrontend.h.in index 705b095f..1814ddbc 100644 --- a/src/GpgFrontend.h.in +++ b/src/GpgFrontend.h.in @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,7 +25,18 @@ #ifndef GPGFRONTEND_H_IN #define GPGFRONTEND_H_IN +// i18n +#include <libintl.h> +#define _(String) gettext (String) +#define gettext_noop(String) String +#define N_(String) gettext_noop (String) + +// logging +#include <easyloggingpp/easylogging++.h> + +#define PROJECT_NAME "@CMAKE_PROJECT_NAME@" #define OS_PLATFORM @OS_PLATFORM@ +#define LOCALE_DIR "@LOCALE_DIR@" /** * Resources File(s) Path Vars diff --git a/src/GpgFrontendBuildInfo.h.in b/src/GpgFrontendBuildInfo.h.in index bf1d3f8a..eaf0475b 100644 --- a/src/GpgFrontendBuildInfo.h.in +++ b/src/GpgFrontendBuildInfo.h.in @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/advance/UnknownSignersChecker.cpp b/src/advance/UnknownSignersChecker.cpp index 73516beb..fc70ee20 100644 --- a/src/advance/UnknownSignersChecker.cpp +++ b/src/advance/UnknownSignersChecker.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,58 +24,52 @@ #include "advance/UnknownSignersChecker.h" - -UnknownSignersChecker::UnknownSignersChecker(GpgFrontend::GpgContext *ctx, gpgme_verify_result_t result) : - appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini"), mCtx(ctx), - mResult(result) { - -} +UnknownSignersChecker::UnknownSignersChecker(GpgFrontend::GpgContext *ctx, + gpgme_verify_result_t result) + : appPath(qApp->applicationDirPath()), + settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini"), + mCtx(ctx), + mResult(result) {} void UnknownSignersChecker::start() { + auto sign = mResult->signatures; + bool canContinue = true; - auto sign = mResult->signatures; - bool canContinue = true; - - while (sign && canContinue) { - - switch (gpg_err_code(sign->status)) { - case GPG_ERR_BAD_SIGNATURE: - break; - case GPG_ERR_NO_ERROR: - if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) - check_signer(sign); - break; - case GPG_ERR_NO_PUBKEY: + while (sign && canContinue) { + switch (gpg_err_code(sign->status)) { + case GPG_ERR_BAD_SIGNATURE: + break; + case GPG_ERR_NO_ERROR: + if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) check_signer(sign); + break; + case GPG_ERR_NO_PUBKEY: - case GPG_ERR_CERT_REVOKED: - case GPG_ERR_SIG_EXPIRED: - case GPG_ERR_KEY_EXPIRED: - check_signer(sign); - break; - case GPG_ERR_GENERAL: - canContinue = false; - break; - default: - break; - } - sign = sign->next; + case GPG_ERR_CERT_REVOKED: + case GPG_ERR_SIG_EXPIRED: + case GPG_ERR_KEY_EXPIRED: + check_signer(sign); + break; + case GPG_ERR_GENERAL: + canContinue = false; + break; + default: + break; } + sign = sign->next; + } - if(!unknownFprs.isEmpty()) { - PubkeyGetter pubkeyGetter(mCtx, unknownFprs); - pubkeyGetter.start(); - if (!pubkeyGetter.result()) { - - } + if (!unknownFprs.isEmpty()) { + PubkeyGetter pubkeyGetter(mCtx, unknownFprs); + pubkeyGetter.start(); + if (!pubkeyGetter.result()) { } + } } void UnknownSignersChecker::check_signer(gpgme_signature_t sign) { - - auto key = mCtx->getKeyRefByFpr(sign->fpr); - if (!key.good) { - qDebug() << "Find Unknown FingerPrint " << sign->fpr; - unknownFprs.append(sign->fpr); - } - + auto key = mCtx->getKeyRefByFpr(sign->fpr); + if (!key.good) { + qDebug() << "Find Unknown FingerPrint " << sign->fpr; + unknownFprs.append(sign->fpr); + } } diff --git a/src/advance/UnknownSignersChecker.h b/src/advance/UnknownSignersChecker.h index 56085265..de07eaf8 100644 --- a/src/advance/UnknownSignersChecker.h +++ b/src/advance/UnknownSignersChecker.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -28,25 +28,22 @@ #include "server/api/PubkeyGetter.h" class UnknownSignersChecker : public QObject { -Q_OBJECT -public: + Q_OBJECT + public: + UnknownSignersChecker(GpgFrontend::GpgContext *ctx, + gpgme_verify_result_t result); - UnknownSignersChecker(GpgFrontend::GpgContext *ctx, gpgme_verify_result_t result); + void start(); - void start(); + private: + QString appPath; + QSettings settings; + GpgFrontend::GpgContext *mCtx; + gpgme_verify_result_t mResult; -private: - - QString appPath; - QSettings settings; - GpgFrontend::GpgContext *mCtx; - gpgme_verify_result_t mResult; - - QVector<QString> unknownFprs; - - void check_signer(gpgme_signature_t sign); + QVector<QString> unknownFprs; + void check_signer(gpgme_signature_t sign); }; - -#endif //GPGFRONTEND_ZH_CN_TS_UNKNOWNSIGNERSCHECKER_H +#endif // GPGFRONTEND_ZH_CN_TS_UNKNOWNSIGNERSCHECKER_H diff --git a/src/gpg/GpgConstants.cpp b/src/gpg/GpgConstants.cpp index 497f7e0c..aa56fe10 100644 --- a/src/gpg/GpgConstants.cpp +++ b/src/gpg/GpgConstants.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/GpgConstants.h b/src/gpg/GpgConstants.h index da8860e8..4804924a 100644 --- a/src/gpg/GpgConstants.h +++ b/src/gpg/GpgConstants.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp index 1372fd73..5d901c3f 100644 --- a/src/gpg/GpgContext.cpp +++ b/src/gpg/GpgContext.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -26,6 +26,7 @@ #include <gpg-error.h> #include <gpgme.h> + #include <functional> #include <string> @@ -43,8 +44,7 @@ namespace GpgFrontend { * Constructor * Set up gpgme-context, set paths to app-run path */ -GpgContext::GpgContext(bool independent_database, - std::string db_path, +GpgContext::GpgContext(bool independent_database, std::string db_path, int channel) : SingletonFunctionObject<GpgContext>(channel) { static bool _first = true; @@ -80,8 +80,7 @@ GpgContext::GpgContext(bool independent_database, if (engineInfo->protocol == GPGME_PROTOCOL_CMS && strcmp(engineInfo->version, "1.0.0") != 0) find_cms = true; - if (engineInfo->protocol == GPGME_PROTOCOL_ASSUAN) - find_assuan = true; + if (engineInfo->protocol == GPGME_PROTOCOL_ASSUAN) find_assuan = true; engineInfo = engineInfo->next; } @@ -115,9 +114,7 @@ GpgContext::GpgContext(bool independent_database, } } -bool GpgContext::good() const { - return good_; -} +bool GpgContext::good() const { return good_; } void GpgContext::SetPassphraseCb(decltype(test_passphrase_cb) cb) const { gpgme_set_passphrase_cb(*this, cb, nullptr); diff --git a/src/gpg/GpgContext.h b/src/gpg/GpgContext.h index 0aa41f2f..7df90060 100644 --- a/src/gpg/GpgContext.h +++ b/src/gpg/GpgContext.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -37,8 +37,7 @@ namespace GpgFrontend { class GpgContext : public SingletonFunctionObject<GpgContext> { public: GpgContext(bool independent_database = false, - std::string path = std::string(), - int channel = 0); + std::string path = std::string(), int channel = 0); ~GpgContext() override = default; @@ -55,8 +54,7 @@ class GpgContext : public SingletonFunctionObject<GpgContext> { struct _ctx_ref_deletor { void operator()(gpgme_ctx_t _ctx) { - if (_ctx != nullptr) - gpgme_release(_ctx); + if (_ctx != nullptr) gpgme_release(_ctx); } }; @@ -66,11 +64,9 @@ class GpgContext : public SingletonFunctionObject<GpgContext> { bool good_ = true; public: - static gpgme_error_t test_passphrase_cb(void* opaque, - const char* uid_hint, + static gpgme_error_t test_passphrase_cb(void* opaque, const char* uid_hint, const char* passphrase_info, - int last_was_bad, - int fd) { + int last_was_bad, int fd) { LOG(INFO) << "test_passphrase_cb Called"; size_t res; char pass[] = "abcdefg\n"; @@ -84,8 +80,7 @@ class GpgContext : public SingletonFunctionObject<GpgContext> { do { res = gpgme_io_write(fd, &pass[off], pass_len - off); - if (res > 0) - off += res; + if (res > 0) off += res; } while (res > 0 && off != pass_len); return off == pass_len ? 0 : gpgme_error_from_errno(errno); diff --git a/src/gpg/GpgFunctionObject.h b/src/gpg/GpgFunctionObject.h index a8746edf..6f1d60af 100644 --- a/src/gpg/GpgFunctionObject.h +++ b/src/gpg/GpgFunctionObject.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,6 +25,8 @@ #ifndef GPGFRONTEND_ZH_CN_TS_FUNCTIONOBJECT_H #define GPGFRONTEND_ZH_CN_TS_FUNCTIONOBJECT_H +#include <easyloggingpp/easylogging++.h> + #include <map> #include <memory> #include <mutex> @@ -32,8 +34,6 @@ #include <stdexcept> #include <string> -#include <easyloggingpp/easylogging++.h> - namespace GpgFrontend { template <typename T> @@ -42,8 +42,7 @@ class SingletonFunctionObject { static T& GetInstance(int channel = 0) { if (!channel) { std::lock_guard<std::mutex> guard(_instance_mutex); - if (_instance == nullptr) - _instance = std::make_unique<T>(); + if (_instance == nullptr) _instance = std::make_unique<T>(); return *_instance; } else { // read _instances_map @@ -60,8 +59,7 @@ class SingletonFunctionObject { } static T& CreateInstance(int channel, std::unique_ptr<T> p_obj = nullptr) { - if (!channel) - return *_instance; + if (!channel) return *_instance; // read _instances_map decltype(_instances_map.end()) _it; @@ -74,8 +72,7 @@ class SingletonFunctionObject { std::lock_guard<std::mutex> guard(_default_channel_mutex); int tmp = channel; std::swap(_default_channel, tmp); - if (p_obj == nullptr) - p_obj = std::make_unique<T>(); + if (p_obj == nullptr) p_obj = std::make_unique<T>(); std::swap(_default_channel, tmp); } T* obj = p_obj.get(); diff --git a/src/gpg/GpgGenKeyInfo.cpp b/src/gpg/GpgGenKeyInfo.cpp index 79d6617c..07708433 100644 --- a/src/gpg/GpgGenKeyInfo.cpp +++ b/src/gpg/GpgGenKeyInfo.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/GpgGenKeyInfo.h b/src/gpg/GpgGenKeyInfo.h index cb627555..53b0c9f1 100644 --- a/src/gpg/GpgGenKeyInfo.h +++ b/src/gpg/GpgGenKeyInfo.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/GpgInfo.cpp b/src/gpg/GpgInfo.cpp index 00a15ef9..392dcf08 100644 --- a/src/gpg/GpgInfo.cpp +++ b/src/gpg/GpgInfo.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/GpgInfo.h b/src/gpg/GpgInfo.h index dbcf3b40..27e13112 100644 --- a/src/gpg/GpgInfo.h +++ b/src/gpg/GpgInfo.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/GpgModel.h b/src/gpg/GpgModel.h index 7b77d678..a9351e50 100644 --- a/src/gpg/GpgModel.h +++ b/src/gpg/GpgModel.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,12 +25,12 @@ #ifndef GPGFRONTEND_ZH_CN_TS_GPGMODEL_H #define GPGFRONTEND_ZH_CN_TS_GPGMODEL_H -#include "gpg/model/GpgData.h" -#include "gpg/model/GpgKey.h" - #include <list> #include <utility> +#include "gpg/model/GpgData.h" +#include "gpg/model/GpgKey.h" + namespace GpgFrontend { using KeyId = std::string; diff --git a/src/gpg/function/BasicOperator.cpp b/src/gpg/function/BasicOperator.cpp index 0e44c9e0..e92d4cfe 100644 --- a/src/gpg/function/BasicOperator.cpp +++ b/src/gpg/function/BasicOperator.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,20 +23,19 @@ */ #include "gpg/function/BasicOperator.h" + #include <vector> + #include "gpg/function/GpgKeyGetter.h" GpgFrontend::GpgError GpgFrontend::BasicOperator::Encrypt( - GpgFrontend::KeyArgsList&& keys, - GpgFrontend::BypeArrayRef in_buffer, - GpgFrontend::ByteArrayPtr& out_buffer, - GpgFrontend::GpgEncrResult& result) { + GpgFrontend::KeyArgsList&& keys, GpgFrontend::BypeArrayRef in_buffer, + GpgFrontend::ByteArrayPtr& out_buffer, GpgFrontend::GpgEncrResult& result) { // gpgme_encrypt_result_t e_result; gpgme_key_t recipients[keys.size() + 1]; int index = 0; - for (const auto& key : keys) - recipients[index++] = gpgme_key_t(key); + for (const auto& key : keys) recipients[index++] = gpgme_key_t(key); // Last entry data_in array has to be nullptr recipients[keys.size()] = nullptr; @@ -56,8 +55,7 @@ GpgFrontend::GpgError GpgFrontend::BasicOperator::Encrypt( } GpgFrontend::GpgError GpgFrontend::BasicOperator::Decrypt( - BypeArrayRef in_buffer, - GpgFrontend::ByteArrayPtr& out_buffer, + BypeArrayRef in_buffer, GpgFrontend::ByteArrayPtr& out_buffer, GpgFrontend::GpgDecrResult& result) { gpgme_error_t err; @@ -74,8 +72,7 @@ GpgFrontend::GpgError GpgFrontend::BasicOperator::Decrypt( } GpgFrontend::GpgError GpgFrontend::BasicOperator::Verify( - BypeArrayRef& in_buffer, - ByteArrayPtr& sig_buffer, + BypeArrayRef& in_buffer, ByteArrayPtr& sig_buffer, GpgVerifyResult& result) const { gpgme_error_t err; @@ -131,10 +128,8 @@ GpgFrontend::GpgError GpgFrontend::BasicOperator::Sign(KeyArgsList&& keys, } gpgme_error_t GpgFrontend::BasicOperator::DecryptVerify( - BypeArrayRef in_buffer, - ByteArrayPtr& out_buffer, - GpgDecrResult& decrypt_result, - GpgVerifyResult& verify_result) { + BypeArrayRef in_buffer, ByteArrayPtr& out_buffer, + GpgDecrResult& decrypt_result, GpgVerifyResult& verify_result) { gpgme_error_t err; GpgData data_in(in_buffer.data(), in_buffer.size()), data_out; @@ -154,11 +149,8 @@ gpgme_error_t GpgFrontend::BasicOperator::DecryptVerify( } gpgme_error_t GpgFrontend::BasicOperator::EncryptSign( - KeyArgsList&& keys, - KeyArgsList&& signers, - BypeArrayRef in_buffer, - ByteArrayPtr& out_buffer, - GpgEncrResult& encr_result, + KeyArgsList&& keys, KeyArgsList&& signers, BypeArrayRef in_buffer, + ByteArrayPtr& out_buffer, GpgEncrResult& encr_result, GpgSignResult& sign_result) { gpgme_error_t err; SetSigners(signers); @@ -168,8 +160,7 @@ gpgme_error_t GpgFrontend::BasicOperator::EncryptSign( // set key for user int index = 0; - for (const auto& key : keys) - recipients[index++] = gpgme_key_t(key); + for (const auto& key : keys) recipients[index++] = gpgme_key_t(key); // Last entry dataIn array has to be nullptr recipients[keys.size()] = nullptr; diff --git a/src/gpg/function/BasicOperator.h b/src/gpg/function/BasicOperator.h index e8fa943d..e83ade70 100644 --- a/src/gpg/function/BasicOperator.h +++ b/src/gpg/function/BasicOperator.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -34,35 +34,26 @@ namespace GpgFrontend { class BasicOperator : public SingletonFunctionObject<BasicOperator> { public: - gpg_error_t Encrypt(KeyArgsList&& keys, - BypeArrayRef in_buffer, - ByteArrayPtr& out_buffer, - GpgEncrResult& result); + gpg_error_t Encrypt(KeyArgsList&& keys, BypeArrayRef in_buffer, + ByteArrayPtr& out_buffer, GpgEncrResult& result); - gpgme_error_t EncryptSign(KeyArgsList&& keys, - KeyArgsList&& signers, - BypeArrayRef in_buffer, - ByteArrayPtr& out_buffer, + gpgme_error_t EncryptSign(KeyArgsList&& keys, KeyArgsList&& signers, + BypeArrayRef in_buffer, ByteArrayPtr& out_buffer, GpgEncrResult& encr_result, GpgSignResult& sign_result); - gpgme_error_t Decrypt(BypeArrayRef in_buffer, - ByteArrayPtr& out_buffer, + gpgme_error_t Decrypt(BypeArrayRef in_buffer, ByteArrayPtr& out_buffer, GpgDecrResult& result); - gpgme_error_t DecryptVerify(BypeArrayRef in_buffer, - ByteArrayPtr& out_buffer, + gpgme_error_t DecryptVerify(BypeArrayRef in_buffer, ByteArrayPtr& out_buffer, GpgDecrResult& decrypt_result, GpgVerifyResult& verify_result); - gpgme_error_t Verify(BypeArrayRef in_buffer, - ByteArrayPtr& sig_buffer, + gpgme_error_t Verify(BypeArrayRef in_buffer, ByteArrayPtr& sig_buffer, GpgVerifyResult& result) const; - gpg_error_t Sign(KeyArgsList&& key_fprs, - BypeArrayRef in_buffer, - ByteArrayPtr& out_buffer, - gpgme_sig_mode_t mode, + gpg_error_t Sign(KeyArgsList&& key_fprs, BypeArrayRef in_buffer, + ByteArrayPtr& out_buffer, gpgme_sig_mode_t mode, GpgSignResult& result); void SetSigners(KeyArgsList& keys); diff --git a/src/gpg/function/GpgCommandExecutor.cpp b/src/gpg/function/GpgCommandExecutor.cpp index efe1446f..a494d4a8 100644 --- a/src/gpg/function/GpgCommandExecutor.cpp +++ b/src/gpg/function/GpgCommandExecutor.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/function/GpgCommandExecutor.h b/src/gpg/function/GpgCommandExecutor.h index 01904fd3..a6eaaf4a 100644 --- a/src/gpg/function/GpgCommandExecutor.h +++ b/src/gpg/function/GpgCommandExecutor.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,23 +25,23 @@ #ifndef GPGFRONTEND_ZH_CN_TS_GPGCOMMANDEXECUTOR_H #define GPGFRONTEND_ZH_CN_TS_GPGCOMMANDEXECUTOR_H +#include <boost/process.hpp> + #include "gpg/GpgContext.h" #include "gpg/GpgFunctionObject.h" -#include <boost/process.hpp> - namespace GpgFrontend { class GpgCommandExecutor : public SingletonFunctionObject<GpgCommandExecutor> { -public: + public: void Execute(StringArgsRef arguments, const std::function<void(boost::process::async_pipe &in, boost::process::async_pipe &out)> &interact_func); -private: + private: GpgContext &ctx = GpgContext::GetInstance(); }; -} // namespace GpgFrontend +} // namespace GpgFrontend -#endif // GPGFRONTEND_ZH_CN_TS_GPGCOMMANDEXECUTOR_H +#endif // GPGFRONTEND_ZH_CN_TS_GPGCOMMANDEXECUTOR_H diff --git a/src/gpg/function/GpgFileOpera.cpp b/src/gpg/function/GpgFileOpera.cpp index ae912ada..67504c0d 100644 --- a/src/gpg/function/GpgFileOpera.cpp +++ b/src/gpg/function/GpgFileOpera.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/function/GpgFileOpera.h b/src/gpg/function/GpgFileOpera.h index ff57b2c0..5b467357 100644 --- a/src/gpg/function/GpgFileOpera.h +++ b/src/gpg/function/GpgFileOpera.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/function/GpgKeyGetter.cpp b/src/gpg/function/GpgKeyGetter.cpp index 18fbe649..be27d69e 100644 --- a/src/gpg/function/GpgKeyGetter.cpp +++ b/src/gpg/function/GpgKeyGetter.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/function/GpgKeyGetter.h b/src/gpg/function/GpgKeyGetter.h index 8eab4e10..c8f5d73a 100644 --- a/src/gpg/function/GpgKeyGetter.h +++ b/src/gpg/function/GpgKeyGetter.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/function/GpgKeyImportExportor.cpp b/src/gpg/function/GpgKeyImportExportor.cpp index bdfc25bd..f4b88c60 100644 --- a/src/gpg/function/GpgKeyImportExportor.cpp +++ b/src/gpg/function/GpgKeyImportExportor.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -33,8 +33,7 @@ */ GpgFrontend::GpgImportInformation GpgFrontend::GpgKeyImportExportor::ImportKey( StdBypeArrayPtr in_buffer) { - if (in_buffer->empty()) - return GpgImportInformation(); + if (in_buffer->empty()) return GpgImportInformation(); GpgData data_in(in_buffer->data(), in_buffer->size()); auto err = check_gpg_error(gpgme_op_import(ctx, data_in)); @@ -60,10 +59,8 @@ GpgFrontend::GpgImportInformation GpgFrontend::GpgKeyImportExportor::ImportKey( * @return if success */ bool GpgFrontend::GpgKeyImportExportor::ExportKeys( - KeyIdArgsListPtr& uid_list, - ByteArrayPtr& out_buffer) const { - if (uid_list->empty()) - return false; + KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer) const { + if (uid_list->empty()) return false; // Alleviate another crash problem caused by an unknown array out-of-bounds // access @@ -89,11 +86,9 @@ bool GpgFrontend::GpgKeyImportExportor::ExportKeys( * @return if success */ bool GpgFrontend::GpgKeyImportExportor::ExportKeys( - const KeyArgsList& keys, - ByteArrayPtr& out_buffer) const { + const KeyArgsList& keys, ByteArrayPtr& out_buffer) const { KeyIdArgsListPtr key_ids = std::make_unique<std::vector<std::string>>(); - for (const auto& key : keys) - key_ids->push_back(key.id()); + for (const auto& key : keys) key_ids->push_back(key.id()); return ExportKeys(key_ids, out_buffer); } @@ -104,8 +99,7 @@ bool GpgFrontend::GpgKeyImportExportor::ExportKeys( * @return if successful */ bool GpgFrontend::GpgKeyImportExportor::ExportSecretKey( - const GpgKey& key, - ByteArrayPtr& out_buffer) const { + const GpgKey& key, ByteArrayPtr& out_buffer) const { DLOG(INFO) << "Export Secret Key" << key.id().c_str(); gpgme_key_t target_key[2] = {gpgme_key_t(key), nullptr}; diff --git a/src/gpg/function/GpgKeyImportExportor.h b/src/gpg/function/GpgKeyImportExportor.h index d71daddb..bceb87ef 100644 --- a/src/gpg/function/GpgKeyImportExportor.h +++ b/src/gpg/function/GpgKeyImportExportor.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -26,6 +26,7 @@ #define _GPGKEYIMPORTEXPORTOR_H #include <string> + #include "gpg/GpgConstants.h" #include "gpg/GpgContext.h" #include "gpg/GpgFunctionObject.h" @@ -46,34 +47,20 @@ class GpgImportInformation { GpgImportInformation() = default; explicit GpgImportInformation(gpgme_import_result_t result) { - if (result->unchanged) - unchanged = result->unchanged; - if (result->considered) - considered = result->considered; - if (result->no_user_id) - no_user_id = result->no_user_id; - if (result->imported) - imported = result->imported; - if (result->imported_rsa) - imported_rsa = result->imported_rsa; - if (result->unchanged) - unchanged = result->unchanged; - if (result->new_user_ids) - new_user_ids = result->new_user_ids; - if (result->new_sub_keys) - new_sub_keys = result->new_sub_keys; - if (result->new_signatures) - new_signatures = result->new_signatures; - if (result->new_revocations) - new_revocations = result->new_revocations; - if (result->secret_read) - secret_read = result->secret_read; - if (result->secret_imported) - secret_imported = result->secret_imported; - if (result->secret_unchanged) - secret_unchanged = result->secret_unchanged; - if (result->not_imported) - not_imported = result->not_imported; + if (result->unchanged) unchanged = result->unchanged; + if (result->considered) considered = result->considered; + if (result->no_user_id) no_user_id = result->no_user_id; + if (result->imported) imported = result->imported; + if (result->imported_rsa) imported_rsa = result->imported_rsa; + if (result->unchanged) unchanged = result->unchanged; + if (result->new_user_ids) new_user_ids = result->new_user_ids; + if (result->new_sub_keys) new_sub_keys = result->new_sub_keys; + if (result->new_signatures) new_signatures = result->new_signatures; + if (result->new_revocations) new_revocations = result->new_revocations; + if (result->secret_read) secret_read = result->secret_read; + if (result->secret_imported) secret_imported = result->secret_imported; + if (result->secret_unchanged) secret_unchanged = result->secret_unchanged; + if (result->not_imported) not_imported = result->not_imported; } int considered = 0; diff --git a/src/gpg/function/GpgKeyManager.cpp b/src/gpg/function/GpgKeyManager.cpp index 361c00bd..9e24b3d6 100644 --- a/src/gpg/function/GpgKeyManager.cpp +++ b/src/gpg/function/GpgKeyManager.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,14 +23,15 @@ */ #include "gpg/function/GpgKeyManager.h" + #include <boost/date_time/posix_time/conversion.hpp> #include <string> + #include "gpg/function/BasicOperator.h" #include "gpg/function/GpgKeyGetter.h" bool GpgFrontend::GpgKeyManager::signKey( - const GpgFrontend::GpgKey& target, - GpgFrontend::KeyArgsList& keys, + const GpgFrontend::GpgKey& target, GpgFrontend::KeyArgsList& keys, const std::string& uid, const std::unique_ptr<boost::gregorian::date>& expires) { using namespace boost::posix_time; @@ -62,27 +63,23 @@ bool GpgFrontend::GpgKeyManager::revSign( auto err = check_gpg_error(gpgme_op_revsig(ctx, gpgme_key_t(key), gpgme_key_t(signing_key), sign_id.second.c_str(), 0)); - if (check_gpg_error_2_err_code(err) != GPG_ERR_NO_ERROR) - return false; + if (check_gpg_error_2_err_code(err) != GPG_ERR_NO_ERROR) return false; } return true; } bool GpgFrontend::GpgKeyManager::setExpire( - const GpgFrontend::GpgKey& key, - std::unique_ptr<GpgSubKey>& subkey, + const GpgFrontend::GpgKey& key, std::unique_ptr<GpgSubKey>& subkey, std::unique_ptr<boost::gregorian::date>& expires) { using namespace boost::posix_time; unsigned long expires_time = 0; - if (expires != nullptr) - expires_time = to_time_t(ptime(*expires)); + if (expires != nullptr) expires_time = to_time_t(ptime(*expires)); const char* sub_fprs = nullptr; - if (subkey != nullptr) - sub_fprs = subkey->fpr().c_str(); + if (subkey != nullptr) sub_fprs = subkey->fpr().c_str(); auto err = check_gpg_error( gpgme_op_setexpire(ctx, gpgme_key_t(key), expires_time, sub_fprs, 0)); diff --git a/src/gpg/function/GpgKeyManager.h b/src/gpg/function/GpgKeyManager.h index f50c8dcc..2b07425c 100644 --- a/src/gpg/function/GpgKeyManager.h +++ b/src/gpg/function/GpgKeyManager.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -40,16 +40,13 @@ class GpgKeyManager : public SingletonFunctionObject<GpgKeyManager> { * @param expires expire date and time of the signature * @return if successful */ - bool signKey(const GpgKey& target, - KeyArgsList& keys, - const std::string& uid, + bool signKey(const GpgKey& target, KeyArgsList& keys, const std::string& uid, const std::unique_ptr<boost::gregorian::date>& expires); bool revSign(const GpgFrontend::GpgKey& key, const GpgFrontend::SignIdArgsListPtr& signature_id); - bool setExpire(const GpgKey& key, - std::unique_ptr<GpgSubKey>& subkey, + bool setExpire(const GpgKey& key, std::unique_ptr<GpgSubKey>& subkey, std::unique_ptr<boost::gregorian::date>& expires); private: diff --git a/src/gpg/function/GpgKeyOpera.cpp b/src/gpg/function/GpgKeyOpera.cpp index c7775d10..2406cbb9 100644 --- a/src/gpg/function/GpgKeyOpera.cpp +++ b/src/gpg/function/GpgKeyOpera.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/function/GpgKeyOpera.h b/src/gpg/function/GpgKeyOpera.h index 54f7f3e6..d9573bd7 100644 --- a/src/gpg/function/GpgKeyOpera.h +++ b/src/gpg/function/GpgKeyOpera.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/function/UidOperator.cpp b/src/gpg/function/UidOperator.cpp index 69caf458..d7acc3b1 100644 --- a/src/gpg/function/UidOperator.cpp +++ b/src/gpg/function/UidOperator.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/function/UidOperator.h b/src/gpg/function/UidOperator.h index e3068b1f..7d5df254 100644 --- a/src/gpg/function/UidOperator.h +++ b/src/gpg/function/UidOperator.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -48,10 +48,8 @@ class UidOperator : public SingletonFunctionObject<UidOperator> { * @param email * @return */ - bool addUID(const GpgKey& key, - const std::string& name, - const std::string& comment, - const std::string& email); + bool addUID(const GpgKey& key, const std::string& name, + const std::string& comment, const std::string& email); /** * Revoke(Delete) UID from certain key pair diff --git a/src/gpg/model/GpgData.cpp b/src/gpg/model/GpgData.cpp index 1ffff0c5..23cdaf2d 100644 --- a/src/gpg/model/GpgData.cpp +++ b/src/gpg/model/GpgData.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/gpg/model/GpgData.h b/src/gpg/model/GpgData.h index 30a1c496..e3202af6 100644 --- a/src/gpg/model/GpgData.h +++ b/src/gpg/model/GpgData.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -42,8 +42,7 @@ class GpgData { private: struct __data_ref_deletor { void operator()(gpgme_data_t _data) { - if (_data != nullptr) - gpgme_data_release(_data); + if (_data != nullptr) gpgme_data_release(_data); } }; diff --git a/src/gpg/model/GpgKey.cpp b/src/gpg/model/GpgKey.cpp index a0511051..c14edd2d 100644 --- a/src/gpg/model/GpgKey.cpp +++ b/src/gpg/model/GpgKey.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -44,8 +44,8 @@ GpgFrontend::GpgKey::subKeys() const { return p_keys; } -std::unique_ptr<std::vector<GpgFrontend::GpgUID>> -GpgFrontend::GpgKey::uids() const { +std::unique_ptr<std::vector<GpgFrontend::GpgUID>> GpgFrontend::GpgKey::uids() + const { auto p_uids = std::make_unique<std::vector<GpgUID>>(); auto uid_next = _key_ref->uids; while (uid_next != nullptr) { diff --git a/src/gpg/model/GpgKey.h b/src/gpg/model/GpgKey.h index ecebf3b2..53c074e8 100644 --- a/src/gpg/model/GpgKey.h +++ b/src/gpg/model/GpgKey.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,12 +25,12 @@ #ifndef GPGFRONTEND_GPGKEY_H #define GPGFRONTEND_GPGKEY_H -#include "GpgSubKey.h" -#include "GpgUID.h" - #include <boost/date_time.hpp> #include <boost/date_time/posix_time/conversion.hpp> +#include "GpgSubKey.h" +#include "GpgUID.h" + namespace GpgFrontend { class GpgKey { @@ -148,8 +148,7 @@ class GpgKey { private: struct _key_ref_deletor { void operator()(gpgme_key_t _key) { - if (_key != nullptr) - gpgme_key_unref(_key); + if (_key != nullptr) gpgme_key_unref(_key); } }; diff --git a/src/gpg/model/GpgKeySignature.cpp b/src/gpg/model/GpgKeySignature.cpp index d7e7c53e..8f937198 100644 --- a/src/gpg/model/GpgKeySignature.cpp +++ b/src/gpg/model/GpgKeySignature.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,5 +24,5 @@ #include "gpg/model/GpgKeySignature.h" -GpgFrontend::GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig) : _signature_ref(sig, - [&](gpgme_key_sig_t signature) {}) {} +GpgFrontend::GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig) + : _signature_ref(sig, [&](gpgme_key_sig_t signature) {}) {} diff --git a/src/gpg/model/GpgKeySignature.h b/src/gpg/model/GpgKeySignature.h index 9de6b074..70eaeb1c 100644 --- a/src/gpg/model/GpgKeySignature.h +++ b/src/gpg/model/GpgKeySignature.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,15 +25,15 @@ #ifndef GPGFRONTEND_GPGKEYSIGNATURE_H #define GPGFRONTEND_GPGKEYSIGNATURE_H -#include "gpg/GpgConstants.h" - #include <boost/date_time.hpp> #include <string> +#include "gpg/GpgConstants.h" + namespace GpgFrontend { class GpgKeySignature { -public: + public: [[nodiscard]] bool revoked() const { return _signature_ref->revoked; } [[nodiscard]] bool expired() const { return _signature_ref->expired; } [[nodiscard]] bool invalid() const { return _signature_ref->invalid; } @@ -72,7 +72,7 @@ public: GpgKeySignature &operator=(const GpgKeySignature &) = delete; -private: + private: using KeySignatrueRefHandler = std::unique_ptr<struct _gpgme_key_sig, std::function<void(gpgme_key_sig_t)>>; @@ -80,6 +80,6 @@ private: KeySignatrueRefHandler _signature_ref = nullptr; }; -} // namespace GpgFrontend +} // namespace GpgFrontend -#endif // GPGFRONTEND_GPGKEYSIGNATURE_H +#endif // GPGFRONTEND_GPGKEYSIGNATURE_H diff --git a/src/gpg/model/GpgSubKey.cpp b/src/gpg/model/GpgSubKey.cpp index 87476d56..83fbcaa2 100644 --- a/src/gpg/model/GpgSubKey.cpp +++ b/src/gpg/model/GpgSubKey.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,4 +23,5 @@ */ #include "gpg/model/GpgSubKey.h" -GpgFrontend::GpgSubKey::GpgSubKey(gpgme_subkey_t subkey) : _subkey_ref(subkey, [&](gpgme_subkey_t subkey) {}) {} +GpgFrontend::GpgSubKey::GpgSubKey(gpgme_subkey_t subkey) + : _subkey_ref(subkey, [&](gpgme_subkey_t subkey) {}) {} diff --git a/src/gpg/model/GpgSubKey.h b/src/gpg/model/GpgSubKey.h index edb52f44..5f65c507 100644 --- a/src/gpg/model/GpgSubKey.h +++ b/src/gpg/model/GpgSubKey.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,11 +24,11 @@ #ifndef GPGFRONTEND_GPGSUBKEY_H #define GPGFRONTEND_GPGSUBKEY_H -#include "gpg/GpgConstants.h" - #include <boost/date_time.hpp> #include <string> +#include "gpg/GpgConstants.h" + namespace GpgFrontend { class GpgSubKey { diff --git a/src/gpg/model/GpgUID.cpp b/src/gpg/model/GpgUID.cpp index ae58daf1..c0a63bab 100644 --- a/src/gpg/model/GpgUID.cpp +++ b/src/gpg/model/GpgUID.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,4 +24,5 @@ #include "gpg/model/GpgUID.h" -GpgFrontend::GpgUID::GpgUID(gpgme_user_id_t uid) : _uid_ref(uid, [&](gpgme_user_id_t uid) {}) {}
\ No newline at end of file +GpgFrontend::GpgUID::GpgUID(gpgme_user_id_t uid) + : _uid_ref(uid, [&](gpgme_user_id_t uid) {}) {}
\ No newline at end of file diff --git a/src/gpg/model/GpgUID.h b/src/gpg/model/GpgUID.h index dbe084b8..66dba321 100644 --- a/src/gpg/model/GpgUID.h +++ b/src/gpg/model/GpgUID.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -30,7 +30,7 @@ namespace GpgFrontend { class GpgUID { -public: + public: [[nodiscard]] std::string name() const { return _uid_ref->name; } [[nodiscard]] std::string email() const { return _uid_ref->email; } @@ -43,8 +43,8 @@ public: [[nodiscard]] bool invalid() const { return _uid_ref->invalid; } - [[nodiscard]] std::unique_ptr<std::vector<GpgKeySignature>> - signatures() const { + [[nodiscard]] std::unique_ptr<std::vector<GpgKeySignature>> signatures() + const { auto sigs = std::make_unique<std::vector<GpgKeySignature>>(); auto sig_next = _uid_ref->signatures; while (sig_next != nullptr) { @@ -69,13 +69,13 @@ public: GpgUID &operator=(const GpgUID &) = delete; -private: + private: using UidRefHandler = std::unique_ptr<struct _gpgme_user_id, std::function<void(gpgme_user_id_t)>>; UidRefHandler _uid_ref = nullptr; }; -} // namespace GpgFrontend +} // namespace GpgFrontend -#endif // GPGFRONTEND_GPGUID_H
\ No newline at end of file +#endif // GPGFRONTEND_GPGUID_H
\ No newline at end of file diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.cpp b/src/gpg/result_analyse/DecryptResultAnalyse.cpp index 8ecb92b9..4ff32c59 100644 --- a/src/gpg/result_analyse/DecryptResultAnalyse.cpp +++ b/src/gpg/result_analyse/DecryptResultAnalyse.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,6 +23,7 @@ */ #include "gpg/result_analyse/DecryptResultAnalyse.h" + #include "gpg/function/GpgKeyGetter.h" GpgFrontend::DecryptResultAnalyse::DecryptResultAnalyse(GpgError error, @@ -30,16 +31,16 @@ GpgFrontend::DecryptResultAnalyse::DecryptResultAnalyse(GpgError error, : error(error), result(std::move(result)) {} void GpgFrontend::DecryptResultAnalyse::do_analyse() { - stream << "[#] Decrypt Operation "; + stream << "[#]" << _("Decrypt Operation"); if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) { - stream << "[Success]" << std::endl; + stream << "[" << _("Success") << "]" << std::endl; } else { - stream << "[Failed] " << gpgme_strerror(error) << std::endl; + stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl; setStatus(-1); if (result != nullptr && result->unsupported_algorithm != nullptr) { stream << "------------>" << std::endl; - stream << "Unsupported Algo: " << result->unsupported_algorithm + stream << _("Unsupported Algo") << ": " << result->unsupported_algorithm << std::endl; } } @@ -47,13 +48,12 @@ void GpgFrontend::DecryptResultAnalyse::do_analyse() { if (result != nullptr && result->recipients != nullptr) { stream << "------------>" << std::endl; if (result->file_name != nullptr) { - stream << "File Name: " << result->file_name << std::endl; + stream << _("File Name") << ": " << result->file_name << std::endl; stream << std::endl; } auto reci = result->recipients; - if (reci != nullptr) - stream << "Recipient(s): " << std::endl; + if (reci != nullptr) stream << _("Recipient(s)") << ": " << std::endl; while (reci != nullptr) { print_reci(stream, reci); reci = reci->next; @@ -67,7 +67,7 @@ void GpgFrontend::DecryptResultAnalyse::do_analyse() { bool GpgFrontend::DecryptResultAnalyse::print_reci(std::stringstream &stream, gpgme_recipient_t reci) { bool keyFound = true; - stream << " {>} Recipient: "; + stream << " {>} " << _("Recipient") << ": "; auto key = GpgFrontend::GpgKeyGetter::GetInstance().GetKey(reci->keyid); if (key.good()) { @@ -76,16 +76,16 @@ bool GpgFrontend::DecryptResultAnalyse::print_reci(std::stringstream &stream, stream << "<" << key.email().c_str() << ">"; } } else { - stream << "<Unknown>"; + stream << "<" << _("Unknown") << ">"; setStatus(0); keyFound = false; } stream << std::endl; - stream << " Keu ID: " << key.id().c_str() << std::endl; - stream << " Public Algo: " << gpgme_pubkey_algo_name(reci->pubkey_algo) - << std::endl; + stream << " " << _("Keu ID") << ": " << key.id().c_str() << std::endl; + stream << " " << _("Public Algo") << ": " + << gpgme_pubkey_algo_name(reci->pubkey_algo) << std::endl; return keyFound; } diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.h b/src/gpg/result_analyse/DecryptResultAnalyse.h index 44640f7a..0864c23b 100644 --- a/src/gpg/result_analyse/DecryptResultAnalyse.h +++ b/src/gpg/result_analyse/DecryptResultAnalyse.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -31,19 +31,19 @@ namespace GpgFrontend { class DecryptResultAnalyse : public ResultAnalyse { -public: + public: explicit DecryptResultAnalyse(GpgError error, GpgDecrResult result); -protected: + protected: void do_analyse() final; -private: + private: bool print_reci(std::stringstream &stream, gpgme_recipient_t reci); GpgError error; GpgDecrResult result; }; -} // namespace GpgFrontend +} // namespace GpgFrontend -#endif // GPGFRONTEND_DECRYPTRESULTANALYSE_H +#endif // GPGFRONTEND_DECRYPTRESULTANALYSE_H diff --git a/src/gpg/result_analyse/EncryptResultAnalyse.cpp b/src/gpg/result_analyse/EncryptResultAnalyse.cpp index 6659f1df..df240a1d 100644 --- a/src/gpg/result_analyse/EncryptResultAnalyse.cpp +++ b/src/gpg/result_analyse/EncryptResultAnalyse.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -29,25 +29,26 @@ GpgFrontend::EncryptResultAnalyse::EncryptResultAnalyse(GpgError error, : error(error), result(std::move(result)) {} void GpgFrontend::EncryptResultAnalyse::do_analyse() { - LOG(INFO) << "Start Encrypt Result Analyse"; + LOG(INFO) << _("Start Encrypt Result Analyse"); - stream << "[#] Encrypt Operation "; + stream << "[#] " << _("Encrypt Operation") << " "; if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) - stream << "[Success]" << std::endl; + stream << "[" << _("Success") << "]" << std::endl; else { - stream << "[Failed] " << gpgme_strerror(error) << std::endl; + stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl; setStatus(-1); } if (!~status) { stream << "------------>" << std::endl; if (result != nullptr) { - stream << "Invalid Recipients: " << std::endl; + stream << _("Invalid Recipients") << ": " << std::endl; auto inv_reci = result->invalid_recipients; while (inv_reci != nullptr) { - stream << "Fingerprint: " << inv_reci->fpr << std::endl; - stream << "Reason: " << gpgme_strerror(inv_reci->reason) << std::endl; + stream << _("Fingerprint") << ": " << inv_reci->fpr << std::endl; + stream << _("Reason") << ": " << gpgme_strerror(inv_reci->reason) + << std::endl; stream << std::endl; inv_reci = inv_reci->next; diff --git a/src/gpg/result_analyse/EncryptResultAnalyse.h b/src/gpg/result_analyse/EncryptResultAnalyse.h index 9b6bc788..e0a411d1 100644 --- a/src/gpg/result_analyse/EncryptResultAnalyse.h +++ b/src/gpg/result_analyse/EncryptResultAnalyse.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -30,16 +30,16 @@ namespace GpgFrontend { class EncryptResultAnalyse : public ResultAnalyse { -public: + public: explicit EncryptResultAnalyse(GpgError error, GpgEncrResult result); -protected: + protected: void do_analyse() final; -private: + private: GpgError error; GpgEncrResult result; }; -} // namespace GpgFrontend +} // namespace GpgFrontend -#endif // GPGFRONTEND_ENCRYPTRESULTANALYSE_H +#endif // GPGFRONTEND_ENCRYPTRESULTANALYSE_H diff --git a/src/gpg/result_analyse/ResultAnalyse.cpp b/src/gpg/result_analyse/ResultAnalyse.cpp index 3005ea1f..821da2ee 100644 --- a/src/gpg/result_analyse/ResultAnalyse.cpp +++ b/src/gpg/result_analyse/ResultAnalyse.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -28,13 +28,10 @@ const std::string GpgFrontend::ResultAnalyse::getResultReport() const { return stream.str(); } -int GpgFrontend::ResultAnalyse::getStatus() const { - return status; -} +int GpgFrontend::ResultAnalyse::getStatus() const { return status; } void GpgFrontend::ResultAnalyse::setStatus(int mStatus) { - if (mStatus < status) - status = mStatus; + if (mStatus < status) status = mStatus; } void GpgFrontend::ResultAnalyse::analyse() { diff --git a/src/gpg/result_analyse/ResultAnalyse.h b/src/gpg/result_analyse/ResultAnalyse.h index d187cd8a..33341b44 100644 --- a/src/gpg/result_analyse/ResultAnalyse.h +++ b/src/gpg/result_analyse/ResultAnalyse.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,10 +24,10 @@ #ifndef GPGFRONTEND_RESULTANALYSE_H #define GPGFRONTEND_RESULTANALYSE_H -#include "gpg/GpgConstants.h" - #include <sstream> #include <string> + +#include "gpg/GpgConstants.h" namespace GpgFrontend { class ResultAnalyse { diff --git a/src/gpg/result_analyse/SignResultAnalyse.cpp b/src/gpg/result_analyse/SignResultAnalyse.cpp index fcad9060..770594ca 100644 --- a/src/gpg/result_analyse/SignResultAnalyse.cpp +++ b/src/gpg/result_analyse/SignResultAnalyse.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,6 +23,7 @@ */ #include "gpg/result_analyse/SignResultAnalyse.h" + #include "gpg/function/GpgKeyGetter.h" GpgFrontend::SignResultAnalyse::SignResultAnalyse(GpgError error, @@ -30,53 +31,52 @@ GpgFrontend::SignResultAnalyse::SignResultAnalyse(GpgError error, : error(error), result(std::move(result)) {} void GpgFrontend::SignResultAnalyse::do_analyse() { - LOG(INFO) << "Start Sign Result Analyse"; + LOG(INFO) << _("Start Sign Result Analyse"); - stream << "[#] Sign Operation "; + stream << "[#] " << _("Sign Operation") << " "; if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) - stream << "[Success]" << std::endl; + stream << "[" << _("Success") << "]" << std::endl; else { - stream << "[Failed] " << gpgme_strerror(error) << std::endl; + stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl; setStatus(-1); } if (result != nullptr && (result->signatures != nullptr || result->invalid_signers != nullptr)) { - - LOG(INFO) << "Sign Result Analyse Getting Result"; + LOG(INFO) << _("Sign Result Analyse Getting Result"); stream << "------------>" << std::endl; auto new_sign = result->signatures; while (new_sign != nullptr) { - stream << "[>] New Signature: " << std::endl; + stream << "[>]" << _("New Signature") << ": " << std::endl; - LOG(INFO) << "Signers Fingerprint: " << new_sign->fpr; + LOG(INFO) << _("Signers Fingerprint") << ": " << new_sign->fpr; - stream << " Sign Mode: "; + stream << " " << _("Sign Mode") << ": "; if (new_sign->type == GPGME_SIG_MODE_NORMAL) - stream << "Normal"; + stream << _("Normal"); else if (new_sign->type == GPGME_SIG_MODE_CLEAR) - stream << "Clear"; + stream << _("Clear"); else if (new_sign->type == GPGME_SIG_MODE_DETACH) - stream << "Detach"; + stream << _("Detach"); stream << std::endl; auto singerKey = GpgFrontend::GpgKeyGetter::GetInstance().GetKey(new_sign->fpr); if (singerKey.good()) { - stream << " Signer: " << singerKey.uids()->front().uid() - << std::endl; + stream << " " << _("Signer") << ": " + << singerKey.uids()->front().uid() << std::endl; } else { - stream << " Signer: " + stream << " " << _("Signer") << ": " << "<unknown>" << std::endl; } - stream << " Public Key Algo: " + stream << " " << _("Public Key Algo") << ": " << gpgme_pubkey_algo_name(new_sign->pubkey_algo) << std::endl; - stream << " Hash Algo: " << gpgme_hash_algo_name(new_sign->hash_algo) - << std::endl; - stream << " Date & Time: " + stream << " " << _("Hash Algo") << ": " + << gpgme_hash_algo_name(new_sign->hash_algo) << std::endl; + stream << " " << _("Date & Time") << ": " << boost::posix_time::to_iso_string( boost::posix_time::from_time_t(new_sign->timestamp)) << std::endl; @@ -86,19 +86,20 @@ void GpgFrontend::SignResultAnalyse::do_analyse() { new_sign = new_sign->next; } - LOG(INFO) << "Sign Result Analyse Getting Invalid Signer"; + LOG(INFO) << _("Sign Result Analyse Getting Invalid Signer"); auto invalid_signer = result->invalid_signers; if (invalid_signer != nullptr) - stream << "Invalid Signers: " << std::endl; + stream << _("Invalid Signers") << ": " << std::endl; while (invalid_signer != nullptr) { setStatus(0); - stream << "[>] Signer: " << std::endl; - stream << " Fingerprint: " << invalid_signer->fpr << std::endl; - stream << " Reason: " << gpgme_strerror(invalid_signer->reason) + stream << "[>] " << _("Signer") << ": " << std::endl; + stream << " " << _("Fingerprint") << ": " << invalid_signer->fpr << std::endl; + stream << " " << _("Reason") << ": " + << gpgme_strerror(invalid_signer->reason) << std::endl; stream << std::endl; invalid_signer = invalid_signer->next; diff --git a/src/gpg/result_analyse/SignResultAnalyse.h b/src/gpg/result_analyse/SignResultAnalyse.h index 4a1234fe..988ddf99 100644 --- a/src/gpg/result_analyse/SignResultAnalyse.h +++ b/src/gpg/result_analyse/SignResultAnalyse.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -30,18 +30,18 @@ namespace GpgFrontend { class SignResultAnalyse : public ResultAnalyse { -public: + public: explicit SignResultAnalyse(GpgError error, GpgSignResult result); -protected: + protected: void do_analyse(); -private: + private: GpgError error; GpgSignResult result; }; -} // namespace GpgFrontend +} // namespace GpgFrontend -#endif // GPGFRONTEND_SIGNRESULTANALYSE_H +#endif // GPGFRONTEND_SIGNRESULTANALYSE_H diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/gpg/result_analyse/VerifyResultAnalyse.cpp index 598329dd..849c2051 100644 --- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp +++ b/src/gpg/result_analyse/VerifyResultAnalyse.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,6 +23,7 @@ */ #include "gpg/result_analyse/VerifyResultAnalyse.h" + #include "GpgFrontend.h" #include "gpg/GpgConstants.h" #include "gpg/function/GpgKeyGetter.h" @@ -32,14 +33,14 @@ GpgFrontend::VerifyResultAnalyse::VerifyResultAnalyse(GpgError error, : error(error), result(std::move(result)) {} void GpgFrontend::VerifyResultAnalyse::do_analyse() { - LOG(INFO) << "Verify Result Analyse Started"; + LOG(INFO) << _("Verify Result Analyse Started"); - stream << "[#] Verify Operation "; + stream << "[#] " << _("Verify Operation") << " "; if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) - stream << "[Success]" << std::endl; + stream << "[" << _("Success") << "]" << std::endl; else { - stream << "[Failed] " << gpgme_strerror(error) << std::endl; + stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl; setStatus(-1); } @@ -48,105 +49,108 @@ void GpgFrontend::VerifyResultAnalyse::do_analyse() { auto sign = result->signatures; if (sign == nullptr) { - stream << "[>] Not Signature Found" << std::endl; + stream << "[>] " << _("Not Signature Found") << std::endl; setStatus(0); return; } - stream << "[>] Signed On " + stream << "[>] " << _("Signed On") << " " << boost::posix_time::to_iso_string( boost::posix_time::from_time_t(sign->timestamp)) << std::endl; - stream << std::endl << "[>] Signatures:" << std::endl; + stream << std::endl << "[>] " << _("Signatures") << ":" << std::endl; bool canContinue = true; while (sign && canContinue) { switch (gpg_err_code(sign->status)) { - case GPG_ERR_BAD_SIGNATURE: - stream << "One or More Bad Signatures." << std::endl; - canContinue = false; - setStatus(-1); - break; - case GPG_ERR_NO_ERROR: - stream << "A "; - if (sign->summary & GPGME_SIGSUM_GREEN) { - stream << "Good "; - } - if (sign->summary & GPGME_SIGSUM_RED) { - stream << "Bad "; - } - if (sign->summary & GPGME_SIGSUM_SIG_EXPIRED) { - stream << "Expired "; - } - if (sign->summary & GPGME_SIGSUM_KEY_MISSING) { - stream << "Missing Key's "; - } - if (sign->summary & GPGME_SIGSUM_KEY_REVOKED) { - stream << "Revoked Key's "; - } - if (sign->summary & GPGME_SIGSUM_KEY_EXPIRED) { - stream << "Expired Key's "; - } - if (sign->summary & GPGME_SIGSUM_CRL_MISSING) { - stream << "Missing CRL's "; - } - - if (sign->summary & GPGME_SIGSUM_VALID) { - stream << "Signature Fully Valid." << std::endl; - } else { - stream << "Signature Not Fully Valid." << std::endl; - } - - if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) { - if (!print_signer(stream, sign)) + case GPG_ERR_BAD_SIGNATURE: + stream << _("One or More Bad Signatures.") << std::endl; + canContinue = false; + setStatus(-1); + break; + case GPG_ERR_NO_ERROR: + stream << _("A") << " "; + if (sign->summary & GPGME_SIGSUM_GREEN) { + stream << _("Good") << " "; + } + if (sign->summary & GPGME_SIGSUM_RED) { + stream << _("Bad") << " "; + } + if (sign->summary & GPGME_SIGSUM_SIG_EXPIRED) { + stream << _("Expired") << " "; + } + if (sign->summary & GPGME_SIGSUM_KEY_MISSING) { + stream << _("Missing Key's") << " "; + } + if (sign->summary & GPGME_SIGSUM_KEY_REVOKED) { + stream << _("Revoked Key's") << " "; + } + if (sign->summary & GPGME_SIGSUM_KEY_EXPIRED) { + stream << _("Expired Key's") << " "; + } + if (sign->summary & GPGME_SIGSUM_CRL_MISSING) { + stream << _("Missing CRL's") << " "; + } + + if (sign->summary & GPGME_SIGSUM_VALID) { + stream << _("Signature Fully Valid.") << std::endl; + } else { + stream << _("Signature Not Fully Valid.") << std::endl; + } + + if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) { + if (!print_signer(stream, sign)) setStatus(0); + } else { + stream << _("Key is NOT present with ID 0x") << sign->fpr + << std::endl; + } + + setStatus(1); + + break; + case GPG_ERR_NO_PUBKEY: + stream << _("A signature could NOT be verified due to a Missing Key") + << std::endl; + setStatus(-1); + break; + case GPG_ERR_CERT_REVOKED: + stream << _("A signature is valid but the key used to verify the " + "signature has been revoked") + << std::endl; + if (!print_signer(stream, sign)) { + setStatus(0); + } + setStatus(-1); + break; + case GPG_ERR_SIG_EXPIRED: + stream << _("A signature is valid but expired") << std::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.") + << std::endl; + if (!print_signer(stream, sign)) { setStatus(0); - } else { - stream << "Key is NOT present with ID 0x" << sign->fpr << std::endl; - } - - setStatus(1); - - break; - case GPG_ERR_NO_PUBKEY: - stream << "A signature could NOT be verified due to a Missing " - "Key\n"; - setStatus(-1); - break; - case GPG_ERR_CERT_REVOKED: - stream << "A signature is valid but the key used to " - "verify the signature has been revoked\n"; - if (!print_signer(stream, sign)) { - setStatus(0); - } - setStatus(-1); - break; - case GPG_ERR_SIG_EXPIRED: - stream << "A signature is valid but expired\n"; - 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.\n"; - if (!print_signer(stream, sign)) { - setStatus(0); - } - break; - case GPG_ERR_GENERAL: - stream << "There was some other error which prevented " - "the signature verification.\n"; - status = -1; - canContinue = false; - break; - default: - auto fpr = std::string(sign->fpr); - stream << "Error for key with fingerprint " - << GpgFrontend::beautify_fingerprint(fpr); - setStatus(-1); + } + break; + case GPG_ERR_GENERAL: + stream << _("There was some other error which prevented " + "the signature verification.") + << std::endl; + status = -1; + canContinue = false; + break; + default: + auto fpr = std::string(sign->fpr); + stream << _("Error for key with fingerprint") << " " + << GpgFrontend::beautify_fingerprint(fpr); + setStatus(-1); } stream << std::endl; sign = sign->next; @@ -161,18 +165,19 @@ bool GpgFrontend::VerifyResultAnalyse::print_signer(std::stringstream &stream, auto key = GpgFrontend::GpgKeyGetter::GetInstance().GetKey(sign->fpr); if (!key.good()) { - stream << " Signed By: " - << "<unknown>" << std::endl; + stream << " " << _("Signed By") << ": " + << "<" << _("Unknown") << ">" << std::endl; setStatus(0); keyFound = false; } else { - stream << " Signed By: " << key.uids()->front().uid() << std::endl; + stream << " " << _("Signed By") << ": " << key.uids()->front().uid() + << std::endl; } - stream << " Public Key Algo: " << gpgme_pubkey_algo_name(sign->pubkey_algo) - << std::endl; - stream << " Hash Algo: " << gpgme_hash_algo_name(sign->hash_algo) - << std::endl; - stream << " Date & Time: " + stream << " " << _("Public Key Algo") << ": " + << gpgme_pubkey_algo_name(sign->pubkey_algo) << std::endl; + stream << " " << _("Hash Algo") << ": " + << gpgme_hash_algo_name(sign->hash_algo) << std::endl; + stream << " " << _("Date & Time") << ": " << boost::posix_time::to_iso_string( boost::posix_time::from_time_t(sign->timestamp)) << std::endl; diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.h b/src/gpg/result_analyse/VerifyResultAnalyse.h index 30352bee..c3364025 100644 --- a/src/gpg/result_analyse/VerifyResultAnalyse.h +++ b/src/gpg/result_analyse/VerifyResultAnalyse.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -31,19 +31,19 @@ namespace GpgFrontend { class VerifyResultAnalyse : public ResultAnalyse { -public: + public: explicit VerifyResultAnalyse(GpgError error, GpgVerifyResult result); -private: + private: void do_analyse(); -private: + private: bool print_signer(std::stringstream &stream, gpgme_signature_t sign); GpgError error; GpgVerifyResult result; }; -} // namespace GpgFrontend +} // namespace GpgFrontend -#endif // GPGFRONTEND_VERIFYRESULTANALYSE_H +#endif // GPGFRONTEND_VERIFYRESULTANALYSE_H diff --git a/src/main.cpp b/src/main.cpp index 7cde6b20..751fd46b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -30,16 +30,25 @@ INITIALIZE_EASYLOGGINGPP void init_logging(); +void init_locale(); int main(int argc, char* argv[]) { + // Qt Q_INIT_RESOURCE(gpgfrontend); - QApplication app(argc, argv); - init_logging(); + // Qt App + QApplication app(argc, argv); // get application path auto app_path = GlobalSettingStation::GetInstance().GetAppDir(); + // logging system + init_logging(); + + // i18n + init_locale(); + + // App config QApplication::setApplicationVersion(BUILD_VERSION); QApplication::setApplicationName(PROJECT_NAME); @@ -62,42 +71,11 @@ int main(int argc, char* argv[]) { * internationalisation. loop to restart mainwindow * with changed translation when settings change. */ - auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); - - if (!settings.exists("general") || - settings.lookup("general").getType() != libconfig::Setting::TypeGroup) - settings.add("general", libconfig::Setting::TypeGroup); - - auto& general = settings["general"]; - if (!general.exists("lang")) - general.add("lang", libconfig::Setting::TypeString) = - QLocale::system().name().toStdString(); - - GlobalSettingStation::GetInstance().Sync(); - - QTranslator translator, translator2; int return_from_event_loop_code; - LOG(INFO) << "Resource Directory" << RESOURCE_DIR(app_path); + LOG(INFO) << _("Resource Directory") << RESOURCE_DIR(app_path); do { - QApplication::removeTranslator(&translator); - QApplication::removeTranslator(&translator2); - - std::string lang; - if (!general.lookupValue("lang", lang)) { - LOG(ERROR) << "could not read properly from configure file"; - }; - - translator.load(QString::fromStdString(RESOURCE_DIR(app_path).string() + - "/ts/" + "gpgfrontend_" + lang)); - QApplication::installTranslator(&translator); - - // set qt translations - translator2.load(QString::fromStdString(RESOURCE_DIR(app_path).string() + - "/ts/qt_" + lang)); - QApplication::installTranslator(&translator2); - QApplication::setQuitOnLastWindowClosed(true); /** @@ -106,11 +84,6 @@ int main(int argc, char* argv[]) { * subsystem in GPGME. (from the info page) */ gpgme_check_version(nullptr); - // the locale set here is used for the other setlocale calls which have - // nullptr - // -> nullptr means use default, which is configured here - setlocale(LC_ALL, lang.c_str()); - /** set locale, because tests do also */ gpgme_set_locale(nullptr, LC_CTYPE, setlocale(LC_CTYPE, nullptr)); #ifndef _WIN32 @@ -147,5 +120,33 @@ void init_logging() { el::Loggers::reconfigureLogger("default", defaultConf); - LOG(INFO) << "Logfile Path" << logfile_path; + LOG(INFO) << _("Logfile Path") << logfile_path; +} + +void init_locale() { + auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); + + if (!settings.exists("general") || + settings.lookup("general").getType() != libconfig::Setting::TypeGroup) + settings.add("general", libconfig::Setting::TypeGroup); + + auto& general = settings["general"]; + if (!general.exists("lang")) + general.add("lang", libconfig::Setting::TypeString) = + QLocale::system().name().toStdString(); + + GlobalSettingStation::GetInstance().Sync(); + + std::string lang; + if (!general.lookupValue("lang", lang)) { + LOG(ERROR) << _("Could not read properly from configure file"); + }; + + LOG(INFO) << "lang" << lang; + + // GNU gettext settings + setlocale(LC_ALL, lang.c_str()); + bindtextdomain(PROJECT_NAME, + GlobalSettingStation::GetInstance().GetLocaleDir().c_str()); + textdomain(PROJECT_NAME); } diff --git a/src/server/BaseAPI.cpp b/src/server/BaseAPI.cpp index be388df9..aa4c3f98 100644 --- a/src/server/BaseAPI.cpp +++ b/src/server/BaseAPI.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,48 +23,47 @@ */ #include "server/BaseAPI.h" + #include "rapidjson/writer.h" -BaseAPI::BaseAPI(ComUtils::ServiceType serviceType) : utils(new ComUtils(nullptr)), - reqUrl(utils->getUrl(serviceType)), request(reqUrl) { - request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); +BaseAPI::BaseAPI(ComUtils::ServiceType serviceType) + : utils(new ComUtils(nullptr)), + reqUrl(utils->getUrl(serviceType)), + request(reqUrl) { + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); } -BaseAPI::~BaseAPI() { - utils->deleteLater(); -} +BaseAPI::~BaseAPI() { utils->deleteLater(); } QNetworkReply *BaseAPI::send_json_data() { - rapidjson::StringBuffer sb; - rapidjson::Writer<rapidjson::StringBuffer> writer(sb); - document.Accept(writer); + rapidjson::StringBuffer sb; + rapidjson::Writer<rapidjson::StringBuffer> writer(sb); + document.Accept(writer); - QByteArray postData(sb.GetString()); - qDebug() << "postData" << QString::fromUtf8(postData); + QByteArray postData(sb.GetString()); + qDebug() << "postData" << QString::fromUtf8(postData); - auto reply = utils->getNetworkManager().post(request, postData); + auto reply = utils->getNetworkManager().post(request, postData); - while (reply->isRunning()) QApplication::processEvents(); + while (reply->isRunning()) QApplication::processEvents(); - QByteArray replyData = reply->readAll().constData(); - if (utils->checkServerReply(replyData)) { - good = true, deal_reply(); - } + QByteArray replyData = reply->readAll().constData(); + if (utils->checkServerReply(replyData)) { + good = true, deal_reply(); + } - return reply; + return reply; } void BaseAPI::start() { - construct_json(); - send_json_data()->deleteLater(); + construct_json(); + send_json_data()->deleteLater(); } void BaseAPI::refresh() { - document.Clear(); - utils->clear(); - good = false; + document.Clear(); + utils->clear(); + good = false; } -bool BaseAPI::result() const { - return good; -} +bool BaseAPI::result() const { return good; } diff --git a/src/server/BaseAPI.h b/src/server/BaseAPI.h index 0b724bbc..46766fed 100644 --- a/src/server/BaseAPI.h +++ b/src/server/BaseAPI.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,49 +25,42 @@ #ifndef GPGFRONTEND_ZH_CN_TS_BASEAPI_H #define GPGFRONTEND_ZH_CN_TS_BASEAPI_H -#include "GpgFrontend.h" #include "ComUtils.h" - +#include "GpgFrontend.h" #include "rapidjson/document.h" class BaseAPI : public QObject { -Q_OBJECT -public: - - explicit BaseAPI(ComUtils::ServiceType serviceType); - - ~BaseAPI() override; + Q_OBJECT + public: + explicit BaseAPI(ComUtils::ServiceType serviceType); - void start(); + ~BaseAPI() override; - void refresh(); + void start(); - [[nodiscard]] bool result() const; + void refresh(); -private: + [[nodiscard]] bool result() const; - ComUtils *utils; + private: + ComUtils *utils; - QUrl reqUrl; + QUrl reqUrl; - QNetworkRequest request; + QNetworkRequest request; - QNetworkReply *send_json_data(); + QNetworkReply *send_json_data(); -protected: + protected: + bool good = false; - bool good = false; + rapidjson::Document document; - rapidjson::Document document; - - const ComUtils &getUtils() { return *utils; }; - - virtual void construct_json() = 0; - - virtual void deal_reply() = 0; + const ComUtils &getUtils() { return *utils; }; + virtual void construct_json() = 0; + virtual void deal_reply() = 0; }; - -#endif //GPGFRONTEND_ZH_CN_TS_BASEAPI_H +#endif // GPGFRONTEND_ZH_CN_TS_BASEAPI_H diff --git a/src/server/ComUtils.cpp b/src/server/ComUtils.cpp index bbcc873c..6a5ce7b0 100644 --- a/src/server/ComUtils.cpp +++ b/src/server/ComUtils.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -30,66 +30,70 @@ * @return if successful */ bool GpgFrontend::ComUtils::checkServerReply(const QByteArray &reply) { - - if(reply.isEmpty()) { - QMessageBox::critical(this, tr("Error"), tr("Nothing Reply. Please check the Internet connection.")); - return false; + if (reply.isEmpty()) { + QMessageBox::critical( + this, _("Error"), + _("Nothing Reply. Please check the Internet connection.")); + return false; + } + + qDebug() << "Reply" << reply; + + /** + * Server Reply Format(Except Timeout) + * { + * "status": 200, + * "msg": "OK", + * "timestamp": 1628652783895 + * "data" : { + * ... + * } + * } + */ + + // check if reply is a json object + if (replyDoc.Parse(reply).HasParseError() || !replyDoc.IsObject()) { + QMessageBox::critical(this, _("Error"), _("Unknown Error")); + return false; + } + + // check status(int) and message(string) + if (replyDoc.HasMember("status") && replyDoc.HasMember("msg") && + replyDoc.HasMember("timestamp") && replyDoc.HasMember("data") && + replyDoc["status"].IsNumber() && replyDoc["msg"].IsString() && + replyDoc["timestamp"].IsNumber() && replyDoc["data"].IsObject()) { + int status = replyDoc["status"].GetInt(); + QDateTime time; + time.setMSecsSinceEpoch(replyDoc["timestamp"].GetInt64()); + auto message = replyDoc["msg"].GetString(); + dataVal = replyDoc["data"].GetObject(); + + qDebug() << "Reply Date & Time" << time; + + // check reply timestamp + if (time < QDateTime::currentDateTime().addSecs(-10)) { + QMessageBox::critical(this, _("Network Error"), _("Outdated Reply")); + return false; } - qDebug() << "Reply" << reply; - - /** - * Server Reply Format(Except Timeout) - * { - * "status": 200, - * "msg": "OK", - * "timestamp": 1628652783895 - * "data" : { - * ... - * } - * } - */ - - // check if reply is a json object - if (replyDoc.Parse(reply).HasParseError() || !replyDoc.IsObject()) { - QMessageBox::critical(this, tr("Error"), tr("Unknown Error")); - return false; + // check status code if successful (200-299) + // check data object + if (status / 100 == 2) { + is_good = true; + return true; + } else { + if (dataVal.HasMember("exceptionMessage") && + dataVal["exceptionMessage"].IsString()) + QMessageBox::critical(this, message, + dataVal["exceptionMessage"].GetString()); + else + QMessageBox::critical(this, message, _("Unknown Reason")); } - // check status(int) and message(string) - if (replyDoc.HasMember("status") && replyDoc.HasMember("msg") && replyDoc.HasMember("timestamp") && - replyDoc.HasMember("data") - && replyDoc["status"].IsNumber() && replyDoc["msg"].IsString() && replyDoc["timestamp"].IsNumber() && - replyDoc["data"].IsObject()) { - - int status = replyDoc["status"].GetInt(); - QDateTime time; - time.setMSecsSinceEpoch(replyDoc["timestamp"].GetInt64()); - auto message = replyDoc["msg"].GetString(); - dataVal = replyDoc["data"].GetObject(); - - qDebug() << "Reply Date & Time" << time; - - // check reply timestamp - if (time < QDateTime::currentDateTime().addSecs(-10)) { - QMessageBox::critical(this, tr("Network Error"), tr("Outdated Reply")); - return false; - } - - // check status code if successful (200-299) - // check data object - if (status / 100 == 2) { - is_good = true; - return true; - } else { - if (dataVal.HasMember("exceptionMessage") && dataVal["exceptionMessage"].IsString()) - QMessageBox::critical(this, message, dataVal["exceptionMessage"].GetString()); - else QMessageBox::critical(this, message, tr("Unknown Reason")); - } - - } else QMessageBox::critical(this, tr("Network Error"), tr("Unknown Reply Format")); + } else + QMessageBox::critical(this, _("Network Error"), _("Unknown Reply Format")); - return false; + return false; } /** @@ -98,12 +102,14 @@ bool GpgFrontend::ComUtils::checkServerReply(const QByteArray &reply) { * @return value in string format */ QString GpgFrontend::ComUtils::getDataValueStr(const QString &key) const { - if (is_good) { - auto k_byte_array = key.toUtf8(); - if (dataVal.HasMember(k_byte_array.data())) { - return dataVal[k_byte_array.data()].GetString(); - } else return {}; - } else return {}; + if (is_good) { + auto k_byte_array = key.toUtf8(); + if (dataVal.HasMember(k_byte_array.data())) { + return dataVal[k_byte_array.data()].GetString(); + } else + return {}; + } else + return {}; } /** @@ -112,86 +118,96 @@ QString GpgFrontend::ComUtils::getDataValueStr(const QString &key) const { * @return url */ QString GpgFrontend::ComUtils::getUrl(ComUtils::ServiceType type) const { - auto host = settings.value("general/currentGpgfrontendServer", - "service.gpgfrontend.pub").toString(); - - auto protocol = QString(); - // Localhost Debug Server - if (host == "localhost") protocol = "http://"; - else protocol = "https://"; - - auto url = protocol + host + ":9049/"; - - switch (type) { - case GetServiceToken: - url += "/user"; - break; - case ShortenCryptText: - url += "/text/new"; - break; - case GetFullCryptText: - url += "/text/get"; - break; - case UploadPubkey: - url += "/key/upload"; - break; - case GetPubkey: - url += "/key/get"; - break; - } - - qDebug() << "ComUtils getUrl" << url; - - return url; + auto host = + settings + .value("general/currentGpgfrontendServer", "service.gpgfrontend.pub") + .toString(); + + auto protocol = QString(); + // Localhost Debug Server + if (host == "localhost") + protocol = "http://"; + else + protocol = "https://"; + + auto url = protocol + host + ":9049/"; + + switch (type) { + case GetServiceToken: + url += "/user"; + break; + case ShortenCryptText: + url += "/text/new"; + break; + case GetFullCryptText: + url += "/text/get"; + break; + case UploadPubkey: + url += "/key/upload"; + break; + case GetPubkey: + url += "/key/get"; + break; + } + + qDebug() << "ComUtils getUrl" << url; + + return url; } bool GpgFrontend::ComUtils::checkDataValueStr(const QString &key) const { - auto key_byte_array_data = key.toUtf8().constData(); - if (is_good) { - return dataVal.HasMember(key_byte_array_data) && dataVal[key_byte_array_data].IsString(); - } else return false; + auto key_byte_array_data = key.toUtf8().constData(); + if (is_good) { + return dataVal.HasMember(key_byte_array_data) && + dataVal[key_byte_array_data].IsString(); + } else + return false; } bool GpgFrontend::ComUtils::checkServiceTokenFormat(const QString &uuid) const { - return re_uuid.match(uuid).hasMatch(); + return re_uuid.match(uuid).hasMatch(); } -QByteArray GpgFrontend::ComUtils::getSignStringBase64(GpgFrontend::GpgContext *ctx, const QString &str, const GpgKey &key) { - std::vector<GpgKey> keys{key}; - QByteArray outSignText; - auto signData = str.toUtf8(); - - // The use of multi-threading brings an improvement in UI smoothness - gpgme_error_t error; - auto thread = QThread::create([&]() { - error = ctx->sign(keys, signData, &outSignText, GPGME_SIG_MODE_NORMAL, nullptr, false); - }); - thread->start(); - while (thread->isRunning()) QApplication::processEvents(); - thread->deleteLater(); - - return outSignText.toBase64(); +QByteArray GpgFrontend::ComUtils::getSignStringBase64( + GpgFrontend::GpgContext *ctx, const QString &str, const GpgKey &key) { + std::vector<GpgKey> keys{key}; + QByteArray outSignText; + auto signData = str.toUtf8(); + + // The use of multi-threading brings an improvement in UI smoothness + gpgme_error_t error; + auto thread = QThread::create([&]() { + error = ctx->sign(keys, signData, &outSignText, GPGME_SIG_MODE_NORMAL, + nullptr, false); + }); + thread->start(); + while (thread->isRunning()) QApplication::processEvents(); + thread->deleteLater(); + + return outSignText.toBase64(); } -const rapidjson::Value &GpgFrontend::ComUtils::getDataValue(const QString &key) const { - if (is_good) { - auto k_byte_array = key.toUtf8(); - if (dataVal.HasMember(k_byte_array.data())) { - return dataVal[k_byte_array.data()]; - } +const rapidjson::Value &GpgFrontend::ComUtils::getDataValue( + const QString &key) const { + if (is_good) { + auto k_byte_array = key.toUtf8(); + if (dataVal.HasMember(k_byte_array.data())) { + return dataVal[k_byte_array.data()]; } - throw std::runtime_error("Inner Error"); + } + throw std::runtime_error("Inner Error"); } -bool GpgFrontend::ComUtils::checkDataValue(const QString &key) const{ - auto key_byte_array_data = key.toUtf8().constData(); - if (is_good) { - return dataVal.HasMember(key_byte_array_data); - } else return false; +bool GpgFrontend::ComUtils::checkDataValue(const QString &key) const { + auto key_byte_array_data = key.toUtf8().constData(); + if (is_good) { + return dataVal.HasMember(key_byte_array_data); + } else + return false; } void GpgFrontend::ComUtils::clear() { - this->dataVal.Clear(); - this->replyDoc.Clear(); - is_good = false; + this->dataVal.Clear(); + this->replyDoc.Clear(); + is_good = false; }
\ No newline at end of file diff --git a/src/server/ComUtils.h b/src/server/ComUtils.h index 1f71f2e6..f281f256 100644 --- a/src/server/ComUtils.h +++ b/src/server/ComUtils.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -31,53 +31,58 @@ namespace GpgFrontend { - class ComUtils : public QWidget { - Q_OBJECT - public: - - enum ServiceType { GetServiceToken, ShortenCryptText, GetFullCryptText, UploadPubkey, GetPubkey }; - - explicit ComUtils(QWidget *parent) : QWidget(parent), appPath(qApp->applicationDirPath()), +class ComUtils : public QWidget { + Q_OBJECT + public: + enum ServiceType { + GetServiceToken, + ShortenCryptText, + GetFullCryptText, + UploadPubkey, + GetPubkey + }; + + explicit ComUtils(QWidget *parent) + : QWidget(parent), + appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", - QSettings::IniFormat) { - - } - - [[nodiscard]] QString getUrl(ServiceType type) const; - - bool checkServerReply(const QByteArray &reply); + QSettings::IniFormat) {} - [[nodiscard]] QString getDataValueStr(const QString &key) const; + [[nodiscard]] QString getUrl(ServiceType type) const; - [[nodiscard]] bool checkDataValueStr(const QString &key) const; + bool checkServerReply(const QByteArray &reply); - [[nodiscard]] const rapidjson::Value &getDataValue(const QString &key) const; + [[nodiscard]] QString getDataValueStr(const QString &key) const; - [[nodiscard]] bool checkDataValue(const QString &key) const; + [[nodiscard]] bool checkDataValueStr(const QString &key) const; - [[nodiscard]] bool checkServiceTokenFormat(const QString& serviceToken) const; + [[nodiscard]] const rapidjson::Value &getDataValue(const QString &key) const; - static QByteArray getSignStringBase64(GpgFrontend::GpgContext *ctx, const QString &str, const GpgKey& key); + [[nodiscard]] bool checkDataValue(const QString &key) const; - [[nodiscard]] bool good() const { return is_good; } + [[nodiscard]] bool checkServiceTokenFormat(const QString &serviceToken) const; - QNetworkAccessManager &getNetworkManager() {return networkMgr;} + static QByteArray getSignStringBase64(GpgFrontend::GpgContext *ctx, + const QString &str, const GpgKey &key); - void clear(); + [[nodiscard]] bool good() const { return is_good; } - private: + QNetworkAccessManager &getNetworkManager() { return networkMgr; } - QString appPath; - QSettings settings; - rapidjson::Document replyDoc; - rapidjson::Value dataVal; - QNetworkAccessManager networkMgr; - QRegularExpression re_uuid{R"(\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b)"}; + void clear(); - bool is_good = false; - }; + private: + QString appPath; + QSettings settings; + rapidjson::Document replyDoc; + rapidjson::Value dataVal; + QNetworkAccessManager networkMgr; + QRegularExpression re_uuid{ + R"(\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b)"}; -} + bool is_good = false; +}; +} // namespace GpgFrontend -#endif //GPGFRONTEND_ZH_CN_TS_COMUTILS_H +#endif // GPGFRONTEND_ZH_CN_TS_COMUTILS_H diff --git a/src/server/api/PubkeyGetter.cpp b/src/server/api/PubkeyGetter.cpp index 6505cb3e..e2cb8708 100644 --- a/src/server/api/PubkeyGetter.cpp +++ b/src/server/api/PubkeyGetter.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,73 +24,72 @@ #include "server/api/PubkeyGetter.h" -PubkeyGetter::PubkeyGetter(GpgFrontend::GpgContext *ctx, const QVector<QString> &fprs) : BaseAPI(ComUtils::GetPubkey), - mCtx(ctx), mFprs(fprs) { -} +PubkeyGetter::PubkeyGetter(GpgFrontend::GpgContext *ctx, + const QVector<QString> &fprs) + : BaseAPI(ComUtils::GetPubkey), mCtx(ctx), mFprs(fprs) {} void PubkeyGetter::construct_json() { - document.SetArray(); - QStringList keyIds; + document.SetArray(); + QStringList keyIds; - rapidjson::Document::AllocatorType &allocator = document.GetAllocator(); + rapidjson::Document::AllocatorType &allocator = document.GetAllocator(); - for (const auto &fprStr : mFprs) { - rapidjson::Value fpr; + for (const auto &fprStr : mFprs) { + rapidjson::Value fpr; - auto fprByteArray = fprStr.toUtf8(); - fpr.SetString(fprByteArray.constData(), fprByteArray.count()); + auto fprByteArray = fprStr.toUtf8(); + fpr.SetString(fprByteArray.constData(), fprByteArray.count()); - document.PushBack(fpr, allocator); - keyIds.clear(); - } + document.PushBack(fpr, allocator); + keyIds.clear(); + } } void PubkeyGetter::deal_reply() { + const auto &utils = getUtils(); + + /** + * { + * "pubkeys" : [ + * { + * "publicKey" : ..., + * "fpr" : ..., + * "sha" : ... + * }, + * ... + * ] + * } + */ + + if (!utils.checkDataValue("pubkeys")) { + QMessageBox::critical(nullptr, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); + } else { + auto &pubkeys = utils.getDataValue("pubkeys"); + qDebug() << "Pubkey Getter" << pubkeys.IsArray() + << pubkeys.GetArray().Size(); + if (pubkeys.IsArray()) { + for (const auto &pubkey : pubkeys.GetArray()) { + if (pubkey.IsObject() && pubkey.HasMember("publicKey") && + pubkey.HasMember("fpr") && pubkey.HasMember("sha") && + pubkey["publicKey"].IsString() && pubkey["fpr"].IsString() && + pubkey["sha"].IsString()) { + auto pubkeyData = QString(pubkey["publicKey"].GetString()); + + QCryptographicHash shaGen(QCryptographicHash::Sha256); + shaGen.addData(pubkeyData.toUtf8()); + + if (shaGen.result().toHex() == pubkey["sha"].GetString()) { + mCtx->importKey(pubkeyData.toUtf8()); + } + } + } - const auto &utils = getUtils(); - - /** - * { - * "pubkeys" : [ - * { - * "publicKey" : ..., - * "fpr" : ..., - * "sha" : ... - * }, - * ... - * ] - * } - */ - - if (!utils.checkDataValue("pubkeys")) { - QMessageBox::critical(nullptr, tr("Error"), - tr("The communication content with the server does not meet the requirements")); } else { - auto &pubkeys = utils.getDataValue("pubkeys"); - qDebug() << "Pubkey Getter" << pubkeys.IsArray() << pubkeys.GetArray().Size(); - if (pubkeys.IsArray()) { - for (const auto &pubkey : pubkeys.GetArray()) { - if (pubkey.IsObject() - && pubkey.HasMember("publicKey") && pubkey.HasMember("fpr") && pubkey.HasMember("sha") - && pubkey["publicKey"].IsString() && pubkey["fpr"].IsString() && pubkey["sha"].IsString()) { - - auto pubkeyData = QString(pubkey["publicKey"].GetString()); - - QCryptographicHash shaGen(QCryptographicHash::Sha256); - shaGen.addData(pubkeyData.toUtf8()); - - if (shaGen.result().toHex() == pubkey["sha"].GetString()) { - mCtx->importKey(pubkeyData.toUtf8()); - } - - } - } - - } else { - QMessageBox::critical(nullptr, tr("Error"), - tr("The communication content with the server does not meet the requirements")); - } + QMessageBox::critical(nullptr, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); } + } } - - diff --git a/src/server/api/PubkeyGetter.h b/src/server/api/PubkeyGetter.h index 216b1ef2..6a3d50e9 100644 --- a/src/server/api/PubkeyGetter.h +++ b/src/server/api/PubkeyGetter.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -26,8 +26,8 @@ #define GPGFRONTEND_ZH_CN_TS_PUBKEYGETTER_H #include "GpgFrontend.h" -#include "server/BaseAPI.h" #include "gpg/GpgContext.h" +#include "server/BaseAPI.h" class ComUtils; @@ -35,23 +35,18 @@ class ComUtils; * Get and Import Pubkey from server */ class PubkeyGetter : public BaseAPI { -public: - - PubkeyGetter(GpgFrontend::GpgContext *ctx, const QVector<QString> &fprs); - -private: + public: + PubkeyGetter(GpgFrontend::GpgContext *ctx, const QVector<QString> &fprs); - GpgFrontend::GpgContext *mCtx; + private: + GpgFrontend::GpgContext *mCtx; - const QVector<QString> &mFprs; + const QVector<QString> &mFprs; -protected: - - void construct_json() final; - - void deal_reply() final; + protected: + void construct_json() final; + void deal_reply() final; }; - -#endif //GPGFRONTEND_ZH_CN_TS_PUBKEYGETTER_H +#endif // GPGFRONTEND_ZH_CN_TS_PUBKEYGETTER_H diff --git a/src/server/api/PubkeyUploader.cpp b/src/server/api/PubkeyUploader.cpp index 2842c2d7..35f764d8 100644 --- a/src/server/api/PubkeyUploader.cpp +++ b/src/server/api/PubkeyUploader.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,83 +24,83 @@ #include "server/api/PubkeyUploader.h" -PubkeyUploader::PubkeyUploader(GpgFrontend::GpgContext *ctx, const QVector<GpgKey> &keys) : BaseAPI(ComUtils::UploadPubkey), - mCtx(ctx), - mKeys(keys) { -} +PubkeyUploader::PubkeyUploader(GpgFrontend::GpgContext *ctx, + const QVector<GpgKey> &keys) + : BaseAPI(ComUtils::UploadPubkey), mCtx(ctx), mKeys(keys) {} void PubkeyUploader::construct_json() { - document.SetArray(); - QStringList keyIds; - QCryptographicHash shaGen(QCryptographicHash::Sha256); - - auto &allocator = document.GetAllocator(); - - QVector<QByteArray> keysData; - for (const auto &key : mKeys) { - QByteArray keyDataBuf; - keyIds << key.id; - - // The use of multi-threading brings an improvement in UI smoothness - gpgme_error_t error; - auto thread = QThread::create([&]() { - error = mCtx->exportKeys(&keyIds, &keyDataBuf); - }); - thread->start(); - while (thread->isRunning()) QApplication::processEvents(); - thread->deleteLater(); - keysData.push_back(keyDataBuf); - keyIds.clear(); - } - - int index = 0; - for (const auto &keyData : keysData) { - rapidjson::Value publicKeyObj, pubkey, sha, signedFpr; - - shaGen.addData(keyData); - auto shaStr = shaGen.result().toHex(); - shaGen.reset(); - - auto signFprStr = ComUtils::getSignStringBase64(mCtx, mKeys[index].fpr, mKeys[index]); - qDebug() << "signFprStr" << signFprStr; - - pubkey.SetString(keyData.data(), keyData.count(), allocator); - sha.SetString(shaStr.data(), shaStr.count(), allocator); - signedFpr.SetString(signFprStr.data(), signFprStr.count(), allocator); - - publicKeyObj.SetObject(); - publicKeyObj.AddMember("publicKey", pubkey, allocator); - publicKeyObj.AddMember("sha", sha, allocator); - publicKeyObj.AddMember("signedFpr", signedFpr, allocator); - - document.PushBack(publicKeyObj, allocator); - index++; - } + document.SetArray(); + QStringList keyIds; + QCryptographicHash shaGen(QCryptographicHash::Sha256); + + auto &allocator = document.GetAllocator(); + + QVector<QByteArray> keysData; + for (const auto &key : mKeys) { + QByteArray keyDataBuf; + keyIds << key.id; + + // The use of multi-threading brings an improvement in UI smoothness + gpgme_error_t error; + auto thread = QThread::create( + [&]() { error = mCtx->exportKeys(&keyIds, &keyDataBuf); }); + thread->start(); + while (thread->isRunning()) QApplication::processEvents(); + thread->deleteLater(); + keysData.push_back(keyDataBuf); + keyIds.clear(); + } + + int index = 0; + for (const auto &keyData : keysData) { + rapidjson::Value publicKeyObj, pubkey, sha, signedFpr; + + shaGen.addData(keyData); + auto shaStr = shaGen.result().toHex(); + shaGen.reset(); + + auto signFprStr = + ComUtils::getSignStringBase64(mCtx, mKeys[index].fpr, mKeys[index]); + qDebug() << "signFprStr" << signFprStr; + + pubkey.SetString(keyData.data(), keyData.count(), allocator); + sha.SetString(shaStr.data(), shaStr.count(), allocator); + signedFpr.SetString(signFprStr.data(), signFprStr.count(), allocator); + + publicKeyObj.SetObject(); + publicKeyObj.AddMember("publicKey", pubkey, allocator); + publicKeyObj.AddMember("sha", sha, allocator); + publicKeyObj.AddMember("signedFpr", signedFpr, allocator); + + document.PushBack(publicKeyObj, allocator); + index++; + } } void PubkeyUploader::deal_reply() { - - const auto &utils = getUtils(); - - /** - * { - * "strings" : [ - * "...", - * "..." - * ] - * } - */ - - if (!utils.checkDataValue("strings")) { - QMessageBox::critical(nullptr, tr("Error"), - tr("The communication content with the server does not meet the requirements")); + const auto &utils = getUtils(); + + /** + * { + * "strings" : [ + * "...", + * "..." + * ] + * } + */ + + if (!utils.checkDataValue("strings")) { + QMessageBox::critical(nullptr, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); + } else { + auto &strings = utils.getDataValue("strings"); + qDebug() << "Pubkey Uploader" << strings.IsArray() + << strings.GetArray().Size(); + if (strings.IsArray() && strings.GetArray().Size() == mKeys.size()) { + good = true; } else { - auto &strings = utils.getDataValue("strings"); - qDebug() << "Pubkey Uploader" << strings.IsArray() << strings.GetArray().Size(); - if (strings.IsArray() && strings.GetArray().Size() == mKeys.size()) { - good = true; - } else { - good = false; - } + good = false; } + } } diff --git a/src/server/api/PubkeyUploader.h b/src/server/api/PubkeyUploader.h index 61096d46..efad27ac 100644 --- a/src/server/api/PubkeyUploader.h +++ b/src/server/api/PubkeyUploader.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -26,33 +26,26 @@ #define GPGFRONTEND_ZH_CN_TS_PUBKEYUPLOADER_H #include "GpgFrontend.h" -#include "server/BaseAPI.h" #include "gpg/GpgContext.h" - #include "rapidjson/document.h" +#include "server/BaseAPI.h" /** * Upload pubkey into server */ class PubkeyUploader : public BaseAPI { -public: - - PubkeyUploader(GpgFrontend::GpgContext *ctx, const QVector<GpgKey> &keys); - -private: + public: + PubkeyUploader(GpgFrontend::GpgContext *ctx, const QVector<GpgKey> &keys); - const QVector<GpgKey> &mKeys; + private: + const QVector<GpgKey> &mKeys; - GpgFrontend::GpgContext *mCtx; - -protected: - - void construct_json() final; - - void deal_reply() final; + GpgFrontend::GpgContext *mCtx; + protected: + void construct_json() final; + void deal_reply() final; }; - -#endif //GPGFRONTEND_ZH_CN_TS_PUBKEYUPLOADER_H +#endif // GPGFRONTEND_ZH_CN_TS_PUBKEYUPLOADER_H diff --git a/src/smtp/mimemessage.cpp b/src/smtp/mimemessage.cpp index cf653e0a..6c058e89 100644 --- a/src/smtp/mimemessage.cpp +++ b/src/smtp/mimemessage.cpp @@ -17,26 +17,26 @@ */ #include "smtp/mimemessage.h" -#include "smtp/quotedprintable.h" #include <QDateTime> #include <QLocale> #include <typeinfo> +#include "smtp/quotedprintable.h" + /* [1] Constructors and Destructors */ MimeMessage::MimeMessage(bool createAutoMimeContent) - : replyTo(nullptr), hEncoding(MimePart::_8Bit) { - if (createAutoMimeContent) - this->content = new MimeMultiPart(); + : replyTo(nullptr), hEncoding(MimePart::_8Bit) { + if (createAutoMimeContent) this->content = new MimeMultiPart(); - autoMimeContentCreated = createAutoMimeContent; + autoMimeContentCreated = createAutoMimeContent; } MimeMessage::~MimeMessage() { - if (this->autoMimeContentCreated) { - this->autoMimeContentCreated = false; - delete (this->content); - } + if (this->autoMimeContentCreated) { + this->autoMimeContentCreated = false; + delete (this->content); + } } /* [1] --- */ @@ -45,34 +45,34 @@ MimeMessage::~MimeMessage() { MimePart &MimeMessage::getContent() { return *content; } void MimeMessage::setContent(MimePart *content) { - if (this->autoMimeContentCreated) { - this->autoMimeContentCreated = false; - delete (this->content); - } - this->content = content; + if (this->autoMimeContentCreated) { + this->autoMimeContentCreated = false; + delete (this->content); + } + this->content = content; } void MimeMessage::setReplyTo(EmailAddress *rto) { replyTo = rto; } void MimeMessage::setSender(EmailAddress *e) { - this->sender = e; - e->setParent(this); + this->sender = e; + e->setParent(this); } void MimeMessage::addRecipient(EmailAddress *rcpt, RecipientType type) { - switch (type) { - case To: - recipientsTo << rcpt; - break; - case Cc: - recipientsCc << rcpt; - break; - case Bcc: - recipientsBcc << rcpt; - break; - } - - rcpt->setParent(this); + switch (type) { + case To: + recipientsTo << rcpt; + break; + case Cc: + recipientsCc << rcpt; + break; + case Bcc: + recipientsBcc << rcpt; + break; + } + + rcpt->setParent(this); } void MimeMessage::addTo(EmailAddress *rcpt) { this->recipientsTo << rcpt; } @@ -82,36 +82,36 @@ void MimeMessage::addCc(EmailAddress *rcpt) { this->recipientsCc << rcpt; } void MimeMessage::addBcc(EmailAddress *rcpt) { this->recipientsBcc << rcpt; } void MimeMessage::setSubject(const QString &subject) { - this->subject = subject; + this->subject = subject; } void MimeMessage::addPart(MimePart *part) { - if (typeid(*content) == typeid(MimeMultiPart)) { - ((MimeMultiPart *) content)->addPart(part); - }; + if (typeid(*content) == typeid(MimeMultiPart)) { + ((MimeMultiPart *)content)->addPart(part); + }; } void MimeMessage::setInReplyTo(const QString &inReplyTo) { - mInReplyTo = inReplyTo; + mInReplyTo = inReplyTo; } void MimeMessage::setHeaderEncoding(MimePart::Encoding hEnc) { - this->hEncoding = hEnc; + this->hEncoding = hEnc; } const EmailAddress &MimeMessage::getSender() const { return *sender; } -const QList<EmailAddress *> & -MimeMessage::getRecipients(RecipientType type) const { - switch (type) { - default: - case To: - return recipientsTo; - case Cc: - return recipientsCc; - case Bcc: - return recipientsBcc; - } +const QList<EmailAddress *> &MimeMessage::getRecipients( + RecipientType type) const { + switch (type) { + default: + case To: + return recipientsTo; + case Cc: + return recipientsCc; + case Bcc: + return recipientsBcc; + } } const EmailAddress *MimeMessage::getReplyTo() const { return replyTo; } @@ -119,13 +119,13 @@ const EmailAddress *MimeMessage::getReplyTo() const { return replyTo; } const QString &MimeMessage::getSubject() const { return subject; } const QList<MimePart *> &MimeMessage::getParts() const { - if (typeid(*content) == typeid(MimeMultiPart)) { - return ((MimeMultiPart *) content)->getParts(); - } else { - auto *res = new QList<MimePart *>(); - res->append(content); - return *res; - } + if (typeid(*content) == typeid(MimeMultiPart)) { + return ((MimeMultiPart *)content)->getParts(); + } else { + auto *res = new QList<MimePart *>(); + res->append(content); + return *res; + } } /* [2] --- */ @@ -133,176 +133,180 @@ const QList<MimePart *> &MimeMessage::getParts() const { /* [3] Public Methods */ QString MimeMessage::toString() { - QString mime; - - /* =========== MIME HEADER ============ */ - - /* ---------- Sender / From ----------- */ - mime = "From:"; - if (sender->getName() != "") { - switch (hEncoding) { - case MimePart::Base64: - mime += " =?utf-8?B?" + - QByteArray().append(sender->getName().toUtf8()).toBase64() + "?="; - break; - case MimePart::QuotedPrintable: - mime += " =?utf-8?Q?" + - QuotedPrintable::encode( - QByteArray().append(sender->getName().toUtf8())) - .replace(' ', "_") - .replace(':', "=3A") + - "?="; - break; - default: - mime += " " + sender->getName(); - } + QString mime; + + /* =========== MIME HEADER ============ */ + + /* ---------- Sender / From ----------- */ + mime = "From:"; + if (!sender->getName().isEmpty()) { + switch (hEncoding) { + case MimePart::Base64: + mime += " =?utf-8?B?" + + QByteArray().append(sender->getName().toUtf8()).toBase64() + + "?="; + break; + case MimePart::QuotedPrintable: + mime += " =?utf-8?Q?" + + QuotedPrintable::encode( + QByteArray().append(sender->getName().toUtf8())) + .replace(' ', "_") + .replace(':', "=3A") + + "?="; + break; + default: + mime += " " + sender->getName(); } - mime += " <" + sender->getAddress() + ">\r\n"; - /* ---------------------------------- */ - - /* ------- Recipients / To ---------- */ - mime += "To:"; - QList<EmailAddress *>::iterator it; - int i; - for (i = 0, it = recipientsTo.begin(); it != recipientsTo.end(); ++it, ++i) { - if (i != 0) { - mime += ","; - } - - if ((*it)->getName() != "") { - switch (hEncoding) { - case MimePart::Base64: - mime += " =?utf-8?B?" + - QByteArray().append((*it)->getName().toUtf8()).toBase64() + - "?="; - break; - case MimePart::QuotedPrintable: - mime += " =?utf-8?Q?" + - QuotedPrintable::encode( - QByteArray().append((*it)->getName().toUtf8())) - .replace(' ', "_") - .replace(':', "=3A") + - "?="; - break; - default: - mime += " " + (*it)->getName(); - } - } - mime += " <" + (*it)->getAddress() + ">"; + } + mime += " <" + sender->getAddress() + ">\r\n"; + /* ---------------------------------- */ + + /* ------- Recipients / To ---------- */ + mime += "To:"; + QList<EmailAddress *>::iterator it; + int i; + for (i = 0, it = recipientsTo.begin(); it != recipientsTo.end(); ++it, ++i) { + if (i != 0) { + mime += ","; } - mime += "\r\n"; - /* ---------------------------------- */ - /* ------- Recipients / Cc ---------- */ - if (!recipientsCc.empty()) { - mime += "Cc:"; - } - for (i = 0, it = recipientsCc.begin(); it != recipientsCc.end(); ++it, ++i) { - if (i != 0) { - mime += ","; - } - - if ((*it)->getName() != "") { - switch (hEncoding) { - case MimePart::Base64: - mime += " =?utf-8?B?" + - QByteArray().append((*it)->getName().toUtf8()).toBase64() + - "?="; - break; - case MimePart::QuotedPrintable: - mime += " =?utf-8?Q?" + - QuotedPrintable::encode( - QByteArray().append((*it)->getName().toUtf8())) - .replace(' ', "_") - .replace(':', "=3A") + - "?="; - break; - default: - mime += " " + (*it)->getName(); - } - } - mime += " <" + (*it)->getAddress() + ">"; + if (!(*it)->getName().isEmpty()) { + switch (hEncoding) { + case MimePart::Base64: + mime += " =?utf-8?B?" + + QByteArray().append((*it)->getName().toUtf8()).toBase64() + + "?="; + break; + case MimePart::QuotedPrintable: + mime += " =?utf-8?Q?" + + QuotedPrintable::encode( + QByteArray().append((*it)->getName().toUtf8())) + .replace(' ', "_") + .replace(':', "=3A") + + "?="; + break; + default: + mime += " " + (*it)->getName(); + } } - if (!recipientsCc.empty()) { - mime += "\r\n"; + mime += " <" + (*it)->getAddress() + ">"; + } + mime += "\r\n"; + /* ---------------------------------- */ + + /* ------- Recipients / Cc ---------- */ + if (!recipientsCc.empty()) { + mime += "Cc:"; + } + for (i = 0, it = recipientsCc.begin(); it != recipientsCc.end(); ++it, ++i) { + if (i != 0) { + mime += ","; } - /* ---------------------------------- */ - /* ------------ Subject ------------- */ - mime += "Subject: "; - - switch (hEncoding) { + if ((*it)->getName() != "") { + switch (hEncoding) { case MimePart::Base64: - mime += "=?utf-8?B?" + QByteArray().append(subject.toUtf8()).toBase64() + "?="; - break; + mime += " =?utf-8?B?" + + QByteArray().append((*it)->getName().toUtf8()).toBase64() + + "?="; + break; case MimePart::QuotedPrintable: - mime += "=?utf-8?Q?" + - QuotedPrintable::encode(QByteArray().append(subject.toUtf8())) - .replace(' ', "_") - .replace(':', "=3A") + - "?="; - break; + mime += " =?utf-8?Q?" + + QuotedPrintable::encode( + QByteArray().append((*it)->getName().toUtf8())) + .replace(' ', "_") + .replace(':', "=3A") + + "?="; + break; default: - mime += subject; + mime += " " + (*it)->getName(); + } } + mime += " <" + (*it)->getAddress() + ">"; + } + if (!recipientsCc.empty()) { mime += "\r\n"; - /* ---------------------------------- */ - - /* ---------- Reply-To -------------- */ - if (replyTo) { - mime += "Reply-To: "; - if (replyTo->getName() != "") { - switch (hEncoding) { - case MimePart::Base64: - mime += " =?utf-8?B?" + - QByteArray().append(replyTo->getName().toUtf8()).toBase64() + "?="; - break; - case MimePart::QuotedPrintable: - mime += " =?utf-8?Q?" + - QuotedPrintable::encode(QByteArray().append(replyTo->getName().toUtf8())) - .replace(' ', "_") - .replace(':', "=3A") + - "?="; - break; - default: - mime += " " + replyTo->getName(); - } - } - mime += " <" + replyTo->getAddress() + ">\r\n"; - } - - /* ---------------------------------- */ - - mime += "MIME-Version: 1.0\r\n"; - if (!mInReplyTo.isEmpty()) { - mime += "In-Reply-To: <" + mInReplyTo + ">\r\n"; - mime += "References: <" + mInReplyTo + ">\r\n"; + } + /* ---------------------------------- */ + + /* ------------ Subject ------------- */ + mime += "Subject: "; + + switch (hEncoding) { + case MimePart::Base64: + mime += "=?utf-8?B?" + QByteArray().append(subject.toUtf8()).toBase64() + + "?="; + break; + case MimePart::QuotedPrintable: + mime += "=?utf-8?Q?" + + QuotedPrintable::encode(QByteArray().append(subject.toUtf8())) + .replace(' ', "_") + .replace(':', "=3A") + + "?="; + break; + default: + mime += subject; + } + mime += "\r\n"; + /* ---------------------------------- */ + + /* ---------- Reply-To -------------- */ + if (replyTo) { + mime += "Reply-To: "; + if (!replyTo->getName().isEmpty()) { + switch (hEncoding) { + case MimePart::Base64: + mime += " =?utf-8?B?" + + QByteArray().append(replyTo->getName().toUtf8()).toBase64() + + "?="; + break; + case MimePart::QuotedPrintable: + mime += " =?utf-8?Q?" + + QuotedPrintable::encode( + QByteArray().append(replyTo->getName().toUtf8())) + .replace(' ', "_") + .replace(':', "=3A") + + "?="; + break; + default: + mime += " " + replyTo->getName(); + } } - - QDateTime now = QDateTime::currentDateTime(); -#if QT_VERSION_MAJOR < 5 // Qt4 workaround since RFC2822Date isn't defined - QString shortDayName = - QLocale::c().dayName(now.date().dayOfWeek(), QLocale::ShortFormat); - QString shortMonthName = - QLocale::c().monthName(now.date().month(), QLocale::ShortFormat); - int utcOffset = now.secsTo(QDateTime(now.date(), now.time(), Qt::UTC)) / 60; - char timezoneSign = utcOffset >= 0 ? '+' : '-'; - utcOffset = utcOffset >= 0 ? utcOffset : -utcOffset; - QString timezone = QString("%1%2%3") - .arg(timezoneSign) - .arg(utcOffset / 60, 2, 10, QChar('0')) - .arg(utcOffset % 60, 2, 10, QChar('0')); - mime += QString("Date: %1\r\n") - .arg(now.toString("%1, dd %2 yyyy hh:mm:ss %3") - .arg(shortDayName) - .arg(shortMonthName) - .arg(timezone)); -#else // Qt5 supported - mime += QString("Date: %1\r\n").arg(now.toString(Qt::RFC2822Date)); -#endif // support RFC2822Date - - mime += content->toString(); - return mime; + mime += " <" + replyTo->getAddress() + ">\r\n"; + } + + /* ---------------------------------- */ + + mime += "MIME-Version: 1.0\r\n"; + if (!mInReplyTo.isEmpty()) { + mime += "In-Reply-To: <" + mInReplyTo + ">\r\n"; + mime += "References: <" + mInReplyTo + ">\r\n"; + } + + QDateTime now = QDateTime::currentDateTime(); +#if QT_VERSION_MAJOR < 5 // Qt4 workaround since RFC2822Date isn't defined + QString shortDayName = + QLocale::c().dayName(now.date().dayOfWeek(), QLocale::ShortFormat); + QString shortMonthName = + QLocale::c().monthName(now.date().month(), QLocale::ShortFormat); + int utcOffset = now.secsTo(QDateTime(now.date(), now.time(), Qt::UTC)) / 60; + char timezoneSign = utcOffset >= 0 ? '+' : '-'; + utcOffset = utcOffset >= 0 ? utcOffset : -utcOffset; + QString timezone = QString("%1%2%3") + .arg(timezoneSign) + .arg(utcOffset / 60, 2, 10, QChar('0')) + .arg(utcOffset % 60, 2, 10, QChar('0')); + mime += QString("Date: %1\r\n") + .arg(now.toString("%1, dd %2 yyyy hh:mm:ss %3") + .arg(shortDayName) + .arg(shortMonthName) + .arg(timezone)); +#else // Qt5 supported + mime += QString("Date: %1\r\n").arg(now.toString(Qt::RFC2822Date)); +#endif // support RFC2822Date + + mime += content->toString(); + return mime; } /* [3] --- */ diff --git a/src/smtp/mimemultipart.cpp b/src/smtp/mimemultipart.cpp index 14a813c2..4dd00d1a 100644 --- a/src/smtp/mimemultipart.cpp +++ b/src/smtp/mimemultipart.cpp @@ -17,30 +17,31 @@ */ #include "smtp/mimemultipart.h" + #include <QCryptographicHash> #include <QRandomGenerator> #include <QTime> const QString MULTI_PART_NAMES[] = { - "multipart/mixed", // Mixed - "multipart/digest", // Digest - "multipart/alternative", // Alternative - "multipart/related", // Related - "multipart/report", // Report - "multipart/signed", // Signed - "multipart/encrypted" // Encrypted + "multipart/mixed", // Mixed + "multipart/digest", // Digest + "multipart/alternative", // Alternative + "multipart/related", // Related + "multipart/report", // Report + "multipart/signed", // Signed + "multipart/encrypted" // Encrypted }; MimeMultiPart::MimeMultiPart(MultiPartType type) { - this->type = type; - this->cType = MULTI_PART_NAMES[this->type]; - this->cEncoding = _8Bit; + this->type = type; + this->cType = MULTI_PART_NAMES[this->type]; + this->cEncoding = _8Bit; - QRandomGenerator generator; + QRandomGenerator generator; - QCryptographicHash md5(QCryptographicHash::Md5); - md5.addData(QByteArray().append((char) generator.generate())); - cBoundary = md5.result().toHex(); + QCryptographicHash md5(QCryptographicHash::Md5); + md5.addData(QByteArray().append((char)generator.generate())); + cBoundary = md5.result().toHex(); } void MimeMultiPart::addPart(MimePart *part) { parts.append(part); } @@ -48,23 +49,23 @@ void MimeMultiPart::addPart(MimePart *part) { parts.append(part); } const QList<MimePart *> &MimeMultiPart::getParts() const { return parts; } void MimeMultiPart::prepare() { - QList<MimePart *>::iterator it; + QList<MimePart *>::iterator it; - content = ""; - for (it = parts.begin(); it != parts.end(); it++) { - content += QString("--" + cBoundary + "\r\n").toUtf8(); - (*it)->prepare(); - content += (*it)->toString().toUtf8(); - }; + content.clear(); + for (it = parts.begin(); it != parts.end(); it++) { + content += QString("--" + cBoundary + "\r\n").toUtf8(); + (*it)->prepare(); + content += (*it)->toString().toUtf8(); + }; - content += QString("--" + cBoundary + "--\r\n").toUtf8(); + content += QString("--" + cBoundary + "--\r\n").toUtf8(); - MimePart::prepare(); + MimePart::prepare(); } void MimeMultiPart::setMimeType(const MultiPartType type) { - this->type = type; - this->cType = MULTI_PART_NAMES[type]; + this->type = type; + this->cType = MULTI_PART_NAMES[type]; } MimeMultiPart::MultiPartType MimeMultiPart::getMimeType() const { return type; } diff --git a/src/smtp/mimepart.cpp b/src/smtp/mimepart.cpp index 5d33884d..10aa6cbc 100644 --- a/src/smtp/mimepart.cpp +++ b/src/smtp/mimepart.cpp @@ -17,14 +17,15 @@ */ #include "smtp/mimepart.h" + #include "smtp/quotedprintable.h" /* [1] Constructors and Destructors */ MimePart::MimePart() { - cEncoding = _7Bit; - prepared = false; - cBoundary = ""; + cEncoding = _7Bit; + prepared = false; + cBoundary.clear(); } /* [1] --- */ @@ -32,13 +33,13 @@ MimePart::MimePart() { /* [2] Getters and Setters */ void MimePart::setContent(const QByteArray &content) { - this->content = content; + this->content = content; } void MimePart::setHeader(const QString &header) { this->header = header; } void MimePart::addHeaderLine(const QString &line) { - this->header += line + "\r\n"; + this->header += line + "\r\n"; } const QString &MimePart::getHeader() const { return header; } @@ -66,7 +67,7 @@ void MimePart::setEncoding(Encoding enc) { this->cEncoding = enc; } MimePart::Encoding MimePart::getEncoding() const { return this->cEncoding; } MimeContentFormatter &MimePart::getContentFormatter() { - return this->formatter; + return this->formatter; } /* [2] --- */ @@ -74,10 +75,9 @@ MimeContentFormatter &MimePart::getContentFormatter() { /* [3] Public methods */ QString MimePart::toString() { - if (!prepared) - prepare(); + if (!prepared) prepare(); - return mimeString; + return mimeString; } /* [3] --- */ @@ -85,75 +85,74 @@ QString MimePart::toString() { /* [4] Protected methods */ void MimePart::prepare() { - mimeString = QString(); - - /* === Header Prepare === */ - - /* Content-Type */ - mimeString.append("Content-Type: ").append(cType); - - if (cName != "") - mimeString.append("; name=\"").append(cName).append("\""); - - if (cCharset != "") - mimeString.append("; charset=").append(cCharset); - - if (cBoundary != "") - mimeString.append("; boundary=").append(cBoundary); - - mimeString.append("\r\n"); - /* ------------ */ - - /* Content-Transfer-Encoding */ - mimeString.append("Content-Transfer-Encoding: "); - switch (cEncoding) { - case _7Bit: - mimeString.append("7bit\r\n"); - break; - case _8Bit: - mimeString.append("8bit\r\n"); - break; - case Base64: - mimeString.append("base64\r\n"); - break; - case QuotedPrintable: - mimeString.append("quoted-printable\r\n"); - break; - } - /* ------------------------ */ - - /* Content-Id */ - if (cId != NULL) - mimeString.append("Content-ID: <").append(cId).append(">\r\n"); - /* ---------- */ - - /* Addition header lines */ - - mimeString.append(header).append("\r\n"); - - /* ------------------------- */ - - /* === End of Header Prepare === */ - - /* === Content === */ - switch (cEncoding) { - case _7Bit: - mimeString.append(QString(content).toLatin1()); - break; - case _8Bit: - mimeString.append(content); - break; - case Base64: - mimeString.append(formatter.format(content.toBase64())); - break; - case QuotedPrintable: - mimeString.append(formatter.format(QuotedPrintable::encode(content), true)); - break; - } - mimeString.append("\r\n"); - /* === End of Content === */ - - prepared = true; + mimeString = QString(); + + /* === Header Prepare === */ + + /* Content-Type */ + mimeString.append("Content-Type: ").append(cType); + + if (!cName.isEmpty()) + mimeString.append("; name=\"").append(cName).append("\""); + + if (!cCharset.isEmpty()) mimeString.append("; charset=").append(cCharset); + + if (!cBoundary.isEmpty()) mimeString.append("; boundary=").append(cBoundary); + + mimeString.append("\r\n"); + /* ------------ */ + + /* Content-Transfer-Encoding */ + mimeString.append("Content-Transfer-Encoding: "); + switch (cEncoding) { + case _7Bit: + mimeString.append("7bit\r\n"); + break; + case _8Bit: + mimeString.append("8bit\r\n"); + break; + case Base64: + mimeString.append("base64\r\n"); + break; + case QuotedPrintable: + mimeString.append("quoted-printable\r\n"); + break; + } + /* ------------------------ */ + + /* Content-Id */ + if (cId != nullptr) + mimeString.append("Content-ID: <").append(cId).append(">\r\n"); + /* ---------- */ + + /* Addition header lines */ + + mimeString.append(header).append("\r\n"); + + /* ------------------------- */ + + /* === End of Header Prepare === */ + + /* === Content === */ + switch (cEncoding) { + case _7Bit: + mimeString.append(QString(content).toLatin1()); + break; + case _8Bit: + mimeString.append(content); + break; + case Base64: + mimeString.append(formatter.format(content.toBase64())); + break; + case QuotedPrintable: + mimeString.append( + formatter.format(QuotedPrintable::encode(content), true)); + break; + } + mimeString.append("\r\n"); + /* === End of Content === */ + + prepared = true; } /* [4] --- */ diff --git a/src/ui/FileEncryptionDialog.cpp b/src/ui/FileEncryptionDialog.cpp index d141df1e..cad0dcb1 100755 --- a/src/ui/FileEncryptionDialog.cpp +++ b/src/ui/FileEncryptionDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -29,17 +29,16 @@ namespace GpgFrontend::UI { FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, - DialogAction action, - QWidget* parent) + DialogAction action, QWidget* parent) : QDialog(parent), mAction(action) { if (mAction == Decrypt) { - setWindowTitle(tr("Decrypt File")); + setWindowTitle(_("Decrypt File")); } else if (mAction == Encrypt) { - setWindowTitle(tr("Encrypt File")); + setWindowTitle(_("Encrypt File")); } else if (mAction == Sign) { - setWindowTitle(tr("Sign File")); + setWindowTitle(_("Sign File")); } else if (mAction == Verify) { - setWindowTitle(tr("Verify File")); + setWindowTitle(_("Verify File")); } setModal(true); @@ -49,19 +48,19 @@ FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotExecuteAction())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - auto* groupBox1 = new QGroupBox(tr("Input Parameters")); + auto* groupBox1 = new QGroupBox(_("Input Parameters")); /* Setup input & Outputfileselection*/ inputFileEdit = new QLineEdit(); auto* fb1 = new QPushButton("Select"); connect(fb1, SIGNAL(clicked()), this, SLOT(slotSelectInputFile())); - auto* fl1 = new QLabel(tr("Target File")); + auto* fl1 = new QLabel(_("Target File")); fl1->setBuddy(inputFileEdit); outputFileEdit = new QLineEdit(); auto* fb2 = new QPushButton("Select"); connect(fb2, SIGNAL(clicked()), this, SLOT(slotSelectOutputFile())); - auto* fl2 = new QLabel(tr("Output File")); + auto* fl2 = new QLabel(_("Output File")); fl2->setBuddy(outputFileEdit); auto* gLayout = new QGridLayout(); @@ -77,7 +76,7 @@ FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, } else { auto* sfb1 = new QPushButton("Select"); connect(sfb1, SIGNAL(clicked()), this, SLOT(slotSelectSignFile())); - auto* sfl1 = new QLabel(tr("Signature File(.sig) Path")); + auto* sfl1 = new QLabel(_("Signature File(.sig) Path")); sfl1->setBuddy(signFileEdit); gLayout->addWidget(sfl1, 1, 0); @@ -114,8 +113,7 @@ FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, return true; }); - if (mAction == Decrypt) - mKeyList->setDisabled(true); + if (mAction == Decrypt) mKeyList->setDisabled(true); mKeyList->slotRefresh(); mKeyList->setChecked(keyList); @@ -136,15 +134,14 @@ FileEncryptionDialog::FileEncryptionDialog(KeyIdArgsListPtr keyList, } void FileEncryptionDialog::slotSelectInputFile() { - QString path = ""; + QString path; if (inputFileEdit->text().size() > 0) { path = QFileInfo(inputFileEdit->text()).absolutePath(); } - // QString infileName = QFileDialog::getOpenFileName(this, tr("Open File"), - // path, tr("Files") + tr("All Files (*)")); - QString infileName = - QFileDialog::getOpenFileName(this, tr("Open File"), path); + // QString infileName = QFileDialog::getOpenFileName(this, _("Open File"), + // path, _("Files") + _("All Files (*)")); + QString infileName = QFileDialog::getOpenFileName(this, _("Open File"), path); inputFileEdit->setText(infileName); // try to find a matching output-filename, if not yet done @@ -169,26 +166,26 @@ void FileEncryptionDialog::slotSelectInputFile() { } void FileEncryptionDialog::slotSelectOutputFile() { - QString path = ""; + QString path; if (outputFileEdit->text().size() > 0) { path = QFileInfo(outputFileEdit->text()).absolutePath(); } QString outfileName = - QFileDialog::getSaveFileName(this, tr("Save File"), path, nullptr, - nullptr, QFileDialog::DontConfirmOverwrite); + QFileDialog::getSaveFileName(this, _("Save File"), path, nullptr, nullptr, + QFileDialog::DontConfirmOverwrite); outputFileEdit->setText(outfileName); } void FileEncryptionDialog::slotSelectSignFile() { - QString path = ""; + QString path; if (signFileEdit->text().size() > 0) { path = QFileInfo(signFileEdit->text()).absolutePath(); } QString signfileName = - QFileDialog::getSaveFileName(this, tr("Open File"), path, nullptr, - nullptr, QFileDialog::DontConfirmOverwrite); + QFileDialog::getSaveFileName(this, _("Open File"), path, nullptr, nullptr, + QFileDialog::DontConfirmOverwrite); signFileEdit->setText(signfileName); if (inputFileEdit->text().size() == 0 && @@ -203,7 +200,7 @@ void FileEncryptionDialog::slotExecuteAction() { QFile infile; infile.setFileName(inputFileEdit->text()); if (!infile.open(QIODevice::ReadOnly)) { - statusLabel->setText(tr("Couldn't open file")); + statusLabel->setText(_("Couldn't open file")); inputFileEdit->setStyleSheet("QLineEdit { background: yellow }"); return; } @@ -223,8 +220,8 @@ void FileEncryptionDialog::slotExecuteAction() { if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) { qDebug() << "Error" << gpgme_strerror(err); - QMessageBox::warning(this, tr("Error"), - tr("Error Occurred During Encryption")); + QMessageBox::warning(this, _("Error"), + _("Error Occurred During Encryption")); return; } } @@ -236,8 +233,8 @@ void FileEncryptionDialog::slotExecuteAction() { BasicOperator::GetInstance().Decrypt(in_data, out_data, result); if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) { qDebug() << "Error" << gpgme_strerror(err); - QMessageBox::warning(this, tr("Error"), - tr("Error Occurred During Decryption")); + QMessageBox::warning(this, _("Error"), + _("Error Occurred During Decryption")); return; } } @@ -249,8 +246,8 @@ void FileEncryptionDialog::slotExecuteAction() { std::move(keys), in_data, out_data, GPGME_SIG_MODE_DETACH, result); if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) { qDebug() << "Error" << gpgme_strerror(err); - QMessageBox::warning(this, tr("Error"), - tr("Error Occurred During Signature")); + QMessageBox::warning(this, _("Error"), + _("Error Occurred During Signature")); return; } } @@ -270,12 +267,8 @@ void FileEncryptionDialog::slotExecuteAction() { accept(); } -void FileEncryptionDialog::slotShowKeyList() { - mKeyList->show(); -} +void FileEncryptionDialog::slotShowKeyList() { mKeyList->show(); } -void FileEncryptionDialog::slotHideKeyList() { - mKeyList->hide(); -} +void FileEncryptionDialog::slotHideKeyList() { mKeyList->hide(); } } // namespace GpgFrontend::UI diff --git a/src/ui/FileEncryptionDialog.h b/src/ui/FileEncryptionDialog.h index a3e56564..613f84e7 100755 --- a/src/ui/FileEncryptionDialog.h +++ b/src/ui/FileEncryptionDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -51,8 +51,7 @@ class FileEncryptionDialog : public QDialog { * @param keyList * @param parent */ - FileEncryptionDialog(KeyIdArgsListPtr keyList, - DialogAction action, + FileEncryptionDialog(KeyIdArgsListPtr keyList, DialogAction action, QWidget* parent = nullptr); public slots: diff --git a/src/ui/FindWidget.cpp b/src/ui/FindWidget.cpp index f9b92685..6326b119 100644 --- a/src/ui/FindWidget.cpp +++ b/src/ui/FindWidget.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -30,13 +30,14 @@ FindWidget::FindWidget(QWidget* parent, QTextEdit* edit) : QWidget(parent) { mTextpage = edit; findEdit = new QLineEdit(this); auto* closeButton = new QPushButton( - this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), "", this); - auto* nextButton = new QPushButton(QIcon(":button_next.png"), ""); + 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(tr("Find:"))); + notificationWidgetLayout->addWidget(new QLabel(QString(_("Find")) + ": ")); notificationWidgetLayout->addWidget(findEdit, 2); notificationWidgetLayout->addWidget(nextButton); notificationWidgetLayout->addWidget(previousButton); diff --git a/src/ui/FindWidget.h b/src/ui/FindWidget.h index f57f95a6..e4cbdaab 100644 --- a/src/ui/FindWidget.h +++ b/src/ui/FindWidget.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/GpgFrontendUI.h b/src/ui/GpgFrontendUI.h index 593ed872..c5d80d01 100644 --- a/src/ui/GpgFrontendUI.h +++ b/src/ui/GpgFrontendUI.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -26,11 +26,24 @@ #define GPGFRONTEND_GPGFRONTENDUI_H #include <GpgFrontend.h> -#include <easyloggingpp/easylogging++.h> #include <QtCore> #include <QtNetwork> #include <QtPrintSupport> #include <QtWidgets> +/** + * Resources File(s) Path Vars + */ +#if defined(MACOS) && defined(RELEASE) +#define RESOURCE_DIR(appDir) (appDir + "/../Resources/") +#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir / ".." / "Resources") +#elif defined(LINUX) && defined(RELEASE) +#define RESOURCE_DIR(appDir) (appDir + "/../share/") +#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir / ".." / "share") +#else +#define RESOURCE_DIR(appDir) (appDir) +#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir) +#endif + #endif // GPGFRONTEND_GPGFRONTENDUI_H diff --git a/src/ui/KeyImportDetailDialog.cpp b/src/ui/KeyImportDetailDialog.cpp index 92c73f0e..321de3a6 100644 --- a/src/ui/KeyImportDetailDialog.cpp +++ b/src/ui/KeyImportDetailDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -33,11 +33,11 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, // If no key for import found, just show a message if (mResult.considered == 0) { if (automatic) - QMessageBox::information(nullptr, tr("Key Update Details"), - tr("No keys found")); + QMessageBox::information(nullptr, _("Key Update Details"), + _("No keys found")); else - QMessageBox::information(nullptr, tr("Key Import Details"), - tr("No keys found to import")); + QMessageBox::information(nullptr, _("Key Import Details"), + _("No keys found to import")); return; } @@ -54,9 +54,9 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, this->setLayout(mvbox); if (automatic) - this->setWindowTitle(tr("Key Update Details")); + this->setWindowTitle(_("Key Update Details")); else - this->setWindowTitle(tr("Key Import Details")); + this->setWindowTitle(_("Key Import Details")); this->resize(QSize(600, 300)); this->setModal(true); @@ -65,48 +65,52 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result, void KeyImportDetailDialog::createGeneralInfoBox() { // GridBox for general import information - generalInfoBox = new QGroupBox(tr("General key info")); + generalInfoBox = new QGroupBox(_("General key info")); auto* generalInfoBoxLayout = new QGridLayout(generalInfoBox); - generalInfoBoxLayout->addWidget(new QLabel(tr("Considered:")), 1, 0); + generalInfoBoxLayout->addWidget(new QLabel(QString(_("Considered")) + ": "), + 1, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.considered)), 1, 1); int row = 2; if (mResult.unchanged != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Public unchanged:")), row, - 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Public unchanged")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.unchanged)), row, 1); row++; } if (mResult.imported != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Imported:")), row, 0); + generalInfoBoxLayout->addWidget(new QLabel(QString(_("Imported")) + ": "), + row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.imported)), row, 1); row++; } if (mResult.not_imported != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Not imported:")), row, 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Not Imported")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.not_imported)), row, 1); row++; } if (mResult.secret_read != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Private read:")), row, 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Private Read")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.secret_read)), row, 1); row++; } if (mResult.secret_imported != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Private imported:")), row, - 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Private Imported")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.secret_imported)), row, 1); row++; } if (mResult.secret_unchanged != 0) { - generalInfoBoxLayout->addWidget(new QLabel(tr("Private unchanged:")), row, - 0); + generalInfoBoxLayout->addWidget( + new QLabel(QString(_("Private Unchanged")) + ": "), row, 0); generalInfoBoxLayout->addWidget( new QLabel(QString::number(mResult.secret_unchanged)), row, 1); row++; @@ -115,7 +119,7 @@ void KeyImportDetailDialog::createGeneralInfoBox() { void KeyImportDetailDialog::createKeysTable() { LOG(INFO) << "KeyImportDetailDialog::createKeysTable() Called"; - + keysTable = new QTableWidget(this); keysTable->setRowCount(0); keysTable->setColumnCount(4); @@ -124,8 +128,7 @@ void KeyImportDetailDialog::createKeysTable() { keysTable->setSelectionMode(QAbstractItemView::NoSelection); QStringList headerLabels; - headerLabels << tr("Name") << tr("Email") << tr("Status") - << tr("Fingerprint"); + headerLabels << _("Name") << _("Email") << _("Status") << _("Fingerprint"); keysTable->verticalHeader()->hide(); keysTable->setHorizontalHeaderLabels(headerLabels); @@ -154,27 +157,27 @@ QString KeyImportDetailDialog::getStatusString(int keyStatus) { QString statusString; // keystatus is greater than 15, if key is private if (keyStatus > 15) { - statusString.append(tr("private")); + statusString.append(_("Private")); keyStatus = keyStatus - 16; } else { - statusString.append(tr("public")); + statusString.append(_("Public")); } if (keyStatus == 0) { - statusString.append(", " + tr("unchanged")); + statusString.append(", " + QString(_("Unchanged"))); } else { if (keyStatus == 1) { - statusString.append(", " + tr("new key")); + statusString.append(", " + QString(_("New Key"))); } else { if (keyStatus > 7) { - statusString.append(", " + tr("new subkey")); + statusString.append(", " + QString(_("New Subkey"))); keyStatus = keyStatus - 8; } if (keyStatus > 3) { - statusString.append(", " + tr("new signature")); + statusString.append(", " + QString(_("New Signature"))); keyStatus = keyStatus - 4; } if (keyStatus > 1) { - statusString.append(", " + tr("new uid")); + statusString.append(", " + QString(_("New UID"))); keyStatus = keyStatus - 2; } } diff --git a/src/ui/KeyImportDetailDialog.h b/src/ui/KeyImportDetailDialog.h index e3137503..0c7d6807 100644 --- a/src/ui/KeyImportDetailDialog.h +++ b/src/ui/KeyImportDetailDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -26,6 +26,7 @@ #define __KEYIMPORTDETAILSDIALOG_H__ #include <gpg/function/GpgKeyImportExportor.h> + #include "gpg/GpgContext.h" #include "ui/GpgFrontendUI.h" @@ -34,8 +35,7 @@ class KeyImportDetailDialog : public QDialog { Q_OBJECT public: - KeyImportDetailDialog(GpgImportInformation result, - bool automatic, + KeyImportDetailDialog(GpgImportInformation result, bool automatic, QWidget* parent = nullptr); private: diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp index df476fc9..0c3d6a14 100755 --- a/src/ui/KeyMgmt.cpp +++ b/src/ui/KeyMgmt.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -88,7 +88,7 @@ KeyMgmt::KeyMgmt(QWidget* parent) this->settings.setValue("keymgmt/setWindowSize", true); } - setWindowTitle(tr("Key Pair Management")); + setWindowTitle(_("Key Pair Management")); mKeyList->addMenuAction(deleteSelectedKeysAct); mKeyList->addMenuAction(showKeyDetailsAct); @@ -97,91 +97,90 @@ KeyMgmt::KeyMgmt(QWidget* parent) } void KeyMgmt::createActions() { - openKeyFileAct = new QAction(tr("&Open"), this); - openKeyFileAct->setShortcut(tr("Ctrl+O")); - openKeyFileAct->setToolTip(tr("Open Key File")); + openKeyFileAct = new QAction(_("Open"), this); + openKeyFileAct->setShortcut(QKeySequence(_("Ctrl+O"))); + openKeyFileAct->setToolTip(_("Open Key File")); connect(openKeyFileAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromFile())); - closeAct = new QAction(tr("&Close"), this); - closeAct->setShortcut(tr("Ctrl+Q")); + closeAct = new QAction(_("Close"), this); + closeAct->setShortcut(QKeySequence(_("Ctrl+Q"))); closeAct->setIcon(QIcon(":exit.png")); - closeAct->setToolTip(tr("Close")); + closeAct->setToolTip(_("Close")); connect(closeAct, SIGNAL(triggered()), this, SLOT(close())); - generateKeyPairAct = new QAction(tr("New Keypair"), this); - generateKeyPairAct->setShortcut(tr("Ctrl+N")); + generateKeyPairAct = new QAction(_("New Keypair"), this); + generateKeyPairAct->setShortcut(QKeySequence(_("Ctrl+N"))); generateKeyPairAct->setIcon(QIcon(":key_generate.png")); - generateKeyPairAct->setToolTip(tr("Generate KeyPair")); + generateKeyPairAct->setToolTip(_("Generate KeyPair")); connect(generateKeyPairAct, SIGNAL(triggered()), this, SLOT(slotGenerateKeyDialog())); - generateSubKeyAct = new QAction(tr("New Subkey"), this); - generateSubKeyAct->setShortcut(tr("Ctrl+Shift+N")); + generateSubKeyAct = new QAction(_("New Subkey"), this); + generateSubKeyAct->setShortcut(QKeySequence(_("Ctrl+Shift+N"))); generateSubKeyAct->setIcon(QIcon(":key_generate.png")); - generateSubKeyAct->setToolTip(tr("Generate Subkey For Selected KeyPair")); + generateSubKeyAct->setToolTip(_("Generate Subkey For Selected KeyPair")); connect(generateSubKeyAct, SIGNAL(triggered()), this, SLOT(slotGenerateSubKey())); - importKeyFromFileAct = new QAction(tr("&File"), this); + importKeyFromFileAct = new QAction(_("File"), this); importKeyFromFileAct->setIcon(QIcon(":import_key_from_file.png")); - importKeyFromFileAct->setToolTip(tr("Import New Key From File")); + importKeyFromFileAct->setToolTip(_("Import New Key From File")); connect(importKeyFromFileAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromFile())); - importKeyFromClipboardAct = new QAction(tr("&Clipboard"), this); + importKeyFromClipboardAct = new QAction(_("Clipboard"), this); importKeyFromClipboardAct->setIcon(QIcon(":import_key_from_clipboard.png")); - importKeyFromClipboardAct->setToolTip(tr("Import New Key From Clipboard")); + importKeyFromClipboardAct->setToolTip(_("Import New Key From Clipboard")); connect(importKeyFromClipboardAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromClipboard())); - importKeyFromKeyServerAct = new QAction(tr("&Keyserver"), this); + importKeyFromKeyServerAct = new QAction(_("Keyserver"), this); importKeyFromKeyServerAct->setIcon(QIcon(":import_key_from_server.png")); - importKeyFromKeyServerAct->setToolTip(tr("Import New Key From Keyserver")); + importKeyFromKeyServerAct->setToolTip(_("Import New Key From Keyserver")); connect(importKeyFromKeyServerAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromKeyServer())); - exportKeyToClipboardAct = new QAction(tr("Export To &Clipboard"), this); + exportKeyToClipboardAct = new QAction(_("Export To Clipboard"), this); exportKeyToClipboardAct->setIcon(QIcon(":export_key_to_clipboard.png")); - exportKeyToClipboardAct->setToolTip( - tr("Export Selected Key(s) To Clipboard")); + exportKeyToClipboardAct->setToolTip(_("Export Selected Key(s) To Clipboard")); connect(exportKeyToClipboardAct, SIGNAL(triggered()), this, SLOT(slotExportKeyToClipboard())); - exportKeyToFileAct = new QAction(tr("Export To &File"), this); + exportKeyToFileAct = new QAction(_("Export To File"), this); exportKeyToFileAct->setIcon(QIcon(":export_key_to_file.png")); - exportKeyToFileAct->setToolTip(tr("Export Selected Key(s) To File")); + exportKeyToFileAct->setToolTip(_("Export Selected Key(s) To File")); connect(exportKeyToFileAct, SIGNAL(triggered()), this, SLOT(slotExportKeyToFile())); - deleteSelectedKeysAct = new QAction(tr("Delete Selected Key(s)"), this); - deleteSelectedKeysAct->setToolTip(tr("Delete the Selected keys")); + deleteSelectedKeysAct = new QAction(_("Delete Selected Key(s)"), this); + deleteSelectedKeysAct->setToolTip(_("Delete the Selected keys")); connect(deleteSelectedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteSelectedKeys())); - deleteCheckedKeysAct = new QAction(tr("Delete Checked Key(s)"), this); - deleteCheckedKeysAct->setToolTip(tr("Delete the Checked keys")); + deleteCheckedKeysAct = new QAction(_("Delete Checked Key(s)"), this); + deleteCheckedKeysAct->setToolTip(_("Delete the Checked keys")); deleteCheckedKeysAct->setIcon(QIcon(":button_delete.png")); connect(deleteCheckedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteCheckedKeys())); - showKeyDetailsAct = new QAction(tr("Show Key Details"), this); - showKeyDetailsAct->setToolTip(tr("Show Details for this Key")); + showKeyDetailsAct = new QAction(_("Show Key Details"), this); + showKeyDetailsAct->setToolTip(_("Show Details for this Key")); connect(showKeyDetailsAct, SIGNAL(triggered()), this, SLOT(slotShowKeyDetails())); } void KeyMgmt::createMenus() { - fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu = menuBar()->addMenu(_("File")); fileMenu->addAction(openKeyFileAct); fileMenu->addAction(closeAct); - keyMenu = menuBar()->addMenu(tr("&Key")); - generateKeyMenu = keyMenu->addMenu(tr("&Generate Key")); + keyMenu = menuBar()->addMenu(_("Key")); + generateKeyMenu = keyMenu->addMenu(_("Generate Key")); generateKeyMenu->addAction(generateKeyPairAct); generateKeyMenu->addAction(generateSubKeyAct); - importKeyMenu = keyMenu->addMenu(tr("&Import Key")); + importKeyMenu = keyMenu->addMenu(_("Import Key")); importKeyMenu->addAction(importKeyFromFileAct); importKeyMenu->addAction(importKeyFromClipboardAct); importKeyMenu->addAction(importKeyFromKeyServerAct); @@ -192,7 +191,7 @@ void KeyMgmt::createMenus() { } void KeyMgmt::createToolBars() { - QToolBar* keyToolBar = addToolBar(tr("Key")); + QToolBar* keyToolBar = addToolBar(_("Key")); keyToolBar->setObjectName("keytoolbar"); // add button with popup menu for import @@ -200,8 +199,8 @@ void KeyMgmt::createToolBars() { generateToolButton->setMenu(generateKeyMenu); generateToolButton->setPopupMode(QToolButton::InstantPopup); generateToolButton->setIcon(QIcon(":key_generate.png")); - generateToolButton->setText(tr("Generate")); - generateToolButton->setToolTip(tr("Generate A New Keypair or Subkey")); + generateToolButton->setText(_("Generate")); + generateToolButton->setToolTip(_("Generate A New Keypair or Subkey")); generateToolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); keyToolBar->addWidget(generateToolButton); @@ -210,8 +209,8 @@ void KeyMgmt::createToolBars() { toolButton->setMenu(importKeyMenu); toolButton->setPopupMode(QToolButton::InstantPopup); toolButton->setIcon(QIcon(":key_import.png")); - toolButton->setToolTip(tr("Import key")); - toolButton->setText(tr("Import Key")); + toolButton->setToolTip(_("Import key")); + toolButton->setText(_("Import Key")); toolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); keyToolBar->addWidget(toolButton); @@ -231,8 +230,8 @@ void KeyMgmt::slotImportKeys(const std::string& in_buffer) { void KeyMgmt::slotImportKeyFromFile() { QString file_name = QFileDialog::getOpenFileName( - this, tr("Open Key"), "", - tr("Key Files") + " (*.asc *.txt);;" + tr("Keyring files") + + this, _("Open Key"), QString(), + QString(_("Key Files")) + " (*.asc *.txt);;" + _("Keyring files") + " (*.gpg);;All Files (*)"); if (!file_name.isNull()) { slotImportKeys(read_all_data_in_file(file_name.toStdString())); @@ -277,10 +276,12 @@ void KeyMgmt::deleteKeysWithWarning(KeyIdArgsListPtr key_ids) { } int ret = QMessageBox::warning( - this, tr("Deleting Keys"), - "<b>" + tr("Are you sure that you want to delete the following keys?") + + this, _("Deleting Keys"), + "<b>" + + QString( + _("Are you sure that you want to delete the following keys?")) + "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { @@ -296,7 +297,7 @@ void KeyMgmt::slotShowKeyDetails() { auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front()); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } @@ -313,19 +314,19 @@ void KeyMgmt::slotExportKeyToFile() { auto key = GpgKeyGetter::GetInstance().GetKey(mKeyList->getSelected()->front()); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } QString fileString = QString::fromStdString(key.name() + " " + key.email() + "(" + key.id() + ")_pub.asc"); QString file_name = QFileDialog::getSaveFileName( - this, tr("Export Key To File"), fileString, - tr("Key Files") + " (*.asc *.txt);;All Files (*)"); + this, _("Export Key To File"), fileString, + QString(_("Key Files")) + " (*.asc *.txt);;All Files (*)"); write_buffer_to_file(file_name.toStdString(), *key_export_data); - emit signalStatusBarChanged(QString(tr("key(s) exported"))); + emit signalStatusBarChanged(QString(_("key(s) exported"))); } void KeyMgmt::slotExportKeyToClipboard() { @@ -349,19 +350,19 @@ void KeyMgmt::slotGenerateSubKey() { auto keys_selected = mKeyList->getSelected(); if (keys_selected->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one KeyPair before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one KeyPair before doing this operation.")); return; } const auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front()); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } if (!key.is_private_key()) { - QMessageBox::critical(nullptr, tr("Invalid Operation"), - tr("If a key pair does not have a private key then " - "it will not be able to generate sub-keys.")); + QMessageBox::critical(nullptr, _("Invalid Operation"), + _("If a key pair does not have a private key then " + "it will not be able to generate sub-keys.")); return; } diff --git a/src/ui/KeyMgmt.h b/src/ui/KeyMgmt.h index f96fbf38..1bf350f7 100755 --- a/src/ui/KeyMgmt.h +++ b/src/ui/KeyMgmt.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp index 866e378a..b529637f 100644 --- a/src/ui/KeyServerImportDialog.cpp +++ b/src/ui/KeyServerImportDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -44,17 +44,17 @@ KeyServerImportDialog::KeyServerImportDialog(KeyList* keyList, bool automatic, } // Buttons - closeButton = createButton(tr("&Close"), SLOT(close())); - importButton = createButton(tr("&Import ALL"), SLOT(slotImport())); + closeButton = createButton(_("Close"), SLOT(close())); + importButton = createButton(_("Import ALL"), SLOT(slotImport())); importButton->setDisabled(true); - searchButton = createButton(tr("&Search"), SLOT(slotSearch())); + searchButton = createButton(_("Search"), SLOT(slotSearch())); // Line edit for search string - searchLabel = new QLabel(tr("Search String:")); + searchLabel = new QLabel(QString(_("Search String")) + _(": ")); searchLineEdit = new QLineEdit(); // combobox for keyserverlist - keyServerLabel = new QLabel(tr("Key Server:")); + keyServerLabel = new QLabel(QString(_("Key Server")) + _(": ")); keyServerComboBox = createComboBox(); // table containing the keys found @@ -101,9 +101,9 @@ KeyServerImportDialog::KeyServerImportDialog(KeyList* keyList, bool automatic, this->setLayout(mainLayout); if (automatic) - this->setWindowTitle(tr("Update Keys from Keyserver")); + this->setWindowTitle(_("Update Keys from Keyserver")); else - this->setWindowTitle(tr("Import Keys from Keyserver")); + this->setWindowTitle(_("Import Keys from Keyserver")); if (automatic) { this->setFixedSize(240, 42); @@ -168,7 +168,7 @@ void KeyServerImportDialog::createKeysTable() { keysTable->setSelectionMode(QAbstractItemView::SingleSelection); QStringList labels; - labels << tr("UID") << tr("Creation date") << tr("KeyID") << tr("Tag"); + labels << _("UID") << _("Creation date") << _("KeyID") << _("Tag"); keysTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::ResizeToContents); keysTable->setHorizontalHeaderLabels(labels); @@ -190,7 +190,7 @@ void KeyServerImportDialog::setMessage(const QString& text, bool error) { void KeyServerImportDialog::slotSearch() { if (searchLineEdit->text().isEmpty()) { - setMessage("<h4>" + tr("Text is empty.") + "</h4>", false); + setMessage("<h4>" + QString(_("Text is empty.")) + "</h4>", false); return; } @@ -233,16 +233,16 @@ void KeyServerImportDialog::slotSearchFinished() { qDebug() << "Error From Reply" << reply->errorString(); switch (error) { case QNetworkReply::ContentNotFoundError: - setMessage(tr("Not Key Found"), true); + setMessage(_("Not Key Found"), true); break; case QNetworkReply::TimeoutError: - setMessage(tr("Timeout"), true); + setMessage(_("Timeout"), true); break; case QNetworkReply::HostNotFoundError: - setMessage(tr("Key Server Not Found"), true); + setMessage(_("Key Server Not Found"), true); break; default: - setMessage(tr("Connection Error"), true); + setMessage(_("Connection Error"), true); } return; } @@ -250,32 +250,35 @@ void KeyServerImportDialog::slotSearchFinished() { if (first_line.contains("Error")) { QString text = QString(reply->readLine(1024)); if (text.contains("Too many responses")) { - setMessage("<h4>" + tr("Too many responses from keyserver!") + "</h4>", - true); + setMessage( + "<h4>" + QString(_("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 = searchLineEdit->text(); if (rx.exactMatch(query)) { - setMessage("<h4>" + - tr("No keys found, input may be kexId, retrying search " - "with 0x.") + - "</h4>", - true); + setMessage( + "<h4>" + + QString(_("No keys found, input may be kexId, retrying search " + "with 0x.")) + + "</h4>", + true); searchLineEdit->setText(query.prepend("0x")); this->slotSearch(); return; } else { - setMessage("<h4>" + tr("No keys found containing the search string!") + - "</h4>", - true); + setMessage( + "<h4>" + QString(_("No keys found containing the search string!")) + + "</h4>", + true); return; } } else if (text.contains("Insufficiently specific words")) { - setMessage( - "<h4>" + tr("Insufficiently specific search string!") + "</h4>", - true); + setMessage("<h4>" + QString(_("Insufficiently specific search string!")) + + "</h4>", + true); return; } else { setMessage(text, true); @@ -306,11 +309,11 @@ void KeyServerImportDialog::slotSearchFinished() { } if (flags.contains("r")) { keysTable->setItem(row, 3, - new QTableWidgetItem(QString(tr("revoked")))); + new QTableWidgetItem(QString(_("revoked")))); } if (flags.contains("d")) { keysTable->setItem(row, 3, - new QTableWidgetItem(QString(tr("disabled")))); + new QTableWidgetItem(QString(_("disabled")))); } } @@ -350,9 +353,12 @@ void KeyServerImportDialog::slotSearchFinished() { } } } - setMessage(tr("<h4>%1 keys found. Double click a key to import it.</h4>") - .arg(row), - false); + setMessage( + QString("<h4>") + + QString(_("%1 keys found. Double click a key to import it.")) + .arg(row) + + "</h4>", + false); } keysTable->resizeColumnsToContents(); importButton->setDisabled(keysTable->size().isEmpty()); @@ -424,16 +430,16 @@ void KeyServerImportDialog::slotImportFinished() { qDebug() << "Error From Reply" << reply->errorString(); switch (error) { case QNetworkReply::ContentNotFoundError: - setMessage(tr("Key Not Found"), true); + setMessage(_("Key Not Found"), true); break; case QNetworkReply::TimeoutError: - setMessage(tr("Timeout"), true); + setMessage(_("Timeout"), true); break; case QNetworkReply::HostNotFoundError: - setMessage(tr("Key Server Not Found"), true); + setMessage(_("Key Server Not Found"), true); break; default: - setMessage(tr("Connection Error"), true); + setMessage(_("Connection Error"), true); } if (mAutomatic) { setWindowFlags(Qt::Window | Qt::WindowTitleHint | @@ -454,9 +460,9 @@ void KeyServerImportDialog::slotImportFinished() { this->importKeys(std::make_unique<ByteArray>(key.constData(), key.length())); if (mAutomatic) { - setMessage(tr("<h4>Key Updated</h4>"), false); + setMessage(QString("<h4>") + _("Key Updated") + "</h4>", false); } else { - setMessage(tr("<h4>Key Imported</h4>"), false); + setMessage(QString("<h4>") + _("Key Imported") + "</h4>", false); } } @@ -518,7 +524,7 @@ KeyServerImportDialog::KeyServerImportDialog(QWidget* parent) mainLayout->addLayout(messageLayout, 0, 0, 1, 3); this->setLayout(mainLayout); - this->setWindowTitle(tr("Upload Keys from Keyserver")); + this->setWindowTitle(_("Upload Keys from Keyserver")); this->setFixedSize(200, 42); this->setModal(true); } diff --git a/src/ui/KeyServerImportDialog.h b/src/ui/KeyServerImportDialog.h index f768afa7..0fb7dbf1 100644 --- a/src/ui/KeyServerImportDialog.h +++ b/src/ui/KeyServerImportDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/KeyUploadDialog.cpp index da905e8e..e8c37c5b 100644 --- a/src/ui/KeyUploadDialog.cpp +++ b/src/ui/KeyUploadDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -50,7 +50,7 @@ KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids, this->setLayout(layout); this->setModal(true); - this->setWindowTitle(tr("Uploading Public Key")); + this->setWindowTitle(_("Uploading Public Key")); this->setFixedSize(240, 42); } @@ -116,16 +116,16 @@ void KeyUploadDialog::slotUploadFinished() { QString message; switch (error) { case QNetworkReply::ContentNotFoundError: - message = tr("Key Not Found"); + message = _("Key Not Found"); break; case QNetworkReply::TimeoutError: - message = tr("Timeout"); + message = _("Timeout"); break; case QNetworkReply::HostNotFoundError: - message = tr("Key Server Not Found"); + message = _("Key Server Not Found"); break; default: - message = tr("Connection Error"); + message = _("Connection Error"); } QMessageBox::critical(this, "Upload Failed", message); return; diff --git a/src/ui/KeyUploadDialog.h b/src/ui/KeyUploadDialog.h index bf7533cb..b607c321 100644 --- a/src/ui/KeyUploadDialog.h +++ b/src/ui/KeyUploadDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index b986782b..cc04f246 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -32,7 +32,7 @@ namespace GpgFrontend::UI { MainWindow::MainWindow() { networkAccessManager = new QNetworkAccessManager(this); - auto waitingDialog = new WaitingDialog(tr("Loading Gnupg"), this); + auto waitingDialog = new WaitingDialog(_("Loading Gnupg"), this); QString baseUrl = "https://api.github.com/repos/saturneric/gpgfrontend/releases/latest"; @@ -57,9 +57,9 @@ MainWindow::MainWindow() { // Check Context Status if (!GpgContext::GetInstance().good()) { QMessageBox::critical( - nullptr, tr("ENV Loading Failed"), - tr("Gnupg is not installed correctly, please follow the ReadME " - "instructions to install gnupg and then open GPGFrontend.")); + nullptr, _("ENV Loading Failed"), + _("Gnupg is not installed correctly, please follow the ReadME " + "instructions to install gnupg and then open GpgFrontend.")); QCoreApplication::quit(); exit(0); } diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 095bc974..82acee63 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -230,11 +230,11 @@ class MainWindow : public QMainWindow { */ void slotOpenSettingsDialog(); -// /** -// * @details Show a warn message in status bar, if there are files in -// * attachment folder. -// */ -// void slotCheckAttachmentFolder(); + // /** + // * @details Show a warn message in status bar, if there are files in + // * attachment folder. + // */ + // void slotCheckAttachmentFolder(); /** * @details Replace double linebreaks by single linebreaks in currently active diff --git a/src/ui/QuitDialog.cpp b/src/ui/QuitDialog.cpp index f6b3f196..a5ed7c3f 100755 --- a/src/ui/QuitDialog.cpp +++ b/src/ui/QuitDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,11 +24,13 @@ #include "ui/QuitDialog.h" +#include <boost/format.hpp> + namespace GpgFrontend::UI { QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) : QDialog(parent) { - setWindowTitle(tr("Unsaved Files")); + setWindowTitle(_("Unsaved Files")); setModal(true); discarded = false; @@ -75,10 +77,12 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) pixmap = pixmap.scaled(50, 50, Qt::KeepAspectRatio, Qt::SmoothTransformation); auto* warn_icon = new QLabel(); warn_icon->setPixmap(pixmap); - auto* warn_label = - new QLabel(tr("%1 files contain unsaved information.<br/>Save the " - "changes before closing?") - .arg(row)); + + const auto info = + boost::format(_("%1% files contain unsaved information.<br/>Save the " + "changes before closing?")) % + std::to_string(row); + auto* warn_label = new QLabel(QString::fromStdString(info.str())); auto* warnBoxLayout = new QHBoxLayout(); warnBoxLayout->addWidget(warn_icon); warnBoxLayout->addWidget(warn_label); @@ -89,10 +93,10 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) /* * Two labels on top and under the filelist */ - auto* checkLabel = new QLabel(tr("Check the files you want to save:")); - auto* note_label = - new QLabel(tr("<b>Note:</b> If you don't save these files, all changes " - "are lost.<br/>")); + auto* checkLabel = new QLabel(_("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/>"); /* * Buttonbox @@ -122,9 +126,7 @@ void QuitDialog::slotMyDiscard() { reject(); } -bool QuitDialog::isDiscarded() const { - return discarded; -} +bool QuitDialog::isDiscarded() const { return discarded; } QList<int> QuitDialog::getTabIdsToSave() { QList<int> tabIdsToSave; diff --git a/src/ui/QuitDialog.h b/src/ui/QuitDialog.h index 86616667..2b1dd37f 100755 --- a/src/ui/QuitDialog.h +++ b/src/ui/QuitDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/ShowCopyDialog.cpp b/src/ui/ShowCopyDialog.cpp index 98a1df3c..0503e079 100644 --- a/src/ui/ShowCopyDialog.cpp +++ b/src/ui/ShowCopyDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -26,8 +26,7 @@ namespace GpgFrontend::UI { -ShowCopyDialog::ShowCopyDialog(const QString& text, - const QString& info, +ShowCopyDialog::ShowCopyDialog(const QString& text, const QString& info, QWidget* parent) : QDialog(parent) { textEdit = new QTextEdit(); diff --git a/src/ui/ShowCopyDialog.h b/src/ui/ShowCopyDialog.h index 82deedee..fefef7ab 100644 --- a/src/ui/ShowCopyDialog.h +++ b/src/ui/ShowCopyDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -32,8 +32,7 @@ namespace GpgFrontend::UI { class ShowCopyDialog : public QDialog { Q_OBJECT public: - explicit ShowCopyDialog(const QString& text, - const QString& info = "", + explicit ShowCopyDialog(const QString& text, const QString& info = "", QWidget* parent = nullptr); private slots: diff --git a/src/ui/SignalStation.cpp b/src/ui/SignalStation.cpp index ad5c0b53..fff2971a 100644 --- a/src/ui/SignalStation.cpp +++ b/src/ui/SignalStation.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/SignalStation.h b/src/ui/SignalStation.h index 92211aa2..38e55d9f 100644 --- a/src/ui/SignalStation.h +++ b/src/ui/SignalStation.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index 4dd571a1..f8658a78 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -53,7 +53,6 @@ void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board, void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board, const ResultAnalyse& result_analyse_a, const ResultAnalyse& result_analyse_b) { - LOG(INFO) << "process_result_analyse Started"; info_board->associateTabWidget(edit->tabWidget); diff --git a/src/ui/UserInterfaceUtils.h b/src/ui/UserInterfaceUtils.h index 979cebe6..ec439461 100644 --- a/src/ui/UserInterfaceUtils.h +++ b/src/ui/UserInterfaceUtils.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/VerifyDetailsDialog.cpp b/src/ui/VerifyDetailsDialog.cpp index f06c31a4..1ad9d996 100644 --- a/src/ui/VerifyDetailsDialog.cpp +++ b/src/ui/VerifyDetailsDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,17 +24,17 @@ #include "ui/VerifyDetailsDialog.h" +#include <boost/format.hpp> + namespace GpgFrontend::UI { -VerifyDetailsDialog::VerifyDetailsDialog(QWidget* parent, - KeyList* keyList, - GpgError error, - GpgVerifyResult result) +VerifyDetailsDialog::VerifyDetailsDialog(QWidget* parent, KeyList* keyList, + GpgError error, GpgVerifyResult result) : QDialog(parent), mKeyList(keyList), mResult(std::move(result)), error(error) { - this->setWindowTitle(tr("Signature Details")); + this->setWindowTitle(_("Signature Details")); mainLayout = new QHBoxLayout(); this->setLayout(mainLayout); @@ -53,12 +53,13 @@ void VerifyDetailsDialog::slotRefresh() { buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); - mVboxLayout->addWidget(new QLabel(tr("Status: ") + gpgme_strerror(error))); + mVboxLayout->addWidget(new QLabel(QString::fromStdString( + std::string(_("Status")) + ": " + gpgme_strerror(error)))); auto sign = mResult->signatures; if (sign == nullptr) { - mVboxLayout->addWidget(new QLabel(tr("No valid input found"))); + mVboxLayout->addWidget(new QLabel(_("No valid input found"))); mVboxLayout->addWidget(buttonBox); return; } @@ -69,15 +70,19 @@ void VerifyDetailsDialog::slotRefresh() { // Set the title widget depending on sign status if (gpg_err_code(sign->status) == GPG_ERR_BAD_SIGNATURE) { - mVboxLayout->addWidget(new QLabel(tr("Error Validating signature"))); + mVboxLayout->addWidget(new QLabel(_("Error Validating signature"))); } else if (mInputSignature != nullptr) { - mVboxLayout->addWidget( - new QLabel(tr("File was signed on %1 <br/> It Contains:<br/><br/>") - .arg(QLocale::system().toString(timestamp)))); + const auto info = (boost::format(_("File was signed on %1%")) % + QLocale::system().toString(timestamp).toStdString()) + .str() + + "<br/>" + _("It Contains") + ": " + "<br/><br/>"; + mVboxLayout->addWidget(new QLabel(info.c_str())); } else { - mVboxLayout->addWidget( - new QLabel(tr("Signed on %1 <br/> It Contains:<br /><br/>") - .arg(QLocale::system().toString(timestamp)))); + const auto info = (boost::format(_("Signed on %1%")) % + QLocale::system().toString(timestamp).toStdString()) + .str() + + "<br/>" + _("It Contains") + ": " + "<br/><br/>"; + mVboxLayout->addWidget(new QLabel(info.c_str())); } // Add information box for every single key while (sign) { diff --git a/src/ui/VerifyDetailsDialog.h b/src/ui/VerifyDetailsDialog.h index 3d201194..3de4a56f 100644 --- a/src/ui/VerifyDetailsDialog.h +++ b/src/ui/VerifyDetailsDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -34,10 +34,8 @@ namespace GpgFrontend::UI { class VerifyDetailsDialog : public QDialog { Q_OBJECT public: - explicit VerifyDetailsDialog(QWidget* parent, - KeyList* keyList, - GpgError error, - GpgVerifyResult result); + explicit VerifyDetailsDialog(QWidget* parent, KeyList* keyList, + GpgError error, GpgVerifyResult result); private slots: diff --git a/src/ui/WaitingDialog.cpp b/src/ui/WaitingDialog.cpp index 44727193..d9aab23b 100644 --- a/src/ui/WaitingDialog.cpp +++ b/src/ui/WaitingDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/WaitingDialog.h b/src/ui/WaitingDialog.h index 342360fd..798c2a3c 100644 --- a/src/ui/WaitingDialog.h +++ b/src/ui/WaitingDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp index 2f050e80..c2733f0c 100644 --- a/src/ui/Wizard.cpp +++ b/src/ui/Wizard.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -40,7 +40,7 @@ Wizard::Wizard(KeyMgmt* keyMgmt, QWidget* parent) #ifndef Q_WS_MAC setWizardStyle(ModernStyle); #endif - setWindowTitle(tr("First Start Wizard")); + setWindowTitle(_("First Start Wizard")); // http://www.flickr.com/photos/laureenp/6141822934/ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/keys2.jpg")); @@ -67,19 +67,19 @@ IntroPage::IntroPage(QWidget* parent) appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { - setTitle(tr("Getting Started...")); - setSubTitle(tr("... with GPGFrontend")); + setTitle(_("Getting Started...")); + setSubTitle(_("... with GpgFrontend")); auto* topLabel = new QLabel( - tr("Welcome to use GPGFrontend for decrypting and signing text or " - "file!") + + QString(_("Welcome to use GpgFrontend for decrypting and signing text or " + "file!")) + " <br><br><a href='https://gpgfrontend.pub'>GpgFrontend</a> " + - 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") + + _("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and " + "Installation-Free OpenPGP Crypto Tool.") + + _("For brief information have a look at the") + " <a href='https://gpgfrontend.pub/index.html#/overview'>" + - tr("Overview") + "</a> (" + - tr("by clicking the link, the page will open in the web browser") + + _("Overview") + "</a> (" + + _("by clicking the link, the page will open in the web browser") + "). <br>"); topLabel->setTextFormat(Qt::RichText); topLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); @@ -87,7 +87,7 @@ IntroPage::IntroPage(QWidget* parent) topLabel->setWordWrap(true); // QComboBox for language selection - auto* langLabel = new QLabel(tr("Choose a Language")); + auto* langLabel = new QLabel(_("Choose a Language")); langLabel->setWordWrap(true); languages = SettingsDialog::listLanguages(); @@ -99,7 +99,7 @@ IntroPage::IntroPage(QWidget* parent) // selected entry from config QString langKey = settings.value("int/lang").toString(); QString langValue = languages.value(langKey); - if (langKey != "") { + if (!langKey.isEmpty()) { langSelectBox->setCurrentIndex(langSelectBox->findText(langValue)); } @@ -120,35 +120,35 @@ void IntroPage::slotLangChange(const QString& lang) { qApp->exit(RESTART_CODE); } -int IntroPage::nextId() const { - return Wizard::Page_Choose; -} +int IntroPage::nextId() const { return Wizard::Page_Choose; } ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { - setTitle(tr("Choose your action...")); - setSubTitle(tr("...by clicking on the appropriate link.")); + setTitle(_("Choose your action...")); + setSubTitle(_("...by clicking on the appropriate link.")); auto* keygenLabel = 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") + + 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.pub/index.html#/manual/generate-key\">" + - tr("Generate Key") + "</a><hr>"); + _("Generate Key") + "</a><hr>"); keygenLabel->setTextFormat(Qt::RichText); keygenLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); keygenLabel->setOpenExternalLinks(true); keygenLabel->setWordWrap(true); auto* encrDecyTextLabel = new QLabel( - tr("If you want to learn how to encrypt, decrypt, sign and verify text, " - "you can read ") + + QString(_( + "If you want to learn how to encrypt, decrypt, sign and verify text, " + "you can read ")) + "<a " "href=\"https://gpgfrontend.pub/index.html#/manual/" "encrypt-decrypt-text\">" + - tr("Encrypt & Decrypt Text") + "</a> " + tr("or") + + _("Encrypt & Decrypt Text") + "</a> " + _("or") + " <a " "href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-text\">" + - tr("Sign & Verify Text") + "</a><hr>"); + _("Sign & Verify Text") + "</a><hr>"); encrDecyTextLabel->setTextFormat(Qt::RichText); encrDecyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); @@ -156,14 +156,14 @@ ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { encrDecyTextLabel->setWordWrap(true); auto* signVerifyTextLabel = new QLabel( - tr("If you want to operate file, you can read ") + + QString(_("If you want to operate file, you can read ")) + "<a " "href=\"https://gpgfrontend.pub/index.html#/manual/" "encrypt-decrypt-file\">" + - tr("Encrypt & Sign File") + "</a> " + tr("or") + + _("Encrypt & Sign File") + "</a> " + _("or") + " <a " "href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-file\">" + - tr("Sign & Verify File") + "</a><hr>"); + _("Sign & Verify File") + "</a><hr>"); signVerifyTextLabel->setTextFormat(Qt::RichText); signVerifyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); signVerifyTextLabel->setOpenExternalLinks(true); @@ -177,9 +177,7 @@ ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { nextPage = Wizard::Page_Conclusion; } -int ChoosePage::nextId() const { - return nextPage; -} +int ChoosePage::nextId() const { return nextPage; } void ChoosePage::slotJumpPage(const QString& page) { QMetaObject qmo = Wizard::staticMetaObject; @@ -191,22 +189,22 @@ void ChoosePage::slotJumpPage(const QString& page) { } KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { - setTitle(tr("Create a keypair...")); - setSubTitle(tr("...for decrypting and signing messages")); + setTitle(_("Create a keypair...")); + setSubTitle(_("...for decrypting and signing messages")); auto* topLabel = 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):")); + _("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( "<a href=" "docu_keygen.html#content" ">" + - tr("Offline tutorial") + "</a>"); + QString(_("Offline tutorial")) + "</a>"); // linkLabel->setOpenExternalLinks(true); // connect(linkLabel, SIGNAL(linkActivated(QString)), @@ -214,7 +212,7 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { auto* createKeyButtonBox = new QWidget(this); auto* createKeyButtonBoxLayout = new QHBoxLayout(createKeyButtonBox); - auto* createKeyButton = new QPushButton(tr("Create New Key")); + auto* createKeyButton = new QPushButton(_("Create New Key")); createKeyButtonBoxLayout->addWidget(createKeyButton); createKeyButtonBoxLayout->addStretch(1); auto* layout = new QVBoxLayout(); @@ -227,9 +225,7 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { setLayout(layout); } -int KeyGenPage::nextId() const { - return Wizard::Page_Conclusion; -} +int KeyGenPage::nextId() const { return Wizard::Page_Conclusion; } void KeyGenPage::slotGenerateKeyDialog() { qDebug() << "Try Opening KeyGenDialog"; @@ -238,27 +234,28 @@ void KeyGenPage::slotGenerateKeyDialog() { } ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { - setTitle(tr("Ready.")); - setSubTitle(tr("Have fun with GPGFrontend!")); + setTitle(_("Ready.")); + setSubTitle(_("Have fun with GpgFrontend!")); auto* bottomLabel = - new QLabel(tr("You are ready to use GPGFrontend now.<br><br>") + + new QLabel(QString(_("You are ready to use GpgFrontend now.<br><br>")) + "<a " "href=\"https://saturneric.github.io/GpgFrontend/index.html#/" "overview\">" + - tr("The Online Document") + "</a>" + - tr(" will get you started with GPGFrontend. It will open in " - "the main window.<br>")); + _("The Online Document") + "</a>" + + _(" will get you started with GpgFrontend. It will open in " + "the main window.") + + "<br>"); bottomLabel->setTextFormat(Qt::RichText); bottomLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); bottomLabel->setOpenExternalLinks(true); bottomLabel->setWordWrap(true); - openHelpCheckBox = new QCheckBox(tr("Open offline help.")); + openHelpCheckBox = new QCheckBox(_("Open offline help.")); openHelpCheckBox->setChecked(Qt::Checked); - dontShowWizardCheckBox = new QCheckBox(tr("Dont show the wizard again.")); + dontShowWizardCheckBox = new QCheckBox(_("Dont show the wizard again.")); dontShowWizardCheckBox->setChecked(Qt::Checked); registerField("showWizard", dontShowWizardCheckBox); @@ -272,8 +269,6 @@ ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { setVisible(true); } -int ConclusionPage::nextId() const { - return -1; -} +int ConclusionPage::nextId() const { return -1; } } // namespace GpgFrontend::UI diff --git a/src/ui/Wizard.h b/src/ui/Wizard.h index 41b1a745..e1e9092d 100644 --- a/src/ui/Wizard.h +++ b/src/ui/Wizard.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/help/AboutDialog.cpp index 4c6c2348..cd0010a6 100644 --- a/src/ui/help/AboutDialog.cpp +++ b/src/ui/help/AboutDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,8 +23,8 @@ */ #include "ui/help/AboutDialog.h" -#include "GpgFrontendBuildInfo.h" +#include "GpgFrontendBuildInfo.h" #include "rapidjson/document.h" #include "rapidjson/writer.h" @@ -33,16 +33,16 @@ using namespace rapidjson; namespace GpgFrontend::UI { AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) : QDialog(parent) { - this->setWindowTitle(tr("About ") + qApp->applicationName()); + this->setWindowTitle(QString(_("About")) + " " + qApp->applicationName()); auto* tabWidget = new QTabWidget; auto* infoTab = new InfoTab(); auto* translatorsTab = new TranslatorsTab(); updateTab = new UpdateTab(); - tabWidget->addTab(infoTab, tr("General")); - tabWidget->addTab(translatorsTab, tr("Translators")); - tabWidget->addTab(updateTab, tr("Update")); + tabWidget->addTab(infoTab, _("General")); + tabWidget->addTab(translatorsTab, _("Translators")); + tabWidget->addTab(updateTab, _("Update")); connect(tabWidget, &QTabWidget::currentChanged, this, [&](int index) { qDebug() << "Current Index" << index; }); @@ -73,20 +73,21 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { "<center><h2>" + qApp->applicationName() + "</h2></center>" + "<center><b>" + qApp->applicationVersion() + "</b></center>" + "<center>" + GIT_VERSION + "</center>" + - tr("<br><center>GPGFrontend is an easy-to-use, compact, cross-platform, " - "<br>" - "and installation-free gpg front-end tool.<br>" - "It visualizes most of the common operations of gpg commands.<br>" - "It's licensed under the GPL v3<br><br>" - "<b>Developer:</b><br>" - "Saturneric<br><br>" - "If you have any questions or suggestions, raise an issue<br/>" - "at <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> " - "or send a mail to my mailing list at <a " - "href=\"mailto:[email protected]\">[email protected]</a>.") + - tr("<br><br> Built with Qt ") + qVersion() + tr(" and GPGME ") + - GpgFrontend::GpgContext::getGpgmeVersion().c_str() + tr("<br>Built at ") + - BUILD_TIMESTAMP + "</center>"); + _("<br><center>GpgFrontend is an easy-to-use, compact, cross-platform, " + "<br>" + "and installation-free gpg front-end tool.<br>" + "It visualizes most of the common operations of gpg commands.<br>" + "It's licensed under the GPL v3<br><br>" + "<b>Developer:</b><br>" + "Saturneric<br><br>" + "If you have any questions or suggestions, raise an issue<br/>" + "at <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> " + "or send a mail to my mailing list at <a " + "href=\"mailto:[email protected]\">[email protected]</a>.") + + "<br><br> " + _("Built with Qt") + " " + qVersion() + " " + + _("and GPGME") + " " + + GpgFrontend::GpgContext::getGpgmeVersion().c_str() + "<br>" + + _("Built at") + " " + BUILD_TIMESTAMP + "</center>"); auto* layout = new QGridLayout(); auto* pixmapLabel = new QLabel(); @@ -128,18 +129,20 @@ UpdateTab::UpdateTab(QWidget* parent) { QString::number(VERSION_PATCH); auto tipsLabel = new QLabel(); - tipsLabel->setText("<center>" + - tr("It is recommended that you always check the version " - "of GpgFrontend and upgrade to the latest version.") + - "</center><br><center>" + - tr("New versions not only represent new features, but " - "also often represent functional and security fixes.") + - "</center>"); + tipsLabel->setText( + "<center>" + + QString(_("It is recommended that you always check the version " + "of GpgFrontend and upgrade to the latest version.")) + + "</center><br><center>" + + _("New versions not only represent new features, but " + "also often represent functional and security fixes.") + + "</center>"); tipsLabel->setWordWrap(true); currentVersionLabel = new QLabel(); - currentVersionLabel->setText("<center>" + tr("Current Version: ") + "<b>" + - currentVersion + "</b></center>"); + currentVersionLabel->setText("<center>" + QString(_("Current Version")) + + _(": ") + "<b>" + currentVersion + + "</b></center>"); currentVersionLabel->setWordWrap(true); latestVersionLabel = new QLabel(); @@ -148,13 +151,13 @@ UpdateTab::UpdateTab(QWidget* parent) { upgradeLabel = new QLabel(); upgradeLabel->setText( "<center>" + - tr("The current version is inconsistent with the latest version on " - "github.") + - "</center><br><center>" + - tr("Please click <a " - "href=\"https://github.com/saturneric/GpgFrontend/releases\">here</a> " - "to download the latest version.") + - "</center>"); + QString( + _("The current version is inconsistent with the latest version on " + "github.")) + + "</center><br><center>" + _("Please click") + + " <a " + "href=\"https://github.com/saturneric/GpgFrontend/releases\">here</a> " + + _("to download the latest version.") + "</center>"); upgradeLabel->setWordWrap(true); upgradeLabel->setOpenExternalLinks(true); upgradeLabel->setHidden(true); @@ -192,8 +195,7 @@ void UpdateTab::getLatestVersion() { request.setUrl(QUrl(baseUrl)); QNetworkReply* replay = manager->get(request); auto thread = QThread::create([replay, this]() { - while (replay->isRunning()) - QApplication::processEvents(); + while (replay->isRunning()) QApplication::processEvents(); emit replyFromUpdateServer(replay->readAll()); }); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); @@ -209,8 +211,8 @@ void UpdateTab::processReplyDataFromUpdateServer(const QByteArray& data) { if (d.Parse(data.constData()).HasParseError() || !d.IsObject()) { qDebug() << "VersionCheckThread Found Network Error"; auto latestVersion = "Unknown"; - latestVersionLabel->setText("<center><b>" + - tr("Latest Version From Github: ") + + latestVersionLabel->setText(QString("<center><b>") + + _("Latest Version From Github") + ": " + latestVersion + "</b></center>"); return; } @@ -228,11 +230,10 @@ void UpdateTab::processReplyDataFromUpdateServer(const QByteArray& data) { latestVersion = "Unknown"; latestVersionLabel->setText("<center><b>" + - tr("Latest Version From Github: ") + + QString(_("Latest Version From Github")) + ": " + latestVersion + "</b></center>"); - if (latestVersion > currentVersion) - upgradeLabel->setHidden(false); + if (latestVersion > currentVersion) upgradeLabel->setHidden(false); } } // namespace GpgFrontend::UI diff --git a/src/ui/help/AboutDialog.h b/src/ui/help/AboutDialog.h index 3b7d42c8..a7d7099b 100644 --- a/src/ui/help/AboutDialog.h +++ b/src/ui/help/AboutDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/help/VersionCheckThread.cpp b/src/ui/help/VersionCheckThread.cpp index 3204dadf..a35583f4 100644 --- a/src/ui/help/VersionCheckThread.cpp +++ b/src/ui/help/VersionCheckThread.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -23,6 +23,7 @@ */ #include "ui/help/VersionCheckThread.h" + #include "GpgFrontendBuildInfo.h" #include "rapidjson/document.h" diff --git a/src/ui/help/VersionCheckThread.h b/src/ui/help/VersionCheckThread.h index eedbfa5b..181ee947 100644 --- a/src/ui/help/VersionCheckThread.h +++ b/src/ui/help/VersionCheckThread.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/keygen/KeygenDialog.cpp index a8bc6935..382be5cb 100644 --- a/src/ui/keygen/KeygenDialog.cpp +++ b/src/ui/keygen/KeygenDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -34,7 +34,7 @@ KeyGenDialog::KeyGenDialog(QWidget* parent) : QDialog(parent) { buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - this->setWindowTitle(tr("Generate Key")); + this->setWindowTitle(_("Generate Key")); this->setModal(true); connect(this, SIGNAL(KeyGenerated()), SignalStation::GetInstance(), @@ -66,16 +66,17 @@ void KeyGenDialog::generateKeyDialog() { } void KeyGenDialog::slotKeyGenAccept() { - QString errorString = ""; + std::stringstream error_stream; /** * check for errors in keygen dialog input */ if ((nameEdit->text()).size() < 5) { - errorString.append(tr(" Name must contain at least five characters. \n")); + error_stream << " " << _("Name must contain at least five characters.") + << std::endl; } if (emailEdit->text().isEmpty() || !check_email_address(emailEdit->text())) { - errorString.append(tr(" Please give a email address. \n")); + error_stream << " " << _("Please give a email address.") << std::endl; } /** @@ -83,10 +84,13 @@ void KeyGenDialog::slotKeyGenAccept() { * in the future) */ if (dateEdit->dateTime() > QDateTime::currentDateTime().addYears(2)) { - errorString.append(tr(" Expiration time no more than 2 years. \n")); + error_stream << " " << _("Expiration time no more than 2 years.") + << std::endl; } - if (errorString.isEmpty()) { + auto err_string = error_stream.str(); + + if (err_string.empty()) { /** * create the string for key generation */ @@ -124,15 +128,15 @@ void KeyGenDialog::slotKeyGenAccept() { auto* msg_box = new QMessageBox(nullptr); msg_box->setAttribute(Qt::WA_DeleteOnClose); msg_box->setStandardButtons(QMessageBox::Ok); - msg_box->setWindowTitle(tr("Success")); - msg_box->setText(tr("The new key pair has been generated.")); + msg_box->setWindowTitle(_("Success")); + msg_box->setText(_("The new key pair has been generated.")); msg_box->setModal(false); msg_box->open(); emit KeyGenerated(); this->close(); } else { - QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(error))); + QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(error))); } } else { @@ -143,7 +147,7 @@ void KeyGenDialog::slotKeyGenAccept() { QPalette error = errorLabel->palette(); error.setColor(QPalette::Window, "#ff8080"); errorLabel->setPalette(error); - errorLabel->setText(errorString); + errorLabel->setText(err_string.c_str()); this->show(); } @@ -161,18 +165,18 @@ QGroupBox* KeyGenDialog::create_key_usage_group_box() { auto* groupBox = new QGroupBox(this); auto* grid = new QGridLayout(this); - groupBox->setTitle(tr("Key Usage")); + groupBox->setTitle(_("Key Usage")); - auto* encrypt = new QCheckBox(tr("Encryption"), groupBox); + auto* encrypt = new QCheckBox(_("Encryption"), groupBox); encrypt->setTristate(false); - auto* sign = new QCheckBox(tr("Signing"), groupBox); + auto* sign = new QCheckBox(_("Signing"), groupBox); sign->setTristate(false); - auto* cert = new QCheckBox(tr("Certification"), groupBox); + auto* cert = new QCheckBox(_("Certification"), groupBox); cert->setTristate(false); - auto* auth = new QCheckBox(tr("Authentication"), groupBox); + auto* auth = new QCheckBox(_("Authentication"), groupBox); auth->setTristate(false); keyUsageCheckBoxes.push_back(encrypt); @@ -317,7 +321,7 @@ bool KeyGenDialog::check_email_address(const QString& str) { } QGroupBox* KeyGenDialog::create_basic_info_group_box() { - errorLabel = new QLabel(tr("")); + errorLabel = new QLabel(); nameEdit = new QLineEdit(this); emailEdit = new QLineEdit(this); commentEdit = new QLineEdit(this); @@ -348,14 +352,14 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() { auto* vbox1 = new QGridLayout; - 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(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(nameEdit, 0, 1, 1, 3); vbox1->addWidget(emailEdit, 1, 1, 1, 3); @@ -368,7 +372,7 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() { auto basicInfoGroupBox = new QGroupBox(); basicInfoGroupBox->setLayout(vbox1); - basicInfoGroupBox->setTitle(tr("Basic Information")); + basicInfoGroupBox->setTitle(_("Basic Information")); return basicInfoGroupBox; } diff --git a/src/ui/keygen/KeygenDialog.h b/src/ui/keygen/KeygenDialog.h index 60a34a90..c16a2e76 100644 --- a/src/ui/keygen/KeygenDialog.h +++ b/src/ui/keygen/KeygenDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -44,8 +44,8 @@ class KeyGenDialog : public QDialog { */ explicit KeyGenDialog(QWidget* parent = nullptr); - signals: - void KeyGenerated(); + signals: + void KeyGenerated(); private: QGroupBox* create_key_usage_group_box(); @@ -54,7 +54,7 @@ class KeyGenDialog : public QDialog { QRegularExpression re_email{ R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"}; - + QStringList errorMessages; /** List of errors occuring when checking entries of lineedits */ std::unique_ptr<GenKeyInfo> genKeyInfo = std::make_unique<GenKeyInfo>(); diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/keygen/SubkeyGenerateDialog.cpp index 41bc36c9..593b1cae 100644 --- a/src/ui/keygen/SubkeyGenerateDialog.cpp +++ b/src/ui/keygen/SubkeyGenerateDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -50,7 +50,7 @@ SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent) vbox2->addWidget(errorLabel); vbox2->addWidget(buttonBox); - this->setWindowTitle(tr("Generate New Subkey")); + this->setWindowTitle(_("Generate New Subkey")); this->setLayout(vbox2); this->setModal(true); @@ -67,16 +67,16 @@ QGroupBox* SubkeyGenerateDialog::create_key_usage_group_box() { groupBox->setTitle("Key Usage"); - auto* encrypt = new QCheckBox(tr("Encryption"), groupBox); + auto* encrypt = new QCheckBox(_("Encryption"), groupBox); encrypt->setTristate(false); - auto* sign = new QCheckBox(tr("Signing"), groupBox); + auto* sign = new QCheckBox(_("Signing"), groupBox); sign->setTristate(false); - auto* cert = new QCheckBox(tr("Certification"), groupBox); + auto* cert = new QCheckBox(_("Certification"), groupBox); cert->setTristate(false); - auto* auth = new QCheckBox(tr("Authentication"), groupBox); + auto* auth = new QCheckBox(_("Authentication"), groupBox); auth->setTristate(false); keyUsageCheckBoxes.push_back(encrypt); @@ -95,7 +95,7 @@ QGroupBox* SubkeyGenerateDialog::create_key_usage_group_box() { } QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() { - errorLabel = new QLabel(tr("")); + errorLabel = new QLabel(); keySizeSpinBox = new QSpinBox(this); keyTypeComboBox = new QComboBox(this); @@ -120,10 +120,10 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() { auto* vbox1 = new QGridLayout; - vbox1->addWidget(new QLabel(tr("Expiration Date:")), 2, 0); - vbox1->addWidget(new QLabel(tr("Never Expire")), 2, 3); - vbox1->addWidget(new QLabel(tr("KeySize (in Bit):")), 1, 0); - vbox1->addWidget(new QLabel(tr("Key Type:")), 0, 0); + vbox1->addWidget(new QLabel(QString(_("Expiration Date")) + ": "), 2, 0); + vbox1->addWidget(new QLabel(QString(_("Never Expire")) + ": "), 2, 3); + vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 1, 0); + vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 0, 0); vbox1->addWidget(dateEdit, 2, 1); vbox1->addWidget(expireCheckBox, 2, 2); @@ -132,7 +132,7 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() { auto basicInfoGroupBox = new QGroupBox(); basicInfoGroupBox->setLayout(vbox1); - basicInfoGroupBox->setTitle(tr("Basic Information")); + basicInfoGroupBox->setTitle(_("Basic Information")); return basicInfoGroupBox; } @@ -215,17 +215,19 @@ void SubkeyGenerateDialog::refresh_widgets_state() { } void SubkeyGenerateDialog::slotKeyGenAccept() { - QString errorString = ""; + std::stringstream err_stream; /** * primary keys should have a reasonable expiration date (no more than 2 years * in the future) */ if (dateEdit->dateTime() > QDateTime::currentDateTime().addYears(2)) { - errorString.append(tr(" Expiration time no more than 2 years. ")); + err_stream << " " << _("Expiration time no more than 2 years.") << " "; } - if (errorString.isEmpty()) { + auto err_string = err_stream.str(); + + if (err_string.empty()) { genKeyInfo->setKeySize(keySizeSpinBox->value()); if (expireCheckBox->checkState()) { @@ -255,15 +257,15 @@ void SubkeyGenerateDialog::slotKeyGenAccept() { auto* msg_box = new QMessageBox(nullptr); msg_box->setAttribute(Qt::WA_DeleteOnClose); msg_box->setStandardButtons(QMessageBox::Ok); - msg_box->setWindowTitle(tr("Success")); - msg_box->setText(tr("The new subkey has been generated.")); + msg_box->setWindowTitle(_("Success")); + msg_box->setText(_("The new subkey has been generated.")); msg_box->setModal(false); msg_box->open(); emit SubKeyGenerated(); this->close(); } else - QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(error))); + QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(error))); } else { /** @@ -273,7 +275,7 @@ void SubkeyGenerateDialog::slotKeyGenAccept() { QPalette error = errorLabel->palette(); error.setColor(QPalette::Window, "#ff8080"); errorLabel->setPalette(error); - errorLabel->setText(errorString); + errorLabel->setText(err_string.c_str()); this->show(); } diff --git a/src/ui/keygen/SubkeyGenerateDialog.h b/src/ui/keygen/SubkeyGenerateDialog.h index 12f608d0..ec7c9fb1 100644 --- a/src/ui/keygen/SubkeyGenerateDialog.h +++ b/src/ui/keygen/SubkeyGenerateDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/keypair_details/EditSubKeyDialog.cpp b/src/ui/keypair_details/EditSubKeyDialog.cpp index e44c987f..6c2e0ce1 100644 --- a/src/ui/keypair_details/EditSubKeyDialog.cpp +++ b/src/ui/keypair_details/EditSubKeyDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/keypair_details/EditSubKeyDialog.h b/src/ui/keypair_details/EditSubKeyDialog.h index 6577d382..51842405 100644 --- a/src/ui/keypair_details/EditSubKeyDialog.h +++ b/src/ui/keypair_details/EditSubKeyDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,10 +25,6 @@ #ifndef GPGFRONTEND_EDITSUBKEY_H #define GPGFRONTEND_EDITSUBKEY_H +class EditSubKeyDialog {}; -class EditSubKeyDialog { - -}; - - -#endif //GPGFRONTEND_EDITSUBKEY_H +#endif // GPGFRONTEND_EDITSUBKEY_H diff --git a/src/ui/keypair_details/KeyDetailsDialog.cpp b/src/ui/keypair_details/KeyDetailsDialog.cpp index 54bc6286..f3cab771 100644 --- a/src/ui/keypair_details/KeyDetailsDialog.cpp +++ b/src/ui/keypair_details/KeyDetailsDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -28,16 +28,16 @@ namespace GpgFrontend::UI { KeyDetailsDialog::KeyDetailsDialog(const GpgKey& key, QWidget* parent) : QDialog(parent) { tabWidget = new QTabWidget(); - tabWidget->addTab(new KeyPairDetailTab(key.id(), tabWidget), tr("KeyPair")); - tabWidget->addTab(new KeyPairUIDTab(key.id(), tabWidget), tr("UIDs")); - tabWidget->addTab(new KeyPairSubkeyTab(key.id(), tabWidget), tr("Subkeys")); + tabWidget->addTab(new KeyPairDetailTab(key.id(), tabWidget), _("KeyPair")); + tabWidget->addTab(new KeyPairUIDTab(key.id(), tabWidget), _("UIDs")); + tabWidget->addTab(new KeyPairSubkeyTab(key.id(), tabWidget), _("Subkeys")); auto* mainLayout = new QVBoxLayout; mainLayout->addWidget(tabWidget); this->setAttribute(Qt::WA_DeleteOnClose, true); this->setLayout(mainLayout); - this->setWindowTitle(tr("Key Details")); + this->setWindowTitle(_("Key Details")); this->setModal(true); this->setMinimumSize(380, 620); this->show(); diff --git a/src/ui/keypair_details/KeyDetailsDialog.h b/src/ui/keypair_details/KeyDetailsDialog.h index 0f7342aa..51fc01cf 100644 --- a/src/ui/keypair_details/KeyDetailsDialog.h +++ b/src/ui/keypair_details/KeyDetailsDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/keypair_details/KeyNewUIDDialog.cpp index 00401231..809a05f8 100644 --- a/src/ui/keypair_details/KeyNewUIDDialog.cpp +++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -41,9 +41,9 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) errorLabel = new QLabel(); auto gridLayout = new QGridLayout(); - 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(new QLabel(_("Name")), 0, 0); + gridLayout->addWidget(new QLabel(_("Email")), 1, 0); + gridLayout->addWidget(new QLabel(_("Comment")), 2, 0); gridLayout->addWidget(name, 0, 1); gridLayout->addWidget(email, 1, 1); @@ -51,14 +51,14 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) gridLayout->addWidget(createButton, 3, 0, 1, 2); gridLayout->addWidget( - new QLabel(tr("Notice: The New UID Created will be set as Primary.")), 4, + new QLabel(_("Notice: The New UID Created will be set as Primary.")), 4, 0, 1, 2); gridLayout->addWidget(errorLabel, 5, 0, 1, 2); connect(createButton, SIGNAL(clicked(bool)), this, SLOT(slotCreateNewUID())); this->setLayout(gridLayout); - this->setWindowTitle(tr("Create New UID")); + this->setWindowTitle(_("Create New UID")); this->setAttribute(Qt::WA_DeleteOnClose, true); this->setModal(true); @@ -67,19 +67,20 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent) } void KeyNewUIDDialog::slotCreateNewUID() { - QString errorString = ""; + std::stringstream error_stream; /** * check for errors in keygen dialog input */ if ((name->text()).size() < 5) { - errorString.append(tr(" Name must contain at least five characters. \n")); + error_stream << " " << _("Name must contain at least five characters.") + << std::endl; } if (email->text().isEmpty() || !check_email_address(email->text())) { - errorString.append(tr(" Please give a email address. \n")); + error_stream << " " << _("Please give a email address.") << std::endl; } - - if (errorString.isEmpty()) { + auto error_string = error_stream.str(); + if (error_string.empty()) { if (UidOperator::GetInstance().addUID(mKey, name->text().toStdString(), comment->text().toStdString(), email->text().toStdString())) { @@ -96,7 +97,7 @@ void KeyNewUIDDialog::slotCreateNewUID() { QPalette error = errorLabel->palette(); error.setColor(QPalette::Window, "#ff8080"); errorLabel->setPalette(error); - errorLabel->setText(errorString); + errorLabel->setText(error_string.c_str()); this->show(); } diff --git a/src/ui/keypair_details/KeyNewUIDDialog.h b/src/ui/keypair_details/KeyNewUIDDialog.h index 73c4aa7b..2e38a7f4 100644 --- a/src/ui/keypair_details/KeyNewUIDDialog.h +++ b/src/ui/keypair_details/KeyNewUIDDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -35,8 +35,8 @@ class KeyNewUIDDialog : public QDialog { public: KeyNewUIDDialog(const KeyId& key, QWidget* parent = nullptr); - signals: - void signalUIDCreated(); + signals: + void signalUIDCreated(); private slots: diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp index 34639cbb..a7d082d1 100644 --- a/src/ui/keypair_details/KeyPairDetailTab.cpp +++ b/src/ui/keypair_details/KeyPairDetailTab.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -34,10 +34,10 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) : QWidget(parent), mKey(GpgKeyGetter::GetInstance().GetKey(key_id)) { keyid = mKey.id(); - ownerBox = new QGroupBox(tr("Owner")); - keyBox = new QGroupBox(tr("Master Key")); - fingerprintBox = new QGroupBox(tr("Fingerprint")); - additionalUidBox = new QGroupBox(tr("Additional UIDs")); + ownerBox = new QGroupBox(_("Owner")); + keyBox = new QGroupBox(_("Master Key")); + fingerprintBox = new QGroupBox(_("Fingerprint")); + additionalUidBox = new QGroupBox(_("Additional UIDs")); nameVarLabel = new QLabel(); nameVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); @@ -59,7 +59,7 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) // Show the situation that master key not exists. masterKeyExistVarLabel = - new QLabel(mKey.has_master_key() ? tr("Exists") : tr("Not Exists")); + new QLabel(mKey.has_master_key() ? _("Exists") : _("Not Exists")); if (!mKey.has_master_key()) { auto paletteExpired = masterKeyExistVarLabel->palette(); paletteExpired.setColor(masterKeyExistVarLabel->foregroundRole(), Qt::red); @@ -85,21 +85,22 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) auto* vboxKD = new QGridLayout(); auto* vboxOD = new QGridLayout(); - vboxOD->addWidget(new QLabel(tr("Name:")), 0, 0); - vboxOD->addWidget(new QLabel(tr("Email Address:")), 1, 0); - vboxOD->addWidget(new QLabel(tr("Comment:")), 2, 0); + vboxOD->addWidget(new QLabel(QString(_("Name")) + ": "), 0, 0); + vboxOD->addWidget(new QLabel(QString(_("Email Address")) + ": "), 1, 0); + vboxOD->addWidget(new QLabel(QString(_("Comment")) + ": "), 2, 0); vboxOD->addWidget(nameVarLabel, 0, 1); vboxOD->addWidget(emailVarLabel, 1, 1); vboxOD->addWidget(commentVarLabel, 2, 1); - vboxKD->addWidget(new QLabel(tr("Key ID: ")), 0, 0); - vboxKD->addWidget(new QLabel(tr("Algorithm: ")), 1, 0); - vboxKD->addWidget(new QLabel(tr("Key Size:")), 2, 0); - vboxKD->addWidget(new QLabel(tr("Nominal Usage: ")), 3, 0); - vboxKD->addWidget(new QLabel(tr("Actual Usage: ")), 4, 0); - vboxKD->addWidget(new QLabel(tr("Expires on: ")), 5, 0); - vboxKD->addWidget(new QLabel(tr("Last Update: ")), 6, 0); - vboxKD->addWidget(new QLabel(tr("Secret Key Existence: ")), 7, 0); + vboxKD->addWidget(new QLabel(QString(_("Key ID")) + ": "), 0, 0); + vboxKD->addWidget(new QLabel(QString(_("Algorithm")) + ": "), 1, 0); + vboxKD->addWidget(new QLabel(QString(_("Key Size")) + ": "), 2, 0); + vboxKD->addWidget(new QLabel(QString(_("Nominal Usage")) + ": "), 3, 0); + vboxKD->addWidget(new QLabel(QString(_("Actual Usage")) + ": "), 4, 0); + vboxKD->addWidget(new QLabel(QString(_("Expires on")) + ": "), 5, 0); + vboxKD->addWidget(new QLabel(QString(_("Last Update")) + ": "), 6, 0); + vboxKD->addWidget(new QLabel(QString(_("Secret Key Existence")) + ": "), 7, + 0); vboxKD->addWidget(keySizeVarLabel, 2, 1); vboxKD->addWidget(expireVarLabel, 5, 1); @@ -123,9 +124,9 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) hboxFP->addWidget(fingerPrintVarLabel); - auto* copyFingerprintButton = new QPushButton(tr("Copy")); + auto* copyFingerprintButton = new QPushButton(_("Copy")); copyFingerprintButton->setFlat(true); - copyFingerprintButton->setToolTip(tr("copy fingerprint to clipboard")); + copyFingerprintButton->setToolTip(_("copy fingerprint to clipboard")); connect(copyFingerprintButton, SIGNAL(clicked()), this, SLOT(slotCopyFingerprint())); @@ -136,29 +137,29 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) mvbox->addStretch(); if (mKey.is_private_key()) { - auto* privKeyBox = new QGroupBox(tr("Operations")); + auto* privKeyBox = new QGroupBox(_("Operations")); auto* vboxPK = new QVBoxLayout(); auto* exportButton = - new QPushButton(tr("Export Private Key (Include Subkey)")); + new QPushButton(_("Export Private Key (Include Subkey)")); vboxPK->addWidget(exportButton); connect(exportButton, SIGNAL(clicked()), this, SLOT(slotExportPrivateKey())); if (mKey.has_master_key()) { auto* editExpiresButton = - new QPushButton(tr("Modify Expiration Datetime (Master Key)")); + new QPushButton(_("Modify Expiration Datetime (Master Key)")); vboxPK->addWidget(editExpiresButton); connect(editExpiresButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime())); auto hBoxLayout = new QHBoxLayout(); auto* keyServerOperaButton = - new QPushButton(tr("Key Server Operation (Pubkey)")); + new QPushButton(_("Key Server Operation (Pubkey)")); keyServerOperaButton->setStyleSheet("text-align:center;"); auto* revokeCertGenButton = - new QPushButton(tr("Generate Revoke Certificate")); + new QPushButton(_("Generate Revoke Certificate")); connect(revokeCertGenButton, SIGNAL(clicked()), this, SLOT(slotGenRevokeCert())); @@ -185,10 +186,10 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) auto* expLabel = new QLabel(); auto* iconLabel = new QLabel(); if (mKey.expired()) { - expLabel->setText(tr("Warning: The Master Key has expired.")); + expLabel->setText(_("Warning: The Master Key has expired.")); } if (mKey.revoked()) { - expLabel->setText(tr("Warning: The Master Key has been revoked")); + expLabel->setText(_("Warning: The Master Key has been revoked")); } iconLabel->setPixmap(pixmap.scaled(24, 24, Qt::KeepAspectRatio)); @@ -215,11 +216,11 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) void KeyPairDetailTab::slotExportPrivateKey() { // Show a information box with explanation about private key int ret = QMessageBox::information( - 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?"), + 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?"), QMessageBox::Cancel | QMessageBox::Ok); // export key, if ok was clicked @@ -234,21 +235,21 @@ void KeyPairDetailTab::slotExportPrivateKey() { auto key = GpgKeyGetter::GetInstance().GetKey(keyid); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } auto fileString = key.name() + " " + key.email() + "(" + key.id() + ")_secret.asc"; auto fileName = QFileDialog::getSaveFileName( - this, tr("Export Key To File"), QString::fromStdString(fileString), - tr("Key Files") + " (*.asc *.txt);;All Files (*)") + this, _("Export Key To File"), QString::fromStdString(fileString), + QString(_("Key Files")) + " (*.asc *.txt);;All Files (*)") .toStdString(); if (!write_buffer_to_file(fileName, *keyArray)) { - QMessageBox::critical(nullptr, tr("Export Error"), - tr("Couldn't open %1 for writing") - .arg(QString::fromStdString(fileName))); + QMessageBox::critical( + nullptr, _("Export Error"), + QString(_("Couldn't open %1 for writing")).arg(fileName.c_str())); return; } } @@ -263,7 +264,7 @@ QString KeyPairDetailTab::beautifyFingerprint(QString fingerprint) { } void KeyPairDetailTab::slotCopyFingerprint() { - QString fpr = fingerPrintVarLabel->text().trimmed().replace(" ", ""); + QString fpr = fingerPrintVarLabel->text().trimmed().replace(" ", QString()); QClipboard* cb = QApplication::clipboard(); cb->setText(fpr); } @@ -305,7 +306,7 @@ void KeyPairDetailTab::slotRefreshKeyInfo() { keySizeVal = QString::number(mKey.length()); if (to_time_t(boost::posix_time::ptime(mKey.expires())) == 0) { - keyExpireVal = tr("Never Expire"); + keyExpireVal = _("Never Expire"); } else { keyExpireVal = QString::fromStdString(boost::gregorian::to_iso_string(mKey.expires())); @@ -327,10 +328,10 @@ void KeyPairDetailTab::slotRefreshKeyInfo() { void KeyPairDetailTab::createKeyServerOperaMenu() { keyServerOperaMenu = new QMenu(this); - auto* uploadKeyPair = new QAction(tr("Upload Key Pair to Key Server"), this); + auto* uploadKeyPair = new QAction(_("Upload Key Pair to Key Server"), this); connect(uploadKeyPair, SIGNAL(triggered()), this, SLOT(slotUploadKeyToServer())); - auto* updateKeyPair = new QAction(tr("Update Key Pair"), this); + auto* updateKeyPair = new QAction(_("Update Key Pair"), this); connect(updateKeyPair, SIGNAL(triggered()), this, SLOT(slotUpdateKeyToServer())); @@ -356,8 +357,8 @@ void KeyPairDetailTab::slotUpdateKeyToServer() { void KeyPairDetailTab::slotGenRevokeCert() { auto mOutputFileName = QFileDialog::getSaveFileName( - this, tr("Generate revocation certificate"), QString(), - QStringLiteral("%1 (*.rev)").arg(tr("Revocation Certificates"))); + this, _("Generate revocation certificate"), QString(), + QStringLiteral("%1 (*.rev)").arg(_("Revocation Certificates"))); // if (!mOutputFileName.isEmpty()) // mCtx->generateRevokeCert(mKey, mOutputFileName); diff --git a/src/ui/keypair_details/KeyPairDetailTab.h b/src/ui/keypair_details/KeyPairDetailTab.h index 5f6e93fe..782696ac 100644 --- a/src/ui/keypair_details/KeyPairDetailTab.h +++ b/src/ui/keypair_details/KeyPairDetailTab.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/keypair_details/KeyPairSubkeyTab.cpp index 61007b37..7b239bf1 100644 --- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp +++ b/src/ui/keypair_details/KeyPairSubkeyTab.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -39,7 +39,7 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent) auto uidButtonsLayout = new QGridLayout(); - auto addSubkeyButton = new QPushButton(tr("Generate A New Subkey")); + auto addSubkeyButton = new QPushButton(_("Generate A New Subkey")); if (!mKey.is_private_key() || !mKey.has_master_key()) { addSubkeyButton->setDisabled(true); setHidden(addSubkeyButton); @@ -56,14 +56,20 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent) auto* subkeyDetailLayout = new QGridLayout(); - subkeyDetailLayout->addWidget(new QLabel(tr("Key ID: ")), 0, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Algorithm: ")), 1, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Key Size:")), 2, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Usage: ")), 3, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Expires On ")), 4, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Last Update: ")), 5, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Existence: ")), 6, 0); - subkeyDetailLayout->addWidget(new QLabel(tr("Fingerprint: ")), 7, 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Key ID")) + ": "), 0, 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Algorithm")) + ": "), 1, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Key Size")) + ": "), 2, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Usage")) + ": "), 3, 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Expires On")) + ": "), 4, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Last Update")) + ": "), 5, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Existence")) + ": "), 6, + 0); + subkeyDetailLayout->addWidget(new QLabel(QString(_("Fingerprint")) + ": "), 7, + 0); keyidVarLabel = new QLabel(); keySizeVarLabel = new QLabel(); @@ -128,8 +134,8 @@ void KeyPairSubkeyTab::createSubkeyList() { subkeyList->setAlternatingRowColors(true); QStringList labels; - labels << tr("Subkey ID") << tr("Key Size") << tr("Algo") << tr("Create Date") - << tr("Expire Date"); + labels << _("Subkey ID") << _("Key Size") << _("Algo") << _("Create Date") + << _("Expire Date"); subkeyList->setHorizontalHeaderLabels(labels); subkeyList->horizontalHeader()->setStretchLastSection(false); @@ -172,7 +178,7 @@ void KeyPairSubkeyTab::slotRefreshSubkeyList() { auto* tmp4 = new QTableWidgetItem( boost::posix_time::to_time_t( boost::posix_time::ptime(subkeys.expires())) == 0 - ? tr("Never Expire") + ? _("Never Expire") : QString::fromStdString(to_iso_string(subkeys.expires()))); tmp4->setTextAlignment(Qt::AlignCenter); subkeyList->setItem(row, 4, tmp4); @@ -207,7 +213,7 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() { expireVarLabel->setText( subkey_time_t == 0 - ? tr("Never Expires") + ? _("Never Expires") : QString::fromStdString(to_iso_string(subkey.expires()))); if (subkey_time_t != 0 && subkey.expires() < boost::posix_time::second_clock::local_time().date()) { @@ -227,15 +233,16 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() { QString usage; QTextStream usage_steam(&usage); - if (subkey.can_certify()) usage_steam << "Cert "; - if (subkey.can_encrypt()) usage_steam << "Encr "; - if (subkey.can_sign()) usage_steam << "Sign "; - if (subkey.can_authenticate()) usage_steam << "Auth "; + if (subkey.can_certify()) usage_steam << _("Cert") << " "; + if (subkey.can_encrypt()) usage_steam << _("Encr") << " "; + if (subkey.can_sign()) usage_steam << _("Sign") << " "; + if (subkey.can_authenticate()) usage_steam << _("Auth") << " "; usageVarLabel->setText(usage); // Show the situation that master key not exists. - masterKeyExistVarLabel->setText(subkey.secret() ? "Exists" : "Not Exists"); + masterKeyExistVarLabel->setText(subkey.secret() ? _("Exists") + : _("Not Exists")); if (!subkey.secret()) { auto paletteExpired = masterKeyExistVarLabel->palette(); paletteExpired.setColor(masterKeyExistVarLabel->foregroundRole(), Qt::red); @@ -252,8 +259,8 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() { void KeyPairSubkeyTab::createSubkeyOperaMenu() { subkeyOperaMenu = new QMenu(this); - // auto *revokeSubkeyAct = new QAction(tr("Revoke Subkey")); - auto* editSubkeyAct = new QAction(tr("Edit Expire Date")); + // auto *revokeSubkeyAct = new QAction(_("Revoke Subkey")); + auto* editSubkeyAct = new QAction(_("Edit Expire Date")); connect(editSubkeyAct, SIGNAL(triggered(bool)), this, SLOT(slotEditSubkey())); // subkeyOperaMenu->addAction(revokeSubkeyAct); diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.h b/src/ui/keypair_details/KeyPairSubkeyTab.h index 6466d8b4..018f6ddc 100644 --- a/src/ui/keypair_details/KeyPairSubkeyTab.h +++ b/src/ui/keypair_details/KeyPairSubkeyTab.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -25,10 +25,9 @@ #ifndef GPGFRONTEND_KEYPAIRSUBKEYTAB_H #define GPGFRONTEND_KEYPAIRSUBKEYTAB_H -#include "ui/GpgFrontendUI.h" - #include "KeySetExpireDateDialog.h" #include "gpg/GpgContext.h" +#include "ui/GpgFrontendUI.h" #include "ui/keygen/SubkeyGenerateDialog.h" namespace GpgFrontend::UI { diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp index f787bebd..7358c20a 100644 --- a/src/ui/keypair_details/KeyPairUIDTab.cpp +++ b/src/ui/keypair_details/KeyPairUIDTab.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -41,8 +41,8 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent) auto uidButtonsLayout = new QGridLayout(); - auto addUIDButton = new QPushButton(tr("New UID")); - auto manageUIDButton = new QPushButton(tr("UID Management")); + auto addUIDButton = new QPushButton(_("New UID")); + auto manageUIDButton = new QPushButton(_("UID Management")); if (mKey.has_master_key()) { manageUIDButton->setMenu(manageSelectedUIDMenu); @@ -61,7 +61,7 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent) auto uidGroupBox = new QGroupBox(); uidGroupBox->setLayout(gridLayout); - uidGroupBox->setTitle(tr("UIDs")); + uidGroupBox->setTitle(_("UIDs")); auto signGridLayout = new QGridLayout(); signGridLayout->addWidget(sigList, 0, 0); @@ -69,7 +69,7 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent) auto signGroupBox = new QGroupBox(); signGroupBox->setLayout(signGridLayout); - signGroupBox->setTitle(tr("Signature of Selected UID")); + signGroupBox->setTitle(_("Signature of Selected UID")); auto vboxLayout = new QVBoxLayout(); vboxLayout->addWidget(uidGroupBox); @@ -112,7 +112,7 @@ void KeyPairUIDTab::createUIDList() { uidList->setAlternatingRowColors(true); QStringList labels; - labels << tr("Select") << tr("Name") << tr("Email") << tr("Comment"); + labels << _("Select") << _("Name") << _("Email") << _("Comment"); uidList->setHorizontalHeaderLabels(labels); uidList->horizontalHeader()->setStretchLastSection(true); } @@ -135,8 +135,8 @@ void KeyPairUIDTab::createSignList() { sigList->setAlternatingRowColors(true); QStringList labels; - labels << tr("Key ID") << tr("Name") << tr("Email") << tr("Create Date") - << tr("Expired Date"); + labels << _("Key ID") << _("Name") << _("Email") << _("Create Date") + << _("Expired Date"); sigList->setHorizontalHeaderLabels(labels); sigList->horizontalHeader()->setStretchLastSection(false); } @@ -235,7 +235,7 @@ void KeyPairUIDTab::slotRefreshSigList() { auto* tmp5 = new QTableWidgetItem( boost::posix_time::to_time_t( boost::posix_time::ptime(sig.expire_time())) == 0 - ? tr("Never Expires") + ? _("Never Expires") : QString::fromStdString( boost::gregorian::to_iso_string(sig.expire_time()))); tmp5->setTextAlignment(Qt::AlignCenter); @@ -253,8 +253,8 @@ void KeyPairUIDTab::slotAddSign() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one or more UIDs before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one or more UIDs before doing this operation.")); return; } @@ -275,9 +275,9 @@ UIDArgsListPtr KeyPairUIDTab::getUIDChecked() { void KeyPairUIDTab::createManageUIDMenu() { manageSelectedUIDMenu = new QMenu(this); - auto* signUIDAct = new QAction(tr("Sign Selected UID(s)"), this); + auto* signUIDAct = new QAction(_("Sign Selected UID(s)"), this); connect(signUIDAct, SIGNAL(triggered()), this, SLOT(slotAddSign())); - auto* delUIDAct = new QAction(tr("Delete Selected UID(s)"), this); + auto* delUIDAct = new QAction(_("Delete Selected UID(s)"), this); connect(delUIDAct, SIGNAL(triggered()), this, SLOT(slotDelUID())); if (mKey.has_master_key()) { @@ -297,11 +297,11 @@ void KeyPairUIDTab::slotAddUID() { void KeyPairUIDTab::slotAddUIDResult(int result) { if (result == 1) { - QMessageBox::information(nullptr, tr("Successful Operation"), - tr("Successfully added a new UID.")); + QMessageBox::information(nullptr, _("Successful Operation"), + _("Successfully added a new UID.")); } else if (result == -1) { - QMessageBox::critical(nullptr, tr("Operation Failed"), - tr("An error occurred during the operation.")); + QMessageBox::critical(nullptr, _("Operation Failed"), + _("An error occurred during the operation.")); } } @@ -310,8 +310,8 @@ void KeyPairUIDTab::slotDelUID() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one or more UIDs before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one or more UIDs before doing this operation.")); return; } @@ -322,10 +322,12 @@ void KeyPairUIDTab::slotDelUID() { } int ret = QMessageBox::warning( - this, tr("Deleting UIDs"), - "<b>" + tr("Are you sure that you want to delete the following uids?") + + this, _("Deleting UIDs"), + "<b>" + + QString( + _("Are you sure that you want to delete the following UIDs?")) + "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); bool if_all_success = true; @@ -340,8 +342,8 @@ void KeyPairUIDTab::slotDelUID() { if (!if_all_success) { QMessageBox::critical( - nullptr, tr("Operation Failed"), - tr("At least an error occurred during the operation.")); + nullptr, _("Operation Failed"), + _("At least an error occurred during the operation.")); } emit signalUpdateUIDInfo(); } @@ -363,17 +365,18 @@ void KeyPairUIDTab::slotSetPrimaryUID() { keynames.append("<br/>"); int ret = QMessageBox::warning( - this, tr("Set Primary UID"), - "<b>" + tr("Are you sure that you want to set the Primary UID to?") + + this, _("Set Primary UID"), + "<b>" + + QString(_("Are you sure that you want to set the Primary UID to?")) + "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { if (!UidOperator::GetInstance().setPrimaryUID(mKey, selected_uids->front())) { - QMessageBox::critical(nullptr, tr("Operation Failed"), - tr("An error occurred during the operation.")); + QMessageBox::critical(nullptr, _("Operation Failed"), + _("An error occurred during the operation.")); } else { emit signalUpdateUIDInfo(); } @@ -404,12 +407,12 @@ SignIdArgsListPtr KeyPairUIDTab::getSignSelected() { void KeyPairUIDTab::createUIDPopupMenu() { uidPopupMenu = new QMenu(this); - auto* serPrimaryUIDAct = new QAction(tr("Set As Primary"), this); + auto* serPrimaryUIDAct = new QAction(_("Set As Primary"), this); connect(serPrimaryUIDAct, SIGNAL(triggered()), this, SLOT(slotSetPrimaryUID())); - auto* signUIDAct = new QAction(tr("Sign UID"), this); + auto* signUIDAct = new QAction(_("Sign UID"), this); connect(signUIDAct, SIGNAL(triggered()), this, SLOT(slotAddSignSingle())); - auto* delUIDAct = new QAction(tr("Delete UID"), this); + auto* delUIDAct = new QAction(_("Delete UID"), this); connect(delUIDAct, SIGNAL(triggered()), this, SLOT(slotDelUIDSingle())); if (mKey.has_master_key()) { @@ -435,8 +438,8 @@ void KeyPairUIDTab::slotAddSignSingle() { if (selected_uids->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one UID before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one UID before doing this operation.")); return; } @@ -449,8 +452,8 @@ void KeyPairUIDTab::slotDelUIDSingle() { auto selected_uids = getUIDSelected(); if (selected_uids->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one UID before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one UID before doing this operation.")); return; } @@ -460,16 +463,18 @@ void KeyPairUIDTab::slotDelUIDSingle() { keynames.append("<br/>"); int ret = QMessageBox::warning( - this, tr("Deleting UID"), - "<b>" + tr("Are you sure that you want to delete the following uid?") + + this, _("Deleting UID"), + "<b>" + + QString( + _("Are you sure that you want to delete the following uid?")) + "</b><br/><br/>" + keynames + +"<br/>" + - tr("The action can not be undone."), + _("The action can not be undone."), QMessageBox::No | QMessageBox::Yes); if (ret == QMessageBox::Yes) { if (!UidOperator::GetInstance().revUID(mKey, selected_uids->front())) { - QMessageBox::critical(nullptr, tr("Operation Failed"), - tr("An error occurred during the operation.")); + QMessageBox::critical(nullptr, _("Operation Failed"), + _("An error occurred during the operation.")); } else { emit signalUpdateUIDInfo(); } @@ -479,7 +484,7 @@ void KeyPairUIDTab::slotDelUIDSingle() { void KeyPairUIDTab::createSignPopupMenu() { signPopupMenu = new QMenu(this); - auto* delSignAct = new QAction(tr("Delete(Revoke) Key Signature"), this); + auto* delSignAct = new QAction(_("Delete(Revoke) Key Signature"), this); connect(delSignAct, SIGNAL(triggered()), this, SLOT(slotDelSign())); signPopupMenu->addAction(delSignAct); @@ -489,8 +494,8 @@ void KeyPairUIDTab::slotDelSign() { auto selected_signs = getSignSelected(); if (selected_signs->empty()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("Please select one Key Signature before doing this operation.")); + nullptr, _("Invalid Operation"), + _("Please select one Key Signature before doing this operation.")); return; } @@ -498,9 +503,9 @@ void KeyPairUIDTab::slotDelSign() { .GetKey(selected_signs->front().first) .good()) { QMessageBox::critical( - nullptr, tr("Invalid Operation"), - tr("To delete the signature, you need to have its corresponding public " - "key in the local database.")); + nullptr, _("Invalid Operation"), + _("To delete the signature, you need to have its corresponding public " + "key in the local database.")); return; } @@ -509,18 +514,19 @@ void KeyPairUIDTab::slotDelSign() { keynames.append(QString::fromStdString(selected_signs->front().second)); keynames.append("<br/>"); - 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); + 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); if (ret == QMessageBox::Yes) { if (!GpgKeyManager::GetInstance().revSign(mKey, selected_signs)) { - QMessageBox::critical(nullptr, tr("Operation Failed"), - tr("An error occurred during the operation.")); + QMessageBox::critical(nullptr, _("Operation Failed"), + _("An error occurred during the operation.")); } } } diff --git a/src/ui/keypair_details/KeyPairUIDTab.h b/src/ui/keypair_details/KeyPairUIDTab.h index 1f88e7b7..6dece8d5 100644 --- a/src/ui/keypair_details/KeyPairUIDTab.h +++ b/src/ui/keypair_details/KeyPairUIDTab.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/keypair_details/KeySetExpireDateDialog.cpp index 2c5b837f..d197a76b 100644 --- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp +++ b/src/ui/keypair_details/KeySetExpireDateDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -69,15 +69,15 @@ void KeySetExpireDateDialog::slotConfirm() { auto* msg_box = new QMessageBox(nullptr); msg_box->setAttribute(Qt::WA_DeleteOnClose); msg_box->setStandardButtons(QMessageBox::Ok); - msg_box->setWindowTitle(tr("Success")); - msg_box->setText(tr("The expire date of the key pair has been updated.")); + msg_box->setWindowTitle(_("Success")); + msg_box->setText(_("The expire date of the key pair has been updated.")); msg_box->setModal(false); msg_box->open(); emit signalKeyExpireDateUpdated(); } else { - QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(err))); + QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(err))); } this->close(); @@ -90,12 +90,12 @@ void KeySetExpireDateDialog::init() { dateTimeEdit->setMaximumDateTime(maxDateTime); nonExpiredCheck = new QCheckBox(); nonExpiredCheck->setTristate(false); - confirmButton = new QPushButton(tr("Confirm")); + confirmButton = new QPushButton(_("Confirm")); auto* gridLayout = new QGridLayout(); gridLayout->addWidget(dateTimeEdit, 0, 0, 1, 2); gridLayout->addWidget(nonExpiredCheck, 0, 2, 1, 1, Qt::AlignRight); - gridLayout->addWidget(new QLabel(tr("Never Expire")), 0, 3); + gridLayout->addWidget(new QLabel(_("Never Expire")), 0, 3); gridLayout->addWidget(confirmButton, 1, 3); connect(nonExpiredCheck, SIGNAL(stateChanged(int)), this, diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.h b/src/ui/keypair_details/KeySetExpireDateDialog.h index f9779005..37a7f7e4 100644 --- a/src/ui/keypair_details/KeySetExpireDateDialog.h +++ b/src/ui/keypair_details/KeySetExpireDateDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/keypair_details/KeyUIDSignDialog.cpp b/src/ui/keypair_details/KeyUIDSignDialog.cpp index 0614024f..6cce116b 100644 --- a/src/ui/keypair_details/KeyUIDSignDialog.cpp +++ b/src/ui/keypair_details/KeyUIDSignDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -78,7 +78,7 @@ KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid, layout->addWidget(mKeyList, 0, 0); layout->addWidget(signKeyButton, 2, 0, Qt::AlignRight); - timeLayout->addWidget(new QLabel(tr("Expire Date")), 0, 0); + timeLayout->addWidget(new QLabel(_("Expire Date")), 0, 0); timeLayout->addWidget(expiresEdit, 0, 1); timeLayout->addWidget(nonExpireCheck, 0, 2); layout->addLayout(timeLayout, 1, 0); @@ -87,7 +87,7 @@ KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid, this->setLayout(layout); this->setModal(true); - this->setWindowTitle(tr("Sign For Key's UID(s)")); + this->setWindowTitle(_("Sign For Key's UID(s)")); this->adjustSize(); setAttribute(Qt::WA_DeleteOnClose, true); @@ -114,15 +114,13 @@ void KeyUIDSignDialog::slotSignKey(bool clicked) { // Sign For mKey if (!GpgKeyManager::GetInstance().signKey(mKey, *keys, uid, expires)) { QMessageBox::critical( - nullptr, tr("Unsuccessful Operation"), - QString(tr("Signature operation failed for UID ") + "%1") - .arg(uid.c_str())); + nullptr, _("Unsuccessful Operation"), + QString(_("Signature operation failed for UID %1")).arg(uid.c_str())); } } - QMessageBox::information( - nullptr, tr("Operation Complete"), - tr("The signature operation of the UID is complete")); + QMessageBox::information(nullptr, _("Operation Complete"), + _("The signature operation of the UID is complete")); this->close(); emit signalKeyUIDSignUpdate(); } diff --git a/src/ui/keypair_details/KeyUIDSignDialog.h b/src/ui/keypair_details/KeyUIDSignDialog.h index 1bd68416..8a83977a 100644 --- a/src/ui/keypair_details/KeyUIDSignDialog.h +++ b/src/ui/keypair_details/KeyUIDSignDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp index 2edac85d..32fae92e 100644 --- a/src/ui/main_window/MainWindowFileSlotFunction.cpp +++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -33,18 +33,18 @@ bool file_pre_check(QWidget* parent, const QString& path) { QFileInfo file_info(path); QFileInfo path_info(file_info.absolutePath()); if (!file_info.isFile()) { - QMessageBox::critical(parent, QApplication::tr("Error"), - QApplication::tr("Select a file before doing it.")); + QMessageBox::critical(parent, _("Error"), + _("Select a file before doing it.")); return false; } if (!file_info.isReadable()) { - QMessageBox::critical(parent, QApplication::tr("Error"), - QApplication::tr("No permission to read this file.")); + QMessageBox::critical(parent, _("Error"), + _("No permission to read this file.")); return false; } if (!path_info.isWritable()) { - QMessageBox::critical(parent, QApplication::tr("Error"), - QApplication::tr("No permission to create file.")); + QMessageBox::critical(parent, _("Error"), + _("No permission to create file.")); return false; } return true; @@ -58,8 +58,8 @@ void MainWindow::slotFileEncrypt() { if (QFile::exists(path + ".asc")) { auto ret = QMessageBox::warning( - this, tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), + this, _("Warning"), + _("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -68,17 +68,18 @@ void MainWindow::slotFileEncrypt() { auto key_ids = mKeyList->getChecked(); auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids); if (keys->empty()) { - QMessageBox::critical(this, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected")); return; } for (const auto& key : *keys) { if (!key.CanEncrActual()) { QMessageBox::information( - this, tr("Invalid Operation"), - tr("The selected key contains a key that does not actually have a " - "encrypt usage.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + 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/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -87,7 +88,7 @@ void MainWindow::slotFileEncrypt() { GpgEncrResult result = nullptr; GpgError error; bool if_error = false; - process_operation(this, tr("Encrypting").toStdString(), [&]() { + process_operation(this, _("Encrypting"), [&]() { try { error = GpgFileOpera::EncryptFile(std::move(*keys), path.toStdString(), result); @@ -102,8 +103,8 @@ void MainWindow::slotFileEncrypt() { process_result_analyse(edit, infoBoard, resultAnalyse); fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } @@ -125,8 +126,8 @@ void MainWindow::slotFileDecrypt() { if (QFile::exists(outFileName)) { auto ret = QMessageBox::warning( - this, tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), + this, _("Warning"), + _("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -135,7 +136,7 @@ void MainWindow::slotFileDecrypt() { GpgDecrResult result = nullptr; gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Decrypting").toStdString(), [&]() { + process_operation(this, _("Decrypting"), [&]() { try { error = GpgFileOpera::DecryptFile(path.toStdString(), result); } catch (const std::runtime_error& e) { @@ -150,8 +151,8 @@ void MainWindow::slotFileDecrypt() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } @@ -164,8 +165,8 @@ void MainWindow::slotFileSign() { if (QFile::exists(path + ".sig")) { auto ret = QMessageBox::warning( - this, tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), + this, _("Warning"), + _("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -175,17 +176,17 @@ void MainWindow::slotFileSign() { auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids); if (keys->empty()) { - QMessageBox::critical(this, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected")); return; } for (const auto& key : *keys) { if (!key.CanSignActual()) { QMessageBox::information( - this, tr("Invalid Operation"), - tr("The selected key contains a key that does not actually have a " - "sign usage.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + 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/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -195,7 +196,7 @@ void MainWindow::slotFileSign() { gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Signing").toStdString(), [&]() { + process_operation(this, _("Signing"), [&]() { try { error = GpgFileOpera::SignFile(std::move(*keys), path.toStdString(), result); @@ -212,8 +213,8 @@ void MainWindow::slotFileSign() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } @@ -244,26 +245,26 @@ void MainWindow::slotFileVerify() { if (!dataFileInfo.isFile() || !signFileInfo.isFile()) { QMessageBox::critical( - this, tr("Error"), - tr("Please select the appropriate target file or signature file. " - "Ensure that both are in this directory.")); + this, _("Error"), + _("Please select the appropriate target file or signature file. " + "Ensure that both are in this directory.")); return; } if (!dataFileInfo.isReadable()) { - QMessageBox::critical(this, tr("Error"), - tr("No permission to read target file.")); + QMessageBox::critical(this, _("Error"), + _("No permission to read target file.")); return; } if (!fileInfo.isReadable()) { - QMessageBox::critical(this, tr("Error"), - tr("No permission to read signature file.")); + QMessageBox::critical(this, _("Error"), + _("No permission to read signature file.")); return; } GpgVerifyResult result = nullptr; gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Verifying").toStdString(), [&]() { + process_operation(this, _("Verifying"), [&]() { try { error = GpgFileOpera::VerifyFile(dataFilePath.toStdString(), result); } catch (const std::runtime_error& e) { @@ -286,8 +287,8 @@ void MainWindow::slotFileVerify() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } @@ -300,8 +301,8 @@ void MainWindow::slotFileEncryptSign() { if (QFile::exists(path + ".gpg")) { auto ret = QMessageBox::warning( - this, tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), + this, _("Warning"), + _("The target file already exists, do you need to overwrite it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -311,7 +312,7 @@ void MainWindow::slotFileEncryptSign() { auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids); if (keys->empty()) { - QMessageBox::critical(this, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected")); return; } @@ -323,10 +324,11 @@ void MainWindow::slotFileEncryptSign() { if (!key_can_sign && !key_can_encr) { QMessageBox::critical( - nullptr, tr("Invalid KeyPair"), - tr("The selected keypair cannot be used for signing and encryption " - "at the same time.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + nullptr, _("Invalid KeyPair"), + QString(_( + "The selected keypair cannot be used for signing and encryption " + "at the same time.")) + + "<br/><br/>" + _("For example the Following Key:") + " <br/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -336,16 +338,16 @@ void MainWindow::slotFileEncryptSign() { } if (!can_encr) { - QMessageBox::critical(nullptr, tr("Incomplete Operation"), - tr("None of the selected key pairs can provide the " - "encryption function.")); + QMessageBox::critical(nullptr, _("Incomplete Operation"), + _("None of the selected key pairs can provide the " + "encryption function.")); return; } if (!can_sign) { - QMessageBox::warning(nullptr, tr("Incomplete Operation"), - tr("None of the selected key pairs can provide the " - "signature function.")); + QMessageBox::warning(nullptr, _("Incomplete Operation"), + _("None of the selected key pairs can provide the " + "signature function.")); } GpgEncrResult encr_result = nullptr; @@ -354,7 +356,7 @@ void MainWindow::slotFileEncryptSign() { gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Encrypting and Signing").toStdString(), [&]() { + process_operation(this, _("Encrypting and Signing"), [&]() { try { error = GpgFileOpera::EncryptSignFile( std::move(*keys), path.toStdString(), encr_result, sign_result); @@ -373,8 +375,8 @@ void MainWindow::slotFileEncryptSign() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } @@ -398,7 +400,7 @@ void MainWindow::slotFileDecryptVerify() { GpgVerifyResult v_result = nullptr; gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Decrypting and Verifying").toStdString(), [&]() { + process_operation(this, _("Decrypting and Verifying"), [&]() { try { error = GpgFileOpera::DecryptVerifyFile(path.toStdString(), d_result, v_result); @@ -426,8 +428,8 @@ void MainWindow::slotFileDecryptVerify() { fileTreeView->update(); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } diff --git a/src/ui/main_window/MainWindowServerSlotFunction.cpp b/src/ui/main_window/MainWindowServerSlotFunction.cpp index 6266efda..17491db7 100644 --- a/src/ui/main_window/MainWindowServerSlotFunction.cpp +++ b/src/ui/main_window/MainWindowServerSlotFunction.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -45,10 +45,10 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { GpgKey key = mCtx->getKeyRefById(ownKeyId); if (!key.good) { - QMessageBox::critical(this, tr("Invalid Own Key"), - tr("Own Key can not be use to do any operation. " - "Please go to the setting interface to select an " - "OwnKey and get a ServiceToken.")); + QMessageBox::critical(this, _("Invalid Own Key"), + _("Own Key can not be use to do any operation. " + "Please go to the setting interface to select an " + "OwnKey and get a ServiceToken.")); return {}; } @@ -57,8 +57,8 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { QString serviceToken = settings.value("general/serviceToken").toString(); if (serviceToken.isEmpty() || !utils->checkServiceTokenFormat(serviceToken)) { QMessageBox::critical( - this, tr("Error"), - tr("Please obtain a Service Token from the server in the settings.")); + this, _("Error"), + _("Please obtain a Service Token from the server in the settings.")); return {}; } @@ -95,11 +95,10 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { QNetworkReply* reply = utils->getNetworkManager().post(request, postData); - auto dialog = new WaitingDialog(tr("Getting Cpt From Server"), this); + auto dialog = new WaitingDialog(_("Getting Cpt From Server"), this); dialog->show(); - while (reply->isRunning()) - QApplication::processEvents(); + while (reply->isRunning()) QApplication::processEvents(); dialog->close(); @@ -117,9 +116,9 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { if (!utils->checkDataValueStr("cryptoText") || !utils->checkDataValueStr("sha") || !utils->checkDataValueStr("serviceToken")) { - QMessageBox::critical(this, tr("Error"), - tr("The communication content with the server does " - "not meet the requirements")); + QMessageBox::critical(this, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); return {}; } @@ -134,7 +133,7 @@ QString MainWindow::getCryptText(const QString& shortenCryptoText) { serviceToken == serviceTokenFromServer) { return cryptoText; } else - QMessageBox::critical(this, tr("Error"), tr("Invalid short ciphertext")); + QMessageBox::critical(this, _("Error"), _("Invalid short ciphertext")); return {}; } @@ -156,8 +155,8 @@ void MainWindow::shortenCryptText() { if (serviceToken.isEmpty() || !utils->checkServiceTokenFormat(serviceToken)) { QMessageBox::critical( - this, tr("Invalid Service Token"), - tr("Please go to the setting interface to get a ServiceToken.")); + this, _("Invalid Service Token"), + _("Please go to the setting interface to get a ServiceToken.")); return; } @@ -167,8 +166,8 @@ void MainWindow::shortenCryptText() { GpgKey key = mCtx->getKeyRefById(ownKeyId); if (!key.good) { - QMessageBox::critical(this, tr("Invalid Own Key"), - tr("Own Key can not be use to do any operation.")); + QMessageBox::critical(this, _("Invalid Own Key"), + _("Own Key can not be use to do any operation.")); return; } @@ -217,10 +216,9 @@ void MainWindow::shortenCryptText() { QNetworkReply* reply = networkAccessManager->post(request, postData); - auto* dialog = new WaitingDialog(tr("Getting Scpt From Server"), this); + auto* dialog = new WaitingDialog(_("Getting Scpt From Server"), this); dialog->show(); - while (reply->isRunning()) - QApplication::processEvents(); + while (reply->isRunning()) QApplication::processEvents(); dialog->close(); if (utils->checkServerReply(reply->readAll().constData())) { @@ -233,9 +231,9 @@ void MainWindow::shortenCryptText() { if (!utils->checkDataValueStr("shortenText") || !utils->checkDataValueStr("md5")) { - QMessageBox::critical(this, tr("Error"), - tr("The communication content with the server does " - "not meet the requirements")); + QMessageBox::critical(this, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); return; } @@ -246,14 +244,14 @@ void MainWindow::shortenCryptText() { if (md5_generator.result().toHex() == utils->getDataValueStr("md5")) { auto* dialog = new ShowCopyDialog(shortenText, - tr("Notice: Use Decrypt & Verify operation to " - "decrypt this short crypto text."), + _("Notice: Use Decrypt & Verify operation to " + "decrypt this short crypto text."), this); dialog->show(); } else { QMessageBox::critical( - this, tr("Error"), - tr("There is a problem with the communication with the server")); + this, _("Error"), + _("There is a problem with the communication with the server")); return; } } diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp index 37150160..0f7bdb26 100644 --- a/src/ui/main_window/MainWindowSlotFunction.cpp +++ b/src/ui/main_window/MainWindowSlotFunction.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -52,8 +52,8 @@ void MainWindow::slotEncrypt() { auto key_ids = mKeyList->getChecked(); if (key_ids->empty()) { - QMessageBox::critical(nullptr, tr("No Key Selected"), - tr("No Key Selected")); + QMessageBox::critical(nullptr, _("No Key Selected"), + _("No Key Selected")); return; } @@ -62,10 +62,11 @@ void MainWindow::slotEncrypt() { for (const auto& key : *keys) { if (!key.CanEncrActual()) { QMessageBox::information( - nullptr, tr("Invalid Operation"), - tr("The selected key contains a key that does not actually have a " - "encrypt usage.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + nullptr, _("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/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -76,7 +77,7 @@ void MainWindow::slotEncrypt() { GpgEncrResult result = nullptr; GpgError error; bool if_error = false; - process_operation(this, tr("Encrypting").toStdString(), [&]() { + process_operation(this, _("Encrypting"), [&]() { try { auto buffer = edit->curTextPage()->toPlainText().toUtf8().toStdString(); error = GpgFrontend::BasicOperator::GetInstance().Encrypt( @@ -100,17 +101,17 @@ void MainWindow::slotEncrypt() { if (settings.value("sendMail/enable", false).toBool()) new SendMailDialog(edit->curTextPage()->toPlainText(), this); else { - QMessageBox::warning(nullptr, tr("Function Disabled"), - tr("Please go to the settings interface to " - "enable and configure this function.")); + QMessageBox::warning(nullptr, _("Function Disabled"), + _("Please go to the settings interface to " + "enable and configure this function.")); } }); } #endif } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } @@ -126,7 +127,7 @@ void MainWindow::slotSign() { auto key_ids = mKeyList->getPrivateChecked(); if (key_ids->empty()) { - QMessageBox::critical(this, tr("No Key Selected"), tr("No Key Selected")); + QMessageBox::critical(this, _("No Key Selected"), _("No Key Selected")); return; } @@ -134,11 +135,12 @@ void MainWindow::slotSign() { for (const auto& key : *keys) { if (!key.CanSignActual()) { QMessageBox::information( - this, tr("Invalid Operation"), - tr("The selected key contains a key that does not actually have a " - "signature usage.<br/>") + - tr("<br/>For example the Following Key: <br/>") + - QString::fromStdString(key.uids()->front().uid())); + 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/>" + + key.uids()->front().uid().c_str()); return; } } @@ -149,7 +151,7 @@ void MainWindow::slotSign() { gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Signing").toStdString(), [&]() { + process_operation(this, _("Signing"), [&]() { try { auto buffer = edit->curTextPage()->toPlainText().toUtf8().toStdString(); error = GpgFrontend::BasicOperator::GetInstance().Sign( @@ -165,8 +167,8 @@ void MainWindow::slotSign() { process_result_analyse(edit, infoBoard, resultAnalyse); edit->slotFillTextEditWithText(QString::fromStdString(*tmp)); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } else if (edit->slotCurPageFileTreeView() != nullptr) { @@ -184,15 +186,15 @@ void MainWindow::slotDecrypt() { if (text.trimmed().startsWith( GpgConstants::GPG_FRONTEND_SHORT_CRYPTO_HEAD)) { QMessageBox::critical( - this, tr("Notice"), - tr("Short Crypto Text only supports Decrypt & Verify.")); + this, _("Notice"), + _("Short Crypto Text only supports Decrypt & Verify.")); return; } GpgDecrResult result = nullptr; gpgme_error_t error; bool if_error = false; - process_operation(this, tr("Decrypting").toStdString(), [&]() { + process_operation(this, _("Decrypting"), [&]() { try { auto buffer = text.toStdString(); error = GpgFrontend::BasicOperator::GetInstance().Decrypt( @@ -210,8 +212,8 @@ void MainWindow::slotDecrypt() { if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) edit->slotFillTextEditWithText(QString::fromStdString(*decrypted)); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } else if (edit->slotCurPageFileTreeView() != nullptr) { @@ -244,7 +246,7 @@ void MainWindow::slotVerify() { GpgVerifyResult result = nullptr; GpgError error; bool if_error = false; - process_operation(this, tr("Verifying").toStdString(), [&]() { + process_operation(this, _("Verifying"), [&]() { try { auto buffer = text.toStdString(); error = GpgFrontend::BasicOperator::GetInstance().Verify( @@ -268,8 +270,8 @@ void MainWindow::slotVerify() { // } } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } else if (edit->slotCurPageFileTreeView() != nullptr) { @@ -284,8 +286,8 @@ void MainWindow::slotEncryptSign() { auto key_ids = mKeyList->getChecked(); if (key_ids->empty()) { - QMessageBox::critical(nullptr, tr("No Key Selected"), - tr("No Key Selected")); + QMessageBox::critical(nullptr, _("No Key Selected"), + _("No Key Selected")); return; } @@ -296,9 +298,9 @@ void MainWindow::slotEncryptSign() { if (!key_can_encrypt) { QMessageBox::critical( - nullptr, tr("Invalid KeyPair"), - tr("The selected keypair cannot be used for encryption.<br/>") + - tr("<br/>For example the Following Key: <br/>") + + nullptr, _("Invalid KeyPair"), + QString(_("The selected keypair cannot be used for encryption.")) + + "<br/><br/>" + _("For example the Following Key:") + " <br/>" + QString::fromStdString(key.uids()->front().uid())); return; } @@ -326,7 +328,7 @@ void MainWindow::slotEncryptSign() { bool if_error = false; auto tmp = std::make_unique<ByteArray>(); - process_operation(this, tr("Encrypting and Signing").toStdString(), [&]() { + process_operation(this, _("Encrypting and Signing"), [&]() { try { auto buffer = edit->curTextPage()->toPlainText().toUtf8().toStdString(); error = GpgFrontend::BasicOperator::GetInstance().EncryptSign( @@ -344,11 +346,11 @@ void MainWindow::slotEncryptSign() { pubkeyUploader.start(); if (!pubkeyUploader.result()) { QMessageBox::warning( - nullptr, tr("Automatic Key Exchange Warning"), - tr("Part of the automatic key exchange failed, " - "which may be related to your key.") + - tr("If possible, try to use the RSA algorithm " - "compatible with the server for signing.")); + nullptr, _("Automatic Key Exchange Warning"), + _("Part of the automatic key exchange failed, " + "which may be related to your key.") + + _("If possible, try to use the RSA algorithm " + "compatible with the server for signing.")); } } #endif @@ -366,9 +368,9 @@ void MainWindow::slotEncryptSign() { if (settings.value("sendMail/enable", false).toBool()) new SendMailDialog(edit->curTextPage()->toPlainText(), this); else { - QMessageBox::warning(nullptr, tr("Function Disabled"), - tr("Please go to the settings interface to " - "enable and configure this function.")); + QMessageBox::warning(nullptr, _("Function Disabled"), + _("Please go to the settings interface to " + "enable and configure this function.")); } }); #endif @@ -376,9 +378,9 @@ void MainWindow::slotEncryptSign() { #ifdef ADVANCE_SUPPORT infoBoard->addOptionalAction("Shorten Ciphertext", [this]() { if (settings.value("general/serviceToken").toString().isEmpty()) - QMessageBox::warning(nullptr, tr("Service Token Empty"), - tr("Please go to the settings interface to set " - "Own Key and get Service Token.")); + QMessageBox::warning(nullptr, _("Service Token Empty"), + _("Please go to the settings interface to set " + "Own Key and get Service Token.")); else { shortenCryptText(); } @@ -386,8 +388,8 @@ void MainWindow::slotEncryptSign() { #endif } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } } else if (edit->slotCurPageFileTreeView() != nullptr) { @@ -432,16 +434,15 @@ void MainWindow::slotDecryptVerify() { } #endif auto decrypted = std::make_unique<ByteArray>(); - process_operation(this, tr("Decrypting and Verifying").toStdString(), - [&]() { - try { - auto buffer = text.toStdString(); - error = BasicOperator::GetInstance().DecryptVerify( - buffer, decrypted, d_result, v_result); - } catch (const std::runtime_error& e) { - if_error = true; - } - }); + process_operation(this, _("Decrypting and Verifying"), [&]() { + try { + auto buffer = text.toStdString(); + error = BasicOperator::GetInstance().DecryptVerify(buffer, decrypted, + d_result, v_result); + } catch (const std::runtime_error& e) { + if_error = true; + } + }); if (!if_error) { infoBoard->associateFileTreeView(edit->curFilePage()); @@ -463,8 +464,8 @@ void MainWindow::slotDecryptVerify() { // }); // } } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occurred during operation.")); + QMessageBox::critical(this, _("Error"), + _("An error occurred during operation.")); return; } @@ -494,7 +495,7 @@ void MainWindow::slotCopyMailAddressToClipboard() { auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); if (!key.good()) { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); return; } QClipboard* cb = QApplication::clipboard(); @@ -509,7 +510,7 @@ void MainWindow::slotShowKeyDetails() { if (key.good()) { new KeyDetailsDialog(key, this); } else { - QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found.")); + QMessageBox::critical(nullptr, _("Error"), _("Key Not Found.")); } } @@ -534,21 +535,24 @@ void MainWindow::slotOpenFile(QString& path) { edit->slotOpenFile(path); } void MainWindow::slotVersionUpgrade(const QString& currentVersion, const QString& latestVersion) { if (currentVersion < latestVersion) { - QMessageBox::warning(this, tr("Outdated Version"), - tr("This version(%1) is out of date, please update " - "the latest version in time. ") - .arg(currentVersion) + - tr("You can download the latest version(%1) on " - "Github Releases Page.<br/>") - .arg(latestVersion)); + QMessageBox::warning( + this, _("Outdated Version"), + QString(_("This version(%1) is out of date, please update " + "the latest version in time. ")) + .arg(currentVersion) + + QString(_("You can download the latest version(%1) on " + "Github Releases Page.<br/>")) + .arg(latestVersion)); } else if (currentVersion > latestVersion) { QMessageBox::warning( - this, tr("Unreleased Version"), - tr("This version(%1) has not been officially released and is not " - "recommended for use in a production environment. <br/>") + this, _("Unreleased Version"), + QString( + _("This version(%1) has not been officially released and is not " + "recommended for use in a production environment. <br/>")) .arg(currentVersion) + - tr("You can download the latest version(%1) on Github Releases " - "Page.<br/>") + QString( + _("You can download the latest version(%1) on Github Releases " + "Page.<br/>")) .arg(latestVersion)); } } diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index 7310bd1c..312364e2 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -53,10 +53,10 @@ void MainWindow::slotStartWizard() { // if (filenum > 0) { // QString statusText; // if (filenum == 1) { -// statusText = tr("There is one unencrypted file in attachment folder"); +// statusText = _("There is one unencrypted file in attachment folder"); // } else { -// statusText = tr("There are ") + QString::number(filenum) + -// tr(" unencrypted files in attachment folder"); +// statusText = _("There are ") + QString::number(filenum) + +// _(" unencrypted files in attachment folder"); // } // statusBarIcon->setStatusTip(statusText); // statusBarIcon->show(); diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp index cf5d1172..08a9e215 100644 --- a/src/ui/main_window/MainWindowUI.cpp +++ b/src/ui/main_window/MainWindowUI.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -29,256 +29,255 @@ namespace GpgFrontend::UI { void MainWindow::createActions() { /* Main Menu */ - newTabAct = new QAction(tr("&New"), this); + newTabAct = new QAction(_("New"), this); newTabAct->setIcon(QIcon(":misc_doc.png")); QList<QKeySequence> newTabActShortcutList; newTabActShortcutList.append(QKeySequence(Qt::CTRL + Qt::Key_N)); newTabActShortcutList.append(QKeySequence(Qt::CTRL + Qt::Key_T)); newTabAct->setShortcuts(newTabActShortcutList); - newTabAct->setToolTip(tr("Open a new file")); + newTabAct->setToolTip(_("Open a new file")); connect(newTabAct, SIGNAL(triggered()), edit, SLOT(slotNewTab())); - openAct = new QAction(tr("&Open..."), this); + openAct = new QAction(_("Open..."), this); openAct->setIcon(QIcon(":fileopen.png")); openAct->setShortcut(QKeySequence::Open); - openAct->setToolTip(tr("Open an existing file")); + openAct->setToolTip(_("Open an existing file")); connect(openAct, SIGNAL(triggered()), edit, SLOT(slotOpen())); - browserAct = new QAction(tr("&Browser"), this); + browserAct = new QAction(_("Browser"), this); browserAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); - browserAct->setToolTip(tr("Open a file browser")); + browserAct->setToolTip(_("Open a file browser")); connect(browserAct, SIGNAL(triggered()), this, SLOT(slotOpenFileTab())); - saveAct = new QAction(tr("&Save"), this); + saveAct = new QAction(_("Save"), this); saveAct->setIcon(QIcon(":filesave.png")); saveAct->setShortcut(QKeySequence::Save); - saveAct->setToolTip(tr("Save the current File")); + saveAct->setToolTip(_("Save the current File")); connect(saveAct, SIGNAL(triggered()), edit, SLOT(slotSave())); - saveAsAct = new QAction(tr("Save &As") + "...", this); + saveAsAct = new QAction(QString(_("Save As")) + "...", this); saveAsAct->setIcon(QIcon(":filesaveas.png")); saveAsAct->setShortcut(QKeySequence::SaveAs); - saveAsAct->setToolTip(tr("Save the current File as...")); + saveAsAct->setToolTip(_("Save the current File as...")); connect(saveAsAct, SIGNAL(triggered()), edit, SLOT(slotSaveAs())); - printAct = new QAction(tr("&Print"), this); + printAct = new QAction(_("Print"), this); printAct->setIcon(QIcon(":fileprint.png")); printAct->setShortcut(QKeySequence::Print); - printAct->setToolTip(tr("Print Document")); + printAct->setToolTip(_("Print Document")); connect(printAct, SIGNAL(triggered()), edit, SLOT(slotPrint())); - closeTabAct = new QAction(tr("&Close"), this); + closeTabAct = new QAction(_("Close"), this); closeTabAct->setShortcut(QKeySequence::Close); - closeTabAct->setToolTip(tr("Close file")); + closeTabAct->setToolTip(_("Close file")); connect(closeTabAct, SIGNAL(triggered()), edit, SLOT(slotCloseTab())); - quitAct = new QAction(tr("&Quit"), this); + quitAct = new QAction(_("Quit"), this); quitAct->setShortcut(QKeySequence::Quit); quitAct->setIcon(QIcon(":exit.png")); - quitAct->setToolTip(tr("Quit Program")); + quitAct->setToolTip(_("Quit Program")); connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); /* Edit Menu */ - undoAct = new QAction(tr("&Undo"), this); + undoAct = new QAction(_("Undo"), this); undoAct->setShortcut(QKeySequence::Undo); - undoAct->setToolTip(tr("Undo Last Edit Action")); + undoAct->setToolTip(_("Undo Last Edit Action")); connect(undoAct, SIGNAL(triggered()), edit, SLOT(slotUndo())); - redoAct = new QAction(tr("&Redo"), this); + redoAct = new QAction(_("Redo"), this); redoAct->setShortcut(QKeySequence::Redo); - redoAct->setToolTip(tr("Redo Last Edit Action")); + redoAct->setToolTip(_("Redo Last Edit Action")); connect(redoAct, SIGNAL(triggered()), edit, SLOT(slotRedo())); - zoomInAct = new QAction(tr("Zoom In"), this); + zoomInAct = new QAction(_("Zoom In"), this); zoomInAct->setShortcut(QKeySequence::ZoomIn); connect(zoomInAct, SIGNAL(triggered()), edit, SLOT(slotZoomIn())); - zoomOutAct = new QAction(tr("Zoom Out"), this); + zoomOutAct = new QAction(_("Zoom Out"), this); zoomOutAct->setShortcut(QKeySequence::ZoomOut); connect(zoomOutAct, SIGNAL(triggered()), edit, SLOT(slotZoomOut())); - pasteAct = new QAction(tr("&Paste"), this); + pasteAct = new QAction(_("Paste"), this); pasteAct->setIcon(QIcon(":button_paste.png")); pasteAct->setShortcut(QKeySequence::Paste); - pasteAct->setToolTip(tr("Paste Text From Clipboard")); + pasteAct->setToolTip(_("Paste Text From Clipboard")); connect(pasteAct, SIGNAL(triggered()), edit, SLOT(slotPaste())); - cutAct = new QAction(tr("Cu&t"), this); + cutAct = new QAction(_("Cut"), this); cutAct->setIcon(QIcon(":button_cut.png")); cutAct->setShortcut(QKeySequence::Cut); cutAct->setToolTip( - tr("Cut the current selection's contents to the " - "clipboard")); + _("Cut the current selection's contents to the " + "clipboard")); connect(cutAct, SIGNAL(triggered()), edit, SLOT(slotCut())); - copyAct = new QAction(tr("&Copy"), this); + copyAct = new QAction(_("Copy"), this); copyAct->setIcon(QIcon(":button_copy.png")); copyAct->setShortcut(QKeySequence::Copy); copyAct->setToolTip( - tr("Copy the current selection's contents to the " - "clipboard")); + _("Copy the current selection's contents to the " + "clipboard")); connect(copyAct, SIGNAL(triggered()), edit, SLOT(slotCopy())); - quoteAct = new QAction(tr("&Quote"), this); + quoteAct = new QAction(_("Quote"), this); quoteAct->setIcon(QIcon(":quote.png")); - quoteAct->setToolTip(tr("Quote whole text")); + quoteAct->setToolTip(_("Quote whole text")); connect(quoteAct, SIGNAL(triggered()), edit, SLOT(slotQuote())); - selectAllAct = new QAction(tr("Select &All"), this); + selectAllAct = new QAction(_("Select All"), this); selectAllAct->setIcon(QIcon(":edit.png")); selectAllAct->setShortcut(QKeySequence::SelectAll); - selectAllAct->setToolTip(tr("Select the whole text")); + selectAllAct->setToolTip(_("Select the whole text")); connect(selectAllAct, SIGNAL(triggered()), edit, SLOT(slotSelectAll())); - findAct = new QAction(tr("&Find"), this); + findAct = new QAction(_("Find"), this); findAct->setShortcut(QKeySequence::Find); - findAct->setToolTip(tr("Find a word")); + findAct->setToolTip(_("Find a word")); connect(findAct, SIGNAL(triggered()), this, SLOT(slotFind())); - cleanDoubleLinebreaksAct = new QAction(tr("Remove &spacing"), this); + cleanDoubleLinebreaksAct = new QAction(_("Remove spacing"), this); cleanDoubleLinebreaksAct->setIcon(QIcon(":format-line-spacing-triple.png")); // cleanDoubleLineBreaksAct->setShortcut(QKeySequence::SelectAll); cleanDoubleLinebreaksAct->setToolTip( - tr("Remove double linebreaks, e.g. in pasted text from webmailer")); + _("Remove double linebreaks, e.g. in pasted text from Web Mailer")); connect(cleanDoubleLinebreaksAct, SIGNAL(triggered()), this, SLOT(slotCleanDoubleLinebreaks())); - openSettingsAct = new QAction(tr("Se&ttings"), this); - openSettingsAct->setToolTip(tr("Open settings dialog")); + openSettingsAct = new QAction(_("Settings"), this); + openSettingsAct->setToolTip(_("Open settings dialog")); openSettingsAct->setShortcut(QKeySequence::Preferences); connect(openSettingsAct, SIGNAL(triggered()), this, SLOT(slotOpenSettingsDialog())); /* Crypt Menu */ - encryptAct = new QAction(tr("&Encrypt"), this); + encryptAct = new QAction(_("Encrypt"), this); encryptAct->setIcon(QIcon(":encrypted.png")); encryptAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E)); - encryptAct->setToolTip(tr("Encrypt Message")); + encryptAct->setToolTip(_("Encrypt Message")); connect(encryptAct, SIGNAL(triggered()), this, SLOT(slotEncrypt())); - encryptSignAct = new QAction(tr("&Encrypt &Sign"), this); + encryptSignAct = new QAction(_("Encrypt Sign"), this); encryptSignAct->setIcon(QIcon(":encrypted_signed.png")); encryptSignAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E)); - encryptSignAct->setToolTip(tr("Encrypt and Sign Message")); + encryptSignAct->setToolTip(_("Encrypt and Sign Message")); connect(encryptSignAct, SIGNAL(triggered()), this, SLOT(slotEncryptSign())); - decryptAct = new QAction(tr("&Decrypt"), this); + decryptAct = new QAction(_("Decrypt"), this); decryptAct->setIcon(QIcon(":decrypted.png")); decryptAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); - decryptAct->setToolTip(tr("Decrypt Message")); + decryptAct->setToolTip(_("Decrypt Message")); connect(decryptAct, SIGNAL(triggered()), this, SLOT(slotDecrypt())); - decryptVerifyAct = new QAction(tr("&Decrypt &Verify"), this); + decryptVerifyAct = new QAction(_("Decrypt Verify"), this); decryptVerifyAct->setIcon(QIcon(":decrypted_verified.png")); decryptVerifyAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D)); - decryptVerifyAct->setToolTip(tr("Decrypt and Verify Message")); + decryptVerifyAct->setToolTip(_("Decrypt and Verify Message")); connect(decryptVerifyAct, SIGNAL(triggered()), this, SLOT(slotDecryptVerify())); /* * File encryption submenu */ - fileEncryptAct = new QAction(tr("&Encrypt File"), this); - fileEncryptAct->setToolTip(tr("Encrypt File")); + fileEncryptAct = new QAction(_("Encrypt File"), this); + fileEncryptAct->setToolTip(_("Encrypt File")); connect(fileEncryptAct, SIGNAL(triggered()), this, SLOT(slotFileEncryptCustom())); - fileDecryptAct = new QAction(tr("&Decrypt File"), this); - fileDecryptAct->setToolTip(tr("Decrypt File")); + fileDecryptAct = new QAction(_("Decrypt File"), this); + fileDecryptAct->setToolTip(_("Decrypt File")); connect(fileDecryptAct, SIGNAL(triggered()), this, SLOT(slotFileDecryptCustom())); - fileSignAct = new QAction(tr("&Sign File"), this); - fileSignAct->setToolTip(tr("Sign File")); + fileSignAct = new QAction(_("Sign File"), this); + fileSignAct->setToolTip(_("Sign File")); connect(fileSignAct, SIGNAL(triggered()), this, SLOT(slotFileSignCustom())); - fileVerifyAct = new QAction(tr("&Verify File"), this); - fileVerifyAct->setToolTip(tr("Verify File")); + fileVerifyAct = new QAction(_("Verify File"), this); + fileVerifyAct->setToolTip(_("Verify File")); connect(fileVerifyAct, SIGNAL(triggered()), this, SLOT(slotFileVerifyCustom())); - signAct = new QAction(tr("&Sign"), this); + signAct = new QAction(_("Sign"), this); signAct->setIcon(QIcon(":signature.png")); signAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I)); - signAct->setToolTip(tr("Sign Message")); + signAct->setToolTip(_("Sign Message")); connect(signAct, SIGNAL(triggered()), this, SLOT(slotSign())); - verifyAct = new QAction(tr("&Verify"), this); + verifyAct = new QAction(_("Verify"), this); verifyAct->setIcon(QIcon(":verify.png")); verifyAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V)); - verifyAct->setToolTip(tr("Verify Message")); + verifyAct->setToolTip(_("Verify Message")); connect(verifyAct, SIGNAL(triggered()), this, SLOT(slotVerify())); /* Key Menu */ - importKeyFromEditAct = new QAction(tr("&Editor"), this); + importKeyFromEditAct = new QAction(_("Editor"), this); importKeyFromEditAct->setIcon(QIcon(":txt.png")); - importKeyFromEditAct->setToolTip(tr("Import New Key From Editor")); + importKeyFromEditAct->setToolTip(_("Import New Key From Editor")); connect(importKeyFromEditAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromEdit())); - openKeyManagementAct = new QAction(tr("Manage &Keys"), this); + openKeyManagementAct = new QAction(_("Manage Keys"), this); openKeyManagementAct->setIcon(QIcon(":keymgmt.png")); - openKeyManagementAct->setToolTip(tr("Open Keymanagement")); + openKeyManagementAct->setToolTip(_("Open Key Management")); connect(openKeyManagementAct, SIGNAL(triggered()), this, SLOT(slotOpenKeyManagement())); /* * About Menu */ - aboutAct = new QAction(tr("&About"), this); + aboutAct = new QAction(_("About"), this); aboutAct->setIcon(QIcon(":help.png")); - aboutAct->setToolTip(tr("Show the application's About box")); + aboutAct->setToolTip(_("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(slotAbout())); /* * Check Update Menu */ - checkUpdateAct = new QAction(tr("&Check for Updates"), this); + checkUpdateAct = new QAction(_("Check for Updates"), this); checkUpdateAct->setIcon(QIcon(":help.png")); - checkUpdateAct->setToolTip(tr("Check for updates")); + checkUpdateAct->setToolTip(_("Check for updates")); connect(checkUpdateAct, SIGNAL(triggered()), this, SLOT(slotCheckUpdate())); - startWizardAct = new QAction(tr("Open &Wizard"), this); - startWizardAct->setToolTip(tr("Open the wizard")); + startWizardAct = new QAction(_("Open Wizard"), this); + startWizardAct->setToolTip(_("Open the wizard")); connect(startWizardAct, SIGNAL(triggered()), this, SLOT(slotStartWizard())); /* Popup-Menu-Action for KeyList */ appendSelectedKeysAct = - new QAction(tr("Append Selected Key(s) To Text"), this); + new QAction(_("Append Selected Key(s) To Text"), this); appendSelectedKeysAct->setToolTip( - tr("Append The Selected Keys To Text in Editor")); + _("Append The Selected Keys To Text in Editor")); connect(appendSelectedKeysAct, SIGNAL(triggered()), this, SLOT(slotAppendSelectedKeys())); - copyMailAddressToClipboardAct = new QAction(tr("Copy Email"), this); + copyMailAddressToClipboardAct = new QAction(_("Copy Email"), this); copyMailAddressToClipboardAct->setToolTip( - tr("Copy selected Email to clipboard")); + _("Copy selected Email to clipboard")); connect(copyMailAddressToClipboardAct, SIGNAL(triggered()), this, SLOT(slotCopyMailAddressToClipboard())); // TODO: find central place for shared actions, to avoid code-duplication with // keymgmt.cpp - showKeyDetailsAct = new QAction(tr("Show Key Details"), this); - showKeyDetailsAct->setToolTip(tr("Show Details for this Key")); + showKeyDetailsAct = new QAction(_("Show Key Details"), this); + showKeyDetailsAct->setToolTip(_("Show Details for this Key")); connect(showKeyDetailsAct, SIGNAL(triggered()), this, SLOT(slotShowKeyDetails())); refreshKeysFromKeyserverAct = - new QAction(tr("Refresh Key From Key Server"), this); + new QAction(_("Refresh Key From Key Server"), this); refreshKeysFromKeyserverAct->setToolTip( - tr("Refresh key from default key server")); + _("Refresh key from default key server")); connect(refreshKeysFromKeyserverAct, SIGNAL(triggered()), this, SLOT(refreshKeysFromKeyserver())); - uploadKeyToServerAct = - new QAction(tr("Upload Public Key(s) To Server"), this); + uploadKeyToServerAct = new QAction(_("Upload Public Key(s) To Server"), this); uploadKeyToServerAct->setToolTip( - tr("Upload The Selected Public Keys To Server")); + _("Upload The Selected Public Keys To Server")); connect(uploadKeyToServerAct, SIGNAL(triggered()), this, SLOT(uploadKeyToServer())); @@ -295,15 +294,15 @@ void MainWindow::createActions() { SLOT(slotSwitchTabDown())); this->addAction(switchTabDownAct); - cutPgpHeaderAct = new QAction(tr("Remove PGP Header"), this); + cutPgpHeaderAct = new QAction(_("Remove PGP Header"), this); connect(cutPgpHeaderAct, SIGNAL(triggered()), this, SLOT(slotCutPgpHeader())); - addPgpHeaderAct = new QAction(tr("Add PGP Header"), this); + addPgpHeaderAct = new QAction(_("Add PGP Header"), this); connect(addPgpHeaderAct, SIGNAL(triggered()), this, SLOT(slotAddPgpHeader())); } void MainWindow::createMenus() { - fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu = menuBar()->addMenu(_("File")); fileMenu->addAction(newTabAct); fileMenu->addAction(browserAct); fileMenu->addAction(openAct); @@ -316,7 +315,7 @@ void MainWindow::createMenus() { fileMenu->addAction(closeTabAct); fileMenu->addAction(quitAct); - editMenu = menuBar()->addMenu(tr("&Edit")); + editMenu = menuBar()->addMenu(_("Edit")); editMenu->addAction(undoAct); editMenu->addAction(redoAct); editMenu->addSeparator(); @@ -334,13 +333,13 @@ void MainWindow::createMenus() { editMenu->addSeparator(); editMenu->addAction(openSettingsAct); - fileEncMenu = new QMenu(tr("&File...")); + fileEncMenu = new QMenu(_("File...")); fileEncMenu->addAction(fileEncryptAct); fileEncMenu->addAction(fileDecryptAct); fileEncMenu->addAction(fileSignAct); fileEncMenu->addAction(fileVerifyAct); - cryptMenu = menuBar()->addMenu(tr("&Crypt")); + cryptMenu = menuBar()->addMenu(_("Crypt")); cryptMenu->addAction(encryptAct); cryptMenu->addAction(encryptSignAct); cryptMenu->addAction(decryptAct); @@ -351,8 +350,8 @@ void MainWindow::createMenus() { cryptMenu->addSeparator(); cryptMenu->addMenu(fileEncMenu); - keyMenu = menuBar()->addMenu(tr("&Keys")); - importKeyMenu = keyMenu->addMenu(tr("&Import Key")); + keyMenu = menuBar()->addMenu(_("Keys")); + importKeyMenu = keyMenu->addMenu(_("Import Key")); importKeyMenu->setIcon(QIcon(":key_import.png")); importKeyMenu->addAction(keyMgmt->importKeyFromFileAct); importKeyMenu->addAction(importKeyFromEditAct); @@ -361,7 +360,7 @@ void MainWindow::createMenus() { importKeyMenu->addAction(keyMgmt->importKeyFromKeyServerAct); keyMenu->addAction(openKeyManagementAct); - steganoMenu = menuBar()->addMenu(tr("&Steganography")); + steganoMenu = menuBar()->addMenu(_("Steganography")); steganoMenu->addAction(cutPgpHeaderAct); steganoMenu->addAction(addPgpHeaderAct); @@ -372,9 +371,9 @@ void MainWindow::createMenus() { } #endif - viewMenu = menuBar()->addMenu(tr("&View")); + viewMenu = menuBar()->addMenu(_("View")); - helpMenu = menuBar()->addMenu(tr("&Help")); + helpMenu = menuBar()->addMenu(_("Help")); helpMenu->addAction(startWizardAct); helpMenu->addSeparator(); helpMenu->addAction(checkUpdateAct); @@ -382,7 +381,7 @@ void MainWindow::createMenus() { } void MainWindow::createToolBars() { - fileToolBar = addToolBar(tr("File")); + fileToolBar = addToolBar(_("File")); fileToolBar->setObjectName("fileToolBar"); fileToolBar->addAction(newTabAct); fileToolBar->addAction(openAct); @@ -390,7 +389,7 @@ void MainWindow::createToolBars() { fileToolBar->hide(); viewMenu->addAction(fileToolBar->toggleViewAction()); - cryptToolBar = addToolBar(tr("Crypt")); + cryptToolBar = addToolBar(_("Crypt")); cryptToolBar->setObjectName("cryptToolBar"); cryptToolBar->addAction(encryptAct); cryptToolBar->addAction(encryptSignAct); @@ -400,19 +399,19 @@ void MainWindow::createToolBars() { cryptToolBar->addAction(verifyAct); viewMenu->addAction(cryptToolBar->toggleViewAction()); - keyToolBar = addToolBar(tr("Key")); + keyToolBar = addToolBar(_("Key")); keyToolBar->setObjectName("keyToolBar"); keyToolBar->addAction(openKeyManagementAct); viewMenu->addAction(keyToolBar->toggleViewAction()); - editToolBar = addToolBar(tr("Edit")); + editToolBar = addToolBar(_("Edit")); editToolBar->setObjectName("editToolBar"); editToolBar->addAction(copyAct); editToolBar->addAction(pasteAct); editToolBar->addAction(selectAllAct); viewMenu->addAction(editToolBar->toggleViewAction()); - specialEditToolBar = addToolBar(tr("Special Edit")); + specialEditToolBar = addToolBar(_("Special Edit")); specialEditToolBar->setObjectName("specialEditToolBar"); specialEditToolBar->addAction(quoteAct); specialEditToolBar->addAction(cleanDoubleLinebreaksAct); @@ -424,8 +423,8 @@ void MainWindow::createToolBars() { importButton->setMenu(importKeyMenu); importButton->setPopupMode(QToolButton::InstantPopup); importButton->setIcon(QIcon(":key_import.png")); - importButton->setToolTip(tr("Import key from...")); - importButton->setText(tr("Import key")); + importButton->setToolTip(_("Import key from...")); + importButton->setText(_("Import key")); keyToolBar->addWidget(importButton); // Add dropdown menu for file encryption/decryption to crypttoolbar @@ -433,8 +432,8 @@ void MainWindow::createToolBars() { connect(fileEncButton, SIGNAL(clicked(bool)), this, SLOT(slotOpenFileTab())); fileEncButton->setPopupMode(QToolButton::InstantPopup); fileEncButton->setIcon(QIcon(":fileencryption.png")); - fileEncButton->setToolTip(tr("Browser to view and operate file")); - fileEncButton->setText(tr("Browser")); + fileEncButton->setToolTip(_("Browser to view and operate file")); + fileEncButton->setText(_("Browser")); fileToolBar->addWidget(fileEncButton); } @@ -451,14 +450,14 @@ void MainWindow::createStatusBar() { statusBarIcon->setPixmap(*pixmap); statusBar()->insertPermanentWidget(0, statusBarIcon, 0); statusBarIcon->hide(); - statusBar()->showMessage(tr("Ready"), 2000); + statusBar()->showMessage(_("Ready"), 2000); statusBarBox->setLayout(statusBarBoxLayout); } void MainWindow::createDockWindows() { /* KeyList-Dockwindow */ - keyListDock = new QDockWidget(tr("Key ToolBox"), this); + keyListDock = new QDockWidget(_("Key ToolBox"), this); keyListDock->setObjectName("EncryptDock"); keyListDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -467,7 +466,7 @@ void MainWindow::createDockWindows() { keyListDock->setWidget(mKeyList); viewMenu->addAction(keyListDock->toggleViewAction()); - infoBoardDock = new QDockWidget(tr("Information Board"), this); + infoBoardDock = new QDockWidget(_("Information Board"), this); infoBoardDock->setObjectName("Information Board"); infoBoardDock->setAllowedAreas(Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, infoBoardDock); diff --git a/src/ui/settings/GlobalSettingStation.cpp b/src/ui/settings/GlobalSettingStation.cpp index 5d292446..3e229091 100644 --- a/src/ui/settings/GlobalSettingStation.cpp +++ b/src/ui/settings/GlobalSettingStation.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -37,11 +37,11 @@ void GlobalSettingStation::Sync() noexcept { using namespace libconfig; try { ui_cfg.writeFile(ui_config_path.c_str()); - LOG(INFO) << "Updated ui configuration successfully written to: " + LOG(INFO) << _("Updated ui configuration successfully written to") << ui_config_path; } catch (const FileIOException& fioex) { - LOG(ERROR) << "I/O error while writing ui configuration file: " + LOG(ERROR) << _("I/O error while writing ui configuration file") << ui_config_path; } } @@ -50,9 +50,13 @@ GlobalSettingStation::GlobalSettingStation() noexcept { using namespace boost::filesystem; using namespace libconfig; - LOG(INFO) << "App Configure Path" << app_configure_path; - LOG(INFO) << "App Data Path" << app_data_path; - LOG(INFO) << "App Log Path" << app_log_path; + el::Loggers::addFlag(el::LoggingFlag::AutoSpacing); + + LOG(INFO) << _("App Path") << app_path; + LOG(INFO) << _("App Configure Path") << app_configure_path; + LOG(INFO) << _("App Data Path") << app_data_path; + LOG(INFO) << _("App Log Path") << app_log_path; + LOG(INFO) << _("App Locale Path") << app_locale_path; if (!is_directory(app_configure_path)) create_directory(app_configure_path); @@ -65,23 +69,24 @@ GlobalSettingStation::GlobalSettingStation() noexcept { if (!exists(ui_config_path)) { try { this->ui_cfg.writeFile(ui_config_path.c_str()); - LOG(INFO) << "UserInterface configuration successfully written to: " + LOG(INFO) << _("UserInterface configuration successfully written to") << ui_config_path; } catch (const FileIOException& fioex) { - LOG(ERROR) << "I/O error while writing UserInterface configuration file: " - << ui_config_path; + LOG(ERROR) + << _("I/O error while writing UserInterface configuration file") + << ui_config_path; } } else { try { this->ui_cfg.readFile(ui_config_path.c_str()); - LOG(INFO) << "UserInterface configuration successfully read from: " + LOG(INFO) << _("UserInterface configuration successfully read from") << ui_config_path; } catch (const FileIOException& fioex) { - LOG(ERROR) << "I/O error while reading UserInterface configure file"; + LOG(ERROR) << _("I/O error while reading UserInterface configure file"); } catch (const ParseException& pex) { - LOG(ERROR) << "Parse error at " << pex.getFile() << ":" << pex.getLine() - << " - " << pex.getError(); + LOG(ERROR) << _("Parse error at ") << pex.getFile() << ":" + << pex.getLine() << " - " << pex.getError(); } } } diff --git a/src/ui/settings/GlobalSettingStation.h b/src/ui/settings/GlobalSettingStation.h index 03a362ba..b5a86865 100644 --- a/src/ui/settings/GlobalSettingStation.h +++ b/src/ui/settings/GlobalSettingStation.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -33,8 +33,6 @@ class GlobalSettingStation : public QObject { Q_OBJECT - static std::unique_ptr<GlobalSettingStation> _instance; - public: static GlobalSettingStation& GetInstance(); @@ -48,6 +46,10 @@ class GlobalSettingStation : public QObject { return app_log_path; } + [[nodiscard]] boost::filesystem::path GetLocaleDir() const { + return app_locale_path; + } + void Sync() noexcept; private: @@ -62,6 +64,10 @@ class GlobalSettingStation : public QObject { // Program Data Location boost::filesystem::path app_log_path = app_data_path / "logs"; + // Program Data Location + boost::filesystem::path app_locale_path = + RESOURCE_DIR_BOOST_PATH(app_path) / "locales"; + // Program Configure Location boost::filesystem::path app_configure_path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) @@ -75,6 +81,8 @@ class GlobalSettingStation : public QObject { boost::filesystem::path ui_config_path = ui_config_dir_path / "ui.cfg"; libconfig::Config ui_cfg; + + static std::unique_ptr<GlobalSettingStation> _instance; }; #endif // GPGFRONTEND_GLOBALSETTINGSTATION_H diff --git a/src/ui/settings/SettingsAdvanced.cpp b/src/ui/settings/SettingsAdvanced.cpp index 048cbe2d..b64ec8e9 100644 --- a/src/ui/settings/SettingsAdvanced.cpp +++ b/src/ui/settings/SettingsAdvanced.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -34,15 +34,15 @@ AdvancedTab::AdvancedTab(QWidget* parent) /***************************************** * Steganography Box *****************************************/ - auto* steganoBox = new QGroupBox(tr("Show Steganography Options")); + auto* steganoBox = new QGroupBox(_("Show Steganography Options")); auto* steganoBoxLayout = new QHBoxLayout(); - steganoCheckBox = new QCheckBox(tr("Show Steganographic Options."), this); + steganoCheckBox = new QCheckBox(_("Show Steganographic Options."), this); steganoBoxLayout->addWidget(steganoCheckBox); steganoBox->setLayout(steganoBoxLayout); - auto* pubkeyExchangeBox = new QGroupBox(tr("Pubkey Exchange")); + auto* pubkeyExchangeBox = new QGroupBox(_("Pubkey Exchange")); auto* pubkeyExchangeBoxLayout = new QHBoxLayout(); - autoPubkeyExchangeCheckBox = new QCheckBox(tr("Auto Pubkey Exchange"), this); + autoPubkeyExchangeCheckBox = new QCheckBox(_("Auto Pubkey Exchange"), this); pubkeyExchangeBoxLayout->addWidget(autoPubkeyExchangeCheckBox); pubkeyExchangeBox->setLayout(pubkeyExchangeBoxLayout); diff --git a/src/ui/settings/SettingsAdvanced.h b/src/ui/settings/SettingsAdvanced.h index 197fa22d..d8ec8089 100644 --- a/src/ui/settings/SettingsAdvanced.h +++ b/src/ui/settings/SettingsAdvanced.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/settings/SettingsAppearance.cpp b/src/ui/settings/SettingsAppearance.cpp index 74ad6c2a..91bef9ef 100644 --- a/src/ui/settings/SettingsAppearance.cpp +++ b/src/ui/settings/SettingsAppearance.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -34,11 +34,11 @@ AppearanceTab::AppearanceTab(QWidget* parent) /***************************************** * Icon-Size-Box *****************************************/ - auto* iconSizeBox = new QGroupBox(tr("Iconsize")); + auto* iconSizeBox = new QGroupBox(_("Icon Size")); iconSizeGroup = new QButtonGroup(); - iconSizeSmall = new QRadioButton(tr("small")); - iconSizeMedium = new QRadioButton(tr("medium")); - iconSizeLarge = new QRadioButton(tr("large")); + iconSizeSmall = new QRadioButton(_("small")); + iconSizeMedium = new QRadioButton(_("medium")); + iconSizeLarge = new QRadioButton(_("large")); iconSizeGroup->addButton(iconSizeSmall, 1); iconSizeGroup->addButton(iconSizeMedium, 2); @@ -54,11 +54,11 @@ AppearanceTab::AppearanceTab(QWidget* parent) /***************************************** * Icon-Style-Box *****************************************/ - auto* iconStyleBox = new QGroupBox(tr("Iconstyle")); + auto* iconStyleBox = new QGroupBox(_("Icon Style")); iconStyleGroup = new QButtonGroup(); - iconTextButton = new QRadioButton(tr("just text")); - iconIconsButton = new QRadioButton(tr("just icons")); - iconAllButton = new QRadioButton(tr("text and icons")); + iconTextButton = new QRadioButton(_("just text")); + iconIconsButton = new QRadioButton(_("just icons")); + iconAllButton = new QRadioButton(_("text and icons")); iconStyleGroup->addButton(iconTextButton, 1); iconStyleGroup->addButton(iconIconsButton, 2); @@ -74,10 +74,10 @@ AppearanceTab::AppearanceTab(QWidget* parent) /***************************************** * Window-Size-Box *****************************************/ - auto* windowSizeBox = new QGroupBox(tr("Windowstate")); + auto* windowSizeBox = new QGroupBox(_("Window State")); auto* windowSizeBoxLayout = new QHBoxLayout(); windowSizeCheckBox = - new QCheckBox(tr("Save window size and position on exit."), this); + new QCheckBox(_("Save window size and position on exit."), this); windowSizeBoxLayout->addWidget(windowSizeCheckBox); windowSizeBox->setLayout(windowSizeBoxLayout); @@ -85,13 +85,13 @@ AppearanceTab::AppearanceTab(QWidget* parent) * Info-Board-Font-Size-Box *****************************************/ - auto* infoBoardBox = new QGroupBox(tr("Information Board")); + auto* infoBoardBox = new QGroupBox(_("Information Board")); auto* infoBoardLayout = new QHBoxLayout(); infoBoardFontSizeSpin = new QSpinBox(); infoBoardFontSizeSpin->setRange(9, 18); infoBoardFontSizeSpin->setValue(10); infoBoardFontSizeSpin->setSingleStep(1); - infoBoardLayout->addWidget(new QLabel(tr(" Front Size"))); + infoBoardLayout->addWidget(new QLabel(_("Front Size"))); infoBoardLayout->addWidget(infoBoardFontSizeSpin); infoBoardBox->setLayout(infoBoardLayout); diff --git a/src/ui/settings/SettingsAppearance.h b/src/ui/settings/SettingsAppearance.h index 163f3c93..284ecb1c 100644 --- a/src/ui/settings/SettingsAppearance.h +++ b/src/ui/settings/SettingsAppearance.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -60,6 +60,6 @@ class AppearanceTab : public QWidget { void signalRestartNeeded(bool needed); }; -} +} // namespace GpgFrontend::UI #endif // GPGFRONTEND_SETTINGSAPPEARANCE_H diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/settings/SettingsDialog.cpp index 553ce53e..4f959b68 100644 --- a/src/ui/settings/SettingsDialog.cpp +++ b/src/ui/settings/SettingsDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -46,14 +46,14 @@ SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) { advancedTab = new AdvancedTab; gpgPathsTab = new GpgPathsTab; - tabWidget->addTab(generalTab, tr("General")); - tabWidget->addTab(appearanceTab, tr("Appearance")); + tabWidget->addTab(generalTab, _("General")); + tabWidget->addTab(appearanceTab, _("Appearance")); #ifdef SMTP_SUPPORT - tabWidget->addTab(sendMailTab, tr("Send Mail")); + tabWidget->addTab(sendMailTab, _("Send Mail")); #endif - tabWidget->addTab(keyserverTab, tr("Key Server")); - // tabWidget->addTab(gpgPathsTab, tr("Gpg paths")); - tabWidget->addTab(advancedTab, tr("Advanced")); + tabWidget->addTab(keyserverTab, _("Key Server")); + // tabWidget->addTab(gpgPathsTab, _("Gpg paths")); + tabWidget->addTab(advancedTab, _("Advanced")); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -68,7 +68,7 @@ SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) { mainLayout->stretch(0); setLayout(mainLayout); - setWindowTitle(tr("Settings")); + setWindowTitle(_("Settings")); // slots for handling the restartneeded member this->slotSetRestartNeeded(false); @@ -118,7 +118,7 @@ void SettingsDialog::slotAccept() { QHash<QString, QString> SettingsDialog::listLanguages() { QHash<QString, QString> languages; - languages.insert("", tr("System Default")); + languages.insert(QString(), _("System Default")); QString appPath = qApp->applicationDirPath(); QDir qmDir = QDir(RESOURCE_DIR(appPath) + "/ts/"); @@ -153,26 +153,29 @@ GpgPathsTab::GpgPathsTab(QWidget* parent) /***************************************** * Keydb Box *****************************************/ - auto* keydbBox = new QGroupBox(tr("Relative path to keydb")); + auto* keydbBox = new QGroupBox(_("Relative path to Key Database")); auto* keydbBoxLayout = new QGridLayout(); // Label containing the current keydbpath relative to default keydb path keydbLabel = new QLabel(accKeydbPath, this); - auto* keydbButton = new QPushButton("Change keydb path", this); + auto* keydbButton = new QPushButton(_("Change Key Database path"), this); connect(keydbButton, SIGNAL(clicked()), this, SLOT(chooseKeydbDir())); - auto* keydbDefaultButton = new QPushButton("Set keydb to default path", this); + auto* keydbDefaultButton = + new QPushButton(_("Set Key Database to default path"), this); connect(keydbDefaultButton, SIGNAL(clicked()), this, SLOT(setKeydbPathToDefault())); keydbBox->setLayout(keydbBoxLayout); - keydbBoxLayout->addWidget(new QLabel(tr("Current keydb path: ")), 1, 1); + keydbBoxLayout->addWidget( + new QLabel(QString(_("Current Key Database path")) + ": "), 1, 1); keydbBoxLayout->addWidget(keydbLabel, 1, 2); keydbBoxLayout->addWidget(keydbButton, 1, 3); keydbBoxLayout->addWidget(keydbDefaultButton, 2, 3); keydbBoxLayout->addWidget( - new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you " - "change the keydb path!")), + new QLabel(QString("<b>") + _("NOTE") + ": </b> " + + _("GpgFrontend will restart automatically if you change the " + "Key Database path!")), 3, 1, 1, 3); auto* mainLayout = new QVBoxLayout; @@ -200,12 +203,12 @@ void GpgPathsTab::setKeydbPathToDefault() { QString GpgPathsTab::chooseKeydbDir() { QString dir = QFileDialog::getExistingDirectory( - this, tr("Choose keydb directory"), accKeydbPath, + this, _("Choose keydb directory"), accKeydbPath, QFileDialog::ShowDirsOnly); accKeydbPath = getRelativePath(defKeydbPath, dir); keydbLabel->setText(accKeydbPath); - return ""; + return {}; } void GpgPathsTab::setSettings() { diff --git a/src/ui/settings/SettingsDialog.h b/src/ui/settings/SettingsDialog.h index 0f89e266..9f670cfd 100755 --- a/src/ui/settings/SettingsDialog.h +++ b/src/ui/settings/SettingsDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/settings/SettingsGeneral.cpp index f5a98282..51e0649c 100644 --- a/src/ui/settings/SettingsGeneral.cpp +++ b/src/ui/settings/SettingsGeneral.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -45,12 +45,12 @@ GeneralTab::GeneralTab(QWidget* parent) /***************************************** * GpgFrontend Server *****************************************/ - auto* serverBox = new QGroupBox(tr("GpgFrontend Server")); + auto* serverBox = new QGroupBox(_("GpgFrontend Server")); auto* serverBoxLayout = new QVBoxLayout(); serverSelectBox = new QComboBox(); serverBoxLayout->addWidget(serverSelectBox); serverBoxLayout->addWidget(new QLabel( - tr("Server that provides short key and key exchange services"))); + _("Server that provides short key and key exchange services"))); serverBox->setLayout(serverBoxLayout); #endif @@ -58,10 +58,10 @@ GeneralTab::GeneralTab(QWidget* parent) /***************************************** * Save-Checked-Keys-Box *****************************************/ - auto* saveCheckedKeysBox = new QGroupBox(tr("Save Checked Keys")); + auto* saveCheckedKeysBox = new QGroupBox(_("Save Checked Keys")); auto* saveCheckedKeysBoxLayout = new QHBoxLayout(); saveCheckedKeysCheckBox = new QCheckBox( - tr("Save checked private keys on exit and restore them on next start."), + _("Save checked private keys on exit and restore them on next start."), this); saveCheckedKeysBoxLayout->addWidget(saveCheckedKeysCheckBox); saveCheckedKeysBox->setLayout(saveCheckedKeysBoxLayout); @@ -70,10 +70,10 @@ GeneralTab::GeneralTab(QWidget* parent) * Key-Impport-Confirmation Box *****************************************/ auto* importConfirmationBox = - new QGroupBox(tr("Confirm drag'n'drop key import")); + new QGroupBox(_("Confirm drag'n'drop key import")); auto* importConfirmationBoxLayout = new QHBoxLayout(); importConfirmationCheckBox = new QCheckBox( - tr("Import files dropped on the keylist without confirmation."), this); + _("Import files dropped on the Key List without confirmation."), this); importConfirmationBoxLayout->addWidget(importConfirmationCheckBox); importConfirmationBox->setLayout(importConfirmationBoxLayout); @@ -81,7 +81,7 @@ GeneralTab::GeneralTab(QWidget* parent) /***************************************** * Language Select Box *****************************************/ - auto* langBox = new QGroupBox(tr("Language")); + auto* langBox = new QGroupBox(_("Language")); auto* langBoxLayout = new QVBoxLayout(); langSelectBox = new QComboBox; lang = SettingsDialog::listLanguages(); @@ -91,9 +91,9 @@ GeneralTab::GeneralTab(QWidget* parent) } langBoxLayout->addWidget(langSelectBox); - langBoxLayout->addWidget( - new QLabel(tr("<b>NOTE: </b> GpgFrontend will restart automatically if " - "you change the language!"))); + langBoxLayout->addWidget(new QLabel( + "<b>" + QString(_("NOTE")) + _(": ") + "</b>" + + _("GpgFrontend will restart automatically if you change the language!"))); langBox->setLayout(langBoxLayout); connect(langSelectBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLanguageChanged())); @@ -103,12 +103,12 @@ GeneralTab::GeneralTab(QWidget* parent) /***************************************** * Own Key Select Box *****************************************/ - auto* ownKeyBox = new QGroupBox(tr("Own key")); + auto* ownKeyBox = new QGroupBox(_("Own key")); auto* ownKeyBoxLayout = new QVBoxLayout(); auto* ownKeyServiceTokenLayout = new QHBoxLayout(); ownKeySelectBox = new QComboBox; - getServiceTokenButton = new QPushButton(tr("Get Service Token")); - serviceTokenLabel = new QLabel(tr("No Service Token Found")); + getServiceTokenButton = new QPushButton(_("Get Service Token")); + serviceTokenLabel = new QLabel(_("No Service Token Found")); serviceTokenLabel->setAlignment(Qt::AlignCenter); ownKeyBox->setLayout(ownKeyBoxLayout); @@ -116,7 +116,7 @@ GeneralTab::GeneralTab(QWidget* parent) mKeyList = new KeyList(); // Fill the keyid hashmap - keyIds.insert({"", "<none>"}); + keyIds.insert({QString(), "<none>"}); auto private_keys = mKeyList->getAllPrivateKeys(); @@ -135,7 +135,7 @@ GeneralTab::GeneralTab(QWidget* parent) SLOT(slotGetServiceToken())); ownKeyBoxLayout->addWidget(new QLabel( - tr("Key pair for synchronization and identity authentication"))); + _("Key pair for synchronization and identity authentication"))); ownKeyBoxLayout->addWidget(ownKeySelectBox); ownKeyBoxLayout->addLayout(ownKeyServiceTokenLayout); ownKeyServiceTokenLayout->addWidget(getServiceTokenButton); @@ -204,7 +204,7 @@ void GeneralTab::setSettings() { // Language setting QString langKey = settings.value("int/lang").toString(); QString langValue = lang.value(langKey); - if (langKey != "") { + if (!langKey.isEmpty()) { langSelectBox->setCurrentIndex(langSelectBox->findText(langValue)); } @@ -277,7 +277,7 @@ void GeneralTab::slotLanguageChanged() { emit signalRestartNeeded(true); } #ifdef SERVER_SUPPORT void GeneralTab::slotOwnKeyIdChanged() { // Set ownKeyId to currently selected - this->serviceTokenLabel->setText(tr("No Service Token Found")); + this->serviceTokenLabel->setText(_("No Service Token Found")); serviceToken.clear(); } #endif @@ -296,8 +296,8 @@ void GeneralTab::slotGetServiceToken() { if (keyId.isEmpty()) { QMessageBox::critical( - this, tr("Invalid Operation"), - tr("Own Key can not be None while getting service token.")); + this, _("Invalid Operation"), + _("Own Key can not be None while getting service token.")); return; } @@ -309,7 +309,7 @@ void GeneralTab::slotGetServiceToken() { GpgKey key = mCtx->getKeyRefById(keyId); if (!key.good) { - QMessageBox::critical(this, tr("Error"), tr("Key Not Exists")); + QMessageBox::critical(this, _("Error"), _("Key Not Exists")); return; } @@ -380,9 +380,9 @@ void GeneralTab::slotGetServiceToken() { if (!utils->checkDataValueStr("serviceToken") || !utils->checkDataValueStr("fpr")) { - QMessageBox::critical(this, tr("Error"), - tr("The communication content with the server does " - "not meet the requirements")); + QMessageBox::critical(this, _("Error"), + _("The communication content with the server does " + "not meet the requirements")); return; } @@ -395,12 +395,12 @@ void GeneralTab::slotGetServiceToken() { // Auto update settings settings.setValue("general/serviceToken", serviceToken); serviceTokenLabel->setText(serviceToken); - QMessageBox::information(this, tr("Notice"), - tr("Succeed in getting service token")); + QMessageBox::information(this, _("Notice"), + _("Succeed in getting service token")); } else { QMessageBox::critical( - this, tr("Error"), - tr("There is a problem with the communication with the server")); + this, _("Error"), + _("There is a problem with the communication with the server")); } } } diff --git a/src/ui/settings/SettingsGeneral.h b/src/ui/settings/SettingsGeneral.h index cc61d8bc..5816af9d 100644 --- a/src/ui/settings/SettingsGeneral.h +++ b/src/ui/settings/SettingsGeneral.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/settings/SettingsKeyServer.cpp b/src/ui/settings/SettingsKeyServer.cpp index d232a46e..dc77491b 100644 --- a/src/ui/settings/SettingsKeyServer.cpp +++ b/src/ui/settings/SettingsKeyServer.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -31,7 +31,7 @@ KeyserverTab::KeyserverTab(QWidget* parent) appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { - auto generalGroupBox = new QGroupBox(tr("General")); + auto generalGroupBox = new QGroupBox(_("General")); auto generalLayout = new QVBoxLayout(); keyServerTable = new QTableWidget(); @@ -53,11 +53,11 @@ KeyserverTab::KeyserverTab(QWidget* parent) keyServerTable->setAlternatingRowColors(true); QStringList labels; - labels << tr("No.") << tr("Address") << tr("Available"); + labels << _("No.") << _("Address") << _("Available"); keyServerTable->setHorizontalHeaderLabels(labels); auto* mainLayout = new QVBoxLayout(this); - auto* label = new QLabel(tr("Default Key Server for Import:")); + auto* label = new QLabel(QString(_("Default Key Server for Import")) + ": "); comboBox = new QComboBox; comboBox->setEditable(false); @@ -67,7 +67,7 @@ KeyserverTab::KeyserverTab(QWidget* parent) auto* addKeyServerLayout = new QHBoxLayout(addKeyServerBox); auto* http = new QLabel("URL: "); newKeyServerEdit = new QLineEdit(this); - auto* newKeyServerButton = new QPushButton(tr("Add"), this); + auto* newKeyServerButton = new QPushButton(_("Add"), this); connect(newKeyServerButton, SIGNAL(clicked()), this, SLOT(addKeyServer())); addKeyServerLayout->addWidget(http); addKeyServerLayout->addWidget(newKeyServerEdit); @@ -140,7 +140,7 @@ void KeyserverTab::refreshTable() { auto* tmp2 = new QTableWidgetItem(server); tmp2->setTextAlignment(Qt::AlignCenter); keyServerTable->setItem(index, 1, tmp2); - auto* tmp3 = new QTableWidgetItem(""); + auto* tmp3 = new QTableWidgetItem(); tmp3->setTextAlignment(Qt::AlignCenter); keyServerTable->setItem(index, 2, tmp3); index++; diff --git a/src/ui/settings/SettingsKeyServer.h b/src/ui/settings/SettingsKeyServer.h index ce7c5b2e..23186702 100644 --- a/src/ui/settings/SettingsKeyServer.h +++ b/src/ui/settings/SettingsKeyServer.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -56,6 +56,6 @@ class KeyserverTab : public QWidget { void signalRestartNeeded(bool needed); }; -} +} // namespace GpgFrontend::UI #endif // GPGFRONTEND_SETTINGSKEYSERVER_H diff --git a/src/ui/settings/SettingsSendMail.cpp b/src/ui/settings/SettingsSendMail.cpp index 9d48b2a0..2518991d 100644 --- a/src/ui/settings/SettingsSendMail.cpp +++ b/src/ui/settings/SettingsSendMail.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -35,7 +35,7 @@ SendMailTab::SendMailTab(QWidget* parent) appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { - enableCheckBox = new QCheckBox(tr("Enable")); + enableCheckBox = new QCheckBox(_("Enable")); enableCheckBox->setTristate(false); smtpAddress = new QLineEdit(); @@ -54,31 +54,31 @@ SendMailTab::SendMailTab(QWidget* parent) defaultSender = new QLineEdit(); ; - checkConnectionButton = new QPushButton(tr("Check Connection")); + checkConnectionButton = new QPushButton(_("Check Connection")); - auto generalGroupBox = new QGroupBox(tr("General")); - auto connectGroupBox = new QGroupBox(tr("Connection")); - auto preferenceGroupBox = new QGroupBox(tr("Preference")); + auto generalGroupBox = new QGroupBox(_("General")); + auto connectGroupBox = new QGroupBox(_("Connection")); + auto preferenceGroupBox = new QGroupBox(_("Preference")); auto generalLayout = new QGridLayout(); generalLayout->addWidget(enableCheckBox); auto connectLayout = new QGridLayout(); - connectLayout->addWidget(new QLabel(tr("SMTP Address")), 1, 0); + connectLayout->addWidget(new QLabel(_("SMTP Address")), 1, 0); connectLayout->addWidget(smtpAddress, 1, 1, 1, 4); - connectLayout->addWidget(new QLabel(tr("Username")), 2, 0); + connectLayout->addWidget(new QLabel(_("Username")), 2, 0); connectLayout->addWidget(username, 2, 1, 1, 4); - connectLayout->addWidget(new QLabel(tr("Password")), 3, 0); + connectLayout->addWidget(new QLabel(_("Password")), 3, 0); connectLayout->addWidget(password, 3, 1, 1, 4); - connectLayout->addWidget(new QLabel(tr("Port")), 4, 0); + connectLayout->addWidget(new QLabel(_("Port")), 4, 0); connectLayout->addWidget(portSpin, 4, 1, 1, 1); - connectLayout->addWidget(new QLabel(tr("Connection Security")), 5, 0); + connectLayout->addWidget(new QLabel(_("Connection Security")), 5, 0); connectLayout->addWidget(connectionTypeComboBox, 5, 1, 1, 1); connectLayout->addWidget(checkConnectionButton, 6, 0); auto preferenceLayout = new QGridLayout(); - preferenceLayout->addWidget(new QLabel(tr("Default Sender")), 0, 0); + preferenceLayout->addWidget(new QLabel(_("Default Sender")), 0, 0); preferenceLayout->addWidget(defaultSender, 0, 1, 1, 4); generalGroupBox->setLayout(generalLayout); @@ -164,17 +164,17 @@ void SendMailTab::slotCheckConnection() { bool if_success = true; if (!smtp.connectToHost()) { - QMessageBox::critical(this, tr("Fail"), tr("Fail to Connect SMTP Server")); + QMessageBox::critical(this, _("Fail"), _("Fail to Connect SMTP Server")); if_success = false; } if (if_success && !smtp.login()) { - QMessageBox::critical(this, tr("Fail"), tr("Fail to Login")); + QMessageBox::critical(this, _("Fail"), _("Fail to Login")); if_success = false; } if (if_success) - QMessageBox::information(this, tr("Success"), - tr("Succeed in connecting and login")); + QMessageBox::information(this, _("Success"), + _("Succeed in connecting and login")); } #endif diff --git a/src/ui/smtp/SendMailDialog.cpp b/src/ui/smtp/SendMailDialog.cpp index 51ece6c9..7c8933a0 100644 --- a/src/ui/smtp/SendMailDialog.cpp +++ b/src/ui/smtp/SendMailDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -40,9 +40,9 @@ SendMailDialog::SendMailDialog(QString text, QWidget* parent) mText(std::move(text)) { if (smtpAddress.isEmpty()) { QMessageBox::critical( - this, tr("Incomplete configuration"), - tr("The SMTP address is empty, please go to the setting interface to " - "complete the configuration.")); + this, _("Incomplete configuration"), + _("The SMTP address is empty, please go to the setting interface to " + "complete the configuration.")); deleteLater(); return; @@ -96,21 +96,23 @@ void SendMailDialog::slotConfirm() { QStringList rcptStringList = recipientEdit->toPlainText().split(';'); if (rcptStringList.isEmpty()) { - errString.append(tr(" Recipient cannot be empty \n")); + errString.append(QString(" ") + _("Recipient cannot be empty") + " \n"); } else { for (const auto& reci : rcptStringList) { qDebug() << "Receiver" << reci.trimmed(); if (!check_email_address(reci.trimmed())) { - errString.append( - tr(" One or more Recipient's Email Address is invalid \n")); + errString.append(QString(" ") + + _("One or more Recipient's Email Address is invalid") + + " \n"); break; } } } if (senderEdit->text().isEmpty()) { - errString.append(tr(" Sender cannot be empty \n")); + errString.append(QString(" ") + _("Sender cannot be empty") + " \n"); } else if (!check_email_address(senderEdit->text())) { - errString.append(tr(" Sender's Email Address is invalid \n")); + errString.append(QString(" ") + _("Sender's Email Address is invalid") + + " \n"); } if (!errString.isEmpty()) { @@ -166,26 +168,25 @@ void SendMailDialog::slotConfirm() { // Now we can send the mail if (!smtp.connectToHost()) { qDebug() << "Connect to SMTP Server Failed"; - QMessageBox::critical(this, tr("Fail"), tr("Fail to Connect SMTP Server")); + QMessageBox::critical(this, _("Fail"), _("Fail to Connect SMTP Server")); return; } if (!smtp.login()) { qDebug() << "Login to SMTP Server Failed"; - QMessageBox::critical(this, tr("Fail"), - tr("Fail to Login into SMTP Server")); + QMessageBox::critical(this, _("Fail"), _("Fail to Login into SMTP Server")); return; } if (!smtp.sendMail(message)) { qDebug() << "Send Mail to SMTP Server Failed"; - QMessageBox::critical(this, tr("Fail"), - tr("Fail to Send Mail to SMTP Server")); + QMessageBox::critical(this, _("Fail"), + _("Fail to Send Mail to SMTP Server")); return; } smtp.quit(); // Close after sending email - QMessageBox::information(this, tr("Success"), - tr("Succeed in Sending Mail to SMTP Server")); + QMessageBox::information(this, _("Success"), + _("Succeed in Sending Mail to SMTP Server")); deleteLater(); } diff --git a/src/ui/smtp/SendMailDialog.h b/src/ui/smtp/SendMailDialog.h index 6afdfe79..87dfd81f 100644 --- a/src/ui/smtp/SendMailDialog.h +++ b/src/ui/smtp/SendMailDialog.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/EditorPage.cpp b/src/ui/widgets/EditorPage.cpp index 26976048..6fd72c20 100644 --- a/src/ui/widgets/EditorPage.cpp +++ b/src/ui/widgets/EditorPage.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -41,7 +41,7 @@ EditorPage::EditorPage(QString filePath, QWidget* parent) mainLayout->addWidget(textPage); mainLayout->setContentsMargins(0, 0, 0, 0); setLayout(mainLayout); - + textPage->setFocus(); // Front in same width diff --git a/src/ui/widgets/EditorPage.h b/src/ui/widgets/EditorPage.h index 0f637500..1e19a0de 100644 --- a/src/ui/widgets/EditorPage.h +++ b/src/ui/widgets/EditorPage.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index 2cb59ae1..4b88092b 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -167,17 +167,17 @@ void FilePage::slotGoPath() { void FilePage::createPopupMenu() { popUpMenu = new QMenu(); - auto openItemAct = new QAction(tr("Open"), this); + auto openItemAct = new QAction(_("Open"), this); connect(openItemAct, SIGNAL(triggered()), this, SLOT(slotOpenItem())); - auto deleteItemAct = new QAction(tr("Delete"), this); + auto deleteItemAct = new QAction(_("Delete"), this); connect(deleteItemAct, SIGNAL(triggered()), this, SLOT(slotDeleteItem())); - encryptItemAct = new QAction(tr("Encrypt and Sign"), this); + encryptItemAct = new QAction(_("Encrypt and Sign"), this); connect(encryptItemAct, SIGNAL(triggered()), this, SLOT(slotEncryptItem())); - decryptItemAct = new QAction(tr("Decrypt and Verify"), this); + decryptItemAct = new QAction(_("Decrypt and Verify"), this); connect(decryptItemAct, SIGNAL(triggered()), this, SLOT(slotDecryptItem())); - signItemAct = new QAction(tr("Only Sign"), this); + signItemAct = new QAction(_("Only Sign"), this); connect(signItemAct, SIGNAL(triggered()), this, SLOT(slotSignItem())); - verifyItemAct = new QAction(tr("Only Verify"), this); + verifyItemAct = new QAction(_("Only Verify"), this); connect(verifyItemAct, SIGNAL(triggered()), this, SLOT(slotVerifyItem())); popUpMenu->addAction(openItemAct); @@ -233,8 +233,8 @@ void FilePage::slotDeleteItem() { QModelIndex index = dirTreeView->currentIndex(); QVariant data = dirTreeView->model()->data(index); - auto ret = QMessageBox::warning(this, tr("Warning"), - tr("Are you sure you want to delete it?"), + auto ret = QMessageBox::warning(this, _("Warning"), + _("Are you sure you want to delete it?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) return; @@ -242,8 +242,8 @@ void FilePage::slotDeleteItem() { qDebug() << "Delete Item" << data.toString(); if (!dirModel->remove(index)) { - QMessageBox::critical(this, tr("Error"), - tr("Unable to delete the file or folder.")); + QMessageBox::critical(this, _("Error"), + _("Unable to delete the file or folder.")); } } diff --git a/src/ui/widgets/FilePage.h b/src/ui/widgets/FilePage.h index 9fd4308e..31be81f3 100644 --- a/src/ui/widgets/FilePage.h +++ b/src/ui/widgets/FilePage.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/GroupKeyList.cpp b/src/ui/widgets/GroupKeyList.cpp index 404e8faf..efba4428 100644 --- a/src/ui/widgets/GroupKeyList.cpp +++ b/src/ui/widgets/GroupKeyList.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/GroupKeyList.h b/src/ui/widgets/GroupKeyList.h index f0c9e2c6..163c7126 100644 --- a/src/ui/widgets/GroupKeyList.h +++ b/src/ui/widgets/GroupKeyList.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/HelpPage.cpp b/src/ui/widgets/HelpPage.cpp index dfc24929..7b1e86c0 100644 --- a/src/ui/widgets/HelpPage.cpp +++ b/src/ui/widgets/HelpPage.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -77,8 +77,6 @@ QUrl HelpPage::localizedHelp(const QUrl& url) { } } -QTextBrowser* HelpPage::getBrowser() { - return browser; -} +QTextBrowser* HelpPage::getBrowser() { return browser; } } // namespace GpgFrontend::UI diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp index aac80514..7de99a2b 100644 --- a/src/ui/widgets/InfoBoardWidget.cpp +++ b/src/ui/widgets/InfoBoardWidget.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -39,7 +39,7 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent, KeyList* keyList) infoBoard->setContentsMargins(0, 0, 0, 0); importFromKeyserverAct = - new QAction(tr("Import missing key from Keyserver"), this); + new QAction(_("Import missing key from Keyserver"), this); connect(importFromKeyserverAct, SIGNAL(triggered()), this, SLOT(slotImportFromKeyserver())); @@ -57,7 +57,7 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent, KeyList* keyList) actionButtonLayout->setSpacing(0); actionButtonMenu->setLayout(actionButtonLayout); - auto label = new QLabel(tr("Optional Actions")); + auto label = new QLabel(_("Optional Actions")); label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); label->setContentsMargins(0, 0, 0, 0); diff --git a/src/ui/widgets/InfoBoardWidget.h b/src/ui/widgets/InfoBoardWidget.h index 5512a78a..858aa014 100644 --- a/src/ui/widgets/InfoBoardWidget.h +++ b/src/ui/widgets/InfoBoardWidget.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 4cb30acf..b3391c68 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -78,8 +78,8 @@ KeyList::KeyList(KeyListRow::KeyType selectType, } QStringList labels; - labels << tr("Select") << tr("Type") << tr("Name") << tr("Email Address") - << tr("Usage") << tr("Validity") << tr("Finger Print"); + labels << _("Select") << _("Type") << _("Name") << _("Email Address") + << _("Usage") << _("Validity") << _("Finger Print"); mKeyList->setHorizontalHeaderLabels(labels); mKeyList->horizontalHeader()->setStretchLastSection(false); @@ -103,7 +103,6 @@ KeyList::KeyList(KeyListRow::KeyType selectType, } void KeyList::slotRefresh() { - LOG(INFO) << "KeyList::slotRefresh Called"; auto keyList = getChecked(); @@ -302,14 +301,16 @@ void KeyList::addMenuAction(QAction* act) { popupMenu->addAction(act); } void KeyList::dropEvent(QDropEvent* event) { auto* dialog = new QDialog(); - dialog->setWindowTitle(tr("Import Keys")); + dialog->setWindowTitle(_("Import Keys")); QLabel* label; - label = new QLabel(tr("You've dropped something on the table.\n GpgFrontend " - "will now try to import key(s).") + - "\n"); + label = + new QLabel(QString(_("You've dropped something on the table.")) + "\n " + + _("GpgFrontend " + "will now try to import key(s).") + + "\n"); // "always import keys"-CheckBox - auto* checkBox = new QCheckBox(tr("Always import without bothering.")); + auto* checkBox = new QCheckBox(_("Always import without bothering.")); if (settings.value("general/confirmImportKeys").toBool()) checkBox->setCheckState(Qt::Unchecked); @@ -343,7 +344,8 @@ void KeyList::dropEvent(QDropEvent* event) { QFile file; file.setFileName(tmp.toLocalFile()); if (!file.open(QIODevice::ReadOnly)) { - qDebug() << tr("Couldn't Open File: ") + tmp.toString(); + LOG(INFO) << _("Couldn't Open File") << ":" + << tmp.toString().toStdString(); } QByteArray inBuffer = file.readAll(); this->importKeys(inBuffer); diff --git a/src/ui/widgets/KeyList.h b/src/ui/widgets/KeyList.h index c1c49c5c..524b2bd0 100644 --- a/src/ui/widgets/KeyList.h +++ b/src/ui/widgets/KeyList.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/SignersPicker.cpp b/src/ui/widgets/SignersPicker.cpp index 3c720b10..3131989b 100644 --- a/src/ui/widgets/SignersPicker.cpp +++ b/src/ui/widgets/SignersPicker.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -27,7 +27,7 @@ namespace GpgFrontend::UI { SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) { - auto confirmButton = new QPushButton(tr("Confirm")); + auto confirmButton = new QPushButton(_("Confirm")); connect(confirmButton, SIGNAL(clicked(bool)), this, SLOT(accept())); /*Setup KeyList*/ diff --git a/src/ui/widgets/SignersPicker.h b/src/ui/widgets/SignersPicker.h index 278e0142..055b6ef6 100644 --- a/src/ui/widgets/SignersPicker.h +++ b/src/ui/widgets/SignersPicker.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp index aaac98ee..efc2abbf 100644 --- a/src/ui/widgets/TextEdit.cpp +++ b/src/ui/widgets/TextEdit.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -24,6 +24,8 @@ #include "ui/widgets/TextEdit.h" +#include <boost/format.hpp> + namespace GpgFrontend::UI { TextEdit::TextEdit(QWidget* parent) : QWidget(parent) { @@ -46,7 +48,7 @@ TextEdit::TextEdit(QWidget* parent) : QWidget(parent) { } void TextEdit::slotNewTab() { - QString header = tr("untitled") + QString::number(++countPage) + ".txt"; + QString header = _("untitled") + QString::number(++countPage) + ".txt"; auto* page = new EditorPage(); tabWidget->addTab(page, header); @@ -83,9 +85,11 @@ void TextEdit::slotOpenFile(QString& path) { page->getTextPage()->setFocus(); page->readFile(); } else { - QMessageBox::warning( - this, tr("Warning"), - tr("Cannot read file %1:\n%2.").arg(path).arg(file.errorString())); + QMessageBox::warning(this, _("Warning"), + (boost::format(_("Cannot read file %1%:\n%2%.")) % + path.toStdString() % file.errorString().toStdString()) + .str() + .c_str()); } file.close(); @@ -93,7 +97,7 @@ void TextEdit::slotOpenFile(QString& path) { void TextEdit::slotOpen() { QStringList fileNames = - QFileDialog::getOpenFileNames(this, tr("Open file"), QDir::currentPath()); + QFileDialog::getOpenFileNames(this, _("Open file"), QDir::currentPath()); for (const auto& fileName : fileNames) { if (!fileName.isEmpty()) { QFile file(fileName); @@ -118,10 +122,12 @@ void TextEdit::slotOpen() { // enableAction(true) file.close(); } else { - QMessageBox::warning(this, tr("Warning"), - tr("Cannot read file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); + QMessageBox::warning( + this, _("Warning"), + (boost::format(_("Cannot read file %1%:\n%2%.")) % + fileName.toStdString() % file.errorString().toStdString()) + .str() + .c_str()); } } } @@ -164,13 +170,16 @@ bool TextEdit::saveFile(const QString& fileName) { int curIndex = tabWidget->currentIndex(); tabWidget->setTabText(curIndex, strippedName(fileName)); page->setFilePath(fileName); - // statusBar()->showMessage(tr("File saved"), 2000); + // statusBar()->showMessage(_("File saved"), 2000); file.close(); return true; } else { QMessageBox::warning( - this, tr("File"), - tr("Cannot write file %1:\n%2.").arg(fileName).arg(file.errorString())); + this, _("Warning"), + (boost::format(_("Cannot read file %1%:\n%2%.")) % + fileName.toStdString() % file.errorString().toStdString()) + .str() + .c_str()); return false; } } @@ -182,13 +191,13 @@ bool TextEdit::slotSaveAs() { EditorPage* page = slotCurPageTextEdit(); QString path; - if (page->getFilePath() != "") { + if (!page->getFilePath().isEmpty()) { path = page->getFilePath(); } else { path = tabWidget->tabText(tabWidget->currentIndex()).remove(0, 2); } - QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), path); + QString fileName = QFileDialog::getSaveFileName(this, _("Save file"), path); return saveFile(fileName); } @@ -250,16 +259,18 @@ bool TextEdit::maybeSaveCurrentTab(bool askToSave) { const QString& filePath = page->getFilePath(); if (askToSave) { result = QMessageBox::warning( - this, tr("Unsaved document"), - tr("The document \"%1\" has been modified. Do you want to " - "save your changes?<br/>") + this, _("Unsaved document"), + QString(_("The document \"%1\" has been modified. Do you want to " + "save your changes?")) .arg(docname) + - tr("<b>Note:</b> If you don't save these files, all changes are " - "lost.<br/>"), + "<br/><b>" + _("Note:") + "</b>" + + _("If you don't save these files, all changes are " + "lost.") + + "<br/>", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); } if ((result == QMessageBox::Save) || (!askToSave)) { - if (filePath == "") { + if (filePath.isEmpty()) { // QString docname = tabWidget->tabText(tabWidget->currentIndex()); // docname.remove(0,2); return slotSaveAs(); @@ -398,8 +409,11 @@ void TextEdit::loadFile(const QString& fileName) { QFile file(fileName); if (!file.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::warning( - this, tr("Application"), - tr("Cannot read file %1:\n%2.").arg(fileName).arg(file.errorString())); + this, _("Warning"), + (boost::format(_("Cannot read file %1%:\n%2%.")) % + fileName.toStdString() % file.errorString().toStdString()) + .str() + .c_str()); return; } QTextStream in(&file); @@ -409,7 +423,7 @@ void TextEdit::loadFile(const QString& fileName) { slotCurPageTextEdit()->setFilePath(fileName); tabWidget->setTabText(tabWidget->currentIndex(), strippedName(fileName)); file.close(); - // statusBar()->showMessage(tr("File loaded"), 2000); + // statusBar()->showMessage(_("File loaded"), 2000); } QString TextEdit::strippedName(const QString& fullFileName) { @@ -434,7 +448,7 @@ void TextEdit::slotPrint() { } document->print(&printer); - // statusBar()->showMessage(tr("Ready"), 2000); + // statusBar()->showMessage(_("Ready"), 2000); #endif } diff --git a/src/ui/widgets/TextEdit.h b/src/ui/widgets/TextEdit.h index beebc8c4..3cff74e7 100644 --- a/src/ui/widgets/TextEdit.h +++ b/src/ui/widgets/TextEdit.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp index 97f792b1..7c25d593 100644 --- a/src/ui/widgets/VerifyKeyDetailBox.cpp +++ b/src/ui/widgets/VerifyKeyDetailBox.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -36,17 +36,17 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(QWidget* parent, KeyList* keyList, switch (gpg_err_code(signature->status)) { case GPG_ERR_NO_PUBKEY: { this->setTitle("A Error Signature"); - auto* importButton = new QPushButton(tr("Import from keyserver")); + auto* importButton = new QPushButton(_("Import from keyserver")); connect(importButton, SIGNAL(clicked()), this, SLOT(slotImportFormKeyserver())); - this->setTitle(tr("Key not present with id 0x") + signature->fpr); + this->setTitle(QString(_("Key not present with id 0x")) + signature->fpr); auto grid = new QGridLayout(); - grid->addWidget(new QLabel(tr("Status:")), 0, 0); - // grid->addWidget(new QLabel(tr("Fingerprint:")), 1, 0); - grid->addWidget(new QLabel(tr("Key not present in keylist")), 0, 1); + 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(signature->fpr), 1, 1); grid->addWidget(importButton, 2, 0, 2, 1); @@ -54,91 +54,96 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(QWidget* parent, KeyList* keyList, break; } case GPG_ERR_NO_ERROR: { - this->setTitle("A Signature:"); + this->setTitle(QString(_("A Signature")) + ":"); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } case GPG_ERR_CERT_REVOKED: { this->setTitle("An Error Signature"); - vbox->addWidget(new QLabel(tr("Status: Cert Revoked"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("Cert Revoked"))); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } case GPG_ERR_SIG_EXPIRED: { this->setTitle("An Error Signature"); - vbox->addWidget(new QLabel(tr("Status: Signature Expired"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("Signature Expired"))); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } case GPG_ERR_KEY_EXPIRED: { this->setTitle("An Error Signature"); - vbox->addWidget(new QLabel(tr("Status: Signature Expired"))); - vbox->addWidget(new QLabel(tr("Status: Key Expired"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("Key Expired"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("Key Expired"))); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } case GPG_ERR_GENERAL: { this->setTitle("An Error Signature"); - vbox->addWidget(new QLabel(tr("Status: General Error"))); + vbox->addWidget( + new QLabel(QString(_("Status")) + ":" + _("General Error"))); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; } default: { this->setTitle("An Error Signature"); - this->setTitle(tr("Status: Unknown Error")); + this->setTitle(QString(_("Status")) + ":" + _("Unknown Error ")); auto gird = createKeyInfoGrid(signature); if (gird != nullptr) { vbox->addLayout(gird); } else { - vbox->addWidget(new QLabel(tr("Key Information is NOT Available"))); + vbox->addWidget(new QLabel(_("Key Information is NOT Available"))); if (signature->fpr != nullptr) { - vbox->addWidget( - new QLabel(tr("Fingerprint: ") + QString(signature->fpr))); + vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " + + QString(signature->fpr))); } } break; @@ -168,48 +173,48 @@ QGridLayout* VerifyKeyDetailBox::createKeyInfoGrid( GpgKey key = GpgKeyGetter::GetInstance().GetKey(signature->fpr); if (!key.good()) return nullptr; - 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(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(QString::fromStdString(key.name())), 0, 1); grid->addWidget(new QLabel(QString::fromStdString(key.email())), 1, 1); grid->addWidget(new QLabel(beautifyFingerprint(signature->fpr)), 2, 1); if (signature->summary & GPGME_SIGSUM_VALID) { - grid->addWidget(new QLabel(tr("Fully Valid")), 3, 1); + grid->addWidget(new QLabel(_("Fully Valid")), 3, 1); } else { - grid->addWidget(new QLabel(tr("NOT Fully Valid")), 3, 1); + grid->addWidget(new QLabel(_("NOT Fully Valid")), 3, 1); } QString flags; QTextStream textStream(&flags); if (signature->summary & GPGME_SIGSUM_GREEN) { - textStream << tr("Good "); + textStream << _("Good") << " "; } if (signature->summary & GPGME_SIGSUM_RED) { - textStream << tr("Bad "); + textStream << _("Bad") << " "; } if (signature->summary & GPGME_SIGSUM_SIG_EXPIRED) { - textStream << tr("Expired "); + textStream << _("Expired") << " "; } if (signature->summary & GPGME_SIGSUM_KEY_MISSING) { - textStream << tr("Missing Key "); + textStream << _("Missing Key") << " "; } if (signature->summary & GPGME_SIGSUM_KEY_REVOKED) { - textStream << tr("Revoked Key "); + textStream << _("Revoked Key") << " "; } if (signature->summary & GPGME_SIGSUM_KEY_EXPIRED) { - textStream << tr("Expired Key "); + textStream << _("Expired Key") << " "; } if (signature->summary & GPGME_SIGSUM_CRL_MISSING) { - textStream << tr("Missing CRL "); + textStream << _("Missing CRL") << " "; } - grid->addWidget(new QLabel(tr(flags.toUtf8().constData())), 4, 1); + grid->addWidget(new QLabel(_(flags.toUtf8().constData())), 4, 1); return grid; } diff --git a/src/ui/widgets/VerifyKeyDetailBox.h b/src/ui/widgets/VerifyKeyDetailBox.h index 7a6ded4e..c1b26bb2 100644 --- a/src/ui/widgets/VerifyKeyDetailBox.h +++ b/src/ui/widgets/VerifyKeyDetailBox.h @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * 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. @@ -33,8 +33,7 @@ namespace GpgFrontend::UI { class VerifyKeyDetailBox : public QGroupBox { Q_OBJECT public: - explicit VerifyKeyDetailBox(QWidget* parent, - KeyList* mKeyList, + explicit VerifyKeyDetailBox(QWidget* parent, KeyList* mKeyList, gpgme_signature_t signature); private slots: |