mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 03:30:20 +00:00
Made Inplace annotations' alignment configurable
Note that PagePainter support for this property is currently broken: it only works at 100% zoom.
This commit is contained in:
parent
f52432aa57
commit
faaaeeb5c9
|
@ -357,6 +357,8 @@ QDomDocument EditAnnotToolDialog::toolXml() const
|
|||
engineElement.setAttribute( "block", "true" );
|
||||
annotationElement.setAttribute( "type", "FreeText" );
|
||||
annotationElement.setAttribute( "color", color );
|
||||
if ( ta->inplaceAlignment() != 0 )
|
||||
annotationElement.setAttribute( "align", ta->inplaceAlignment() );
|
||||
if ( ta->textFont() != QApplication::font() )
|
||||
annotationElement.setAttribute( "font", ta->textFont().toString() );
|
||||
}
|
||||
|
@ -599,6 +601,8 @@ void EditAnnotToolDialog::loadTool( const QDomElement &toolElement )
|
|||
{
|
||||
setToolType( "note-inline" );
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
if ( annotationElement.hasAttribute( "align" ) )
|
||||
ta->setInplaceAlignment( annotationElement.attribute( "align" ).toInt() );
|
||||
if ( annotationElement.hasAttribute( "font" ) )
|
||||
{
|
||||
QFont f;
|
||||
|
|
|
@ -271,15 +271,26 @@ QWidget * TextAnnotationWidget::createStyleWidget()
|
|||
}
|
||||
else if ( m_textAnn->textType() == Okular::TextAnnotation::InPlace )
|
||||
{
|
||||
QHBoxLayout * fontlay = new QHBoxLayout();
|
||||
QGridLayout * innerlay = new QGridLayout();
|
||||
lay->addLayout( innerlay );
|
||||
|
||||
QLabel * tmplabel = new QLabel( i18n( "Font:" ), widget );
|
||||
fontlay->addWidget( tmplabel );
|
||||
innerlay->addWidget( tmplabel, 0, 0 );
|
||||
m_fontReq = new KFontRequester( widget );
|
||||
fontlay->addWidget( m_fontReq );
|
||||
lay->addLayout( fontlay );
|
||||
innerlay->addWidget( m_fontReq, 0, 1 );
|
||||
m_fontReq->setFont( m_textAnn->textFont() );
|
||||
|
||||
tmplabel = new QLabel( i18n( "Align:" ), widget );
|
||||
innerlay->addWidget( tmplabel, 1, 0 );
|
||||
m_textAlign = new KComboBox( widget );
|
||||
innerlay->addWidget( m_textAlign, 1, 1 );
|
||||
m_textAlign->addItem( i18n("Left") );
|
||||
m_textAlign->addItem( i18n("Center") );
|
||||
m_textAlign->addItem( i18n("Right") );
|
||||
m_textAlign->setCurrentIndex( m_textAnn->inplaceAlignment() );
|
||||
|
||||
connect( m_fontReq, SIGNAL(fontSelected(QFont)), this, SIGNAL(dataChanged()) );
|
||||
connect( m_textAlign, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) );
|
||||
}
|
||||
|
||||
return widget;
|
||||
|
@ -295,6 +306,7 @@ void TextAnnotationWidget::applyChanges()
|
|||
else if ( m_textAnn->textType() == Okular::TextAnnotation::InPlace )
|
||||
{
|
||||
m_textAnn->setTextFont( m_fontReq->font() );
|
||||
m_textAnn->setInplaceAlignment( m_textAlign->currentIndex() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,6 +115,7 @@ private:
|
|||
Okular::TextAnnotation * m_textAnn;
|
||||
PixmapPreviewSelector * m_pixmapSelector;
|
||||
KFontRequester * m_fontReq;
|
||||
QComboBox * m_textAlign;
|
||||
};
|
||||
|
||||
class StampAnnotationWidget
|
||||
|
|
|
@ -167,6 +167,9 @@ class PickPointEngine : public AnnotatorEngine
|
|||
ann = ta;
|
||||
ta->setContents( note );
|
||||
ta->setTextType( Okular::TextAnnotation::InPlace );
|
||||
//set alignment
|
||||
if ( m_annotElement.hasAttribute( "align" ) )
|
||||
ta->setInplaceAlignment( m_annotElement.attribute( "align" ).toInt() );
|
||||
//set font
|
||||
if ( m_annotElement.hasAttribute( "font" ) )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue