mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Issue #261: About translation to Korean
This commit is contained in:
@ -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
|
||||
|
@ -36,7 +36,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
@ -225,10 +225,10 @@ li.checked::marker { content: "\2612"; }
|
||||
<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>
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "audiobookcreator.h"
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#include <sapi.h>
|
||||
|
@ -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)
|
||||
|
166
Pdf4QtLibCore/sources/pdfapplicationtranslator.cpp
Normal file
166
Pdf4QtLibCore/sources/pdfapplicationtranslator.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
QString PDFApplicationTranslator::loadLanguageKeyFromSettings()
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<ELanguage>();
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
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
|
66
Pdf4QtLibCore/sources/pdfapplicationtranslator.h
Normal file
66
Pdf4QtLibCore/sources/pdfapplicationtranslator.h
Normal file
@ -0,0 +1,66 @@
|
||||
// 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>
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
QString loadLanguageKeyFromSettings();
|
||||
QString getLanguageFileName() const;
|
||||
|
||||
QTranslator* m_translator = nullptr;
|
||||
ELanguage m_language = E_LANGUAGE_AUTOMATIC_SELECTION;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // PDFAPPLICATIONTRANSLATOR_H
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
@ -225,10 +225,10 @@ li.checked::marker { content: "\2612"; }
|
||||
<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>
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -36,7 +36,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
@ -225,10 +225,10 @@ li.checked::marker { content: "\2612"; }
|
||||
<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>
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
14569
translations/PDF4QT_cs.ts
Normal file
14569
translations/PDF4QT_cs.ts
Normal file
File diff suppressed because it is too large
Load Diff
14569
translations/PDF4QT_de.ts
Normal file
14569
translations/PDF4QT_de.ts
Normal file
File diff suppressed because it is too large
Load Diff
14569
translations/PDF4QT_en.ts
Normal file
14569
translations/PDF4QT_en.ts
Normal file
File diff suppressed because it is too large
Load Diff
14569
translations/PDF4QT_es.ts
Normal file
14569
translations/PDF4QT_es.ts
Normal file
File diff suppressed because it is too large
Load Diff
14569
translations/PDF4QT_ko.ts
Normal file
14569
translations/PDF4QT_ko.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user