Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/branches/editor_plugin_R…
Browse files Browse the repository at this point in the history
…EBASED4'
  • Loading branch information
JakubMelka committed Jun 26, 2024
2 parents c9b262f + b007656 commit 1e79871
Show file tree
Hide file tree
Showing 81 changed files with 6,152 additions and 573 deletions.
7 changes: 4 additions & 3 deletions Pdf4QtDiff/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ void DifferencesDrawInterface::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
Expand Down Expand Up @@ -329,7 +330,7 @@ void DifferencesDrawInterface::drawPage(QPainter* painter,
const auto& item = *it;
if (item.first == leftPageIndex)
{
QColor color = getColorForIndex(i);
QColor color = convertor.convert(getColorForIndex(i), false, true);
drawRectangle(painter, pagePointToDevicePointMatrix, item.second, color);
drawMarker(painter, pagePointToDevicePointMatrix, item.second, color, true);
}
Expand All @@ -352,7 +353,7 @@ void DifferencesDrawInterface::drawPage(QPainter* painter,
const auto& item = *it;
if (item.first == rightPageIndex)
{
QColor color = getColorForIndex(i);
QColor color = convertor.convert(getColorForIndex(i), false, true);
drawRectangle(painter, pagePointToDevicePointMatrix, item.second, color);
drawMarker(painter, pagePointToDevicePointMatrix, item.second, color, false);
}
Expand Down Expand Up @@ -388,7 +389,7 @@ void DifferencesDrawInterface::drawPage(QPainter* painter,
break;
}

QColor color = getColorForIndex(*pageMoveIndex);
QColor color = convertor.convert(getColorForIndex(*pageMoveIndex), false, true);
QPointF targetPoint = pagePointToDevicePointMatrix.map(QPointF(5, 5));
pdf::PDFPainterHelper::drawBubble(painter, targetPoint.toPoint(), color, text, Qt::AlignRight | Qt::AlignTop);
}
Expand Down
1 change: 1 addition & 0 deletions Pdf4QtDiff/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class DifferencesDrawInterface : public pdf::IDocumentDrawInterface
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;

virtual void drawPostRendering(QPainter* painter, QRect rect) const override;
Expand Down
6 changes: 4 additions & 2 deletions Pdf4QtEditorPlugins/AudioBookPlugin/audiobookplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "pdfwidgettool.h"
#include "pdfutils.h"
#include "pdfwidgetutils.h"
#include "pdfcms.h"
#include "audiobookcreator.h"

#include <QAction>
Expand Down Expand Up @@ -170,6 +171,7 @@ void AudioBookPlugin::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
Expand Down Expand Up @@ -208,8 +210,8 @@ void AudioBookPlugin::drawPage(QPainter* painter,
fillColor.setAlphaF(0.2f);

pen.setColor(strokeColor);
painter->setPen(pen);
painter->setBrush(QBrush(fillColor));
painter->setPen(convertor.convert(pen));
painter->setBrush(convertor.convert(QBrush(fillColor)));

QPainterPath path;
path.addRect(boundingRect);
Expand Down
1 change: 1 addition & 0 deletions Pdf4QtEditorPlugins/AudioBookPlugin/audiobookplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AudioBookPlugin : public pdf::PDFPlugin,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;

// IDrawWidgetInputInterface interface
Expand Down
3 changes: 2 additions & 1 deletion Pdf4QtEditorPlugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Jakub Melka
# Copyright (C) 2022-2023 Jakub Melka
#
# This file is part of PDF4QT.
#
Expand Down Expand Up @@ -28,3 +28,4 @@ add_subdirectory(OutputPreviewPlugin)
add_subdirectory(RedactPlugin)
add_subdirectory(SignaturePlugin)
add_subdirectory(SoftProofingPlugin)
add_subdirectory(EditorPlugin)
14 changes: 8 additions & 6 deletions Pdf4QtEditorPlugins/DimensionsPlugin/dimensionsplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "dimensionsplugin.h"
#include "pdfdrawwidget.h"
#include "pdfwidgetutils.h"
#include "pdfcms.h"
#include "settingsdialog.h"

#include <QPainter>
Expand Down Expand Up @@ -149,6 +150,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
Expand Down Expand Up @@ -196,7 +198,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
QPointF unitVector = unitVectorLine.p2() - unitVectorLine.p1();
qreal extensionLineSize = pdf::PDFWidgetUtils::scaleDPI_y(painter->device(), 5);

painter->setPen(Qt::black);
painter->setPen(convertor.convert(QColor(Qt::black), false, true));
painter->drawLine(line);

QLineF extensionLineLeft(p1 - unitVector * extensionLineSize, p1 + unitVector * extensionLineSize);
Expand Down Expand Up @@ -237,14 +239,14 @@ void DimensionsPlugin::drawPage(QPainter* painter,

QColor brushColor = Qt::black;
brushColor.setAlphaF(0.1f);
painter->setPen(qMove(pen));
painter->setBrush(QBrush(brushColor, isArea ? Qt::SolidPattern : Qt::DiagCrossPattern));
painter->setPen(convertor.convert(pen));
painter->setBrush(convertor.convert(QBrush(brushColor, isArea ? Qt::SolidPattern : Qt::DiagCrossPattern)));

painter->setTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->drawPolygon(polygon.data(), int(polygon.size()), Qt::OddEvenFill);
painter->restore();

QPen penPoint(Qt::black);
QPen penPoint(convertor.convert(QColor(Qt::black), false, true));
penPoint.setCapStyle(Qt::RoundCap);
penPoint.setWidthF(pointSize);
painter->setPen(penPoint);
Expand Down Expand Up @@ -287,7 +289,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
line1.setLength(maxLength);
line2.setLength(maxLength);

QPen pen(Qt::black);
QPen pen(convertor.convert(QColor(Qt::black), false, true));
pen.setWidthF(lineSize);
painter->setPen(qMove(pen));

Expand All @@ -301,7 +303,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
rect.translate(line1.p1());
painter->drawArc(rect, startAngle - angleLength, angleLength);

QPen penPoint(Qt::black);
QPen penPoint(convertor.convert(QColor(Qt::black), false, true));
penPoint.setCapStyle(Qt::RoundCap);
penPoint.setWidthF(pointSize);
painter->setPen(penPoint);
Expand Down
1 change: 1 addition & 0 deletions Pdf4QtEditorPlugins/DimensionsPlugin/dimensionsplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class DimensionsPlugin : public pdf::PDFPlugin, public pdf::IDocumentDrawInterfa
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;

private:
Expand Down
4 changes: 3 additions & 1 deletion Pdf4QtEditorPlugins/DimensionsPlugin/dimensiontool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "dimensiontool.h"
#include "pdfwidgetutils.h"
#include "pdfdrawwidget.h"
#include "pdfcms.h"

#include <QPainter>

Expand All @@ -41,6 +42,7 @@ void DimensionTool::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
Expand All @@ -59,7 +61,7 @@ void DimensionTool::drawPage(QPainter* painter,
return;
}

painter->setPen(Qt::black);
painter->setPen(convertor.convert(QColor(Qt::black), false, true));
const std::vector<QPointF>& points = m_pickTool->getPickedPoints();
for (size_t i = 1; i < points.size(); ++i)
{
Expand Down
1 change: 1 addition & 0 deletions Pdf4QtEditorPlugins/DimensionsPlugin/dimensiontool.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class DimensionTool : public pdf::PDFWidgetTool
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;

signals:
Expand Down
32 changes: 32 additions & 0 deletions Pdf4QtEditorPlugins/EditorPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (C) 2023 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/>.

add_library(EditorPlugin SHARED
editorplugin.cpp
icons.qrc
)

target_link_libraries(EditorPlugin PRIVATE Pdf4QtLibCore Pdf4QtLibWidgets Qt6::Core Qt6::Gui Qt6::Widgets)

set_target_properties(EditorPlugin PROPERTIES
VERSION ${PDF4QT_VERSION}
SOVERSION ${PDF4QT_VERSION}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PDF4QT_PLUGINS_DIR}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PDF4QT_PLUGINS_DIR})

install(TARGETS EditorPlugin RUNTIME DESTINATION ${PDF4QT_PLUGINS_DIR} LIBRARY DESTINATION ${PDF4QT_PLUGINS_DIR})

7 changes: 7 additions & 0 deletions Pdf4QtEditorPlugins/EditorPlugin/EditorPlugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Name" : "Editor",
"Author" : "Jakub Melka",
"Version" : "1.0.0",
"License" : "LGPL v3",
"Description" : "Edit content of PDF document."
}
13 changes: 13 additions & 0 deletions Pdf4QtEditorPlugins/EditorPlugin/accept-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions Pdf4QtEditorPlugins/EditorPlugin/activate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1e79871

Please sign in to comment.