From db2dcdade399b374b7aff1eee89748c5227f7359 Mon Sep 17 00:00:00 2001 From: Rajeesh K Nambiar Date: Tue, 7 May 2019 10:56:12 +0200 Subject: [PATCH] Okular Annotation: add support for line ending style for Straight Line tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- conf/editannottooldialog.cpp | 3 +++ ui/annotationwidgets.cpp | 24 ++++++++++++++++++++++++ ui/annotationwidgets.h | 1 + ui/pageviewannotator.cpp | 2 ++ 4 files changed, 30 insertions(+) diff --git a/conf/editannottooldialog.cpp b/conf/editannottooldialog.cpp index 63f9ae9ee..b9eb8adc0 100644 --- a/conf/editannottooldialog.cpp +++ b/conf/editannottooldialog.cpp @@ -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") ) { diff --git a/ui/annotationwidgets.cpp b/ui/annotationwidgets.cpp index 619f983f0..e20193fd9 100644 --- a/ui/annotationwidgets.cpp +++ b/ui/annotationwidgets.cpp @@ -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()); } diff --git a/ui/annotationwidgets.h b/ui/annotationwidgets.h index 0f8f76fa0..155e73c27 100644 --- a/ui/annotationwidgets.h +++ b/ui/annotationwidgets.h @@ -180,6 +180,7 @@ private: QCheckBox * m_useColor; KColorButton * m_innerColor; QDoubleSpinBox * m_spinSize; + QComboBox * m_termStyleCombo; }; class HighlightAnnotationWidget diff --git a/ui/pageviewannotator.cpp b/ui/pageviewannotator.cpp index 4faa16649..729674bde 100644 --- a/ui/pageviewannotator.cpp +++ b/ui/pageviewannotator.cpp @@ -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 );