PDF4QT/Pdf4QtViewerPlugins/SignaturePlugin/signatureplugin.h

129 lines
3.2 KiB
C
Raw Normal View History

2022-02-11 19:15:57 +01:00
// 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>
2022-02-26 19:46:13 +01:00
namespace pdf
{
class PDFPageContentEditorWidget;
}
2022-02-11 19:15:57 +01:00
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:
void onSceneChanged(bool graphicsOnly);
2022-04-02 16:29:31 +02:00
void onSceneSelectionChanged();
void onWidgetSelectionChanged();
2022-04-10 19:30:12 +02:00
void onToolActivityChanged();
void onSceneEditElement(const std::set<pdf::PDFInteger>& elements);
2022-04-18 13:54:58 +02:00
void onSignElectronically();
void onSignDigitally();
2022-04-30 18:12:14 +02:00
void onOpenCertificatesManager();
2022-04-10 19:30:12 +02:00
void onPenChanged(const QPen& pen);
void onBrushChanged(const QBrush& brush);
void onFontChanged(const QFont& font);
void onAlignmentChanged(Qt::Alignment alignment);
void onTextAngleChanged(pdf::PDFReal angle);
2022-02-11 19:15:57 +01:00
enum Action
{
2022-02-24 20:25:18 +01:00
// Activate action
Activate,
2022-02-11 19:15:57 +01:00
// Create graphics actions
Text,
2022-02-24 20:25:18 +01:00
FreehandCurve,
2022-02-11 19:15:57 +01:00
AcceptMark,
RejectMark,
Rectangle,
RoundedRectangle,
HorizontalLine,
VerticalLine,
Line,
Dot,
SvgImage,
Clear,
// Sign actions
SignElectronically,
SignDigitally,
2022-02-24 20:25:18 +01:00
Certificates,
2022-02-11 19:15:57 +01:00
LastAction
};
enum Tools
{
2022-03-26 19:26:32 +01:00
TextTool,
2022-02-27 19:59:53 +01:00
FreehandCurveTool,
2022-02-19 19:30:52 +01:00
AcceptMarkTool,
RejectMarkTool,
2022-02-11 19:15:57 +01:00
RectangleTool,
RoundedRectangleTool,
2022-02-13 19:46:09 +01:00
HorizontalLineTool,
VerticalLineTool,
LineTool,
2022-02-27 17:08:24 +01:00
DotTool,
ImageTool,
2022-02-11 19:15:57 +01:00
LastTool
};
2022-02-24 20:25:18 +01:00
void setActive(bool active);
2022-02-11 19:15:57 +01:00
void updateActions();
void updateGraphics();
2022-02-26 19:46:13 +01:00
void updateDockWidget();
2022-02-11 19:15:57 +01:00
QString getSignedFileName() const;
2022-02-11 19:15:57 +01:00
std::array<QAction*, LastAction> m_actions;
std::array<pdf::PDFWidgetTool*, LastTool> m_tools;
2022-02-26 19:46:13 +01:00
pdf::PDFPageContentEditorWidget* m_editorWidget;
2022-02-11 19:15:57 +01:00
pdf::PDFPageContentScene m_scene;
2022-04-02 16:29:31 +02:00
bool m_sceneSelectionChangeEnabled;
2022-04-10 19:30:12 +02:00
pdf::PDFWidgetTool* getActiveTool();
2022-02-11 19:15:57 +01:00
};
} // namespace pdfplugin
#endif // SIGNATURESPLUGIN_H