Merge remote-tracking branch 'remotes/origin/branches/issue261_REBASED'

This commit is contained in:
Jakub Melka
2025-04-21 16:47:19 +02:00
31 changed files with 73608 additions and 200 deletions

View File

@@ -23,7 +23,7 @@ jobs:
- name: Install KDE SDK and Runtime
run: |
sudo flatpak install -y flathub org.kde.Sdk/x86_64/6.8 org.kde.Platform/x86_64/6.8
sudo flatpak install -y flathub org.kde.Sdk/x86_64/6.9 org.kde.Platform/x86_64/6.9
- name: List Flatpak Installed Packages and Version
run: |

View File

@@ -5,13 +5,13 @@ on:
jobs:
build_ubuntu:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxcb-cursor0
sudo apt-get install -y libxcb-cursor0 libfuse2
sudo apt-get install -y libspeechd2
sudo apt-get install -y gnupg2 wget
sudo apt-get install -y appstream
@@ -88,20 +88,20 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '6.8.0'
version: '6.9.0'
host: 'linux'
target: 'desktop'
dir: '${{ github.workspace }}/qt/'
install-deps: 'true'
modules: 'qtspeech qtmultimedia'
cache: 'true'
cache-key-prefix: ${{ runner.os }}-qt-680
cache-key-prefix: ${{ runner.os }}-qt-690
- name: Build Project
working-directory: pdf4qt
run: |
cmake -B build -S . -DPDF4QT_INSTALL_QT_DEPENDENCIES=0 -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VCPKG_BUILD_TYPE=Release -DVCPKG_OVERLAY_PORTS=vcpkg/overlays -DPDF4QT_INSTALL_TO_USR=ON
cmake --build build -j6
cmake --build build --target all release_translations -j6
cmake --install build
- name: Read version

View File

@@ -116,7 +116,7 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '6.8.0'
version: '6.9.0'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2022_64'
@@ -124,7 +124,7 @@ jobs:
install-deps: 'true'
modules: 'qtspeech qtmultimedia qtimageformats'
cache: 'true'
cache-key-prefix: ${{ runner.os }}-qt-680
cache-key-prefix: ${{ runner.os }}-qt-690
- name: Find VC Redistributable Directories
@@ -156,8 +156,9 @@ jobs:
shell: pwsh
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_VCPKG_BUILD_TYPE=Release -DPDF4QT_INSTALL_QT_DEPENDENCIES=ON -DPDF4QT_INSTALL_DEPENDENCIES=ON -DCMAKE_TOOLCHAIN_FILE="${env:GITHUB_WORKSPACE}\vcpkg\scripts\buildsystems\vcpkg.cmake" -DPDF4QT_QT_ROOT="${env:Qt6_DIR}" -DPDF4QT_INSTALL_MSVC_REDISTRIBUTABLE=ON -DPDF4QT_INSTALL_PREPARE_WIX_INSTALLER=ON -DPDF4QT_INSTALL_TO_USR=ON
cmake --build build --target release_translations --config Release -j6
cmake --build build --config Release -j6
cmake --install build
cmake --install build --config Release
env:
VCToolsRedistDir: ${{ env.VCToolsRedistDir }}
VSCMD_ARG_TGT_ARCH: ${{ env.VSCMD_ARG_TGT_ARCH }}

View File

@@ -48,20 +48,20 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.8.0'
version: '6.9.0'
host: 'linux'
target: 'desktop'
dir: '${{ github.workspace }}/qt/'
install-deps: 'true'
modules: 'qtspeech qtmultimedia'
cache: 'true'
cache-key-prefix: ${{ runner.os }}-qt-680
cache-key-prefix: ${{ runner.os }}-qt-690
- name: Build project
working-directory: pdf4qt
run: |
cmake -B build -S . -DPDF4QT_INSTALL_QT_DEPENDENCIES=0 -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VCPKG_BUILD_TYPE=Release
cmake --build build -j6
cmake --build build --target all release_translations --config Release -j6
cmake --install build
- name: Make DEB package
@@ -113,7 +113,7 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.8.0'
version: '6.9.0'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2022_64'
@@ -121,15 +121,17 @@ jobs:
install-deps: 'true'
modules: 'qtspeech qtmultimedia'
cache: 'true'
cache-key-prefix: ${{ runner.os }}-qt-680
cache-key-prefix: ${{ runner.os }}-qt-690
- name: Build project
working-directory: pdf4qt
shell: pwsh
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_VCPKG_BUILD_TYPE=Release -DPDF4QT_INSTALL_QT_DEPENDENCIES=ON -DPDF4QT_INSTALL_DEPENDENCIES=ON -DCMAKE_TOOLCHAIN_FILE="${env:GITHUB_WORKSPACE}\vcpkg\scripts\buildsystems\vcpkg.cmake" -DPDF4QT_QT_ROOT="${env:Qt6_DIR}" -DPDF4QT_INSTALL_MSVC_REDISTRIBUTABLE=ON -DPDF4QT_INSTALL_PREPARE_WIX_INSTALLER=ON -DPDF4QT_INSTALL_TO_USR=ON
cmake --build build --target help
cmake --build build --target release_translations --config Release -j6
cmake --build build --config Release -j6
cmake --install build
cmake --install build --config Release
- name: Upload Windows package
uses: actions/upload-artifact@v4

View File

@@ -46,13 +46,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(GNUInstallDirs)
find_package(Qt6 REQUIRED COMPONENTS Core LinguistTools)
if(PDF4QT_BUILD_ONLY_CORE_LIBRARY)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Svg Xml)
else()
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport TextToSpeech Test)
endif()
qt_standard_project_setup()
qt_standard_project_setup(I18N_TRANSLATED_LANGUAGES en de cs es ko)
find_package(OpenSSL REQUIRED)
find_package(lcms2 REQUIRED)
@@ -140,12 +142,33 @@ if(NOT PDF4QT_BUILD_ONLY_CORE_LIBRARY)
add_subdirectory(WixInstaller)
endif()
qt_collect_translation_source_targets(i18n_targets)
message("CMAKE_TRANSLATION_TARGETS = " ${i18n_targets})
set(PDF4QT_TRANSLATION_TS_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/translations)
set(PDF4QT_TRANSLATION_QM_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PDF4QT_INSTALL_BIN_DIR}/translations)
message("PDF4QT_TRANSLATION_TS_OUTPUT_DIRECTORY" ${PDF4QT_TRANSLATION_TS_OUTPUT_DIRECTORY})
message("PDF4QT_TRANSLATION_QM_OUTPUT_DIRECTORY" ${PDF4QT_TRANSLATION_QM_OUTPUT_DIRECTORY})
qt_add_translations(TARGETS Pdf4QtEditor Pdf4QtViewer Pdf4QtPageMaster Pdf4QtDiff PdfTool
SOURCE_TARGETS ${i18n_targets}
MERGE_QT_TRANSLATIONS
TS_OUTPUT_DIRECTORY ${PDF4QT_TRANSLATION_TS_OUTPUT_DIRECTORY}
QM_OUTPUT_DIRECTORY ${PDF4QT_TRANSLATION_QM_OUTPUT_DIRECTORY}
QM_FILES_OUTPUT_VARIABLE pdf4qt_qm_files)
message("CMAKE_PREFIX_PATH = " ${CMAKE_PREFIX_PATH})
message("CMAKE_TOOLCHAIN_FILE = " ${CMAKE_TOOLCHAIN_FILE})
configure_file(version.txt.in version.txt)
if(NOT PDF4QT_BUILD_ONLY_CORE_LIBRARY)
install(DIRECTORY ${PDF4QT_TRANSLATION_QM_OUTPUT_DIRECTORY}
RUNTIME DESTINATION ${PDF4QT_INSTALL_BIN_DIR}
FILES_MATCHING
PATTERN *.qm)
if(WIN32)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Desktop/44x44/
RUNTIME DESTINATION ${PDF4QT_INSTALL_BIN_DIR}/assets/44x44

View File

@@ -1,7 +1,7 @@
{
"app-id": "io.github.JakubMelka.Pdf4qt",
"runtime": "org.kde.Sdk",
"runtime-version": "6.8",
"runtime-version": "6.9",
"sdk": "org.kde.Sdk",
"command": "Pdf4QtEditor",
"finish-args": [
@@ -121,6 +121,10 @@
"-DPDF4QT_INSTALL_TO_USR=OFF",
"-DCMAKE_VERBOSE_MAKEFILE=OFF"
],
"build-commands": [
"ninja all",
"ninja release_translations"
],
"sources": [
{
"type": "git",

View File

@@ -36,7 +36,7 @@
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
@@ -225,10 +225,10 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>

View File

@@ -18,6 +18,7 @@
#include "pdfconstants.h"
#include "pdfdocumentreader.h"
#include "pdfsecurityhandler.h"
#include "pdfapplicationtranslator.h"
#include "mainwindow.h"
#include <QApplication>
@@ -49,6 +50,9 @@ int main(int argc, char *argv[])
pdf::PDFSecurityHandler::setNoDRMMode();
}
pdf::PDFApplicationTranslator translator;
translator.installTranslator();
QIcon appIcon(":/app-icon.svg");
QApplication::setWindowIcon(appIcon);

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2021-2024 Jakub Melka
// Copyright (C) 2021-2025 Jakub Melka
//
// This file is part of PDF4QT.
//
@@ -20,6 +20,7 @@
#include "pdfsecurityhandler.h"
#include "pdfwidgetutils.h"
#include "pdfviewersettings.h"
#include "pdfapplicationtranslator.h"
#include <QSettings>
#include <QApplication>
@@ -60,6 +61,10 @@ int main(int argc, char *argv[])
pdf::PDFSecurityHandler::setNoDRMMode();
}
pdf::PDFApplicationTranslator translator;
translator.loadSettings();
translator.installTranslator();
bool isLightGui = false;
bool isDarkGui = false;
const pdfviewer::PDFViewerSettings::ColorScheme colorScheme = pdfviewer::PDFViewerSettings::getColorSchemeStatic();

View File

@@ -17,6 +17,8 @@
#include "audiobookcreator.h"
#include <QTextStream>
#ifdef Q_OS_WIN
#include <windows.h>
#include <sapi.h>

View File

@@ -153,6 +153,8 @@ add_library(Pdf4QtLibCore SHARED
sources/pdfpagecontenteditorprocessor.cpp
sources/pdfpagecontenteditorcontentstreambuilder.h
sources/pdfpagecontenteditorcontentstreambuilder.cpp
sources/pdfapplicationtranslator.h
sources/pdfapplicationtranslator.cpp
)
include(GenerateExportHeader)

View File

@@ -0,0 +1,189 @@
// Copyright (C) 2025-2025 Jakub Melka
//
// This file is part of PDF4QT.
//
// PDF4QT is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// with the written consent of the copyright owner, any later version.
//
// PDF4QT 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
#include "pdfapplicationtranslator.h"
#include <QDir>
#include <QSettings>
#include <QMetaEnum>
#include <QCoreApplication>
namespace pdf
{
PDFApplicationTranslator::PDFApplicationTranslator()
{
}
PDFApplicationTranslator::~PDFApplicationTranslator()
{
uninstallTranslator();
}
PDFApplicationTranslator::ELanguage PDFApplicationTranslator::getLanguage() const
{
return m_language;
}
void PDFApplicationTranslator::installTranslator()
{
QDir applicationDirectory(QCoreApplication::applicationDirPath());
applicationDirectory.cd("translations");
QString translationPath = applicationDirectory.absolutePath();
Q_ASSERT(!m_translator);
m_translator = new QTranslator();
switch (m_language)
{
case E_LANGUAGE_AUTOMATIC_SELECTION:
{
if (m_translator->load(QLocale::system(), "PDF4QT", "_", translationPath))
{
QCoreApplication::installTranslator(m_translator);
}
else
{
delete m_translator;
m_translator = nullptr;
}
break;
}
case E_LANGUAGE_ENGLISH:
case E_LANGUAGE_CZECH:
case E_LANGUAGE_GERMAN:
case E_LANGUAGE_KOREAN:
case E_LANGUAGE_SPANISH:
{
QString languageFileName = getLanguageFileName();
if (m_translator->load(languageFileName, translationPath))
{
QCoreApplication::installTranslator(m_translator);
}
else
{
delete m_translator;
m_translator = nullptr;
}
break;
}
default:
{
delete m_translator;
m_translator = nullptr;
Q_ASSERT(false);
break;
}
}
}
void PDFApplicationTranslator::uninstallTranslator()
{
if (m_translator)
{
QCoreApplication::removeTranslator(m_translator);
delete m_translator;
m_translator = nullptr;
}
}
void PDFApplicationTranslator::loadSettings()
{
QMetaEnum metaEnum = QMetaEnum::fromType<ELanguage>();
std::string languageKeyString = loadLanguageKeyFromSettings().toStdString();
std::optional<quint64> value = metaEnum.keyToValue(languageKeyString.c_str());
m_language = static_cast<ELanguage>(value.value_or(E_LANGUAGE_AUTOMATIC_SELECTION));
}
void PDFApplicationTranslator::saveSettings()
{
QMetaEnum metaEnum = QMetaEnum::fromType<ELanguage>();
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
settings.beginGroup("Language");
settings.setValue("language", metaEnum.valueToKey(m_language));
settings.endGroup();
}
void PDFApplicationTranslator::setLanguage(ELanguage newLanguage)
{
m_language = newLanguage;
}
void PDFApplicationTranslator::saveSettings(QSettings& settings, ELanguage language)
{
QMetaEnum metaEnum = QMetaEnum::fromType<ELanguage>();
settings.beginGroup("Language");
settings.setValue("language", metaEnum.valueToKey(language));
settings.endGroup();
}
PDFApplicationTranslator::ELanguage PDFApplicationTranslator::loadSettings(QSettings& settings)
{
QMetaEnum metaEnum = QMetaEnum::fromType<ELanguage>();
std::string languageKeyString = loadLanguageKeyFromSettings(settings).toStdString();
std::optional<quint64> value = metaEnum.keyToValue(languageKeyString.c_str());
return static_cast<ELanguage>(value.value_or(E_LANGUAGE_AUTOMATIC_SELECTION));
}
QString PDFApplicationTranslator::loadLanguageKeyFromSettings()
{
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
return loadLanguageKeyFromSettings(settings);
}
QString PDFApplicationTranslator::loadLanguageKeyFromSettings(QSettings& settings)
{
QMetaEnum metaEnum = QMetaEnum::fromType<ELanguage>();
settings.beginGroup("Language");
QString languageKey = settings.value("language", metaEnum.valueToKey(E_LANGUAGE_AUTOMATIC_SELECTION)).toString();
settings.endGroup();
return languageKey;
}
QString PDFApplicationTranslator::getLanguageFileName() const
{
switch (m_language)
{
case E_LANGUAGE_ENGLISH:
return QLatin1String("PDF4QT_en.qm");
case E_LANGUAGE_CZECH:
return QLatin1String("PDF4QT_cs.qm");
case E_LANGUAGE_GERMAN:
return QLatin1String("PDF4QT_de.qm");
case E_LANGUAGE_KOREAN:
return QLatin1String("PDF4QT_es.qm");
case E_LANGUAGE_SPANISH:
return QLatin1String("PDF4QT_ko.qm");
break;
default:
Q_ASSERT(false);
}
return QString();
}
} // namespace

View File

@@ -0,0 +1,73 @@
// Copyright (C) 2025-2025 Jakub Melka
//
// This file is part of PDF4QT.
//
// PDF4QT is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// with the written consent of the copyright owner, any later version.
//
// PDF4QT 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
#ifndef PDFAPPLICATIONTRANSLATOR_H
#define PDFAPPLICATIONTRANSLATOR_H
#include "pdfglobal.h"
#include <QTranslator>
class QSettings;
namespace pdf
{
class PDF4QTLIBCORESHARED_EXPORT PDFApplicationTranslator
{
Q_GADGET
public:
explicit PDFApplicationTranslator();
~PDFApplicationTranslator();
enum ELanguage
{
E_LANGUAGE_AUTOMATIC_SELECTION,
E_LANGUAGE_ENGLISH,
E_LANGUAGE_CZECH,
E_LANGUAGE_GERMAN,
E_LANGUAGE_KOREAN,
E_LANGUAGE_SPANISH
};
Q_ENUM(ELanguage)
void installTranslator();
void uninstallTranslator();
void loadSettings();
void saveSettings();
ELanguage getLanguage() const;
void setLanguage(ELanguage newLanguage);
static ELanguage loadSettings(QSettings& settings);
static void saveSettings(QSettings& settings, ELanguage language);
private:
static QString loadLanguageKeyFromSettings(QSettings& settings);
QString loadLanguageKeyFromSettings();
QString getLanguageFileName() const;
QTranslator* m_translator = nullptr;
ELanguage m_language = E_LANGUAGE_AUTOMATIC_SELECTION;
};
} // namespace
#endif // PDFAPPLICATIONTRANSLATOR_H

View File

@@ -161,7 +161,7 @@ void PDFDocumentSanitizer::performSanitizeMetadata()
PDFExecutionPolicy::execute(PDFExecutionPolicy::Scope::Unknown, objects.begin(), objects.end(), processEntry);
m_storage.setObjects(qMove(objects));
Q_EMIT sanitizationProgress(tr("Metadata streams removed: %1").arg(counter));
Q_EMIT sanitizationProgress(tr("Metadata streams removed: %1").arg(counter.load()));
}
void PDFDocumentSanitizer::performSanitizeOutline()

View File

@@ -23,8 +23,8 @@
#include "pdfconstants.h"
#include "pdfdocumentbuilder.h"
#include "pdfstreamfilters.h"
#include "pdfdbgheap.h"
#include "pdfdocumentwriter.h"
#include "pdfdbgheap.h"
namespace pdf
{
@@ -194,7 +194,7 @@ bool PDFOptimizer::performDereferenceSimpleObjects()
PDFExecutionPolicy::execute(PDFExecutionPolicy::Scope::Unknown, objects.begin(), objects.end(), processEntry);
m_storage.setObjects(qMove(objects));
Q_EMIT optimizationProgress(tr("Simple objects dereferenced and embedded: %1").arg(counter));
Q_EMIT optimizationProgress(tr("Simple objects dereferenced and embedded: %1").arg(counter.load()));
return false;
}
@@ -213,7 +213,7 @@ bool PDFOptimizer::performRemoveNullObjects()
PDFExecutionPolicy::execute(PDFExecutionPolicy::Scope::Unknown, objects.begin(), objects.end(), processEntry);
m_storage.setObjects(qMove(objects));
Q_EMIT optimizationProgress(tr("Null objects entries from dictionaries removed: %1").arg(counter));
Q_EMIT optimizationProgress(tr("Null objects entries from dictionaries removed: %1").arg(counter.load()));
return false;
}
@@ -238,7 +238,7 @@ bool PDFOptimizer::performRemoveUnusedObjects()
PDFExecutionPolicy::execute(PDFExecutionPolicy::Scope::Unknown, range.begin(), range.end(), processEntry);
m_storage.setObjects(qMove(objects));
Q_EMIT optimizationProgress(tr("Unused objects removed: %1").arg(counter));
Q_EMIT optimizationProgress(tr("Unused objects removed: %1").arg(counter.load()));
return counter > 0;
}
@@ -311,7 +311,7 @@ bool PDFOptimizer::performMergeIdenticalObjects()
}
m_storage.setObjects(qMove(objects));
Q_EMIT optimizationProgress(tr("Identical objects merged: %1").arg(counter));
Q_EMIT optimizationProgress(tr("Identical objects merged: %1").arg(counter.load()));
return counter > 0;
}
@@ -457,7 +457,7 @@ bool PDFOptimizer::performRecompressFlateStreams()
PDFExecutionPolicy::execute(PDFExecutionPolicy::Scope::Unknown, objects.begin(), objects.end(), processEntry);
m_storage.setObjects(qMove(objects));
Q_EMIT optimizationProgress(tr("Bytes saved by recompressing stream: %1").arg(bytesSaved));
Q_EMIT optimizationProgress(tr("Bytes saved by recompressing stream: %1").arg(bytesSaved.load()));
return false;
}

View File

@@ -36,7 +36,7 @@
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
@@ -225,10 +225,10 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>

View File

@@ -101,106 +101,6 @@ void PDFCreateBitonalDocumentPreviewWidget::setImage(QImage image)
update();
}
class ImagePreviewDelegate : public QStyledItemDelegate
{
public:
ImagePreviewDelegate(std::vector<PDFCreateBitonalDocumentDialog::ImageConversionInfo>* imageConversionInfos, QObject* parent) :
QStyledItemDelegate(parent),
m_imageConversionInfos(imageConversionInfos)
{
m_yesRenderer.load(QString(":/resources/result-ok.svg"));
m_noRenderer.load(QString(":/resources/result-error.svg"));
}
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override
{
QStyledItemDelegate::paint(painter, option, index);
QRect markRect = getMarkRect(option);
if (index.isValid())
{
const PDFCreateBitonalDocumentDialog::ImageConversionInfo& info = m_imageConversionInfos->at(index.row());
if (info.conversionEnabled)
{
m_yesRenderer.render(painter, markRect);
}
else
{
m_noRenderer.render(painter, markRect);
}
}
}
virtual bool editorEvent(QEvent* event,
QAbstractItemModel* model,
const QStyleOptionViewItem& option,
const QModelIndex& index)
{
Q_UNUSED(model);
Q_UNUSED(index);
if (event->type() == QEvent::MouseButtonPress && index.isValid())
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent && mouseEvent->button() == Qt::LeftButton)
{
// Do we click on yes/no mark?
QRectF markRect = getMarkRect(option);
if (markRect.contains(mouseEvent->position()))
{
PDFCreateBitonalDocumentDialog::ImageConversionInfo& info = m_imageConversionInfos->at(index.row());
info.conversionEnabled = !info.conversionEnabled;
return true;
}
}
}
return false;
}
virtual bool helpEvent(QHelpEvent* event,
QAbstractItemView* view,
const QStyleOptionViewItem& option,
const QModelIndex& index) override
{
Q_UNUSED(index);
if (!event || !view)
{
return false;
}
if (event->type() == QEvent::ToolTip)
{
// Are we hovering over yes/no mark?
QRectF markRect = getMarkRect(option);
if (markRect.contains(event->pos()))
{
event->accept();
QToolTip::showText(event->globalPos(), tr("Toggle this icon to switch image conversion to bitonal format on or off."), view);
return true;
}
}
return false;
}
private:
static constexpr QSize s_iconSize = QSize(24, 24);
QRect getMarkRect(const QStyleOptionViewItem& option) const
{
QSize markSize = pdf::PDFWidgetUtils::scaleDPI(option.widget, s_iconSize);
QRect markRect(option.rect.left(), option.rect.top(), markSize.width(), markSize.height());
return markRect;
}
std::vector<PDFCreateBitonalDocumentDialog::ImageConversionInfo>* m_imageConversionInfos;
mutable QSvgRenderer m_yesRenderer;
mutable QSvgRenderer m_noRenderer;
};
PDFCreateBitonalDocumentDialog::PDFCreateBitonalDocumentDialog(const pdf::PDFDocument* document,
const pdf::PDFCMS* cms,
pdf::PDFProgress* progress,
@@ -506,6 +406,89 @@ std::optional<pdf::PDFImage> PDFCreateBitonalDocumentDialog::getImageFromReferen
return pdfImage;
}
ImagePreviewDelegate::ImagePreviewDelegate(std::vector<PDFCreateBitonalDocumentDialog::ImageConversionInfo>* imageConversionInfos, QObject *parent) :
QStyledItemDelegate(parent),
m_imageConversionInfos(imageConversionInfos)
{
m_yesRenderer.load(QString(":/resources/result-ok.svg"));
m_noRenderer.load(QString(":/resources/result-error.svg"));
}
void ImagePreviewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
QStyledItemDelegate::paint(painter, option, index);
QRect markRect = getMarkRect(option);
if (index.isValid())
{
const PDFCreateBitonalDocumentDialog::ImageConversionInfo& info = m_imageConversionInfos->at(index.row());
if (info.conversionEnabled)
{
m_yesRenderer.render(painter, markRect);
}
else
{
m_noRenderer.render(painter, markRect);
}
}
}
bool ImagePreviewDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index)
{
Q_UNUSED(model);
Q_UNUSED(index);
if (event->type() == QEvent::MouseButtonPress && index.isValid())
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent && mouseEvent->button() == Qt::LeftButton)
{
// Do we click on yes/no mark?
QRectF markRect = getMarkRect(option);
if (markRect.contains(mouseEvent->position()))
{
PDFCreateBitonalDocumentDialog::ImageConversionInfo& info = m_imageConversionInfos->at(index.row());
info.conversionEnabled = !info.conversionEnabled;
return true;
}
}
}
return false;
}
bool ImagePreviewDelegate::helpEvent(QHelpEvent* event, QAbstractItemView* view, const QStyleOptionViewItem& option, const QModelIndex& index)
{
Q_UNUSED(index);
if (!event || !view)
{
return false;
}
if (event->type() == QEvent::ToolTip)
{
// Are we hovering over yes/no mark?
QRectF markRect = getMarkRect(option);
if (markRect.contains(event->pos()))
{
event->accept();
QToolTip::showText(event->globalPos(), tr("Toggle this icon to switch image conversion to bitonal format on or off."), view);
return true;
}
}
return false;
}
QRect ImagePreviewDelegate::getMarkRect(const QStyleOptionViewItem& option) const
{
QSize markSize = pdf::PDFWidgetUtils::scaleDPI(option.widget, s_iconSize);
QRect markRect(option.rect.left(), option.rect.top(), markSize.width(), markSize.height());
return markRect;
}
} // namespace pdfviewer

View File

@@ -27,7 +27,9 @@
#include <QDialog>
#include <QFuture>
#include <QSvgRenderer>
#include <QFutureWatcher>
#include <QStyledItemDelegate>
namespace Ui
{
@@ -110,6 +112,34 @@ private:
int m_manualThreshold = 128;
};
class ImagePreviewDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
ImagePreviewDelegate(std::vector<PDFCreateBitonalDocumentDialog::ImageConversionInfo>* imageConversionInfos, QObject* parent);
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
virtual bool editorEvent(QEvent* event,
QAbstractItemModel* model,
const QStyleOptionViewItem& option,
const QModelIndex& index) override;
virtual bool helpEvent(QHelpEvent* event,
QAbstractItemView* view,
const QStyleOptionViewItem& option,
const QModelIndex& index) override;
private:
static constexpr QSize s_iconSize = QSize(24, 24);
QRect getMarkRect(const QStyleOptionViewItem& option) const;
std::vector<PDFCreateBitonalDocumentDialog::ImageConversionInfo>* m_imageConversionInfos;
mutable QSvgRenderer m_yesRenderer;
mutable QSvgRenderer m_noRenderer;
};
} // namespace pdfviewer
#endif // PDFCREATEBITONALDOCUMENTDIALOG_H

View File

@@ -112,6 +112,9 @@ void PDFViewerSettings::readSettings(QSettings& settings, const pdf::PDFCMSSetti
m_settings.m_colorScheme = static_cast<ColorScheme>(settings.value("colorScheme", int(defaultSettings.m_colorScheme)).toInt());
settings.endGroup();
// Language
m_settings.m_language = pdf::PDFApplicationTranslator::loadSettings(settings);
Q_EMIT settingsChanged();
}
@@ -188,6 +191,8 @@ void PDFViewerSettings::writeSettings(QSettings& settings)
settings.beginGroup("ColorScheme");
settings.setValue("colorScheme", int(m_settings.m_colorScheme));
settings.endGroup();
pdf::PDFApplicationTranslator::saveSettings(settings, m_settings.m_language);
}
QString PDFViewerSettings::getDirectory() const
@@ -311,7 +316,8 @@ PDFViewerSettings::Settings::Settings() :
m_signatureIgnoreCertificateValidityTime(false),
m_signatureUseSystemStore(true),
m_autoGenerateBookmarks(true),
m_colorScheme(AutoScheme)
m_colorScheme(AutoScheme),
m_language(pdf::PDFApplicationTranslator::E_LANGUAGE_AUTOMATIC_SELECTION)
{
}

View File

@@ -24,6 +24,7 @@
#include "pdfcms.h"
#include "pdfexecutionpolicy.h"
#include "pdfform.h"
#include "pdfapplicationtranslator.h"
#include <QObject>
@@ -105,6 +106,9 @@ public:
// UI Dark/Light mode settings
ColorScheme m_colorScheme;
// Language
pdf::PDFApplicationTranslator::ELanguage m_language;
};
const Settings& getSettings() const { return m_settings; }

View File

@@ -138,6 +138,14 @@ PDFViewerSettingsDialog::PDFViewerSettingsDialog(const PDFViewerSettings::Settin
ui->colorSchemeCombo->addItem(tr("Light scheme"), static_cast<int>(PDFViewerSettings::LightScheme));
ui->colorSchemeCombo->addItem(tr("Dark scheme"), static_cast<int>(PDFViewerSettings::DarkScheme));
// Langauges
ui->languageCombo->addItem(tr("Automatic detection"), static_cast<int>(pdf::PDFApplicationTranslator::E_LANGUAGE_AUTOMATIC_SELECTION));
ui->languageCombo->addItem(tr("English"), static_cast<int>(pdf::PDFApplicationTranslator::E_LANGUAGE_ENGLISH));
ui->languageCombo->addItem(tr("German"), static_cast<int>(pdf::PDFApplicationTranslator::E_LANGUAGE_GERMAN));
ui->languageCombo->addItem(tr("Korean"), static_cast<int>(pdf::PDFApplicationTranslator::E_LANGUAGE_KOREAN));
ui->languageCombo->addItem(tr("Spanish"), static_cast<int>(pdf::PDFApplicationTranslator::E_LANGUAGE_SPANISH));
ui->languageCombo->addItem(tr("Czech"), static_cast<int>(pdf::PDFApplicationTranslator::E_LANGUAGE_CZECH));
auto fillColorProfileList = [](QComboBox* comboBox, const pdf::PDFColorProfileIdentifiers& identifiers)
{
for (const pdf::PDFColorProfileIdentifier& identifier : identifiers)
@@ -311,6 +319,7 @@ void PDFViewerSettingsDialog::loadData()
ui->developerModeCheckBox->setChecked(m_settings.m_allowDeveloperMode);
ui->logicalPixelZoomCheckBox->setChecked(m_settings.m_features.testFlag(pdf::PDFRenderer::LogicalSizeZooming));
ui->colorSchemeCombo->setCurrentIndex(ui->colorSchemeCombo->findData(static_cast<int>(m_settings.m_colorScheme)));
ui->languageCombo->setCurrentIndex(ui->languageCombo->findData(static_cast<int>(m_settings.m_language)));
// CMS
ui->cmsTypeComboBox->setCurrentIndex(ui->cmsTypeComboBox->findData(int(m_cmsSettings.system)));
@@ -402,7 +411,11 @@ void PDFViewerSettingsDialog::saveData()
QObject* sender = this->sender();
if (sender == ui->colorSchemeCombo)
if (sender == ui->languageCombo)
{
m_settings.m_language = static_cast<pdf::PDFApplicationTranslator::ELanguage>(ui->languageCombo->currentData().toInt());
}
else if (sender == ui->colorSchemeCombo)
{
m_settings.m_colorScheme = static_cast<PDFViewerSettings::ColorScheme>(ui->colorSchemeCombo->currentData().toInt());
}

View File

@@ -35,7 +35,7 @@
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
<number>8</number>
</property>
<widget class="QWidget" name="enginePage">
<layout class="QVBoxLayout" name="enginePageLayout">
@@ -928,45 +928,87 @@ li.checked::marker { content: &quot;\2612&quot;; }
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,1">
<item>
<layout class="QGridLayout" name="uiGroupBoxLayout">
<item row="1" column="1">
<widget class="QSpinBox" name="maximumRecentFileCountEdit"/>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="developerModeCheckBox">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="maximumRedoStepsLabel">
<property name="text">
<string>Maximum redo steps</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="magnifierSizeLabel">
<property name="text">
<string>Magnifier size</string>
<item row="5" column="1">
<widget class="QSpinBox" name="maximumUndoStepsEdit">
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="8" column="1">
<widget class="QCheckBox" name="developerModeCheckBox">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="maximumRedoStepsEdit">
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="magnifierZoomLabel">
<property name="text">
<string>Magnifier zoom</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="logicalPixelZoomLabel">
<property name="text">
<string>Use logical pixels when zooming</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="3" column="0">
<widget class="QLabel" name="magnifierSizeLabel">
<property name="text">
<string>Magnifier size</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="magnifierZoomEdit">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="maximumUndoStepsLabel">
<property name="text">
<string>Maximum undo steps</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="maximumRecentFileCountLabel">
<property name="text">
<string>Maximum count of recent files</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="logicalPixelZoomCheckBox">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QSpinBox" name="magnifierSizeEdit">
<property name="suffix">
<string>px</string>
@@ -979,68 +1021,36 @@ li.checked::marker { content: &quot;\2612&quot;; }
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="magnifierZoomEdit">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="maximumUndoStepsEdit">
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="maximumUndoStepsLabel">
<property name="text">
<string>Maximum undo steps</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="magnifierZoomLabel">
<property name="text">
<string>Magnifier zoom</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="maximumRedoStepsEdit">
<property name="maximum">
<number>20</number>
</property>
</widget>
<item row="1" column="1">
<widget class="QComboBox" name="colorSchemeCombo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="maximumRecentFileCountLabel">
<widget class="QLabel" name="colorSchemeLabel">
<property name="text">
<string>Maximum count of recent files</string>
<string>Color Scheme (GUI)</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="2" column="1">
<widget class="QSpinBox" name="maximumRecentFileCountEdit"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="developerModeLabel">
<property name="text">
<string>Developer mode</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="colorSchemeCombo"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="colorSchemeLabel">
<widget class="QLabel" name="languageLabel">
<property name="text">
<string>Color Scheme (GUI)</string>
<string>Language</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="languageCombo"/>
</item>
</layout>
</item>
<item>

View File

@@ -36,7 +36,7 @@
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
@@ -225,10 +225,10 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>

View File

@@ -18,6 +18,7 @@
#include "pdfconstants.h"
#include "pdfsecurityhandler.h"
#include "pdfwidgetutils.h"
#include "pdfapplicationtranslator.h"
#include "mainwindow.h"
#include <QApplication>
@@ -54,6 +55,9 @@ int main(int argc, char *argv[])
pdf::PDFWidgetUtils::setDarkTheme(parser.isSet(lightGui), parser.isSet(darkGui));
pdf::PDFApplicationTranslator translator;
translator.installTranslator();
QIcon appIcon(":/app-icon.svg");
QApplication::setWindowIcon(appIcon);

View File

@@ -20,6 +20,7 @@
#include "pdfsecurityhandler.h"
#include "pdfwidgetutils.h"
#include "pdfviewersettings.h"
#include "pdfapplicationtranslator.h"
#include <QApplication>
#include <QCommandLineParser>
@@ -53,6 +54,10 @@ int main(int argc, char *argv[])
pdf::PDFSecurityHandler::setNoDRMMode();
}
pdf::PDFApplicationTranslator translator;
translator.loadSettings();
translator.installTranslator();
bool isLightGui = false;
bool isDarkGui = false;
const pdfviewer::PDFViewerSettings::ColorScheme colorScheme = pdfviewer::PDFViewerSettings::getColorSchemeStatic();

View File

@@ -207,6 +207,27 @@
<Component Id="cmpasmjit" Directory="INSTALLFOLDER" Guid="{E0C3FFC2-930D-4DD3-817F-C96ECDC49A40}">
<File Id="filasmjit" KeyPath="yes" Source="$(var.MyInstallDir)\asmjit.dll" />
</Component>
<Component Id="cmptransen" Directory="dir_translations" Guid="{9A96085A-079F-4DD6-B41E-8F854911D3D2}">
<File Id="filtransen" KeyPath="yes" Source="$(var.MyInstallDir)\translations\PDF4QT_en.qm" />
</Component>
<Component Id="cmptransde" Directory="dir_translations" Guid="{B39F38CF-B6C0-47C3-8684-7B154654F435}">
<File Id="filtransde" KeyPath="yes" Source="$(var.MyInstallDir)\translations\PDF4QT_de.qm" />
</Component>
<Component Id="cmptranscs" Directory="dir_translations" Guid="{CE00279C-8F80-4365-A368-10C2BD569795}">
<File Id="filtranscs" KeyPath="yes" Source="$(var.MyInstallDir)\translations\PDF4QT_cs.qm" />
</Component>
<Component Id="cmptranses" Directory="dir_translations" Guid="{8857D5F3-D960-4E33-95CF-8F13C300D0E6}">
<File Id="filtranses" KeyPath="yes" Source="$(var.MyInstallDir)\translations\PDF4QT_es.qm" />
</Component>
<Component Id="cmptransko" Directory="dir_translations" Guid="{B959062A-9893-4891-A862-69DFA83E36FA}">
<File Id="filtransko" KeyPath="yes" Source="$(var.MyInstallDir)\translations\PDF4QT_ko.qm" />
</Component>
</ComponentGroup>
</Fragment>
@@ -346,4 +367,10 @@
<Directory Id="dir_platforms" Name="platforms" />
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Directory Id="dir_translations" Name="translations" />
</DirectoryRef>
</Fragment>
</Wix>

14605
translations/PDF4QT_cs.ts Normal file

File diff suppressed because it is too large Load Diff

14604
translations/PDF4QT_de.ts Normal file

File diff suppressed because it is too large Load Diff

14604
translations/PDF4QT_en.ts Normal file

File diff suppressed because it is too large Load Diff

14604
translations/PDF4QT_es.ts Normal file

File diff suppressed because it is too large Load Diff

14604
translations/PDF4QT_ko.ts Normal file

File diff suppressed because it is too large Load Diff