mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Signature plugin
This commit is contained in:
@ -71,6 +71,8 @@ SOURCES += \
|
|||||||
sources/pdfoptimizer.cpp \
|
sources/pdfoptimizer.cpp \
|
||||||
sources/pdfoptionalcontent.cpp \
|
sources/pdfoptionalcontent.cpp \
|
||||||
sources/pdfoutline.cpp \
|
sources/pdfoutline.cpp \
|
||||||
|
sources/pdfpagecontenteditortools.cpp \
|
||||||
|
sources/pdfpagecontentelements.cpp \
|
||||||
sources/pdfpagenavigation.cpp \
|
sources/pdfpagenavigation.cpp \
|
||||||
sources/pdfpagetransition.cpp \
|
sources/pdfpagetransition.cpp \
|
||||||
sources/pdfpainterutils.cpp \
|
sources/pdfpainterutils.cpp \
|
||||||
@ -146,6 +148,8 @@ HEADERS += \
|
|||||||
sources/pdfoptimizer.h \
|
sources/pdfoptimizer.h \
|
||||||
sources/pdfoptionalcontent.h \
|
sources/pdfoptionalcontent.h \
|
||||||
sources/pdfoutline.h \
|
sources/pdfoutline.h \
|
||||||
|
sources/pdfpagecontenteditortools.h \
|
||||||
|
sources/pdfpagecontentelements.h \
|
||||||
sources/pdfpagenavigation.h \
|
sources/pdfpagenavigation.h \
|
||||||
sources/pdfpagetransition.h \
|
sources/pdfpagetransition.h \
|
||||||
sources/pdfpainterutils.h \
|
sources/pdfpainterutils.h \
|
||||||
|
@ -659,7 +659,7 @@ void PDFCreateFreehandCurveTool::mousePressEvent(QWidget* widget, QMouseEvent* e
|
|||||||
resetTool();
|
resetTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
getProxy()->repaintNeeded();
|
emit getProxy()->repaintNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFCreateFreehandCurveTool::mouseReleaseEvent(QWidget* widget, QMouseEvent* event)
|
void PDFCreateFreehandCurveTool::mouseReleaseEvent(QWidget* widget, QMouseEvent* event)
|
||||||
@ -1063,7 +1063,7 @@ void PDFCreateHighlightTextTool::setSelection(PDFTextSelection&& textSelection)
|
|||||||
if (m_textSelection != textSelection)
|
if (m_textSelection != textSelection)
|
||||||
{
|
{
|
||||||
m_textSelection = qMove(textSelection);
|
m_textSelection = qMove(textSelection);
|
||||||
getProxy()->repaintNeeded();
|
emit getProxy()->repaintNeeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
explicit PDFCreateEllipseTool(PDFDrawWidgetProxy* proxy, PDFToolManager* toolManager, QAction* action, QObject* parent);
|
explicit PDFCreateEllipseTool(PDFDrawWidgetProxy* proxy, PDFToolManager* toolManager, QAction* action, QObject* parent);
|
||||||
|
|
||||||
virtual void drawPage(QPainter* painter, PDFInteger pageIndex,
|
virtual void drawPage(QPainter* painter,
|
||||||
|
PDFInteger pageIndex,
|
||||||
const PDFPrecompiledPage* compiledPage,
|
const PDFPrecompiledPage* compiledPage,
|
||||||
PDFTextLayoutGetter& layoutGetter,
|
PDFTextLayoutGetter& layoutGetter,
|
||||||
const QMatrix& pagePointToDevicePointMatrix,
|
const QMatrix& pagePointToDevicePointMatrix,
|
||||||
|
120
Pdf4QtLib/sources/pdfpagecontenteditortools.cpp
Normal file
120
Pdf4QtLib/sources/pdfpagecontenteditortools.cpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
// Copyright (C) 2022 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 "pdfpagecontenteditortools.h"
|
||||||
|
#include "pdfpagecontentelements.h"
|
||||||
|
|
||||||
|
#include <QPen>
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
|
||||||
|
PDFCreatePCElementTool::PDFCreatePCElementTool(PDFDrawWidgetProxy* proxy,
|
||||||
|
PDFPageContentScene* scene,
|
||||||
|
QAction* action,
|
||||||
|
QObject* parent) :
|
||||||
|
PDFWidgetTool(proxy, action, parent),
|
||||||
|
m_scene(scene)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFCreatePCElementRectangleTool::PDFCreatePCElementRectangleTool(PDFDrawWidgetProxy* proxy,
|
||||||
|
PDFPageContentScene* scene,
|
||||||
|
QAction* action,
|
||||||
|
bool isRounded,
|
||||||
|
QObject* parent) :
|
||||||
|
BaseClass(proxy, scene, action, parent),
|
||||||
|
m_pickTool(nullptr),
|
||||||
|
m_element(nullptr)
|
||||||
|
{
|
||||||
|
m_pickTool = new PDFPickTool(proxy, PDFPickTool::Mode::Rectangles, this);
|
||||||
|
m_pickTool->setDrawSelectionRectangle(false);
|
||||||
|
addTool(m_pickTool);
|
||||||
|
connect(m_pickTool, &PDFPickTool::rectanglePicked, this, &PDFCreatePCElementRectangleTool::onRectanglePicked);
|
||||||
|
|
||||||
|
QPen pen(Qt::SolidLine);
|
||||||
|
pen.setWidthF(1.0);
|
||||||
|
|
||||||
|
m_element = new PDFPageContentElementRectangle();
|
||||||
|
m_element->setBrush(Qt::NoBrush);
|
||||||
|
m_element->setPen(std::move(pen));
|
||||||
|
m_element->setRounded(isRounded);
|
||||||
|
|
||||||
|
updateActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFCreatePCElementRectangleTool::~PDFCreatePCElementRectangleTool()
|
||||||
|
{
|
||||||
|
delete m_element;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFCreatePCElementRectangleTool::drawPage(QPainter* painter,
|
||||||
|
PDFInteger pageIndex,
|
||||||
|
const PDFPrecompiledPage* compiledPage,
|
||||||
|
PDFTextLayoutGetter& layoutGetter,
|
||||||
|
const QMatrix& pagePointToDevicePointMatrix,
|
||||||
|
QList<PDFRenderError>& errors) const
|
||||||
|
{
|
||||||
|
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
|
||||||
|
|
||||||
|
if (pageIndex != m_pickTool->getPageIndex())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<QPointF>& points = m_pickTool->getPickedPoints();
|
||||||
|
if (points.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_element->setPageIndex(pageIndex);
|
||||||
|
|
||||||
|
QPointF mousePoint = pagePointToDevicePointMatrix.inverted().map(m_pickTool->getSnappedPoint());
|
||||||
|
QPointF point = points.front();
|
||||||
|
qreal xMin = qMin(point.x(), mousePoint.x());
|
||||||
|
qreal xMax = qMax(point.x(), mousePoint.x());
|
||||||
|
qreal yMin = qMin(point.y(), mousePoint.y());
|
||||||
|
qreal yMax = qMax(point.y(), mousePoint.y());
|
||||||
|
qreal width = xMax - xMin;
|
||||||
|
qreal height = yMax - yMin;
|
||||||
|
|
||||||
|
if (!qFuzzyIsNull(width) && !qFuzzyIsNull(height))
|
||||||
|
{
|
||||||
|
QRectF rect(xMin, yMin, width, height);
|
||||||
|
m_element->setRectangle(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_element->drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFCreatePCElementRectangleTool::onRectanglePicked(PDFInteger pageIndex, QRectF pageRectangle)
|
||||||
|
{
|
||||||
|
if (pageRectangle.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_element->setPageIndex(pageIndex);
|
||||||
|
m_element->setRectangle(pageRectangle);
|
||||||
|
m_scene->addElement(m_element->clone());
|
||||||
|
|
||||||
|
setActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace pdf
|
73
Pdf4QtLib/sources/pdfpagecontenteditortools.h
Normal file
73
Pdf4QtLib/sources/pdfpagecontenteditortools.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// Copyright (C) 2022 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 PDFPAGECONTENTEDITORTOOLS_H
|
||||||
|
#define PDFPAGECONTENTEDITORTOOLS_H
|
||||||
|
|
||||||
|
#include "pdfwidgettool.h"
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
|
||||||
|
class PDFPageContentScene;
|
||||||
|
class PDFPageContentElementRectangle;
|
||||||
|
|
||||||
|
class PDFCreatePCElementTool : public PDFWidgetTool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PDFCreatePCElementTool(PDFDrawWidgetProxy* proxy,
|
||||||
|
PDFPageContentScene* scene,
|
||||||
|
QAction* action,
|
||||||
|
QObject* parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PDFPageContentScene* m_scene;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Tool that creates rectangle element.
|
||||||
|
class PDF4QTLIBSHARED_EXPORT PDFCreatePCElementRectangleTool : public PDFCreatePCElementTool
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
using BaseClass = PDFCreatePCElementTool;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PDFCreatePCElementRectangleTool(PDFDrawWidgetProxy* proxy,
|
||||||
|
PDFPageContentScene* scene,
|
||||||
|
QAction* action,
|
||||||
|
bool isRounded,
|
||||||
|
QObject* parent);
|
||||||
|
virtual ~PDFCreatePCElementRectangleTool() override;
|
||||||
|
|
||||||
|
virtual void drawPage(QPainter* painter,
|
||||||
|
PDFInteger pageIndex,
|
||||||
|
const PDFPrecompiledPage* compiledPage,
|
||||||
|
PDFTextLayoutGetter& layoutGetter,
|
||||||
|
const QMatrix& pagePointToDevicePointMatrix,
|
||||||
|
QList<PDFRenderError>& errors) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onRectanglePicked(pdf::PDFInteger pageIndex, QRectF pageRectangle);
|
||||||
|
|
||||||
|
PDFPickTool* m_pickTool;
|
||||||
|
PDFPageContentElementRectangle* m_element;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pdf
|
||||||
|
|
||||||
|
#endif // PDFPAGECONTENTEDITORTOOLS_H
|
222
Pdf4QtLib/sources/pdfpagecontentelements.cpp
Normal file
222
Pdf4QtLib/sources/pdfpagecontentelements.cpp
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
// Copyright (C) 2022 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 "pdfpagecontentelements.h"
|
||||||
|
#include "pdfpainterutils.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QCursor>
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
|
||||||
|
PDFInteger PDFPageContentElement::getPageIndex() const
|
||||||
|
{
|
||||||
|
return m_pageIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentElement::setPageIndex(PDFInteger newPageIndex)
|
||||||
|
{
|
||||||
|
m_pageIndex = newPageIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QPen& PDFPageContentStyledElement::getPen() const
|
||||||
|
{
|
||||||
|
return m_pen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentStyledElement::setPen(const QPen& newPen)
|
||||||
|
{
|
||||||
|
m_pen = newPen;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QBrush& PDFPageContentStyledElement::getBrush() const
|
||||||
|
{
|
||||||
|
return m_brush;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentStyledElement::setBrush(const QBrush& newBrush)
|
||||||
|
{
|
||||||
|
m_brush = newBrush;
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFPageContentElementRectangle* PDFPageContentElementRectangle::clone() const
|
||||||
|
{
|
||||||
|
PDFPageContentElementRectangle* copy = new PDFPageContentElementRectangle();
|
||||||
|
copy->setPageIndex(getPageIndex());
|
||||||
|
copy->setPen(getPen());
|
||||||
|
copy->setBrush(getBrush());
|
||||||
|
copy->setRectangle(getRectangle());
|
||||||
|
copy->setRounded(isRounded());
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PDFPageContentElementRectangle::isRounded() const
|
||||||
|
{
|
||||||
|
return m_rounded;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentElementRectangle::setRounded(bool newRounded)
|
||||||
|
{
|
||||||
|
m_rounded = newRounded;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QRectF& PDFPageContentElementRectangle::getRectangle() const
|
||||||
|
{
|
||||||
|
return m_rectangle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentElementRectangle::setRectangle(const QRectF& newRectangle)
|
||||||
|
{
|
||||||
|
m_rectangle = newRectangle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentElementRectangle::drawPage(QPainter* painter,
|
||||||
|
PDFInteger pageIndex,
|
||||||
|
const PDFPrecompiledPage* compiledPage,
|
||||||
|
PDFTextLayoutGetter& layoutGetter,
|
||||||
|
const QMatrix& pagePointToDevicePointMatrix,
|
||||||
|
QList<PDFRenderError>& errors) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(compiledPage);
|
||||||
|
Q_UNUSED(layoutGetter);
|
||||||
|
Q_UNUSED(errors);
|
||||||
|
|
||||||
|
if (pageIndex != getPageIndex())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFPainterStateGuard guard(painter);
|
||||||
|
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
|
||||||
|
painter->setPen(getPen());
|
||||||
|
painter->setBrush(getBrush());
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
|
QRectF rect = getRectangle();
|
||||||
|
if (isRounded())
|
||||||
|
{
|
||||||
|
qreal radius = qMin(rect.width(), rect.height()) * 0.25;
|
||||||
|
painter->drawRoundedRect(rect, radius, radius, Qt::AbsoluteSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
painter->drawRect(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFPageContentScene::PDFPageContentScene(QObject* parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFPageContentScene::~PDFPageContentScene()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::addElement(PDFPageContentElement* element)
|
||||||
|
{
|
||||||
|
m_elements.emplace_back(element);
|
||||||
|
emit sceneChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::clear()
|
||||||
|
{
|
||||||
|
if (!m_elements.empty())
|
||||||
|
{
|
||||||
|
m_elements.clear();
|
||||||
|
emit sceneChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::shortcutOverrideEvent(QWidget* widget, QKeyEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::keyPressEvent(QWidget* widget, QKeyEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::keyReleaseEvent(QWidget* widget, QKeyEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::mousePressEvent(QWidget* widget, QMouseEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::mouseDoubleClickEvent(QWidget* widget, QMouseEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::mouseReleaseEvent(QWidget* widget, QMouseEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::mouseMoveEvent(QWidget* widget, QMouseEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::wheelEvent(QWidget* widget, QWheelEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PDFPageContentScene::getTooltip() const
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::optional<QCursor>& PDFPageContentScene::getCursor() const
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PDFPageContentScene::getInputPriority() const
|
||||||
|
{
|
||||||
|
return ToolPriority + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFPageContentScene::drawPage(QPainter* painter,
|
||||||
|
PDFInteger pageIndex,
|
||||||
|
const PDFPrecompiledPage* compiledPage,
|
||||||
|
PDFTextLayoutGetter& layoutGetter,
|
||||||
|
const QMatrix& pagePointToDevicePointMatrix,
|
||||||
|
QList<PDFRenderError>& errors) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace pdf
|
147
Pdf4QtLib/sources/pdfpagecontentelements.h
Normal file
147
Pdf4QtLib/sources/pdfpagecontentelements.h
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
// Copyright (C) 2022 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 PDFPAGECONTENTELEMENTS_H
|
||||||
|
#define PDFPAGECONTENTELEMENTS_H
|
||||||
|
|
||||||
|
#include "pdfdocumentdrawinterface.h"
|
||||||
|
|
||||||
|
#include <QPen>
|
||||||
|
#include <QBrush>
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
|
||||||
|
class PDFPageContentElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit PDFPageContentElement() = default;
|
||||||
|
virtual ~PDFPageContentElement() = default;
|
||||||
|
|
||||||
|
virtual PDFPageContentElement* clone() const = 0;
|
||||||
|
|
||||||
|
virtual void drawPage(QPainter* painter,
|
||||||
|
PDFInteger pageIndex,
|
||||||
|
const PDFPrecompiledPage* compiledPage,
|
||||||
|
PDFTextLayoutGetter& layoutGetter,
|
||||||
|
const QMatrix& pagePointToDevicePointMatrix,
|
||||||
|
QList<PDFRenderError>& errors) const = 0;
|
||||||
|
|
||||||
|
PDFInteger getPageIndex() const;
|
||||||
|
void setPageIndex(PDFInteger newPageIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PDFInteger m_pageIndex = -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PDFPageContentStyledElement : public PDFPageContentElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit PDFPageContentStyledElement() = default;
|
||||||
|
virtual ~PDFPageContentStyledElement() = default;
|
||||||
|
|
||||||
|
const QPen& getPen() const;
|
||||||
|
void setPen(const QPen& newPen);
|
||||||
|
|
||||||
|
const QBrush& getBrush() const;
|
||||||
|
void setBrush(const QBrush& newBrush);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QPen m_pen;
|
||||||
|
QBrush m_brush;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PDFPageContentElementRectangle : public PDFPageContentStyledElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~PDFPageContentElementRectangle() = default;
|
||||||
|
|
||||||
|
virtual PDFPageContentElementRectangle* clone() const override;
|
||||||
|
|
||||||
|
bool isRounded() const;
|
||||||
|
void setRounded(bool newRounded);
|
||||||
|
|
||||||
|
const QRectF& getRectangle() const;
|
||||||
|
void setRectangle(const QRectF& newRectangle);
|
||||||
|
|
||||||
|
virtual void drawPage(QPainter* painter,
|
||||||
|
PDFInteger pageIndex,
|
||||||
|
const PDFPrecompiledPage* compiledPage,
|
||||||
|
PDFTextLayoutGetter& layoutGetter,
|
||||||
|
const QMatrix& pagePointToDevicePointMatrix,
|
||||||
|
QList<PDFRenderError>& errors) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_rounded = false;
|
||||||
|
QRectF m_rectangle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PDF4QTLIBSHARED_EXPORT PDFPageContentScene : public QObject,
|
||||||
|
public IDocumentDrawInterface,
|
||||||
|
public IDrawWidgetInputInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PDFPageContentScene(QObject* parent);
|
||||||
|
virtual ~PDFPageContentScene();
|
||||||
|
|
||||||
|
/// Add new element to page content scene, scene
|
||||||
|
/// takes ownership over the element.
|
||||||
|
/// \param element Element
|
||||||
|
void addElement(PDFPageContentElement* element);
|
||||||
|
|
||||||
|
/// Clear whole scene - remove all page content elements
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/// Returns true, if scene is empty
|
||||||
|
bool isEmpty() const { return m_elements.empty(); }
|
||||||
|
|
||||||
|
// IDrawWidgetInputInterface interface
|
||||||
|
public:
|
||||||
|
virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) override;
|
||||||
|
virtual void keyPressEvent(QWidget* widget, QKeyEvent* event) override;
|
||||||
|
virtual void keyReleaseEvent(QWidget* widget, QKeyEvent* event) override;
|
||||||
|
virtual void mousePressEvent(QWidget* widget, QMouseEvent* event) override;
|
||||||
|
virtual void mouseDoubleClickEvent(QWidget* widget, QMouseEvent* event) override;
|
||||||
|
virtual void mouseReleaseEvent(QWidget* widget, QMouseEvent* event) override;
|
||||||
|
virtual void mouseMoveEvent(QWidget* widget, QMouseEvent* event) override;
|
||||||
|
virtual void wheelEvent(QWidget* widget, QWheelEvent* event) override;
|
||||||
|
virtual QString getTooltip() const override;
|
||||||
|
virtual const std::optional<QCursor>& getCursor() const override;
|
||||||
|
virtual int getInputPriority() const override;
|
||||||
|
|
||||||
|
// IDocumentDrawInterface interface
|
||||||
|
public:
|
||||||
|
virtual void drawPage(QPainter* painter,
|
||||||
|
PDFInteger pageIndex,
|
||||||
|
const PDFPrecompiledPage* compiledPage,
|
||||||
|
PDFTextLayoutGetter& layoutGetter,
|
||||||
|
const QMatrix& pagePointToDevicePointMatrix,
|
||||||
|
QList<PDFRenderError>& errors) const override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/// This signal is emitted when scene has changed (including graphics)
|
||||||
|
void sceneChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::unique_ptr<PDFPageContentElement>> m_elements;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pdf
|
||||||
|
|
||||||
|
#endif // PDFPAGECONTENTELEMENTS_H
|
@ -1233,7 +1233,7 @@ void PDFPickTool::resetTool()
|
|||||||
m_snapper.clearReferencePoint();
|
m_snapper.clearReferencePoint();
|
||||||
|
|
||||||
buildSnapData();
|
buildSnapData();
|
||||||
getProxy()->repaintNeeded();
|
emit getProxy()->repaintNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFPickTool::buildSnapData()
|
void PDFPickTool::buildSnapData()
|
||||||
|
@ -344,8 +344,8 @@ public:
|
|||||||
void setSelectionRectangleColor(QColor selectionRectangleColor);
|
void setSelectionRectangleColor(QColor selectionRectangleColor);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pointPicked(PDFInteger pageIndex, QPointF pagePoint);
|
void pointPicked(pdf::PDFInteger pageIndex, QPointF pagePoint);
|
||||||
void rectanglePicked(PDFInteger pageIndex, QRectF pageRectangle);
|
void rectanglePicked(pdf::PDFInteger pageIndex, QRectF pageRectangle);
|
||||||
void imagePicked(const QImage& image);
|
void imagePicked(const QImage& image);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -10,6 +10,6 @@ Pdf4QtPlugin {
|
|||||||
]
|
]
|
||||||
Properties {
|
Properties {
|
||||||
condition: qbs.hostOS.contains("windows")
|
condition: qbs.hostOS.contains("windows")
|
||||||
cpp.defines: "DIMENTIONPLUGIN_LIBRARY"
|
cpp.defines: "DIMENSIONPLUGIN_LIBRARY"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ SUBDIRS += \
|
|||||||
RedactPlugin \
|
RedactPlugin \
|
||||||
OutputPreviewPlugin \
|
OutputPreviewPlugin \
|
||||||
ObjectInspectorPlugin \
|
ObjectInspectorPlugin \
|
||||||
AudioBookPlugin
|
AudioBookPlugin \
|
||||||
|
SignaturePlugin
|
||||||
|
|
||||||
|
|
||||||
|
7
Pdf4QtViewerPlugins/SignaturePlugin/SignaturePlugin.json
Normal file
7
Pdf4QtViewerPlugins/SignaturePlugin/SignaturePlugin.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"Name" : "Signature",
|
||||||
|
"Author" : "Jakub Melka",
|
||||||
|
"Version" : "1.0.0",
|
||||||
|
"License" : "LGPL v3",
|
||||||
|
"Description" : "Electronically or digitally sign PDF document."
|
||||||
|
}
|
48
Pdf4QtViewerPlugins/SignaturePlugin/SignaturePlugin.pro
Normal file
48
Pdf4QtViewerPlugins/SignaturePlugin/SignaturePlugin.pro
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Copyright (C) 2022 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/>.
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
DEFINES += SIGNATUREPLUGIN_LIBRARY
|
||||||
|
|
||||||
|
QT += gui widgets
|
||||||
|
|
||||||
|
LIBS += -L$$OUT_PWD/../..
|
||||||
|
|
||||||
|
LIBS += -lPdf4QtLib
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS += /std:c++latest /utf-8
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/../../Pdf4QtLib/Sources
|
||||||
|
|
||||||
|
DESTDIR = $$OUT_PWD/../../pdfplugins
|
||||||
|
|
||||||
|
CONFIG += c++11
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
signatureplugin.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
signatureplugin.h
|
||||||
|
|
||||||
|
CONFIG += force_debug_info
|
||||||
|
|
||||||
|
DISTFILES += \
|
||||||
|
SignaturePlugin.json
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
icons.qrc
|
||||||
|
|
15
Pdf4QtViewerPlugins/SignaturePlugin/SignaturePlugin.qbs
Normal file
15
Pdf4QtViewerPlugins/SignaturePlugin/SignaturePlugin.qbs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import qbs
|
||||||
|
|
||||||
|
Pdf4QtPlugin {
|
||||||
|
name: "SignaturePlugin"
|
||||||
|
files: [
|
||||||
|
"*.h",
|
||||||
|
"*.cpp",
|
||||||
|
"*.ui",
|
||||||
|
"icons.qrc",
|
||||||
|
]
|
||||||
|
Properties {
|
||||||
|
condition: qbs.hostOS.contains("windows")
|
||||||
|
cpp.defines: "SIGNATUREPLUGIN_LIBRARY"
|
||||||
|
}
|
||||||
|
}
|
4
Pdf4QtViewerPlugins/SignaturePlugin/icons.qrc
Normal file
4
Pdf4QtViewerPlugins/SignaturePlugin/icons.qrc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/pdfplugins/signatureplugin">
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
170
Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.cpp
Normal file
170
Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.cpp
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
// Copyright (C) 2022 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 "signatureplugin.h"
|
||||||
|
#include "pdfdrawwidget.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
namespace pdfplugin
|
||||||
|
{
|
||||||
|
|
||||||
|
SignaturePlugin::SignaturePlugin() :
|
||||||
|
pdf::PDFPlugin(nullptr),
|
||||||
|
m_actions({ }),
|
||||||
|
m_tools({ }),
|
||||||
|
m_scene(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SignaturePlugin::setWidget(pdf::PDFWidget* widget)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!m_widget);
|
||||||
|
|
||||||
|
BaseClass::setWidget(widget);
|
||||||
|
|
||||||
|
QAction* createTextAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-text.svg"), tr("Create Text Label"), this);
|
||||||
|
QAction* createAcceptMarkAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-yes-mark.svg"), tr("Create Accept Mark"), this);
|
||||||
|
QAction* createRejectMarkAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-no-mark.svg"), tr("Create Reject Mark"), this);
|
||||||
|
QAction* createRectangleAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-rectangle.svg"), tr("Create Rectangle"), this);
|
||||||
|
QAction* createRoundedRectangleAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-rounded-rectangle.svg"), tr("Create Rounded Rectangle"), this);
|
||||||
|
QAction* createHorizontalLineAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-horizontal-line.svg"), tr("Create Horizontal Line"), this);
|
||||||
|
QAction* createVerticalLineAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-vertical-line.svg"), tr("Create Vertical Line"), this);
|
||||||
|
QAction* createLineAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-line.svg"), tr("Create Line"), this);
|
||||||
|
QAction* createDotAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-dot.svg"), tr("Create Dot"), this);
|
||||||
|
QAction* createSvgImageAction = new QAction(QIcon(":/pdfplugins/signaturetool/create-svg-image.svg"), tr("Create SVG Image"), this);
|
||||||
|
QAction* clearAction = new QAction(QIcon(":/pdfplugins/signaturetool/clear.svg"), tr("Clear All Graphics"), this);
|
||||||
|
QAction* setColorAction = new QAction(QIcon(":/pdfplugins/signaturetool/set-color.svg"), tr("Set Color"), this);
|
||||||
|
QAction* setPenAction = new QAction(QIcon(":/pdfplugins/signaturetool/set-pen.svg"), tr("Set Pen"), this);
|
||||||
|
QAction* setBrushAction = new QAction(QIcon(":/pdfplugins/signaturetool/set-brush.svg"), tr("Set Brush"), this);
|
||||||
|
QAction* signElectronicallyAction = new QAction(QIcon(":/pdfplugins/signaturetool/sign-electronically.svg"), tr("Sign Electronically"), this);
|
||||||
|
QAction* signDigitallyAction = new QAction(QIcon(":/pdfplugins/signaturetool/sign-digitally.svg"), tr("Sign Digitally With Certificate"), this);
|
||||||
|
QAction* certificatesAction = new QAction(QIcon(":/pdfplugins/signaturetool/certificates.svg"), tr("Certificates Manager"), this);
|
||||||
|
|
||||||
|
createTextAction->setObjectName("signaturetool_createTextAction");
|
||||||
|
createAcceptMarkAction->setObjectName("signaturetool_createAcceptMarkAction");
|
||||||
|
createRejectMarkAction->setObjectName("signaturetool_createRejectMarkAction");
|
||||||
|
createRectangleAction->setObjectName("signaturetool_createRectangleAction");
|
||||||
|
createRoundedRectangleAction->setObjectName("signaturetool_createRoundedRectangleAction");
|
||||||
|
createHorizontalLineAction->setObjectName("signaturetool_createHorizontalLineAction");
|
||||||
|
createVerticalLineAction->setObjectName("signaturetool_createVerticalLineAction");
|
||||||
|
createLineAction->setObjectName("signaturetool_createLineAction");
|
||||||
|
createDotAction->setObjectName("signaturetool_createDotAction");
|
||||||
|
createSvgImageAction->setObjectName("signaturetool_createSvgImageAction");
|
||||||
|
clearAction->setObjectName("signaturetool_clearAction");
|
||||||
|
setColorAction->setObjectName("signaturetool_setColorAction");
|
||||||
|
setPenAction->setObjectName("signaturetool_setPenAction");
|
||||||
|
setBrushAction->setObjectName("signaturetool_setBrushAction");
|
||||||
|
signElectronicallyAction->setObjectName("signaturetool_signElectronicallyAction");
|
||||||
|
signDigitallyAction->setObjectName("signaturetool_signDigitallyAction");
|
||||||
|
certificatesAction->setObjectName("signaturetool_certificatesAction");
|
||||||
|
|
||||||
|
createTextAction->setCheckable(true);
|
||||||
|
createAcceptMarkAction->setCheckable(true);
|
||||||
|
createRejectMarkAction->setCheckable(true);
|
||||||
|
createRectangleAction->setCheckable(true);
|
||||||
|
createRoundedRectangleAction->setCheckable(true);
|
||||||
|
createHorizontalLineAction->setCheckable(true);
|
||||||
|
createVerticalLineAction->setCheckable(true);
|
||||||
|
createLineAction->setCheckable(true);
|
||||||
|
createDotAction->setCheckable(true);
|
||||||
|
createSvgImageAction->setCheckable(true);
|
||||||
|
|
||||||
|
m_actions[Text] = createTextAction;
|
||||||
|
m_actions[AcceptMark] = createAcceptMarkAction;
|
||||||
|
m_actions[RejectMark] = createRejectMarkAction;
|
||||||
|
m_actions[Rectangle] = createRectangleAction;
|
||||||
|
m_actions[RoundedRectangle] = createRoundedRectangleAction;
|
||||||
|
m_actions[HorizontalLine] = createHorizontalLineAction;
|
||||||
|
m_actions[VerticalLine] = createVerticalLineAction;
|
||||||
|
m_actions[Line] = createLineAction;
|
||||||
|
m_actions[Dot] = createDotAction;
|
||||||
|
m_actions[SvgImage] = createSvgImageAction;
|
||||||
|
m_actions[Clear] = clearAction;
|
||||||
|
m_actions[SetColor] = setColorAction;
|
||||||
|
m_actions[SetPen] = setPenAction;
|
||||||
|
m_actions[SetBrush] = setBrushAction;
|
||||||
|
m_actions[SignElectronically] = signElectronicallyAction;
|
||||||
|
m_actions[SignDigitally] = signDigitallyAction;
|
||||||
|
m_actions[Ceritificates] = certificatesAction;
|
||||||
|
|
||||||
|
m_tools[RectangleTool] = new pdf::PDFCreatePCElementRectangleTool(widget->getDrawWidgetProxy(), &m_scene, createRectangleAction, false, this);
|
||||||
|
m_tools[RoundedRectangleTool] = new pdf::PDFCreatePCElementRectangleTool(widget->getDrawWidgetProxy(), &m_scene, createRoundedRectangleAction, true, this);
|
||||||
|
|
||||||
|
pdf::PDFToolManager* toolManager = widget->getToolManager();
|
||||||
|
for (pdf::PDFWidgetTool* tool : m_tools)
|
||||||
|
{
|
||||||
|
toolManager->addTool(tool);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_widget->getDrawWidgetProxy()->registerDrawInterface(&m_scene);
|
||||||
|
|
||||||
|
updateActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SignaturePlugin::setDocument(const pdf::PDFModifiedDocument& document)
|
||||||
|
{
|
||||||
|
BaseClass::setDocument(document);
|
||||||
|
|
||||||
|
if (document.hasReset())
|
||||||
|
{
|
||||||
|
m_scene.clear();
|
||||||
|
updateActions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<QAction*> SignaturePlugin::getActions() const
|
||||||
|
{
|
||||||
|
std::vector<QAction*> result;
|
||||||
|
|
||||||
|
result.push_back(m_actions[Text]);
|
||||||
|
result.push_back(m_actions[AcceptMark]);
|
||||||
|
result.push_back(m_actions[RejectMark]);
|
||||||
|
result.push_back(m_actions[Rectangle]);
|
||||||
|
result.push_back(m_actions[RoundedRectangle]);
|
||||||
|
result.push_back(m_actions[HorizontalLine]);
|
||||||
|
result.push_back(m_actions[VerticalLine]);
|
||||||
|
result.push_back(m_actions[Line]);
|
||||||
|
result.push_back(m_actions[Dot]);
|
||||||
|
result.push_back(m_actions[Clear]);
|
||||||
|
result.push_back(nullptr);
|
||||||
|
result.push_back(m_actions[SetColor]);
|
||||||
|
result.push_back(m_actions[SetPen]);
|
||||||
|
result.push_back(m_actions[SetBrush]);
|
||||||
|
result.push_back(nullptr);
|
||||||
|
result.push_back(m_actions[SignElectronically]);
|
||||||
|
result.push_back(m_actions[SignDigitally]);
|
||||||
|
result.push_back(m_actions[Ceritificates]);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SignaturePlugin::updateActions()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SignaturePlugin::updateGraphics()
|
||||||
|
{
|
||||||
|
if (m_widget)
|
||||||
|
{
|
||||||
|
m_widget->getDrawWidget()->getWidget()->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
93
Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.h
Normal file
93
Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.h
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
// Copyright (C) 2022 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 SIGNATURESPLUGIN_H
|
||||||
|
#define SIGNATURESPLUGIN_H
|
||||||
|
|
||||||
|
#include "pdfplugin.h"
|
||||||
|
#include "pdfpagecontentelements.h"
|
||||||
|
#include "pdfpagecontenteditortools.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace pdfplugin
|
||||||
|
{
|
||||||
|
|
||||||
|
class SignaturePlugin : public pdf::PDFPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "PDF4QT.SignaturePlugin" FILE "SignaturePlugin.json")
|
||||||
|
|
||||||
|
private:
|
||||||
|
using BaseClass = pdf::PDFPlugin;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SignaturePlugin();
|
||||||
|
|
||||||
|
virtual void setWidget(pdf::PDFWidget* widget) override;
|
||||||
|
virtual void setDocument(const pdf::PDFModifiedDocument& document) override;
|
||||||
|
virtual std::vector<QAction*> getActions() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
enum Action
|
||||||
|
{
|
||||||
|
// Create graphics actions
|
||||||
|
Text,
|
||||||
|
AcceptMark,
|
||||||
|
RejectMark,
|
||||||
|
Rectangle,
|
||||||
|
RoundedRectangle,
|
||||||
|
HorizontalLine,
|
||||||
|
VerticalLine,
|
||||||
|
Line,
|
||||||
|
Dot,
|
||||||
|
SvgImage,
|
||||||
|
Clear,
|
||||||
|
|
||||||
|
// Settings actions
|
||||||
|
SetColor,
|
||||||
|
SetPen,
|
||||||
|
SetBrush,
|
||||||
|
|
||||||
|
// Sign actions
|
||||||
|
SignElectronically,
|
||||||
|
SignDigitally,
|
||||||
|
Ceritificates,
|
||||||
|
|
||||||
|
LastAction
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Tools
|
||||||
|
{
|
||||||
|
RectangleTool,
|
||||||
|
RoundedRectangleTool,
|
||||||
|
LastTool
|
||||||
|
};
|
||||||
|
|
||||||
|
void updateActions();
|
||||||
|
void updateGraphics();
|
||||||
|
|
||||||
|
std::array<QAction*, LastAction> m_actions;
|
||||||
|
std::array<pdf::PDFWidgetTool*, LastTool> m_tools;
|
||||||
|
|
||||||
|
pdf::PDFPageContentScene m_scene;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pdfplugin
|
||||||
|
|
||||||
|
#endif // SIGNATURESPLUGIN_H
|
Reference in New Issue
Block a user