Commit 59a86c3f authored by Rajeesh K V's avatar Rajeesh K V Committed by Tobias Deiminger

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

Summary: Similar to the line ending style, add support for line start style for the Straight Line annotation tool

Test Plan:
1. Go to Configure annotations
2. Create (or edit existing) Straight Line tool
3. Set the ‘Line Start’ option on Style and Apply
4. Use the Straight Line tool to draw a line and check the line starting style.

Reviewers: #okular, tobiasdeiminger

Reviewed By: tobiasdeiminger

Subscribers: ngraham, tobiasdeiminger, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D21238
parent 5c5e5fce
......@@ -189,7 +189,8 @@ 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() ));
annotationElement.setAttribute( QStringLiteral("startStyle"), QString::number( la->lineStartStyle() ) );
annotationElement.setAttribute( QStringLiteral("endStyle"), QString::number( la->lineEndStyle() ) );
}
else if ( toolType == ToolPolygon )
{
......@@ -485,6 +486,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("startStyle") ) )
la->setLineStartStyle( (Okular::LineAnnotation::TermStyle)annotationElement.attribute( QStringLiteral("startStyle") ).toInt() );
if ( annotationElement.hasAttribute( QStringLiteral("endStyle") ) )
la->setLineEndStyle( (Okular::LineAnnotation::TermStyle)annotationElement.attribute( QStringLiteral("endStyle") ).toInt() );
}
......
......@@ -538,27 +538,32 @@ QWidget * LineAnnotationWidget::createStyleWidget()
connect( m_spinSize, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &LineAnnotationWidget::dataChanged );
//Line Term Styles
QLabel * tmplabel3 = new QLabel( i18n( "Line End:" ), widget );
QLabel * tmplabel3 = new QLabel( i18n( "Line Start:" ), widget );
QLabel * tmplabel4 = 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, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged );
gridlay2->addWidget( tmplabel4, 2, 0, Qt::AlignRight );
m_startStyleCombo = new QComboBox( widget );
m_endStyleCombo = new QComboBox( widget );
tmplabel3->setBuddy( m_startStyleCombo );
tmplabel4->setBuddy( m_endStyleCombo );
gridlay2->addWidget( m_startStyleCombo, 1, 1, Qt::AlignLeft );
gridlay2->addWidget( m_endStyleCombo, 2, 1, Qt::AlignLeft );
tmplabel3->setToolTip( i18n("Only for PDF documents") );
tmplabel4->setToolTip( i18n("Only for PDF documents") );
m_startStyleCombo->setToolTip( i18n("Only for PDF documents"));
m_endStyleCombo->setToolTip( i18n("Only for PDF documents"));
for ( const QString &i: { i18n( " Square" ), i18n( " Circle" ), i18n( " Diamond" ), i18n( " Open Arrow" ), i18n( " Closed Arrow" ),
i18n( " None" ), i18n( " Butt" ), i18n( " Right Open Arrow" ), i18n( " Right Closed Arrow" ), i18n( "Slash" ) } )
{
m_startStyleCombo->addItem(i);
m_endStyleCombo->addItem(i);
}
m_startStyleCombo->setCurrentIndex( m_lineAnn->lineStartStyle() );
m_endStyleCombo->setCurrentIndex( m_lineAnn->lineEndStyle() );
connect( m_startStyleCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged );
connect( m_endStyleCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged );
return widget;
}
......@@ -583,7 +588,8 @@ void LineAnnotationWidget::applyChanges()
}
}
m_lineAnn->style().setWidth( m_spinSize->value() );
m_lineAnn->setLineEndStyle( (Okular::LineAnnotation::TermStyle)m_termStyleCombo->currentIndex());
m_lineAnn->setLineStartStyle( (Okular::LineAnnotation::TermStyle)m_startStyleCombo->currentIndex() );
m_lineAnn->setLineEndStyle( (Okular::LineAnnotation::TermStyle)m_endStyleCombo->currentIndex() );
}
......
......@@ -180,7 +180,8 @@ private:
QCheckBox * m_useColor;
KColorButton * m_innerColor;
QDoubleSpinBox * m_spinSize;
QComboBox * m_termStyleCombo;
QComboBox * m_startStyleCombo;
QComboBox * m_endStyleCombo;
};
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("startStyle") ) )
la->setLineStartStyle( (Okular::LineAnnotation::TermStyle)m_annotElement.attribute( QStringLiteral("startStyle") ).toInt() );
if ( m_annotElement.hasAttribute( QStringLiteral("endStyle") ) )
la->setLineEndStyle( (Okular::LineAnnotation::TermStyle)m_annotElement.attribute( QStringLiteral("endStyle") ).toInt() );
......
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