Made polygon annotations' inner color configurable

remotes/origin/epub-qtextdoc
Fabio D'Urso 14 years ago
parent d07735b23d
commit 5397f99262
  1. 11
      conf/widgetannottools.cpp
  2. 77
      ui/annotationwidgets.cpp
  3. 2
      ui/annotationwidgets.h
  4. 6
      ui/pageviewannotator.cpp

@ -312,12 +312,17 @@ QString NewAnnotToolDialog::toolXml() const
else if ( toolType == "polygon" ) else if ( toolType == "polygon" )
{ {
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann ); Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
Q_UNUSED( la );
QString innerColor;
if ( la->lineInnerColor().isValid() )
innerColor = QString( "innerColor=\"%1\"" ).arg( la->lineInnerColor().name() );
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\" color=\"%1\" opacity=\"%2\" width=\"%3\" />" "<annotation type=\"Line\" color=\"%1\" opacity=\"%2\" width=\"%3\" %4 />"
"</engine>" "</engine>"
"</tool>" ).arg( color ).arg( opacity ).arg( width ); "</tool>" ).arg( color ).arg( opacity ).arg( width )
.arg( innerColor );
} }
else if ( toolType == "text-markup" ) else if ( toolType == "text-markup" )
{ {

@ -371,20 +371,20 @@ QWidget * LineAnnotationWidget::createStyleWidget()
lay->setMargin( 0 ); lay->setMargin( 0 );
if ( m_lineType == 0 ) if ( m_lineType == 0 )
{ {
QGroupBox * gb = new QGroupBox( widget ); QGroupBox * gb = new QGroupBox( widget );
lay->addWidget( gb ); lay->addWidget( gb );
gb->setTitle( i18n( "Line Extensions" ) ); gb->setTitle( i18n( "Line Extensions" ) );
QGridLayout * gridlay = new QGridLayout( gb ); QGridLayout * gridlay = new QGridLayout( gb );
QLabel * tmplabel = new QLabel( i18n( "Leader Line Length:" ), gb ); QLabel * tmplabel = new QLabel( i18n( "Leader Line Length:" ), gb );
gridlay->addWidget( tmplabel, 0, 0, Qt::AlignRight ); gridlay->addWidget( tmplabel, 0, 0, Qt::AlignRight );
m_spinLL = new QDoubleSpinBox( gb ); m_spinLL = new QDoubleSpinBox( gb );
gridlay->addWidget( m_spinLL, 0, 1 ); gridlay->addWidget( m_spinLL, 0, 1 );
tmplabel->setBuddy( m_spinLL ); tmplabel->setBuddy( m_spinLL );
tmplabel = new QLabel( i18n( "Leader Line Extensions Length:" ), gb ); tmplabel = new QLabel( i18n( "Leader Line Extensions Length:" ), gb );
gridlay->addWidget( tmplabel, 1, 0, Qt::AlignRight ); gridlay->addWidget( tmplabel, 1, 0, Qt::AlignRight );
m_spinLLE = new QDoubleSpinBox( gb ); m_spinLLE = new QDoubleSpinBox( gb );
gridlay->addWidget( m_spinLLE, 1, 1 ); gridlay->addWidget( m_spinLLE, 1, 1 );
tmplabel->setBuddy( m_spinLLE ); tmplabel->setBuddy( m_spinLLE );
} }
QGroupBox * gb2 = new QGroupBox( widget ); QGroupBox * gb2 = new QGroupBox( widget );
@ -397,20 +397,46 @@ QWidget * LineAnnotationWidget::createStyleWidget()
gridlay2->addWidget( m_spinSize, 0, 1 ); gridlay2->addWidget( m_spinSize, 0, 1 );
tmplabel2->setBuddy( m_spinSize ); tmplabel2->setBuddy( m_spinSize );
if ( m_lineType == 1 )
{
m_useColor = new QCheckBox( i18n( "Inner color:" ), gb2 );
gridlay2->addWidget( m_useColor, 1, 0 );
m_innerColor = new KColorButton( gb2 );
gridlay2->addWidget( m_innerColor, 1, 1 );
}
if ( m_lineType == 0 ) if ( m_lineType == 0 )
{ {
m_spinLL->setRange( -500, 500 ); m_spinLL->setRange( -500, 500 );
m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() ); m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() );
m_spinLLE->setRange( 0, 500 ); m_spinLLE->setRange( 0, 500 );
m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() ); m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() );
}
else if ( m_lineType == 1 )
{
m_innerColor->setColor( m_lineAnn->lineInnerColor() );
if ( m_lineAnn->lineInnerColor().isValid() )
{
m_useColor->setChecked( true );
}
else
{
m_innerColor->setEnabled( false );
}
} }
m_spinSize->setRange( 1, 100 ); m_spinSize->setRange( 1, 100 );
m_spinSize->setValue( m_lineAnn->style().width() ); m_spinSize->setValue( m_lineAnn->style().width() );
if ( m_lineType == 0 ) if ( m_lineType == 0 )
{ {
connect( m_spinLL, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); connect( m_spinLL, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) );
connect( m_spinLLE, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); connect( m_spinLLE, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) );
}
else if ( m_lineType == 1 )
{
connect( m_innerColor, SIGNAL(changed(QColor)), this, SIGNAL(dataChanged()) );
connect( m_useColor, SIGNAL(toggled(bool)), this, SIGNAL(dataChanged()) );
connect( m_useColor, SIGNAL(toggled(bool)), m_innerColor, SLOT(setEnabled(bool)) );
} }
connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) );
@ -425,6 +451,17 @@ void LineAnnotationWidget::applyChanges()
m_lineAnn->setLineLeadingForwardPoint( m_spinLL->value() ); m_lineAnn->setLineLeadingForwardPoint( m_spinLL->value() );
m_lineAnn->setLineLeadingBackwardPoint( m_spinLLE->value() ); m_lineAnn->setLineLeadingBackwardPoint( m_spinLLE->value() );
} }
else if ( m_lineType == 1 )
{
if ( !m_useColor->isChecked() )
{
m_lineAnn->setLineInnerColor( QColor() );
}
else
{
m_lineAnn->setLineInnerColor( m_innerColor->color() );
}
}
m_lineAnn->style().setWidth( m_spinSize->value() ); m_lineAnn->style().setWidth( m_spinSize->value() );
} }

@ -153,6 +153,8 @@ private:
int m_lineType; int m_lineType;
QDoubleSpinBox * m_spinLL; QDoubleSpinBox * m_spinLL;
QDoubleSpinBox * m_spinLLE; QDoubleSpinBox * m_spinLLE;
QCheckBox * m_useColor;
KColorButton * m_innerColor;
QDoubleSpinBox * m_spinSize; QDoubleSpinBox * m_spinSize;
}; };

@ -416,7 +416,11 @@ class PolyLineEngine : public AnnotatorEngine
la->setLinePoints( list ); la->setLinePoints( list );
if ( numofpoints == -1 ) if ( numofpoints == -1 )
{
la->setLineClosed( true ); la->setLineClosed( true );
if ( m_annotElement.hasAttribute( "innerColor" ) )
la->setLineInnerColor( QColor( m_annotElement.attribute( "innerColor" ) ) );
}
la->setBoundingRectangle( normRect ); la->setBoundingRectangle( normRect );
@ -1083,6 +1087,8 @@ QPixmap PageViewAnnotator::makeToolPixmap( const QDomElement &toolElement )
path.lineTo( 23, 14 ); path.lineTo( 23, 14 );
path.lineTo( 23, 20 ); path.lineTo( 23, 20 );
path.lineTo( 0, 20 ); path.lineTo( 0, 20 );
if ( innerColor.isValid() )
p.setBrush( innerColor );
p.setPen( QPen( engineColor, 1 ) ); p.setPen( QPen( engineColor, 1 ) );
p.drawPath( path ); p.drawPath( path );
} }

Loading…
Cancel
Save