aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-31 05:57:48 +0000
committersaturneric <[email protected]>2024-01-31 05:57:48 +0000
commit01dfc8df4f019e439e7b3e774ef3a02a2a908de2 (patch)
tree68fda3203652e01136e90e4944e190e8a5d41c51
parentfeat: try to add qt5 support (diff)
downloadGpgFrontend-01dfc8df4f019e439e7b3e774ef3a02a2a908de2.tar.gz
GpgFrontend-01dfc8df4f019e439e7b3e774ef3a02a2a908de2.zip
feat: support qt5 build option
-rw-r--r--.github/workflows/release-qt5.yml2
-rw-r--r--src/core/function/ArchiveFileOperator.cpp4
-rw-r--r--src/core/function/gpg/GpgCommandExecutor.cpp2
-rw-r--r--src/core/function/gpg/GpgContext.cpp14
-rw-r--r--src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp9
-rw-r--r--src/pinentry/pinentry.cpp8
-rw-r--r--src/pinentry/qti18n.cpp2
-rw-r--r--src/ui/GpgFrontendUIInit.cpp1
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.cpp5
-rw-r--r--src/ui/dialog/settings/SettingsDialog.cpp4
-rw-r--r--src/ui/main_window/MainWindow.cpp1
-rw-r--r--src/ui/widgets/FileTreeView.cpp2
12 files changed, 43 insertions, 11 deletions
diff --git a/.github/workflows/release-qt5.yml b/.github/workflows/release-qt5.yml
index d19bc68b..00ec531e 100644
--- a/.github/workflows/release-qt5.yml
+++ b/.github/workflows/release-qt5.yml
@@ -63,7 +63,7 @@ jobs:
run: |
cd $(echo "/${{github.workspace}}" | sed 's/\\/\//g' | sed 's/://')
mkdir build && cd build
- cmake -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGPGFRONTEND_BUILD_TYPE_STABLE=ON ..
+ cmake -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGPGFRONTEND_BUILD_TYPE_STABLE=ON -DGPGFRONTEND_QT5_BUILD=ON ..
# Build your program with the given configuration
cmake --build . --config ${{env.BUILD_TYPE}} -- -j 2
if: matrix.os == 'windows-2019'
diff --git a/src/core/function/ArchiveFileOperator.cpp b/src/core/function/ArchiveFileOperator.cpp
index 2b76e4ac..475ef434 100644
--- a/src/core/function/ArchiveFileOperator.cpp
+++ b/src/core/function/ArchiveFileOperator.cpp
@@ -143,7 +143,11 @@ void ArchiveFileOperator::NewArchive2DataExchanger(
#endif
QFile file(source_path);
+#ifdef QT5_BUILD
+ if (file.open(QIODevice::ReadOnly)) {
+#else
if (file.open(QIODeviceBase::ReadOnly)) {
+#endif
// turn absolute path to relative path
auto relativ_path_name = base_path.relativeFilePath(source_path);
archive_entry_set_pathname(entry, relativ_path_name.toUtf8());
diff --git a/src/core/function/gpg/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp
index 6d24f9bd..66c18ae1 100644
--- a/src/core/function/gpg/GpgCommandExecutor.cpp
+++ b/src/core/function/gpg/GpgCommandExecutor.cpp
@@ -41,7 +41,7 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context)
const auto &interact_function = context.int_func;
const auto &cmd_executor_callback = context.cb_func;
- const QString joined_argument = QStringList::fromVector(arguments).join(" ");
+ const QString joined_argument = arguments.join(" ");
GF_CORE_LOG_DEBUG("building task: called cmd {} arguments size: {}", cmd,
arguments.size());
diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp
index 6523386c..7c84d3c4 100644
--- a/src/core/function/gpg/GpgContext.cpp
+++ b/src/core/function/gpg/GpgContext.cpp
@@ -93,13 +93,23 @@ class GpgContext::Impl {
const char *passphrase_info, int last_was_bad,
int fd) -> gpgme_error_t {
size_t res;
- QString pass = "abcdefg\n";
+#ifdef QT5_BUILD
+ QString pass_qstr = "abcdefg\n";
+ QByteArray pass = pass_qstr.toUtf8();
+#else
+ QString pass = "abcdefg\n";
+#endif
+
auto passpahrase_size = pass.size();
-
size_t off = 0;
do {
+#ifdef QT5_BUILD
+ const char* p_pass = pass.data();
+ res = gpgme_io_write(fd, &p_pass[off], passpahrase_size - off);
+#else
res = gpgme_io_write(fd, &pass[off], passpahrase_size - off);
+#endif
if (res > 0) off += res;
} while (res > 0 && off != passpahrase_size);
diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp
index c965ed30..a1e5cd5a 100644
--- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp
+++ b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp
@@ -209,8 +209,11 @@ auto GnuPGInfoGatheringModule::Exec(EventRefrernce event) -> int {
getTaskRunner()});
GpgCommandExecutor::ExecuteContexts exec_contexts;
-
+#ifdef QT5_BUILD
+ exec_contexts.push_back(GpgCommandExecutor::ExecuteContext{
+#else
exec_contexts.emplace_back(GpgCommandExecutor::ExecuteContext{
+#endif
gpgconf_path, QStringList{"--list-dirs"},
[this](int exit_code, const QString &p_out, const QString &p_err) {
if (exit_code != 0) return;
@@ -264,7 +267,11 @@ auto GnuPGInfoGatheringModule::Exec(EventRefrernce event) -> int {
continue;
}
+#ifdef QT5_BUILD
+ exec_contexts.push_back(GpgCommandExecutor::ExecuteContext{
+#else
exec_contexts.emplace_back(GpgCommandExecutor::ExecuteContext{
+#endif
gpgconf_path, QStringList{"--list-options", component_info.name},
[this, component_info](int exit_code, const QString &p_out,
const QString &p_err) {
diff --git a/src/pinentry/pinentry.cpp b/src/pinentry/pinentry.cpp
index c648aea6..5f233f5d 100644
--- a/src/pinentry/pinentry.cpp
+++ b/src/pinentry/pinentry.cpp
@@ -375,19 +375,19 @@ int pinentry_inq_quality(const QString &passphrase) {
static_cast<int>(has_digit) + static_cast<int>(has_special);
score += variety_count * 10;
- for (size_t i = 0; i < passphrase.length() - 1; ++i) {
+ for (auto i = 0; i < passphrase.length() - 1; ++i) {
if (passphrase[i] == passphrase[i + 1]) {
score -= 5;
}
}
- std::unordered_map<QChar, int> char_count;
+ QHash<QChar, int> char_count;
for (const auto ch : passphrase) {
char_count[ch]++;
}
for (auto &p : char_count) {
- if (p.second > 1) {
- score -= (p.second - 1) * 3;
+ if (p > 1) {
+ score -= (p - 1) * 3;
}
}
diff --git a/src/pinentry/qti18n.cpp b/src/pinentry/qti18n.cpp
index 49c27dd3..198e6cc4 100644
--- a/src/pinentry/qti18n.cpp
+++ b/src/pinentry/qti18n.cpp
@@ -30,7 +30,7 @@ static bool loadCatalog(const QString &catalog, const QLocale &locale) {
auto translator = new QTranslator(QCoreApplication::instance());
if (!translator->load(locale, catalog, QString(),
- QLibraryInfo::path(QLibraryInfo::TranslationsPath))) {
+ QLatin1String(":/i18n_qt"))) {
qDebug() << "Loading the" << catalog << "catalog failed for locale"
<< locale;
delete translator;
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp
index 148402d4..08cf012d 100644
--- a/src/ui/GpgFrontendUIInit.cpp
+++ b/src/ui/GpgFrontendUIInit.cpp
@@ -33,6 +33,7 @@
#include "core/GpgConstants.h"
#include "core/function/CoreSignalStation.h"
#include "core/function/GlobalSettingStation.h"
+#include "core/model/GpgPassphraseContext.h"
#include "core/module/ModuleManager.h"
#include "ui/UISignalStation.h"
#include "ui/UserInterfaceUtils.h"
diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
index 6e4a1df0..74f827aa 100644
--- a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
@@ -432,7 +432,12 @@ void KeyPairOperaTab::slot_import_revoke_cert() {
}
QFile rev_file(rev_file_info.absoluteFilePath());
+
+#ifdef QT5_BUILD
+ if (!rev_file.open(QIODevice::ReadOnly)) {
+#else
if (!rev_file.open(QIODeviceBase::ReadOnly)) {
+#endif
QMessageBox::critical(
this, tr("Error"),
tr("Cannot open this file. Please make sure that this "
diff --git a/src/ui/dialog/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp
index a26ddf0b..cb17eb0d 100644
--- a/src/ui/dialog/settings/SettingsDialog.cpp
+++ b/src/ui/dialog/settings/SettingsDialog.cpp
@@ -137,7 +137,11 @@ auto SettingsDialog::ListLanguages() -> QHash<QString, QString> {
auto locale = file.mid(start, end - start);
QLocale const q_locale(locale);
+#ifdef QT5_BUILD
+ if (q_locale.nativeCountryName().isEmpty()) continue;
+#else
if (q_locale.nativeTerritoryName().isEmpty()) continue;
+#endif
auto language = q_locale.nativeLanguageName() + " (" + locale + ")";
languages.insert(q_locale.name(), language);
diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp
index 27634570..a7bd63d8 100644
--- a/src/ui/main_window/MainWindow.cpp
+++ b/src/ui/main_window/MainWindow.cpp
@@ -32,6 +32,7 @@
#include "core/function/CoreSignalStation.h"
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgAdvancedOperator.h"
+#include "core/model/GpgPassphraseContext.h"
#include "core/module/ModuleManager.h"
#include "ui/UISignalStation.h"
#include "ui/main_window/GeneralMainWindow.h"
diff --git a/src/ui/widgets/FileTreeView.cpp b/src/ui/widgets/FileTreeView.cpp
index b0241b63..7a725e10 100644
--- a/src/ui/widgets/FileTreeView.cpp
+++ b/src/ui/widgets/FileTreeView.cpp
@@ -67,7 +67,7 @@ void FileTreeView::selectionChanged(const QItemSelection& selected,
GF_UI_LOG_DEBUG("file tree view selected target path: {}", selected_path_);
emit SignalSelectedChanged(selected_path_);
} else {
- selected_path_ = {};
+ selected_path_ = QString();
if (!this->selectedIndexes().isEmpty()) {
selected_path_ = dir_model_->filePath(this->selectedIndexes().front());
emit SignalSelectedChanged(selected_path_);