Editor plugin: Disable editation when signature plugin is active and vice versa

This commit is contained in:
Jakub Melka
2024-06-23 19:37:42 +02:00
parent 178ef02cc8
commit b5f102abbd
8 changed files with 82 additions and 1 deletions

View File

@@ -23,6 +23,7 @@
#include "pdfwidgetannotation.h"
#include "pdfwidgetformmanager.h"
#include "pdfblpainter.h"
#include "pdfpagecontentelements.h"
#include <QPainter>
#include <QGridLayout>
@@ -145,6 +146,11 @@ void PDFWidget::onPageImageChanged(bool all, const std::vector<PDFInteger>& page
}
}
void PDFWidget::onSceneActiveStateChanged(bool)
{
Q_EMIT sceneActivityChanged();
}
void PDFWidget::removeInputInterface(IDrawWidgetInputInterface* inputInterface)
{
auto it = std::find(m_inputInterfaces.begin(), m_inputInterfaces.end(), inputInterface);
@@ -152,6 +158,17 @@ void PDFWidget::removeInputInterface(IDrawWidgetInputInterface* inputInterface)
{
m_inputInterfaces.erase(it);
}
PDFPageContentScene* scene = dynamic_cast<PDFPageContentScene*>(inputInterface);
if (scene)
{
auto itScene = std::find(m_scenes.begin(), m_scenes.end(), inputInterface);
if (itScene != m_scenes.end())
{
m_scenes.erase(itScene);
disconnect(scene, &PDFPageContentScene::sceneActiveStateChanged, this, &PDFWidget::onSceneActiveStateChanged);
}
}
}
void PDFWidget::addInputInterface(IDrawWidgetInputInterface* inputInterface)
@@ -160,9 +177,29 @@ void PDFWidget::addInputInterface(IDrawWidgetInputInterface* inputInterface)
{
m_inputInterfaces.push_back(inputInterface);
std::sort(m_inputInterfaces.begin(), m_inputInterfaces.end(), IDrawWidgetInputInterface::Comparator());
PDFPageContentScene* scene = dynamic_cast<PDFPageContentScene*>(inputInterface);
if (scene)
{
m_scenes.push_back(scene);
connect(scene, &PDFPageContentScene::sceneActiveStateChanged, this, &PDFWidget::onSceneActiveStateChanged);
}
}
}
bool PDFWidget::isAnySceneActive(PDFPageContentScene* sceneToSkip) const
{
for (PDFPageContentScene* scene : m_scenes)
{
if (scene->isActive() && scene != sceneToSkip)
{
return true;
}
}
return false;
}
PDFWidgetFormManager* PDFWidget::getFormManager() const
{
return m_formManager;

View File

@@ -38,6 +38,7 @@ class PDFDrawWidgetProxy;
class PDFModifiedDocument;
class PDFWidgetAnnotationManager;
class IDrawWidgetInputInterface;
class PDFPageContentScene;
class IDrawWidget
{
@@ -105,12 +106,17 @@ public:
void removeInputInterface(IDrawWidgetInputInterface* inputInterface);
void addInputInterface(IDrawWidgetInputInterface* inputInterface);
/// Returns true, if any scene is active
bool isAnySceneActive(PDFPageContentScene* sceneToSkip) const;
signals:
void sceneActivityChanged();
void pageRenderingErrorsChanged(pdf::PDFInteger pageIndex, int errorsCount);
private:
void onRenderingError(PDFInteger pageIndex, const QList<PDFRenderError>& errors);
void onPageImageChanged(bool all, const std::vector<PDFInteger>& pages);
void onSceneActiveStateChanged(bool);
const PDFCMSManager* m_cmsManager;
PDFToolManager* m_toolManager;
@@ -122,6 +128,7 @@ private:
PDFDrawWidgetProxy* m_proxy;
PageRenderingErrors m_pageRenderingErrors;
std::vector<IDrawWidgetInputInterface*> m_inputInterfaces;
std::vector<PDFPageContentScene*> m_scenes;
RendererEngine m_rendererEngine;
};

View File

@@ -870,6 +870,7 @@ void PDFPageContentScene::setActive(bool newIsActive)
}
Q_EMIT sceneChanged(false);
Q_EMIT sceneActiveStateChanged(newIsActive);
}
}

View File

@@ -643,6 +643,8 @@ signals:
/// Request to edit the elements
void editElementRequest(const std::set<PDFInteger>& elements);
void sceneActiveStateChanged(bool activated);
private:
struct MouseEventInfo