mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 18:35:37 +00:00
Add a very simple configuration widget for caret annotations.
svn path=/trunk/KDE/kdegraphics/okular/; revision=800059
This commit is contained in:
parent
8a3dda1142
commit
e6a93e2f38
|
@ -139,6 +139,9 @@ AnnotationWidget * AnnotationWidgetFactory::widgetFor( Okular::Annotation * ann
|
|||
case Okular::Annotation::AFileAttachment:
|
||||
return new FileAttachmentAnnotationWidget( ann );
|
||||
break;
|
||||
case Okular::Annotation::ACaret:
|
||||
return new CaretAnnotationWidget( ann );
|
||||
break;
|
||||
// shut up gcc
|
||||
default:
|
||||
;
|
||||
|
@ -557,4 +560,60 @@ void FileAttachmentAnnotationWidget::applyChanges()
|
|||
}
|
||||
|
||||
|
||||
|
||||
static QString caretSymbolToIcon( Okular::CaretAnnotation::CaretSymbol symbol )
|
||||
{
|
||||
switch ( symbol )
|
||||
{
|
||||
case Okular::CaretAnnotation::None:
|
||||
return QString::fromLatin1( "caret-none" );
|
||||
case Okular::CaretAnnotation::P:
|
||||
return QString::fromLatin1( "caret-p" );
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
static Okular::CaretAnnotation::CaretSymbol caretSymbolFromIcon( const QString &icon )
|
||||
{
|
||||
if ( icon == QLatin1String( "caret-none" ) )
|
||||
return Okular::CaretAnnotation::None;
|
||||
else if ( icon == QLatin1String( "caret-p" ) )
|
||||
return Okular::CaretAnnotation::P;
|
||||
return Okular::CaretAnnotation::None;
|
||||
}
|
||||
|
||||
CaretAnnotationWidget::CaretAnnotationWidget( Okular::Annotation * ann )
|
||||
: AnnotationWidget( ann ), m_pixmapSelector( 0 )
|
||||
{
|
||||
m_caretAnn = static_cast< Okular::CaretAnnotation * >( ann );
|
||||
}
|
||||
|
||||
QWidget * CaretAnnotationWidget::createStyleWidget()
|
||||
{
|
||||
QWidget * widget = new QWidget();
|
||||
QVBoxLayout * lay = new QVBoxLayout( widget );
|
||||
lay->setMargin( 0 );
|
||||
QGroupBox * gb = new QGroupBox( widget );
|
||||
lay->addWidget( gb );
|
||||
gb->setTitle( i18n( "Caret Symbol" ) );
|
||||
QHBoxLayout * gblay = new QHBoxLayout( gb );
|
||||
m_pixmapSelector = new PixmapPreviewSelector( gb );
|
||||
gblay->addWidget( m_pixmapSelector );
|
||||
|
||||
m_pixmapSelector->addItem( i18nc( "Symbol for caret annotations", "None" ), "caret-none" );
|
||||
m_pixmapSelector->addItem( i18nc( "Symbol for caret annotations", "P" ), "caret-p" );
|
||||
m_pixmapSelector->setIcon( caretSymbolToIcon( m_caretAnn->caretSymbol() ) );
|
||||
|
||||
connect( m_pixmapSelector, SIGNAL( iconChanged( const QString& ) ), this, SIGNAL( dataChanged() ) );
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
void CaretAnnotationWidget::applyChanges()
|
||||
{
|
||||
m_caretAnn->setCaretSymbol( caretSymbolFromIcon( m_pixmapSelector->icon() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "annotationwidgets.moc"
|
||||
|
|
|
@ -210,4 +210,22 @@ private:
|
|||
PixmapPreviewSelector * m_pixmapSelector;
|
||||
};
|
||||
|
||||
class CaretAnnotationWidget
|
||||
: public AnnotationWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CaretAnnotationWidget( Okular::Annotation * ann );
|
||||
|
||||
virtual void applyChanges();
|
||||
|
||||
protected:
|
||||
virtual QWidget * createStyleWidget();
|
||||
|
||||
private:
|
||||
Okular::CaretAnnotation * m_caretAnn;
|
||||
PixmapPreviewSelector * m_pixmapSelector;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue