mirror of
https://invent.kde.org/graphics/okular
synced 2024-11-05 18:34:53 +00:00
Okular Annotation: add line start/end style config only for Straight Line tool
Summary: “Inner Color” configuration of Polygon tool was overlapping with the line start/end styles intended for only Straight Line tool. Fix it. CCBUG: 381629 Test Plan: 1. Configure annotations 2. Create/Edit Polygon tool 3. Observe that no Line Start/End styles are visible 4. Create/Edit Straight Line tool 5. Observe that line start/end styles can be configured Reviewers: #okular, tobiasdeiminger Reviewed By: tobiasdeiminger Subscribers: tobiasdeiminger, okular-devel Tags: #okular Differential Revision: https://phabricator.kde.org/D21332
This commit is contained in:
parent
2083e763d0
commit
b1c30cd0ed
2 changed files with 52 additions and 50 deletions
|
@ -494,23 +494,12 @@ QWidget * LineAnnotationWidget::createStyleWidget()
|
|||
gridlay2->addWidget( m_spinSize, 0, 1 );
|
||||
tmplabel2->setBuddy( m_spinSize );
|
||||
|
||||
if ( m_lineType == 1 )
|
||||
if ( m_lineType == 1 ) //Polygon
|
||||
{
|
||||
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 )
|
||||
{
|
||||
m_spinLL->setRange( -500, 500 );
|
||||
m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() );
|
||||
m_spinLLE->setRange( 0, 500 );
|
||||
m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() );
|
||||
}
|
||||
else if ( m_lineType == 1 )
|
||||
{
|
||||
m_innerColor->setColor( m_lineAnn->lineInnerColor() );
|
||||
if ( m_lineAnn->lineInnerColor().isValid() )
|
||||
{
|
||||
|
@ -521,6 +510,44 @@ QWidget * LineAnnotationWidget::createStyleWidget()
|
|||
m_innerColor->setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_lineType == 0 ) //Straight line
|
||||
{
|
||||
m_spinLL->setRange( -500, 500 );
|
||||
m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() );
|
||||
m_spinLLE->setRange( 0, 500 );
|
||||
m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() );
|
||||
|
||||
//Line Term Styles
|
||||
QLabel * tmplabel3 = new QLabel( i18n( "Line Start:" ), widget );
|
||||
QLabel * tmplabel4 = new QLabel( i18n( "Line End:" ), widget );
|
||||
gridlay2->addWidget( tmplabel3, 1, 0, Qt::AlignRight );
|
||||
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 );
|
||||
|
||||
}
|
||||
|
||||
m_spinSize->setRange( 1, 100 );
|
||||
m_spinSize->setValue( m_lineAnn->style().width() );
|
||||
|
||||
|
@ -533,38 +560,10 @@ QWidget * LineAnnotationWidget::createStyleWidget()
|
|||
{
|
||||
connect( m_innerColor, &KColorButton::changed, this, &AnnotationWidget::dataChanged );
|
||||
connect( m_useColor, &QAbstractButton::toggled, this, &AnnotationWidget::dataChanged );
|
||||
connect(m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled);
|
||||
connect( m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled );
|
||||
}
|
||||
connect( m_spinSize, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &LineAnnotationWidget::dataChanged );
|
||||
|
||||
//Line Term Styles
|
||||
QLabel * tmplabel3 = new QLabel( i18n( "Line Start:" ), widget );
|
||||
QLabel * tmplabel4 = new QLabel( i18n( "Line End:" ), widget );
|
||||
gridlay2->addWidget( tmplabel3, 1, 0, Qt::AlignRight );
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -573,11 +572,15 @@ void LineAnnotationWidget::applyChanges()
|
|||
AnnotationWidget::applyChanges();
|
||||
if ( m_lineType == 0 )
|
||||
{
|
||||
Q_ASSERT(m_spinLL && m_spinLLE && m_startStyleCombo && m_endStyleCombo);
|
||||
m_lineAnn->setLineLeadingForwardPoint( m_spinLL->value() );
|
||||
m_lineAnn->setLineLeadingBackwardPoint( m_spinLLE->value() );
|
||||
m_lineAnn->setLineStartStyle( (Okular::LineAnnotation::TermStyle)m_startStyleCombo->currentIndex() );
|
||||
m_lineAnn->setLineEndStyle( (Okular::LineAnnotation::TermStyle)m_endStyleCombo->currentIndex() );
|
||||
}
|
||||
else if ( m_lineType == 1 )
|
||||
{
|
||||
Q_ASSERT( m_useColor && m_innerColor );
|
||||
if ( !m_useColor->isChecked() )
|
||||
{
|
||||
m_lineAnn->setLineInnerColor( QColor() );
|
||||
|
@ -587,9 +590,8 @@ void LineAnnotationWidget::applyChanges()
|
|||
m_lineAnn->setLineInnerColor( m_innerColor->color() );
|
||||
}
|
||||
}
|
||||
Q_ASSERT( m_spinSize );
|
||||
m_lineAnn->style().setWidth( m_spinSize->value() );
|
||||
m_lineAnn->setLineStartStyle( (Okular::LineAnnotation::TermStyle)m_startStyleCombo->currentIndex() );
|
||||
m_lineAnn->setLineEndStyle( (Okular::LineAnnotation::TermStyle)m_endStyleCombo->currentIndex() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -175,13 +175,13 @@ protected:
|
|||
private:
|
||||
Okular::LineAnnotation * m_lineAnn;
|
||||
int m_lineType;
|
||||
QDoubleSpinBox * m_spinLL;
|
||||
QDoubleSpinBox * m_spinLLE;
|
||||
QCheckBox * m_useColor;
|
||||
KColorButton * m_innerColor;
|
||||
QDoubleSpinBox * m_spinSize;
|
||||
QComboBox * m_startStyleCombo;
|
||||
QComboBox * m_endStyleCombo;
|
||||
QDoubleSpinBox * m_spinLL { nullptr };
|
||||
QDoubleSpinBox * m_spinLLE { nullptr };
|
||||
QCheckBox * m_useColor { nullptr };
|
||||
KColorButton * m_innerColor { nullptr };
|
||||
QDoubleSpinBox * m_spinSize { nullptr };
|
||||
QComboBox * m_startStyleCombo { nullptr };
|
||||
QComboBox * m_endStyleCombo { nullptr };
|
||||
};
|
||||
|
||||
class HighlightAnnotationWidget
|
||||
|
|
Loading…
Reference in a new issue