mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
Made line width configurable in Ink, Line, Polygon, Square and Circle annotation tools
Note that previously the width attrubute was ignored by the PolyLine engine and it always set width=1, that's why I had to change the default value in tools.xml.
This commit is contained in:
parent
db9ced5ff4
commit
8d969a8dbf
|
@ -259,6 +259,7 @@ QString NewAnnotToolDialog::toolXml() const
|
|||
const QByteArray toolType = m_type->itemData( m_type->currentIndex() ).toByteArray();
|
||||
const QString color = m_stubann->style().color().name();
|
||||
const double opacity = m_stubann->style().opacity();
|
||||
const double width = m_stubann->style().width();
|
||||
|
||||
if ( toolType == "note-linked" )
|
||||
{
|
||||
|
@ -286,9 +287,9 @@ QString NewAnnotToolDialog::toolXml() const
|
|||
Q_UNUSED( ia );
|
||||
return QString( "<tool type=\"ink\">"
|
||||
"<engine type=\"SmoothLine\" color=\"%1\">"
|
||||
"<annotation type=\"Ink\" color=\"%1\" width=\"2\" opacity=\"%2\" />"
|
||||
"<annotation type=\"Ink\" color=\"%1\" opacity=\"%2\" width=\"%3\" />"
|
||||
"</engine>"
|
||||
"</tool>").arg( color ).arg( opacity );
|
||||
"</tool>").arg( color ).arg( opacity ).arg( width );
|
||||
}
|
||||
else if ( toolType == "straight-line" )
|
||||
{
|
||||
|
@ -296,9 +297,9 @@ QString NewAnnotToolDialog::toolXml() const
|
|||
Q_UNUSED( la );
|
||||
return QString( "<tool type=\"straight-line\">"
|
||||
"<engine type=\"PolyLine\" color=\"%1\" points=\"2\">"
|
||||
"<annotation type=\"Line\" width=\"4\" color=\"%1\" opacity=\"%2\" />"
|
||||
"<annotation type=\"Line\" color=\"%1\" opacity=\"%2\" width=\"%3\" />"
|
||||
"</engine>"
|
||||
"</tool>" ).arg( color ).arg( opacity );
|
||||
"</tool>" ).arg( color ).arg( opacity ).arg( width );
|
||||
}
|
||||
else if ( toolType == "polygon" )
|
||||
{
|
||||
|
@ -306,9 +307,9 @@ QString NewAnnotToolDialog::toolXml() const
|
|||
Q_UNUSED( la );
|
||||
return QString( "<tool type=\"polygon\">"
|
||||
"<engine type=\"PolyLine\" color=\"%1\" points=\"-1\">"
|
||||
"<annotation type=\"Line\" width=\"4\" color=\"%1\" opacity=\"%2\" />"
|
||||
"<annotation type=\"Line\" color=\"%1\" opacity=\"%2\" width=\"%3\" />"
|
||||
"</engine>"
|
||||
"</tool>" ).arg( color ).arg( opacity );
|
||||
"</tool>" ).arg( color ).arg( opacity ).arg( width );
|
||||
}
|
||||
else if ( toolType == "text-markup" )
|
||||
{
|
||||
|
@ -346,11 +347,11 @@ QString NewAnnotToolDialog::toolXml() const
|
|||
{
|
||||
Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann );
|
||||
const bool isCircle = (ga->geometricalType() == Okular::GeomAnnotation::InscribedCircle);
|
||||
return QString( "<tool type=\"%3\">"
|
||||
return QString( "<tool type=\"%4\">"
|
||||
"<engine type=\"PickPoint\" color=\"%1\" block=\"true\">"
|
||||
"<annotation type=\"%4\" color=\"%1\" opacity=\"%2\" />"
|
||||
"<annotation type=\"%5\" color=\"%1\" opacity=\"%2\" width=\"%3\" />"
|
||||
"</engine>"
|
||||
"</tool>").arg( color ).arg( opacity )
|
||||
"</tool>").arg( color ).arg( opacity ).arg( width )
|
||||
.arg( isCircle ? "ellipse" : "rectangle" )
|
||||
.arg( isCircle ? "GeomCircle" : "GeomSquare" );
|
||||
}
|
||||
|
|
|
@ -48,14 +48,14 @@ Engine/Annotation Types [specific attributes]:
|
|||
<tool id="5" name="Straight Yellow Line" type="straight-line">
|
||||
<tooltip>Straight Yellow Line</tooltip>
|
||||
<engine type="PolyLine" color="#FFE000" points="2">
|
||||
<annotation type="Line" width="4" color="#FFE000" />
|
||||
<annotation type="Line" width="1" color="#FFE000" />
|
||||
</engine>
|
||||
<shortcut>5</shortcut>
|
||||
</tool>
|
||||
<tool id="6" name="Blue Polygon" type="polygon">
|
||||
<tooltip>Draw a polygon (click on the first point to close it)</tooltip>
|
||||
<engine type="PolyLine" color="#007EEE" points="-1">
|
||||
<annotation type="Line" width="4" color="#007EEE" />
|
||||
<annotation type="Line" width="1" color="#007EEE" />
|
||||
</engine>
|
||||
<shortcut>6</shortcut>
|
||||
</tool>
|
||||
|
@ -76,7 +76,7 @@ Engine/Annotation Types [specific attributes]:
|
|||
<tool id="9" name="Cyan Ellipse" type="ellipse">
|
||||
<tooltip>A cyan ellipse</tooltip>
|
||||
<engine type="PickPoint" color="#00ffff" block="true">
|
||||
<annotation type="GeomCircle" color="#00ffff" />
|
||||
<annotation type="GeomCircle" width="5" color="#00ffff" />
|
||||
</engine>
|
||||
<shortcut>9</shortcut>
|
||||
</tool>
|
||||
|
|
|
@ -238,7 +238,8 @@ class PickPointEngine : public AnnotatorEngine
|
|||
ga->setGeometricalType( Okular::GeomAnnotation::InscribedSquare );
|
||||
else
|
||||
ga->setGeometricalType( Okular::GeomAnnotation::InscribedCircle );
|
||||
ga->style().setWidth( 5 );
|
||||
if ( m_annotElement.hasAttribute( "width" ) )
|
||||
ann->style().setWidth( m_annotElement.attribute( "width" ).toDouble() );
|
||||
//set boundary
|
||||
rect.left = qMin( startpoint.x, point.x );
|
||||
rect.top = qMin( startpoint.y, point.y );
|
||||
|
@ -423,6 +424,9 @@ class PolyLineEngine : public AnnotatorEngine
|
|||
if ( !ann )
|
||||
return QList< Okular::Annotation* >();
|
||||
|
||||
if ( m_annotElement.hasAttribute( "width" ) )
|
||||
ann->style().setWidth( m_annotElement.attribute( "width" ).toDouble() );
|
||||
|
||||
// set common attributes
|
||||
ann->style().setColor( m_annotElement.hasAttribute( "color" ) ?
|
||||
m_annotElement.attribute( "color" ) : m_engineColor );
|
||||
|
|
Loading…
Reference in a new issue