mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-28 19:28:38 +00:00
Draw an initial rectangle where to place the signature
This commit is contained in:
parent
b5117aff6c
commit
339ce239f5
3 changed files with 57 additions and 8 deletions
|
@ -4779,6 +4779,12 @@ void PageView::slotToggleSignature()
|
|||
{
|
||||
d->messageWindow->display(i18n("Draw a rectangle to insert the signature field"), QString(), PageViewMessage::Info, -1);
|
||||
|
||||
if (!d->annotator) {
|
||||
d->annotator = new PageViewAnnotator(this, d->document);
|
||||
}
|
||||
|
||||
d->annotator->setSignatureMode(true);
|
||||
|
||||
// force an update of the cursor
|
||||
updateCursor();
|
||||
Okular::Settings::self()->save();
|
||||
|
|
|
@ -295,18 +295,38 @@ public:
|
|||
return QList<Okular::Annotation *>() << ann;
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
bool clicked;
|
||||
bool m_block;
|
||||
double xscale, yscale;
|
||||
|
||||
private:
|
||||
Okular::NormalizedRect rect;
|
||||
Okular::NormalizedPoint startpoint;
|
||||
Okular::NormalizedPoint point;
|
||||
QPixmap pixmap;
|
||||
QString hoverIconName, iconName;
|
||||
int size;
|
||||
double xscale, yscale;
|
||||
double pagewidth, pageheight;
|
||||
bool center;
|
||||
bool m_block;
|
||||
};
|
||||
|
||||
class PickPointEngine2 : public PickPointEngine
|
||||
{
|
||||
public:
|
||||
PickPointEngine2(const QDomElement &engineElement)
|
||||
: PickPointEngine(engineElement)
|
||||
{
|
||||
clicked = false;
|
||||
m_block = true;
|
||||
xscale = 1.0;
|
||||
yscale = 1.0;
|
||||
}
|
||||
|
||||
QRect event(EventType type, Button button, Modifiers modifiers, double nX, double nY, double xScale, double yScale, const Okular::Page *page) override
|
||||
{
|
||||
return PickPointEngine::event(type, button, modifiers, nX, nY, xScale, yScale, page);
|
||||
}
|
||||
};
|
||||
|
||||
/** @short PolyLineEngine */
|
||||
|
@ -776,9 +796,19 @@ PageViewAnnotator::~PageViewAnnotator()
|
|||
delete m_quickToolsDefinition;
|
||||
}
|
||||
|
||||
void PageViewAnnotator::setSignatureMode(bool sigMode)
|
||||
{
|
||||
m_signatureMode = sigMode;
|
||||
}
|
||||
|
||||
bool PageViewAnnotator::signatureMode() const
|
||||
{
|
||||
return m_signatureMode;
|
||||
}
|
||||
|
||||
bool PageViewAnnotator::active() const
|
||||
{
|
||||
return m_engine != nullptr;
|
||||
return (m_engine != nullptr) || m_signatureMode;
|
||||
}
|
||||
|
||||
bool PageViewAnnotator::annotating() const
|
||||
|
@ -788,7 +818,7 @@ bool PageViewAnnotator::annotating() const
|
|||
|
||||
QCursor PageViewAnnotator::cursor() const
|
||||
{
|
||||
return m_engine->cursor();
|
||||
return m_engine ? m_engine->cursor() : Qt::CrossCursor;
|
||||
}
|
||||
|
||||
QRect PageViewAnnotator::performRouteMouseOrTabletEvent(const AnnotatorEngine::EventType eventType, const AnnotatorEngine::Button button, const AnnotatorEngine::Modifiers modifiers, const QPointF pos, PageViewItem *item)
|
||||
|
@ -810,6 +840,13 @@ QRect PageViewAnnotator::performRouteMouseOrTabletEvent(const AnnotatorEngine::E
|
|||
return QRect();
|
||||
}
|
||||
|
||||
if (signatureMode() && eventType == AnnotatorEngine::Press) {
|
||||
QDomElement elem;
|
||||
elem.setTagName("engine");
|
||||
elem.setAttribute("block", 1);
|
||||
m_engine = new PickPointEngine2(elem);
|
||||
}
|
||||
|
||||
// 1. lock engine to current item
|
||||
if (!m_lockedItem && eventType == AnnotatorEngine::Press) {
|
||||
m_lockedItem = item;
|
||||
|
@ -1074,9 +1111,11 @@ void PageViewAnnotator::selectStampTool(const QString &stampSymbol)
|
|||
|
||||
void PageViewAnnotator::detachAnnotation()
|
||||
{
|
||||
selectTool(-1, ShowTip::No);
|
||||
if (m_actionHandler)
|
||||
m_actionHandler->deselectAllAnnotationActions();
|
||||
if (!signatureMode()) {
|
||||
selectTool(-1, ShowTip::No);
|
||||
if (m_actionHandler)
|
||||
m_actionHandler->deselectAllAnnotationActions();
|
||||
}
|
||||
}
|
||||
|
||||
QString PageViewAnnotator::defaultToolName(const QDomElement &toolElement)
|
||||
|
|
|
@ -70,6 +70,9 @@ public:
|
|||
// @return Are we currently annotating (using the selected tool)?
|
||||
bool annotating() const;
|
||||
|
||||
void setSignatureMode(bool forced);
|
||||
bool signatureMode() const;
|
||||
|
||||
// returns the preferred cursor for the current tool. call this only
|
||||
// if active() == true
|
||||
QCursor cursor() const;
|
||||
|
@ -156,6 +159,7 @@ private:
|
|||
AnnotationTools *m_quickToolsDefinition;
|
||||
bool m_continuousMode;
|
||||
bool m_constrainRatioAndAngle;
|
||||
bool m_signatureMode;
|
||||
|
||||
// creation related variables
|
||||
int m_lastToolId;
|
||||
|
|
Loading…
Reference in a new issue