Commit db2dcdad authored by Rajeesh K V's avatar Rajeesh K V Committed by Oliver Sander

Okular Annotation: add support for line ending style for Straight Line tool

Summary:
Poppler and Okular already have support for specifying Line End style (`TermStyle`) for the Straight Line tool. Expose the functionality in configuration and hook up the correct slots.

Configure annotations (before):
{F6788150}

Configure annotations (after):
{F6788151}

Straight Line tool with Open Arrow end in action:
{F6788153}

Test Plan:
1. Open a PDF in Okular
2. Enable Review
3. Right click on Review toolbar and Configure annotations
4. Create (or edit existing) Straight Line tool
5. Set the ‘Line End’ option on Style and Apply
6. Use the Straight Line tool to draw a line and check the line ending style.

Reviewers: #okular, #vdg, sander, ngraham

Reviewed By: #vdg, sander, ngraham

Subscribers: pino, sander, davidhurka, tobiasdeiminger, ngraham, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D20760
parent 43cf8c8a
......@@ -189,6 +189,7 @@ QDomDocument EditAnnotToolDialog::toolXml() const
annotationElement.setAttribute( QStringLiteral("leadFwd"), QString::number( la->lineLeadingForwardPoint() ) );
annotationElement.setAttribute( QStringLiteral("leadBack"), QString::number( la->lineLeadingBackwardPoint() ) );
}
annotationElement.setAttribute( QStringLiteral("endStyle"), QString::number( la->lineEndStyle() ));
}
else if ( toolType == ToolPolygon )
{
......@@ -484,6 +485,8 @@ void EditAnnotToolDialog::loadTool( const QDomElement &toolElement )
la->setLineLeadingForwardPoint( annotationElement.attribute( QStringLiteral("leadFwd") ).toDouble() );
if ( annotationElement.hasAttribute( QStringLiteral("leadBack") ) )
la->setLineLeadingBackwardPoint( annotationElement.attribute( QStringLiteral("leadBack") ).toDouble() );
if ( annotationElement.hasAttribute( QStringLiteral("endStyle") ) )
la->setLineEndStyle( (Okular::LineAnnotation::TermStyle)annotationElement.attribute( QStringLiteral("endStyle") ).toInt() );
}
else if ( annotType == QLatin1String("strikeout") )
{
......
......@@ -537,6 +537,29 @@ QWidget * LineAnnotationWidget::createStyleWidget()
}
connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) );
//Line Term Styles
QLabel * tmplabel3 = new QLabel( i18n( "Line End:" ), widget );
gridlay2->addWidget( tmplabel3, 1, 0, Qt::AlignRight );
m_termStyleCombo = new KComboBox( widget );
tmplabel3->setBuddy( m_termStyleCombo );
gridlay2->addWidget( m_termStyleCombo );
tmplabel3->setToolTip( i18n("Only for PDF documents"));
m_termStyleCombo->setToolTip( i18n("Only for PDF documents"));
m_termStyleCombo->addItem( i18n( "Square" ) );
m_termStyleCombo->addItem( i18n( "Circle" ) );
m_termStyleCombo->addItem( i18n( "Diamond" ) );
m_termStyleCombo->addItem( i18n( "Open Arrow" ) );
m_termStyleCombo->addItem( i18n( "Closed Arrow" ) );
m_termStyleCombo->addItem( i18n( "None" ) );
m_termStyleCombo->addItem( i18n( "Butt" ) );
m_termStyleCombo->addItem( i18n( "Right Open Arrow" ) );
m_termStyleCombo->addItem( i18n( "Right Closed Arrow" ) );
m_termStyleCombo->addItem( i18n( "Slash" ) );
m_termStyleCombo->setCurrentIndex( m_lineAnn->lineEndStyle() );
connect( m_termStyleCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) );
return widget;
}
......@@ -560,6 +583,7 @@ void LineAnnotationWidget::applyChanges()
}
}
m_lineAnn->style().setWidth( m_spinSize->value() );
m_lineAnn->setLineEndStyle( (Okular::LineAnnotation::TermStyle)m_termStyleCombo->currentIndex());
}
......
......@@ -180,6 +180,7 @@ private:
QCheckBox * m_useColor;
KColorButton * m_innerColor;
QDoubleSpinBox * m_spinSize;
QComboBox * m_termStyleCombo;
};
class HighlightAnnotationWidget
......
......@@ -463,6 +463,8 @@ class PolyLineEngine : public AnnotatorEngine
if ( m_annotElement.hasAttribute( QStringLiteral("leadBack") ) )
la->setLineLeadingBackwardPoint( m_annotElement.attribute( QStringLiteral("leadBack") ).toDouble() );
}
if ( m_annotElement.hasAttribute( QStringLiteral("endStyle") ) )
la->setLineEndStyle( (Okular::LineAnnotation::TermStyle)m_annotElement.attribute( QStringLiteral("endStyle") ).toInt() );
la->setBoundingRectangle( normRect );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment