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.
remotes/origin/epub-qtextdoc
Fabio D'Urso 14 years ago
parent db9ced5ff4
commit 8d969a8dbf
  1. 19
      conf/widgetannottools.cpp
  2. 6
      ui/data/tools.xml
  3. 6
      ui/pageviewannotator.cpp

@ -259,6 +259,7 @@ QString NewAnnotToolDialog::toolXml() const
const QByteArray toolType = m_type->itemData( m_type->currentIndex() ).toByteArray(); const QByteArray toolType = m_type->itemData( m_type->currentIndex() ).toByteArray();
const QString color = m_stubann->style().color().name(); const QString color = m_stubann->style().color().name();
const double opacity = m_stubann->style().opacity(); const double opacity = m_stubann->style().opacity();
const double width = m_stubann->style().width();
if ( toolType == "note-linked" ) if ( toolType == "note-linked" )
{ {
@ -286,9 +287,9 @@ QString NewAnnotToolDialog::toolXml() const
Q_UNUSED( ia ); Q_UNUSED( ia );
return QString( "<tool type=\"ink\">" return QString( "<tool type=\"ink\">"
"<engine type=\"SmoothLine\" color=\"%1\">" "<engine type=\"SmoothLine\" color=\"%1\">"
"<annotation type=\"Ink\" color=\"%1\" width=\"2\" opacity=\"%2\" />" "<annotation type=\"Ink\" color=\"%1\" opacity=\"%2\" width=\"%3\" />"
"</engine>" "</engine>"
"</tool>").arg( color ).arg( opacity ); "</tool>").arg( color ).arg( opacity ).arg( width );
} }
else if ( toolType == "straight-line" ) else if ( toolType == "straight-line" )
{ {
@ -296,9 +297,9 @@ QString NewAnnotToolDialog::toolXml() const
Q_UNUSED( la ); Q_UNUSED( la );
return QString( "<tool type=\"straight-line\">" return QString( "<tool type=\"straight-line\">"
"<engine type=\"PolyLine\" color=\"%1\" points=\"2\">" "<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>" "</engine>"
"</tool>" ).arg( color ).arg( opacity ); "</tool>" ).arg( color ).arg( opacity ).arg( width );
} }
else if ( toolType == "polygon" ) else if ( toolType == "polygon" )
{ {
@ -306,9 +307,9 @@ QString NewAnnotToolDialog::toolXml() const
Q_UNUSED( la ); Q_UNUSED( la );
return QString( "<tool type=\"polygon\">" return QString( "<tool type=\"polygon\">"
"<engine type=\"PolyLine\" color=\"%1\" points=\"-1\">" "<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>" "</engine>"
"</tool>" ).arg( color ).arg( opacity ); "</tool>" ).arg( color ).arg( opacity ).arg( width );
} }
else if ( toolType == "text-markup" ) else if ( toolType == "text-markup" )
{ {
@ -346,11 +347,11 @@ QString NewAnnotToolDialog::toolXml() const
{ {
Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann ); Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann );
const bool isCircle = (ga->geometricalType() == Okular::GeomAnnotation::InscribedCircle); 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\">" "<engine type=\"PickPoint\" color=\"%1\" block=\"true\">"
"<annotation type=\"%4\" color=\"%1\" opacity=\"%2\" />" "<annotation type=\"%5\" color=\"%1\" opacity=\"%2\" width=\"%3\" />"
"</engine>" "</engine>"
"</tool>").arg( color ).arg( opacity ) "</tool>").arg( color ).arg( opacity ).arg( width )
.arg( isCircle ? "ellipse" : "rectangle" ) .arg( isCircle ? "ellipse" : "rectangle" )
.arg( isCircle ? "GeomCircle" : "GeomSquare" ); .arg( isCircle ? "GeomCircle" : "GeomSquare" );
} }

@ -48,14 +48,14 @@ Engine/Annotation Types [specific attributes]:
<tool id="5" name="Straight Yellow Line" type="straight-line"> <tool id="5" name="Straight Yellow Line" type="straight-line">
<tooltip>Straight Yellow Line</tooltip> <tooltip>Straight Yellow Line</tooltip>
<engine type="PolyLine" color="#FFE000" points="2"> <engine type="PolyLine" color="#FFE000" points="2">
<annotation type="Line" width="4" color="#FFE000" /> <annotation type="Line" width="1" color="#FFE000" />
</engine> </engine>
<shortcut>5</shortcut> <shortcut>5</shortcut>
</tool> </tool>
<tool id="6" name="Blue Polygon" type="polygon"> <tool id="6" name="Blue Polygon" type="polygon">
<tooltip>Draw a polygon (click on the first point to close it)</tooltip> <tooltip>Draw a polygon (click on the first point to close it)</tooltip>
<engine type="PolyLine" color="#007EEE" points="-1"> <engine type="PolyLine" color="#007EEE" points="-1">
<annotation type="Line" width="4" color="#007EEE" /> <annotation type="Line" width="1" color="#007EEE" />
</engine> </engine>
<shortcut>6</shortcut> <shortcut>6</shortcut>
</tool> </tool>
@ -76,7 +76,7 @@ Engine/Annotation Types [specific attributes]:
<tool id="9" name="Cyan Ellipse" type="ellipse"> <tool id="9" name="Cyan Ellipse" type="ellipse">
<tooltip>A cyan ellipse</tooltip> <tooltip>A cyan ellipse</tooltip>
<engine type="PickPoint" color="#00ffff" block="true"> <engine type="PickPoint" color="#00ffff" block="true">
<annotation type="GeomCircle" color="#00ffff" /> <annotation type="GeomCircle" width="5" color="#00ffff" />
</engine> </engine>
<shortcut>9</shortcut> <shortcut>9</shortcut>
</tool> </tool>

@ -238,7 +238,8 @@ class PickPointEngine : public AnnotatorEngine
ga->setGeometricalType( Okular::GeomAnnotation::InscribedSquare ); ga->setGeometricalType( Okular::GeomAnnotation::InscribedSquare );
else else
ga->setGeometricalType( Okular::GeomAnnotation::InscribedCircle ); ga->setGeometricalType( Okular::GeomAnnotation::InscribedCircle );
ga->style().setWidth( 5 ); if ( m_annotElement.hasAttribute( "width" ) )
ann->style().setWidth( m_annotElement.attribute( "width" ).toDouble() );
//set boundary //set boundary
rect.left = qMin( startpoint.x, point.x ); rect.left = qMin( startpoint.x, point.x );
rect.top = qMin( startpoint.y, point.y ); rect.top = qMin( startpoint.y, point.y );
@ -423,6 +424,9 @@ class PolyLineEngine : public AnnotatorEngine
if ( !ann ) if ( !ann )
return QList< Okular::Annotation* >(); return QList< Okular::Annotation* >();
if ( m_annotElement.hasAttribute( "width" ) )
ann->style().setWidth( m_annotElement.attribute( "width" ).toDouble() );
// set common attributes // set common attributes
ann->style().setColor( m_annotElement.hasAttribute( "color" ) ? ann->style().setColor( m_annotElement.hasAttribute( "color" ) ?
m_annotElement.attribute( "color" ) : m_engineColor ); m_annotElement.attribute( "color" ) : m_engineColor );

Loading…
Cancel
Save