aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-07-31 05:55:59 +0000
committersaturneric <[email protected]>2024-07-31 05:55:59 +0000
commit2be9cf21aef39a34a807eb29b29eec726ec68f97 (patch)
treeb1c053696132d4754bff72261061cfb84c4365ab
parentfeat: update copyright info (diff)
downloadModules-2be9cf21aef39a34a807eb29b29eec726ec68f97.tar.gz
Modules-2be9cf21aef39a34a807eb29b29eec726ec68f97.zip
fix: addressing some of the issues identified
-rw-r--r--include/GFModuleCommonUtils.hpp87
-rw-r--r--include/GFModuleDefine.h3
-rw-r--r--src/m_gpg_info/CMakeLists.txt12
-rw-r--r--src/m_gpg_info/GnuPGInfoGatheringModule.cpp33
-rw-r--r--src/m_paper_key/CMakeLists.txt10
-rw-r--r--src/m_pinentry/CMakeLists.txt10
-rw-r--r--src/m_pinentry/GpgPassphraseContext.cpp6
-rw-r--r--src/m_pinentry/GpgPassphraseContext.h5
-rw-r--r--src/m_pinentry/PinentryModule.cpp33
-rw-r--r--src/m_pinentry/RaisePinentry.cpp4
-rw-r--r--src/m_pinentry/pinentry.cpp6
-rw-r--r--src/m_pinentry/pinentry.h2
-rw-r--r--src/m_pinentry/qti18n.cpp93
-rw-r--r--src/m_ver_check/CMakeLists.txt16
-rw-r--r--src/m_ver_check/VersionCheckingModule.cpp22
-rw-r--r--src/m_ver_check/ts/ModuleVersionChecking.de_DE.ts2
-rw-r--r--src/m_ver_check/ts/ModuleVersionChecking.en_US.ts2
-rw-r--r--src/m_ver_check/ts/ModuleVersionChecking.fr_FR.ts2
-rw-r--r--src/m_ver_check/ts/ModuleVersionChecking.it_IT.ts36
-rw-r--r--src/m_ver_check/ts/ModuleVersionChecking.zh_CN.ts23
-rw-r--r--src/m_ver_check/ts/ModuleVersionChecking.zh_TW.ts36
21 files changed, 203 insertions, 240 deletions
diff --git a/include/GFModuleCommonUtils.hpp b/include/GFModuleCommonUtils.hpp
index 491d954..7e1f654 100644
--- a/include/GFModuleCommonUtils.hpp
+++ b/include/GFModuleCommonUtils.hpp
@@ -45,17 +45,35 @@
#define LISTEN(event) GFModuleListenEvent(GFGetModuleID(), DUP(event))
-#define LOAD_TRANS(name) \
- { \
- QFile f(QString(":/i18n/%2.%1.qm").arg(GFAppActiveLocale()).arg(name)); \
- if (f.exists() && f.open(QIODevice::ReadOnly)) { \
- FLOG_INFO("%3 loading, locale: %1, path: %2", GFAppActiveLocale(), \
- f.fileName(), UDUP(GFGetModuleID())); \
- auto b = f.readAll(); \
- GFAppRegisterTranslator(AllocBufferAndCopy(b), b.size()); \
- } \
+#define DEFINE_TRANSLATIONS_STRUCTURE(name) \
+ class GTrC { \
+ Q_DECLARE_TR_FUNCTIONS(GTrC) \
+ }; \
+ auto TranslatorDataReader(const char* p_l, char** p_d) -> int { \
+ auto locale = UDUP(p_l); \
+ QFile f(QString(":/i18n/%2.%1.qm").arg(locale).arg(#name)); \
+ if (f.exists() && f.open(QIODevice::ReadOnly)) { \
+ auto b = f.readAll(); \
+ *p_d = AllocBufferAndCopy(b); \
+ return b.size(); \
+ } \
+ FLOG_WARN("%3 loading, locale: %1, not found", locale, f.fileName(), \
+ UDUP(GFGetModuleID())); \
+ *p_d = nullptr; \
+ return 0; \
}
+#define REGISTER_TRANS_READER() \
+ GFAppRegisterTranslatorReader(GFGetModuleID(), TranslatorDataReader)
+
+#define CONCATENATE_DETAIL(x, y) x##y
+#define CONCATENATE(x, y) CONCATENATE_DETAIL(x, y)
+#define GTRC_TR(name, src) CONCATENATE(GTrC_, name)::tr(src)
+
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+#define GTRC_AS_STRING(name) TOSTRING(GTrC_##name)
+
#define EXECUTE_MODULE() \
auto GFExecuteModule(GFModuleEvent* p_event) -> int { \
auto event = ConvertEventToMap(p_event);
@@ -96,10 +114,29 @@ inline void MLogError(const QString& s) { GFModuleLogError(s.toUtf8()); }
inline auto QStrDup(QString str) -> char* { return DUP(str.toUtf8()); }
-inline auto UnStrDup(const char* src) -> QString {
- auto qt_str = QString::fromUtf8(src);
- GFFreeMemory(static_cast<void*>(const_cast<char*>(src)));
- return qt_str;
+inline auto UnStrDup(const char* s) -> QString {
+ auto q_s = QString::fromUtf8(s == nullptr ? "" : s);
+ if (s != nullptr) GFFreeMemory(static_cast<void*>(const_cast<char*>(s)));
+ return q_s;
+}
+
+template <typename T>
+auto FormatStringHelper(const QString& format, T arg) -> QString {
+ return format.arg(arg);
+}
+
+template <typename T, typename... Args>
+auto FormatStringHelper(const QString& format, T arg, Args... args) -> QString {
+ return FormatStringHelper(format.arg(arg), args...);
+}
+
+inline auto FormatStringHelper(const QString& format) -> QString {
+ return format;
+}
+
+template <typename... Args>
+auto FormatString(const QString& format, Args... args) -> QString {
+ return FormatStringHelper(format, args...);
}
inline auto QMapToMetaDataArray(const QMap<QString, QString>& map)
@@ -160,7 +197,10 @@ inline auto ConvertEventParamsToMap(GFModuleEventParam* params)
GFModuleEventParam* last;
while (current != nullptr) {
- param_map[current->name] = UDUP(current->value);
+ const auto name = UDUP(current->name);
+ const auto value = UDUP(current->value);
+
+ if (!name.isEmpty()) param_map[name] = value;
last = current;
current = current->next;
@@ -306,22 +346,3 @@ inline auto CharArrayToQStringList(char** pl_components,
GFFreeMemory(pl_components);
return list;
}
-
-template <typename T>
-auto FormatStringHelper(const QString& format, T arg) -> QString {
- return format.arg(arg);
-}
-
-template <typename T, typename... Args>
-auto FormatStringHelper(const QString& format, T arg, Args... args) -> QString {
- return FormatStringHelper(format.arg(arg), args...);
-}
-
-inline auto FormatStringHelper(const QString& format) -> QString {
- return format;
-}
-
-template <typename... Args>
-auto FormatString(const QString& format, Args... args) -> QString {
- return FormatStringHelper(format, args...);
-}
diff --git a/include/GFModuleDefine.h b/include/GFModuleDefine.h
index 557d064..9585140 100644
--- a/include/GFModuleDefine.h
+++ b/include/GFModuleDefine.h
@@ -32,9 +32,6 @@
#include "GFSDKBuildInfo.h"
#define GF_MODULE_API_DEFINE(id, name, ver, desc, author) \
- class GTrC { \
- Q_DECLARE_TR_FUNCTIONS(GTrC) \
- }; \
auto GFGetModuleGFSDKVersion() -> const char* { \
return DUP(GF_SDK_VERSION_STR); \
} \
diff --git a/src/m_gpg_info/CMakeLists.txt b/src/m_gpg_info/CMakeLists.txt
index 3833547..e9f269d 100644
--- a/src/m_gpg_info/CMakeLists.txt
+++ b/src/m_gpg_info/CMakeLists.txt
@@ -25,6 +25,7 @@
# com.bktus.gpgfrontend.module.integrated.gnupg_info_gathering
+set(INTEGRATED_MODULE_SOURCE "")
aux_source_directory(. INTEGRATED_MODULE_SOURCE)
# define libgpgfrontend_module
@@ -38,13 +39,8 @@ install(TARGETS mod_gpg_info
target_link_libraries(mod_gpg_info PRIVATE
gpgfrontend_module_sdk)
-if(GPGFRONTEND_QT5_BUILD)
- # link Qt core
- target_link_libraries(mod_gpg_info PRIVATE Qt5::Core Qt5::Widgets)
-else()
- # link Qt core
- target_link_libraries(mod_gpg_info PRIVATE Qt6::Core Qt6::Widgets)
-endif()
+# link qt
+target_link_libraries(mod_gpg_info PRIVATE Qt::Core Qt::Widgets)
# using std c++ 17
target_compile_features(mod_gpg_info PRIVATE cxx_std_17)
@@ -60,5 +56,5 @@ set(TS_FILES "${LOCALE_TS_PATH}/ModuleGnuPGInfoGathering.en_US.ts"
qt_add_translations(mod_gpg_info
RESOURCE_PREFIX "/i18n"
TS_FILES ${TS_FILES}
- SOURCES ${MODULE_SOURCE_FILES}
+ SOURCES ${INTEGRATED_MODULE_SOURCE}
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file
diff --git a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp
index f0ff772..7c6d70c 100644
--- a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp
+++ b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp
@@ -50,6 +50,8 @@ GF_MODULE_API_DEFINE("com.bktus.gpgfrontend.module.gnupg_info_gathering",
"GatherGnupgInfo", "1.0.0",
"Try gathering gnupg informations.", "Saturneric")
+DEFINE_TRANSLATIONS_STRUCTURE(ModuleGnuPGInfoGathering);
+
extern auto CalculateBinaryChacksum(const QString &path)
-> std::optional<QString>;
@@ -69,16 +71,23 @@ using Context = struct {
GpgComponentInfo component_info;
};
-auto GFRegisterModule() -> int { return 0; }
+auto GFRegisterModule() -> int {
+ MLogDebug("gnupg info gathering module registering...");
+
+ REGISTER_TRANS_READER();
+
+ GFUIMountEntry(DUP("AboutDialogTabs"),
+ QMapToMetaDataArray({
+ {"TabTitle", GTrC::tr("GnuPG")},
+ }),
+ 1, GnupgTabFactory);
+
+ return 0;
+}
auto GFActiveModule() -> int {
LISTEN("REQUEST_GATHERING_GNUPG_INFO");
- LOAD_TRANS("ModuleGnuPGInfoGathering");
-
- GFUIMountEntry(DUP("AboutDialogTabs"),
- QMapToMetaDataArray({{"TabTitle", GTrC::tr("GnuPG")}}), 1,
- GnupgTabFactory);
return 0;
}
@@ -95,7 +104,7 @@ END_EXECUTE_MODULE()
auto GFDeactivateModule() -> int { return 0; }
auto GFUnregisterModule() -> int {
- MLogDebug("gnupg info gathering module unregistering");
+ MLogDebug("gnupg info gathering module unregistering...");
return 0;
}
@@ -118,10 +127,10 @@ auto StartGatheringGnuPGInfo() -> int {
GFExecuteCommandSync(gpgconf_path, 1, argv, GetGpgComponentInfos, &context);
MLogDebug("load gnupg component info done.");
-#ifdef QT5_BUILD
- QVector<GFCommandExecuteContext> exec_contexts;
-#else
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 4)
QList<GFCommandExecuteContext> exec_contexts;
+#else
+ QVector<GFCommandExecuteContext> exec_contexts;
#endif
const char **argv_0 =
@@ -277,7 +286,7 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out,
auto component_desc = info_split_list[1].trimmed();
auto component_path = info_split_list[2].trimmed();
-#ifdef WINDOWS
+#ifdef __MINGW32__
// replace some special substrings on windows
// platform
component_path.replace("%3a", ":");
@@ -353,7 +362,7 @@ void GetGpgDirectoryInfos(void *, int exit_code, const char *out,
auto configuration_name = info_split_list[0].trimmed();
auto configuration_value = info_split_list[1].trimmed();
-#ifdef WINDOWS
+#ifdef __MINGW32__
// replace some special substrings on windows
// platform
configuration_value.replace("%3a", ":");
diff --git a/src/m_paper_key/CMakeLists.txt b/src/m_paper_key/CMakeLists.txt
index 42e4d8c..de2be24 100644
--- a/src/m_paper_key/CMakeLists.txt
+++ b/src/m_paper_key/CMakeLists.txt
@@ -25,6 +25,7 @@
# com.bktus.gpgfrontend.module.integrated.gnupg_info_gathering
+set(INTEGRATED_MODULE_SOURCE "")
aux_source_directory(. INTEGRATED_MODULE_SOURCE)
# define libgpgfrontend_module
@@ -38,13 +39,8 @@ install(TARGETS mod_paper_key
target_link_libraries(mod_paper_key PRIVATE
gpgfrontend_module_sdk)
-if(GPGFRONTEND_QT5_BUILD)
- # link Qt core
- target_link_libraries(mod_paper_key PRIVATE Qt5::Core)
-else()
- # link Qt core
- target_link_libraries(mod_paper_key PRIVATE Qt6::Core)
-endif()
+# link qt
+target_link_libraries(mod_paper_key PRIVATE Qt::Core)
# using std c++ 17
target_compile_features(mod_paper_key PRIVATE cxx_std_17)
diff --git a/src/m_pinentry/CMakeLists.txt b/src/m_pinentry/CMakeLists.txt
index bf17acd..344fc38 100644
--- a/src/m_pinentry/CMakeLists.txt
+++ b/src/m_pinentry/CMakeLists.txt
@@ -23,6 +23,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
+set(INTEGRATED_MODULE_SOURCE "")
aux_source_directory(. INTEGRATED_MODULE_SOURCE)
# capslock
@@ -49,13 +50,8 @@ install(TARGETS mod_pinentry
target_link_libraries(mod_pinentry PRIVATE
gpgfrontend_module_sdk)
-if(GPGFRONTEND_QT5_BUILD)
- # link Qt core
- target_link_libraries(mod_pinentry PUBLIC Qt5::Widgets)
-else()
- # link Qt core
- target_link_libraries(mod_pinentry PUBLIC Qt6::Widgets)
-endif()
+# link qt
+target_link_libraries(mod_pinentry PUBLIC Qt::Widgets)
# using std c++ 17
target_compile_features(mod_pinentry PUBLIC cxx_std_17)
diff --git a/src/m_pinentry/GpgPassphraseContext.cpp b/src/m_pinentry/GpgPassphraseContext.cpp
index 4e21a20..61add57 100644
--- a/src/m_pinentry/GpgPassphraseContext.cpp
+++ b/src/m_pinentry/GpgPassphraseContext.cpp
@@ -54,4 +54,8 @@ auto GpgPassphraseContext::GetPassphraseInfo() const -> QString {
auto GpgPassphraseContext::IsPreWasBad() const -> bool { return prev_was_bad_; }
-auto GpgPassphraseContext::IsAskForNew() const -> bool { return ask_for_new_; } \ No newline at end of file
+auto GpgPassphraseContext::IsAskForNew() const -> bool { return ask_for_new_; }
+
+auto GpgPassphraseContext::IsSuccess() const -> bool { return success_; }
+
+void GpgPassphraseContext::SetSuccess(bool success) { success_ = success; } \ No newline at end of file
diff --git a/src/m_pinentry/GpgPassphraseContext.h b/src/m_pinentry/GpgPassphraseContext.h
index 107307b..f021cb8 100644
--- a/src/m_pinentry/GpgPassphraseContext.h
+++ b/src/m_pinentry/GpgPassphraseContext.h
@@ -42,6 +42,8 @@ class GpgPassphraseContext : public QObject {
void SetPassphrase(const QString& passphrase);
+ void SetSuccess(bool success);
+
[[nodiscard]] auto GetPassphrase() const -> QString;
[[nodiscard]] auto GetUidsInfo() const -> QString;
@@ -52,10 +54,13 @@ class GpgPassphraseContext : public QObject {
[[nodiscard]] auto IsAskForNew() const -> bool;
+ [[nodiscard]] auto IsSuccess() const -> bool;
+
private:
QString passphrase_info_;
QString uids_info_;
QString passphrase_;
bool prev_was_bad_;
bool ask_for_new_;
+ bool success_;
};
diff --git a/src/m_pinentry/PinentryModule.cpp b/src/m_pinentry/PinentryModule.cpp
index 5d767a9..01b2185 100644
--- a/src/m_pinentry/PinentryModule.cpp
+++ b/src/m_pinentry/PinentryModule.cpp
@@ -58,27 +58,38 @@ auto GFExecuteModule(GFModuleEvent *p_event) -> int {
auto event = ConvertEventToMap(p_event);
if (event["prev_was_bad"].isEmpty() || event["ask_for_new"].isEmpty()) {
- GFModuleTriggerModuleEventCallback(
- ConvertMapToEvent(event), GFGetModuleID(),
- ConvertMapToParams({{"ret", "-1"}, {"passphrase", ""}}));
+ CB(event, GFGetModuleID(),
+ {
+ {"ret", "-1"},
+ {"passphrase", ""},
+ });
return -1;
}
QMetaObject::invokeMethod(
- QApplication::instance()->thread(), [p_event, event]() -> int {
+ QApplication::instance()->thread(), [event]() -> int {
auto *p = new RaisePinentry(
nullptr,
SecureCreateQSharedObject<GpgPassphraseContext>(
event["uid_hint"], event["passphrase_info"],
event["prev_was_bad"].toInt(), event["ask_for_new"].toInt()));
- QObject::connect(
- p, &RaisePinentry::SignalUserInputPassphraseCallback, p,
- [event](const QSharedPointer<GpgPassphraseContext> &c) {
- GFModuleTriggerModuleEventCallback(
- ConvertMapToEvent(event), GFGetModuleID(),
- ConvertMapToParams({{"passphrase", c->GetPassphrase()}}));
- });
+ QObject::connect(p, &RaisePinentry::SignalUserInputPassphraseCallback,
+ p, [event](QSharedPointer<GpgPassphraseContext> c) {
+ if (c) {
+ CB(event, GFGetModuleID(),
+ {
+ {"ret", "0"},
+ {"passphrase", c->GetPassphrase()},
+ });
+ } else {
+ CB(event, GFGetModuleID(),
+ {
+ {"ret", "-1"},
+ {"passphrase", ""},
+ });
+ }
+ });
p->Exec();
return 0;
diff --git a/src/m_pinentry/RaisePinentry.cpp b/src/m_pinentry/RaisePinentry.cpp
index ed9538d..e4061e6 100644
--- a/src/m_pinentry/RaisePinentry.cpp
+++ b/src/m_pinentry/RaisePinentry.cpp
@@ -90,12 +90,14 @@ auto RaisePinentry::Exec() -> int {
bool ret = result != 0;
if (!ret) {
- emit SignalUserInputPassphraseCallback({});
+ context_->SetSuccess(false);
+ emit SignalUserInputPassphraseCallback(context_);
return -1;
}
auto pin = pinentry->pin().toUtf8();
+ context_->SetSuccess(true);
context_->SetPassphrase(pin);
emit SignalUserInputPassphraseCallback(context_);
return 0;
diff --git a/src/m_pinentry/pinentry.cpp b/src/m_pinentry/pinentry.cpp
index c2965a8..b46cde1 100644
--- a/src/m_pinentry/pinentry.cpp
+++ b/src/m_pinentry/pinentry.cpp
@@ -26,7 +26,7 @@
#include "GFModuleCommonUtils.hpp"
#include "GFSDKBasic.h"
-#ifdef WINDOWS
+#if defined(_WIN32) || defined(WIN32)
#define getpid() GetCurrentProcessId()
#endif
@@ -39,7 +39,7 @@ static const char *flavor_flag;
/* Return a malloced copy of the commandline for PID. If this is not
* possible NULL is returned. */
-#ifndef WINDOWS
+#if !(defined(_WIN32) || defined(WIN32))
static char *get_cmdline(unsigned long pid) {
char buffer[200];
FILE *fp;
@@ -76,7 +76,7 @@ static char *get_cmdline(unsigned long pid) {
* This is not as informative as get_cmdline, but it verifies that the
* process does belong to the user in question.
*/
-#ifndef WINDOWS
+#if !(defined(_WIN32) || defined(WIN32))
static char *get_pid_name_for_uid(unsigned long pid, int uid) {
char buffer[400];
FILE *fp;
diff --git a/src/m_pinentry/pinentry.h b/src/m_pinentry/pinentry.h
index 5c38c68..c25ae0f 100644
--- a/src/m_pinentry/pinentry.h
+++ b/src/m_pinentry/pinentry.h
@@ -325,7 +325,7 @@ void pinentry_parse_opts(int argc, char *argv[]);
/* Set the optional flag used with getinfo. */
void pinentry_set_flavor_flag(const char *string);
-#ifdef WINDOWS
+#if defined(_WIN32) || defined(WIN32)
/* Windows declares sleep as obsolete, but provides a definition for
_sleep but non for the still existing sleep. */
#define sleep(a) _sleep((a))
diff --git a/src/m_pinentry/qti18n.cpp b/src/m_pinentry/qti18n.cpp
deleted file mode 100644
index 198e6cc..0000000
--- a/src/m_pinentry/qti18n.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/* qti18n.cpp - Load qt translations for pinentry.
- * Copyright 2021 g10 Code GmbH
- * SPDX-FileCopyrightText: 2015 Lukáš Tinkl <[email protected]>
- * SPDX-FileCopyrightText: 2021 Ingo Klöcker <[email protected]>
- *
- * Copied from k18n under the terms of LGPLv2 or later.
- *
- * This program 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <https://www.gnu.org/licenses/>.
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#include <QCoreApplication>
-#include <QDebug>
-#include <QLibraryInfo>
-#include <QLocale>
-#include <QTranslator>
-
-static bool loadCatalog(const QString &catalog, const QLocale &locale) {
- auto translator = new QTranslator(QCoreApplication::instance());
-
- if (!translator->load(locale, catalog, QString(),
- QLatin1String(":/i18n_qt"))) {
- qDebug() << "Loading the" << catalog << "catalog failed for locale"
- << locale;
- delete translator;
- return false;
- }
- QCoreApplication::instance()->installTranslator(translator);
- return true;
-}
-
-static bool loadCatalog(const QString &catalog, const QLocale &locale,
- const QLocale &fallbackLocale) {
- // try to load the catalog for locale
- if (loadCatalog(catalog, locale)) {
- return true;
- }
- // if this fails, then try the fallback locale (if it's different from locale)
- if (fallbackLocale != locale) {
- return loadCatalog(catalog, fallbackLocale);
- }
- return false;
-}
-
-// load global Qt translation, needed in KDE e.g. by lots of builtin dialogs
-// (QColorDialog, QFontDialog) that we use
-static void loadTranslation(const QString &localeName,
- const QString &fallbackLocaleName) {
- const QLocale locale{localeName};
- const QLocale fallbackLocale{fallbackLocaleName};
- // first, try to load the qt_ meta catalog
- if (loadCatalog(QStringLiteral("qt_"), locale, fallbackLocale)) {
- return;
- }
- // if loading the meta catalog failed, then try loading the four catalogs
- // it depends on, i.e. qtbase, qtscript, qtmultimedia, qtxmlpatterns,
- // separately
- const auto catalogs = {
- QStringLiteral("qtbase_"),
- /* QStringLiteral("qtscript_"),
- QStringLiteral("qtmultimedia_"),
- QStringLiteral("qtxmlpatterns_"), */
- };
- for (const auto &catalog : catalogs) {
- loadCatalog(catalog, locale, fallbackLocale);
- }
-}
-
-static void load() {
- // The way Qt translation system handles plural forms makes it necessary to
- // have a translation file which contains only plural forms for `en`. That's
- // why we load the `en` translation unconditionally, then load the
- // translation for the current locale to overload it.
- loadCatalog(QStringLiteral("qt_"), QLocale{QStringLiteral("en")});
-
- const QLocale locale = QLocale::system();
- if (locale.name() != QStringLiteral("en")) {
- loadTranslation(locale.name(), locale.bcp47Name());
- }
-}
-
-Q_COREAPP_STARTUP_FUNCTION(load)
diff --git a/src/m_ver_check/CMakeLists.txt b/src/m_ver_check/CMakeLists.txt
index ce68f30..cdf691a 100644
--- a/src/m_ver_check/CMakeLists.txt
+++ b/src/m_ver_check/CMakeLists.txt
@@ -25,10 +25,11 @@
# com.bktus.gpgfrontend.module.integrated.version_checking
-aux_source_directory(. MODULE_SOURCE_FILES)
+set(INTEGRATED_MODULE_SOURCE "")
+aux_source_directory(. INTEGRATED_MODULE_SOURCE)
# define libgpgfrontend_module
-add_library(mod_ver_check SHARED ${MODULE_SOURCE_FILES})
+add_library(mod_ver_check SHARED ${INTEGRATED_MODULE_SOURCE})
# install dir
install(TARGETS mod_ver_check
@@ -38,13 +39,8 @@ install(TARGETS mod_ver_check
target_link_libraries(mod_ver_check PRIVATE
gpgfrontend_module_sdk)
-if(GPGFRONTEND_QT5_BUILD)
- # link Qt
- target_link_libraries(mod_ver_check PUBLIC Qt5::Core Qt5::Network Qt5::Widgets)
-else()
- # link Qt
- target_link_libraries(mod_ver_check PUBLIC Qt6::Core Qt6::Network Qt6::Widgets)
-endif()
+# link qt
+target_link_libraries(mod_ver_check PUBLIC Qt::Core Qt::Network Qt::Widgets)
# using std c++ 17
target_compile_features(mod_ver_check PRIVATE cxx_std_17)
@@ -64,5 +60,5 @@ set(TS_FILES
qt_add_translations(mod_ver_check
RESOURCE_PREFIX "/i18n"
TS_FILES ${TS_FILES}
- SOURCES ${MODULE_SOURCE_FILES}
+ SOURCES ${INTEGRATED_MODULE_SOURCE}
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file
diff --git a/src/m_ver_check/VersionCheckingModule.cpp b/src/m_ver_check/VersionCheckingModule.cpp
index b819288..5e6fef6 100644
--- a/src/m_ver_check/VersionCheckingModule.cpp
+++ b/src/m_ver_check/VersionCheckingModule.cpp
@@ -43,11 +43,23 @@
#include "UpdateTab.h"
#include "VersionCheckTask.h"
-GF_MODULE_API_DEFINE("com.bktus.gpgfrontend.module.VersionChecking", "Pinentry",
- "1.0.0", "Try checking GpgFrontend version.", "Saturneric")
+GF_MODULE_API_DEFINE("com.bktus.gpgfrontend.module.version_checking",
+ "VersionChecking", "1.0.0",
+ "Try checking GpgFrontend version.", "Saturneric");
+
+DEFINE_TRANSLATIONS_STRUCTURE(ModuleVersionChecking);
auto GFRegisterModule() -> int {
MLogInfo("version checking module registering");
+
+ REGISTER_TRANS_READER();
+
+ GFUIMountEntry(DUP("AboutDialogTabs"),
+ QMapToMetaDataArray({
+ {"TabTitle", GTrC::tr("Update")},
+ }),
+ 1, UpdateTabFactory);
+
return 0;
}
@@ -57,12 +69,6 @@ auto GFActiveModule() -> int {
LISTEN("APPLICATION_LOADED");
LISTEN("CHECK_APPLICATION_VERSION");
- LOAD_TRANS("ModuleVersionChecking");
-
- GFUIMountEntry(DUP("AboutDialogTabs"),
- QMapToMetaDataArray({{"TabTitle", GTrC::tr("Update")}}), 1,
- UpdateTabFactory);
-
return 0;
}
diff --git a/src/m_ver_check/ts/ModuleVersionChecking.de_DE.ts b/src/m_ver_check/ts/ModuleVersionChecking.de_DE.ts
index e9f23e2..e9a6a4c 100644
--- a/src/m_ver_check/ts/ModuleVersionChecking.de_DE.ts
+++ b/src/m_ver_check/ts/ModuleVersionChecking.de_DE.ts
@@ -4,7 +4,7 @@
<context>
<name>GTrC</name>
<message>
- <location filename="../VersionCheckingModule.cpp" line="72"/>
+ <location filename="../VersionCheckingModule.cpp" line="59"/>
<source>Update</source>
<translation type="unfinished">Aktualisieren</translation>
</message>
diff --git a/src/m_ver_check/ts/ModuleVersionChecking.en_US.ts b/src/m_ver_check/ts/ModuleVersionChecking.en_US.ts
index 1235090..5f2890b 100644
--- a/src/m_ver_check/ts/ModuleVersionChecking.en_US.ts
+++ b/src/m_ver_check/ts/ModuleVersionChecking.en_US.ts
@@ -4,7 +4,7 @@
<context>
<name>GTrC</name>
<message>
- <location filename="../VersionCheckingModule.cpp" line="72"/>
+ <location filename="../VersionCheckingModule.cpp" line="59"/>
<source>Update</source>
<translation type="unfinished"></translation>
</message>
diff --git a/src/m_ver_check/ts/ModuleVersionChecking.fr_FR.ts b/src/m_ver_check/ts/ModuleVersionChecking.fr_FR.ts
index fff22ee..0b073d1 100644
--- a/src/m_ver_check/ts/ModuleVersionChecking.fr_FR.ts
+++ b/src/m_ver_check/ts/ModuleVersionChecking.fr_FR.ts
@@ -4,7 +4,7 @@
<context>
<name>GTrC</name>
<message>
- <location filename="../VersionCheckingModule.cpp" line="72"/>
+ <location filename="../VersionCheckingModule.cpp" line="59"/>
<source>Update</source>
<translation type="unfinished">Mettre à jour</translation>
</message>
diff --git a/src/m_ver_check/ts/ModuleVersionChecking.it_IT.ts b/src/m_ver_check/ts/ModuleVersionChecking.it_IT.ts
index c8d1df9..1879041 100644
--- a/src/m_ver_check/ts/ModuleVersionChecking.it_IT.ts
+++ b/src/m_ver_check/ts/ModuleVersionChecking.it_IT.ts
@@ -4,7 +4,7 @@
<context>
<name>GTrC</name>
<message>
- <location filename="../VersionCheckingModule.cpp" line="72"/>
+ <location filename="../VersionCheckingModule.cpp" line="59"/>
<source>Update</source>
<translation type="unfinished">Aggiorna</translation>
</message>
@@ -12,63 +12,63 @@
<context>
<name>UpdateTab</name>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="163"/>
+ <location filename="../UpdateTab.cpp" line="46"/>
<source>It is recommended that you always check the version of GpgFrontend and upgrade to the latest version.</source>
<translation type="unfinished">Si consiglia di controllare sempre la versione di GpgFrontend e di aggiornare all&apos;ultima versione.</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="166"/>
+ <location filename="../UpdateTab.cpp" line="49"/>
<source>New versions not only represent new features, but also often represent functional and security fixes.</source>
<translation type="unfinished">Le nuove versioni non rappresentano solo nuove funzionalità, ma spesso rappresentano anche correzioni funzionali e di sicurezza.</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="172"/>
+ <location filename="../UpdateTab.cpp" line="55"/>
<source>Current Version</source>
<translation type="unfinished">Versione corrente</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="173"/>
+ <location filename="../UpdateTab.cpp" line="56"/>
<source>: </source>
<translation type="unfinished">: </translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="248"/>
+ <location filename="../UpdateTab.cpp" line="132"/>
<source>Latest Version From Github</source>
<translation type="unfinished">Ultima versione da Github</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="254"/>
+ <location filename="../UpdateTab.cpp" line="138"/>
<source>The current version is less than the latest version on github.</source>
<translation type="unfinished">La versione corrente è inferiore all&apos;ultima versione su github.</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="256"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="267"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="279"/>
+ <location filename="../UpdateTab.cpp" line="140"/>
+ <location filename="../UpdateTab.cpp" line="151"/>
+ <location filename="../UpdateTab.cpp" line="163"/>
<source>Please click</source>
<translation type="unfinished">Per favore clicca</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="259"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="270"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="282"/>
+ <location filename="../UpdateTab.cpp" line="143"/>
+ <location filename="../UpdateTab.cpp" line="154"/>
+ <location filename="../UpdateTab.cpp" line="166"/>
<source>Here</source>
<translation type="unfinished">Qui</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="259"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="270"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="282"/>
+ <location filename="../UpdateTab.cpp" line="143"/>
+ <location filename="../UpdateTab.cpp" line="154"/>
+ <location filename="../UpdateTab.cpp" line="166"/>
<source>to download the latest stable version.</source>
<translation type="unfinished">per scaricare l&apos;ultima versione stabile.</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="265"/>
+ <location filename="../UpdateTab.cpp" line="149"/>
<source>This version has serious problems and has been withdrawn. Please stop using it immediately.</source>
<translation type="unfinished">Questa versione ha seri problemi ed è stata ritirata. Si prega di smettere di usarlo immediatamente.</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="276"/>
+ <location filename="../UpdateTab.cpp" line="160"/>
<source>This version has not been released yet, it may be a beta version. If you are not a tester and care about version stability, please do not use this version.</source>
<translation type="unfinished">Questa versione non è ancora stata rilasciata, potrebbe essere una versione beta. Se non sei un tester e ti interessa la stabilità della versione, non utilizzare questa versione.</translation>
</message>
diff --git a/src/m_ver_check/ts/ModuleVersionChecking.zh_CN.ts b/src/m_ver_check/ts/ModuleVersionChecking.zh_CN.ts
index f789572..2d02588 100644
--- a/src/m_ver_check/ts/ModuleVersionChecking.zh_CN.ts
+++ b/src/m_ver_check/ts/ModuleVersionChecking.zh_CN.ts
@@ -4,7 +4,7 @@
<context>
<name>GTrC</name>
<message>
- <location filename="../VersionCheckingModule.cpp" line="72"/>
+ <location filename="../VersionCheckingModule.cpp" line="59"/>
<source>Update</source>
<translation type="unfinished">更新</translation>
</message>
@@ -12,46 +12,63 @@
<context>
<name>UpdateTab</name>
<message>
+ <location filename="../UpdateTab.cpp" line="46"/>
<source>It is recommended that you always check the version of GpgFrontend and upgrade to the latest version.</source>
<translation type="unfinished">建议您经常检查 GpgFrontend 的版本更新。</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="49"/>
<source>New versions not only represent new features, but also often represent functional and security fixes.</source>
<translation type="unfinished">新版本不仅代表新功能,而且通常代表功能和安全修复。</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="55"/>
<source>Current Version</source>
<translation type="unfinished">当前版本</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="56"/>
<source>: </source>
- <translation type="vanished">: </translation>
+ <translation>: </translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="132"/>
<source>Latest Version From Github</source>
<translation type="unfinished">来自 Github 的最新版本</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="138"/>
<source>The current version is less than the latest version on github.</source>
<translation type="unfinished">当前版本低于github上的最新版本。</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="140"/>
+ <location filename="../UpdateTab.cpp" line="151"/>
+ <location filename="../UpdateTab.cpp" line="163"/>
<source>Please click</source>
<translation type="unfinished">请点击</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="143"/>
+ <location filename="../UpdateTab.cpp" line="154"/>
+ <location filename="../UpdateTab.cpp" line="166"/>
<source>Here</source>
<translation type="unfinished">这里</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="143"/>
+ <location filename="../UpdateTab.cpp" line="154"/>
+ <location filename="../UpdateTab.cpp" line="166"/>
<source>to download the latest stable version.</source>
<translation type="unfinished">来下载最新的稳定版本。</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="149"/>
<source>This version has serious problems and has been withdrawn. Please stop using it immediately.</source>
- <translation type="vanished">此版本存在严重问题,已经被召回。请立即停止使用。</translation>
+ <translation>此版本存在严重问题,已经被召回。请立即停止使用。</translation>
</message>
<message>
+ <location filename="../UpdateTab.cpp" line="160"/>
<source>This version has not been released yet, it may be a beta version. If you are not a tester and care about version stability, please do not use this version.</source>
<translation type="unfinished">此版本尚未发布,可能是测试版。如果您不是测试人员并且关心版本稳定性,请不要使用此版本。</translation>
</message>
diff --git a/src/m_ver_check/ts/ModuleVersionChecking.zh_TW.ts b/src/m_ver_check/ts/ModuleVersionChecking.zh_TW.ts
index 4873fc5..e59955e 100644
--- a/src/m_ver_check/ts/ModuleVersionChecking.zh_TW.ts
+++ b/src/m_ver_check/ts/ModuleVersionChecking.zh_TW.ts
@@ -4,7 +4,7 @@
<context>
<name>GTrC</name>
<message>
- <location filename="../VersionCheckingModule.cpp" line="72"/>
+ <location filename="../VersionCheckingModule.cpp" line="59"/>
<source>Update</source>
<translation type="unfinished">更新</translation>
</message>
@@ -12,63 +12,63 @@
<context>
<name>UpdateTab</name>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="163"/>
+ <location filename="../UpdateTab.cpp" line="46"/>
<source>It is recommended that you always check the version of GpgFrontend and upgrade to the latest version.</source>
<translation type="unfinished">建議您經常檢查 GpgFrontend 的版本併升級到最新版本。</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="166"/>
+ <location filename="../UpdateTab.cpp" line="49"/>
<source>New versions not only represent new features, but also often represent functional and security fixes.</source>
<translation type="unfinished">新版本不僅代表新功能,而且通常代表功能和安全修復。</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="172"/>
+ <location filename="../UpdateTab.cpp" line="55"/>
<source>Current Version</source>
<translation type="unfinished">當前版本</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="173"/>
+ <location filename="../UpdateTab.cpp" line="56"/>
<source>: </source>
<translation type="unfinished">: </translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="248"/>
+ <location filename="../UpdateTab.cpp" line="132"/>
<source>Latest Version From Github</source>
<translation type="unfinished">來自 Github 的最新版本</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="254"/>
+ <location filename="../UpdateTab.cpp" line="138"/>
<source>The current version is less than the latest version on github.</source>
<translation type="unfinished">當前版本低於github上的最新版本。</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="256"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="267"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="279"/>
+ <location filename="../UpdateTab.cpp" line="140"/>
+ <location filename="../UpdateTab.cpp" line="151"/>
+ <location filename="../UpdateTab.cpp" line="163"/>
<source>Please click</source>
<translation type="unfinished">請點擊</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="259"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="270"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="282"/>
+ <location filename="../UpdateTab.cpp" line="143"/>
+ <location filename="../UpdateTab.cpp" line="154"/>
+ <location filename="../UpdateTab.cpp" line="166"/>
<source>Here</source>
<translation type="unfinished">這裡</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="259"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="270"/>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="282"/>
+ <location filename="../UpdateTab.cpp" line="143"/>
+ <location filename="../UpdateTab.cpp" line="154"/>
+ <location filename="../UpdateTab.cpp" line="166"/>
<source>to download the latest stable version.</source>
<translation type="unfinished">下載最新的穩定版本。</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="265"/>
+ <location filename="../UpdateTab.cpp" line="149"/>
<source>This version has serious problems and has been withdrawn. Please stop using it immediately.</source>
<translation type="unfinished">此版本存在嚴重問題,已撤回。請立即停止使用。</translation>
</message>
<message>
- <location filename="../../../../src/ui/dialog/help/AboutDialog.cpp" line="276"/>
+ <location filename="../UpdateTab.cpp" line="160"/>
<source>This version has not been released yet, it may be a beta version. If you are not a tester and care about version stability, please do not use this version.</source>
<translation type="unfinished">此版本尚未發布,可能是測試版。如果您不是測試人員並且關心版本穩定性,請不要使用此版本。</translation>
</message>