2006-09-12 20:21:34 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2006 by Pino Toscano <pino@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2007-04-19 18:30:20 +00:00
|
|
|
#include "annotationwidgets.h"
|
|
|
|
|
2006-09-12 20:21:34 +00:00
|
|
|
// qt/kde includes
|
2006-11-19 00:46:01 +00:00
|
|
|
#include <qcheckbox.h>
|
2006-09-12 20:21:34 +00:00
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlayout.h>
|
2006-09-16 14:58:32 +00:00
|
|
|
#include <qspinbox.h>
|
2006-09-14 10:36:15 +00:00
|
|
|
#include <qvariant.h>
|
2006-11-19 00:46:01 +00:00
|
|
|
#include <kcolorbutton.h>
|
2008-01-12 19:06:46 +00:00
|
|
|
#include <kcombobox.h>
|
2006-12-23 18:37:04 +00:00
|
|
|
#include <kfontrequester.h>
|
2008-04-18 21:37:41 +00:00
|
|
|
#include <kicon.h>
|
2006-09-12 20:21:34 +00:00
|
|
|
#include <kiconloader.h>
|
|
|
|
#include <klocale.h>
|
2006-09-14 10:36:15 +00:00
|
|
|
#include <kdebug.h>
|
2006-09-12 20:21:34 +00:00
|
|
|
|
2008-04-18 21:37:41 +00:00
|
|
|
#include "core/document.h"
|
2007-12-24 15:02:32 +00:00
|
|
|
#include "guiutils.h"
|
|
|
|
|
2008-04-18 21:37:41 +00:00
|
|
|
#define FILEATTACH_ICONSIZE 48
|
|
|
|
|
2006-09-13 17:28:32 +00:00
|
|
|
PixmapPreviewSelector::PixmapPreviewSelector( QWidget * parent )
|
|
|
|
: QWidget( parent )
|
|
|
|
{
|
|
|
|
QHBoxLayout * mainlay = new QHBoxLayout( this );
|
|
|
|
mainlay->setMargin( 0 );
|
2008-01-12 19:06:46 +00:00
|
|
|
m_comboItems = new KComboBox( this );
|
2006-09-13 17:28:32 +00:00
|
|
|
mainlay->addWidget( m_comboItems );
|
|
|
|
m_iconLabel = new QLabel( this );
|
|
|
|
mainlay->addWidget( m_iconLabel );
|
|
|
|
m_iconLabel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
|
|
|
m_iconLabel->setAlignment( Qt::AlignCenter );
|
|
|
|
m_iconLabel->setFrameStyle( QFrame::StyledPanel );
|
|
|
|
setPreviewSize( 32 );
|
|
|
|
|
|
|
|
connect( m_comboItems, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( iconComboChanged( const QString& ) ) );
|
2007-09-04 18:21:33 +00:00
|
|
|
connect( m_comboItems, SIGNAL( editTextChanged( const QString& ) ), this, SLOT( iconComboChanged( const QString& ) ) );
|
2006-09-13 17:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PixmapPreviewSelector::~PixmapPreviewSelector()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void PixmapPreviewSelector::setIcon( const QString& icon )
|
|
|
|
{
|
2006-09-14 10:36:15 +00:00
|
|
|
int id = m_comboItems->findData( QVariant( icon ), Qt::UserRole, Qt::MatchFixedString );
|
2007-11-13 22:32:59 +00:00
|
|
|
if ( id == -1 )
|
2006-09-14 10:36:15 +00:00
|
|
|
id = m_comboItems->findText( icon, Qt::MatchFixedString );
|
2006-09-13 17:28:32 +00:00
|
|
|
if ( id > -1 )
|
|
|
|
{
|
|
|
|
m_comboItems->setCurrentIndex( id );
|
|
|
|
}
|
2007-09-04 18:21:33 +00:00
|
|
|
else if ( m_comboItems->isEditable() )
|
|
|
|
{
|
|
|
|
m_comboItems->addItem( icon, QVariant( icon ) );
|
|
|
|
m_comboItems->setCurrentIndex( m_comboItems->findText( icon, Qt::MatchFixedString ) );
|
|
|
|
}
|
2006-09-13 17:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString PixmapPreviewSelector::icon() const
|
|
|
|
{
|
|
|
|
return m_icon;
|
|
|
|
}
|
|
|
|
|
2006-09-14 10:36:15 +00:00
|
|
|
void PixmapPreviewSelector::addItem( const QString& item, const QString& id )
|
2006-09-13 17:28:32 +00:00
|
|
|
{
|
2006-09-14 10:36:15 +00:00
|
|
|
m_comboItems->addItem( item, QVariant( id ) );
|
2006-09-13 17:28:32 +00:00
|
|
|
setIcon( m_icon );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PixmapPreviewSelector::setPreviewSize( int size )
|
|
|
|
{
|
|
|
|
m_previewSize = size;
|
|
|
|
m_iconLabel->setFixedSize( m_previewSize + 8, m_previewSize + 8 );
|
|
|
|
iconComboChanged( m_icon );
|
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapPreviewSelector::previewSize() const
|
|
|
|
{
|
|
|
|
return m_previewSize;
|
|
|
|
}
|
|
|
|
|
2007-09-04 18:21:33 +00:00
|
|
|
void PixmapPreviewSelector::setEditable( bool editable )
|
|
|
|
{
|
|
|
|
m_comboItems->setEditable( editable );
|
|
|
|
}
|
|
|
|
|
2006-09-13 17:28:32 +00:00
|
|
|
void PixmapPreviewSelector::iconComboChanged( const QString& icon )
|
|
|
|
{
|
2006-09-14 10:36:15 +00:00
|
|
|
int id = m_comboItems->findText( icon, Qt::MatchFixedString );
|
2007-09-04 18:21:33 +00:00
|
|
|
if ( id >= 0 )
|
|
|
|
{
|
|
|
|
m_icon = m_comboItems->itemData( id ).toString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_icon = icon;
|
|
|
|
}
|
2006-09-14 10:36:15 +00:00
|
|
|
|
2008-09-19 20:21:57 +00:00
|
|
|
QPixmap pixmap = GuiUtils::loadStamp( m_icon, QSize( m_previewSize, m_previewSize ) );
|
2006-09-13 17:28:32 +00:00
|
|
|
m_iconLabel->setPixmap( pixmap );
|
2007-09-04 18:21:33 +00:00
|
|
|
|
|
|
|
emit iconChanged( m_icon );
|
2006-09-13 17:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
AnnotationWidget * AnnotationWidgetFactory::widgetFor( Okular::Annotation * ann )
|
2006-09-12 20:21:34 +00:00
|
|
|
{
|
|
|
|
switch ( ann->subType() )
|
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::AStamp:
|
2006-09-12 20:21:34 +00:00
|
|
|
return new StampAnnotationWidget( ann );
|
|
|
|
break;
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::AText:
|
2006-09-13 18:19:22 +00:00
|
|
|
return new TextAnnotationWidget( ann );
|
|
|
|
break;
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::ALine:
|
2006-09-16 14:58:32 +00:00
|
|
|
return new LineAnnotationWidget( ann );
|
|
|
|
break;
|
2006-11-18 20:37:03 +00:00
|
|
|
case Okular::Annotation::AHighlight:
|
|
|
|
return new HighlightAnnotationWidget( ann );
|
|
|
|
break;
|
2006-11-19 00:46:01 +00:00
|
|
|
case Okular::Annotation::AGeom:
|
|
|
|
return new GeomAnnotationWidget( ann );
|
|
|
|
break;
|
2008-04-18 21:37:41 +00:00
|
|
|
case Okular::Annotation::AFileAttachment:
|
|
|
|
return new FileAttachmentAnnotationWidget( ann );
|
|
|
|
break;
|
2008-04-23 07:55:39 +00:00
|
|
|
case Okular::Annotation::ACaret:
|
|
|
|
return new CaretAnnotationWidget( ann );
|
|
|
|
break;
|
2006-09-12 20:21:34 +00:00
|
|
|
// shut up gcc
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
// cases not covered yet
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
AnnotationWidget::AnnotationWidget( Okular::Annotation * ann )
|
2008-04-18 21:37:41 +00:00
|
|
|
: QObject(), m_ann( ann ), m_styleWidget( 0 ), m_extraWidget( 0 )
|
2006-09-12 20:21:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AnnotationWidget::~AnnotationWidget()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::Annotation::SubType AnnotationWidget::annotationType() const
|
2006-09-12 20:21:34 +00:00
|
|
|
{
|
|
|
|
return m_ann->subType();
|
|
|
|
}
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * AnnotationWidget::styleWidget()
|
|
|
|
{
|
|
|
|
if ( m_styleWidget )
|
|
|
|
return m_styleWidget;
|
|
|
|
|
|
|
|
m_styleWidget = createStyleWidget();
|
|
|
|
return m_styleWidget;
|
|
|
|
}
|
|
|
|
|
2008-04-18 21:37:41 +00:00
|
|
|
QWidget * AnnotationWidget::extraWidget()
|
|
|
|
{
|
|
|
|
if ( m_extraWidget )
|
|
|
|
return m_extraWidget;
|
|
|
|
|
|
|
|
m_extraWidget = createExtraWidget();
|
|
|
|
return m_extraWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget * AnnotationWidget::createExtraWidget()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-12 20:21:34 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
TextAnnotationWidget::TextAnnotationWidget( Okular::Annotation * ann )
|
2008-04-18 20:34:35 +00:00
|
|
|
: AnnotationWidget( ann ), m_pixmapSelector( 0 )
|
2006-09-13 18:19:22 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
m_textAnn = static_cast< Okular::TextAnnotation * >( ann );
|
2006-09-13 18:19:22 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * TextAnnotationWidget::createStyleWidget()
|
2006-09-13 18:19:22 +00:00
|
|
|
{
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * widget = new QWidget();
|
|
|
|
QVBoxLayout * lay = new QVBoxLayout( widget );
|
2006-09-13 18:19:22 +00:00
|
|
|
lay->setMargin( 0 );
|
2006-12-23 18:37:04 +00:00
|
|
|
|
|
|
|
if ( m_textAnn->textType() == Okular::TextAnnotation::Linked )
|
|
|
|
{
|
2008-04-18 20:34:35 +00:00
|
|
|
QGroupBox * gb = new QGroupBox( widget );
|
2006-09-13 18:19:22 +00:00
|
|
|
lay->addWidget( gb );
|
|
|
|
gb->setTitle( i18n( "Icon" ) );
|
|
|
|
QHBoxLayout * gblay = new QHBoxLayout( gb );
|
|
|
|
m_pixmapSelector = new PixmapPreviewSelector( gb );
|
|
|
|
gblay->addWidget( m_pixmapSelector );
|
|
|
|
|
2006-09-14 10:36:15 +00:00
|
|
|
m_pixmapSelector->addItem( i18n( "Comment" ), "Comment" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Help" ), "Help" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Insert" ), "Insert" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Key" ), "Key" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "New Paragraph" ), "NewParagraph" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Note" ), "Note" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Paragraph" ), "Paragraph" );
|
2006-12-11 07:59:02 +00:00
|
|
|
m_pixmapSelector->setIcon( m_textAnn->textIcon() );
|
2006-09-13 18:19:22 +00:00
|
|
|
|
2006-09-13 19:52:46 +00:00
|
|
|
connect( m_pixmapSelector, SIGNAL( iconChanged( const QString& ) ), this, SIGNAL( dataChanged() ) );
|
2006-12-23 18:37:04 +00:00
|
|
|
}
|
|
|
|
|
2007-07-15 15:09:11 +00:00
|
|
|
QHBoxLayout * fontlay = new QHBoxLayout();
|
2008-04-18 20:34:35 +00:00
|
|
|
QLabel * tmplabel = new QLabel( i18n( "Font:" ), widget );
|
2006-12-23 18:37:04 +00:00
|
|
|
fontlay->addWidget( tmplabel );
|
2008-04-18 20:34:35 +00:00
|
|
|
m_fontReq = new KFontRequester( widget );
|
2006-12-23 18:37:04 +00:00
|
|
|
fontlay->addWidget( m_fontReq );
|
|
|
|
lay->addLayout( fontlay );
|
|
|
|
|
|
|
|
m_fontReq->setFont( m_textAnn->textFont() );
|
|
|
|
|
|
|
|
connect( m_fontReq, SIGNAL( fontSelected( const QFont& ) ), this, SIGNAL( dataChanged() ) );
|
2006-09-13 19:52:46 +00:00
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
return widget;
|
2006-09-13 18:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextAnnotationWidget::applyChanges()
|
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
if ( m_textAnn->textType() == Okular::TextAnnotation::Linked )
|
2006-09-13 18:19:22 +00:00
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
m_textAnn->setTextIcon( m_pixmapSelector->icon() );
|
2006-09-13 18:19:22 +00:00
|
|
|
}
|
2006-12-23 18:37:04 +00:00
|
|
|
m_textAnn->setTextFont( m_fontReq->font() );
|
2006-09-13 18:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann )
|
2008-04-18 20:34:35 +00:00
|
|
|
: AnnotationWidget( ann ), m_pixmapSelector( 0 )
|
2006-09-12 20:21:34 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
m_stampAnn = static_cast< Okular::StampAnnotation * >( ann );
|
2006-09-12 20:21:34 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * StampAnnotationWidget::createStyleWidget()
|
2006-09-12 20:21:34 +00:00
|
|
|
{
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * widget = new QWidget();
|
|
|
|
QVBoxLayout * lay = new QVBoxLayout( widget );
|
2006-09-12 20:21:34 +00:00
|
|
|
lay->setMargin( 0 );
|
2008-04-18 20:34:35 +00:00
|
|
|
QGroupBox * gb = new QGroupBox( widget );
|
2006-09-12 20:21:34 +00:00
|
|
|
lay->addWidget( gb );
|
|
|
|
gb->setTitle( i18n( "Stamp Symbol" ) );
|
|
|
|
QHBoxLayout * gblay = new QHBoxLayout( gb );
|
2006-09-13 17:28:32 +00:00
|
|
|
m_pixmapSelector = new PixmapPreviewSelector( gb );
|
|
|
|
gblay->addWidget( m_pixmapSelector );
|
2007-09-04 18:21:33 +00:00
|
|
|
m_pixmapSelector->setEditable( true );
|
2006-09-12 20:21:34 +00:00
|
|
|
|
|
|
|
// FIXME!!! use the standard names instead (when we'll have the artwork)
|
2008-06-12 18:51:36 +00:00
|
|
|
m_pixmapSelector->addItem( i18n( "Okular" ), "okular" );
|
2008-01-03 23:54:18 +00:00
|
|
|
m_pixmapSelector->addItem( i18n( "Bookmark" ), "bookmarks" );
|
2007-12-03 06:27:42 +00:00
|
|
|
m_pixmapSelector->addItem( i18n( "KDE" ), "kde" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Information" ), "help-about" );
|
2006-09-12 20:21:34 +00:00
|
|
|
#if 0
|
2006-09-14 10:36:15 +00:00
|
|
|
m_pixmapSelector->addItem( i18n( "Approved" ), "Approved" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "As Is" ), "AsIs" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Confidential" ), "Confidential" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Departmental" ), "Departmental" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Draft" ), "Draft" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Experimental" ), "Experimental" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Expired" ), "Expired" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Final" ), "Final" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "For Comment" ), "ForComment" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "For Public Release" ), "ForPublicRelease" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Not Approved" ), "NotApproved" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Not For Public Release" ), "NotForPublicRelease" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Sold" ), "Sold" );
|
|
|
|
m_pixmapSelector->addItem( i18n( "Top Secret" ), "TopSecret" );
|
2006-09-12 20:21:34 +00:00
|
|
|
#endif
|
2006-12-11 07:59:02 +00:00
|
|
|
m_pixmapSelector->setIcon( m_stampAnn->stampIconName() );
|
2006-09-13 17:28:32 +00:00
|
|
|
m_pixmapSelector->setPreviewSize( 64 );
|
2006-09-12 20:21:34 +00:00
|
|
|
|
2006-09-13 19:52:46 +00:00
|
|
|
connect( m_pixmapSelector, SIGNAL( iconChanged( const QString& ) ), this, SIGNAL( dataChanged() ) );
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
return widget;
|
2006-09-12 20:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StampAnnotationWidget::applyChanges()
|
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
m_stampAnn->setStampIconName( m_pixmapSelector->icon() );
|
2006-09-12 20:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
LineAnnotationWidget::LineAnnotationWidget( Okular::Annotation * ann )
|
2008-04-18 20:34:35 +00:00
|
|
|
: AnnotationWidget( ann )
|
2006-09-16 14:58:32 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
m_lineAnn = static_cast< Okular::LineAnnotation * >( ann );
|
2006-12-11 07:59:02 +00:00
|
|
|
if ( m_lineAnn->linePoints().count() == 2 )
|
2006-09-16 14:58:32 +00:00
|
|
|
m_lineType = 0; // line
|
2006-12-11 07:59:02 +00:00
|
|
|
else if ( m_lineAnn->lineClosed() )
|
2006-09-16 14:58:32 +00:00
|
|
|
m_lineType = 1; // polygon
|
|
|
|
else
|
|
|
|
m_lineType = 2; // polyline
|
|
|
|
}
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * LineAnnotationWidget::createStyleWidget()
|
2006-09-16 14:58:32 +00:00
|
|
|
{
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * widget = new QWidget();
|
|
|
|
QVBoxLayout * lay = new QVBoxLayout( widget );
|
2006-09-16 14:58:32 +00:00
|
|
|
lay->setMargin( 0 );
|
2007-12-08 11:31:37 +00:00
|
|
|
if ( m_lineType == 0 )
|
|
|
|
{
|
2008-04-18 20:34:35 +00:00
|
|
|
QGroupBox * gb = new QGroupBox( widget );
|
2006-09-16 14:58:32 +00:00
|
|
|
lay->addWidget( gb );
|
2007-04-20 13:53:01 +00:00
|
|
|
gb->setTitle( i18n( "Line Extensions" ) );
|
2006-09-16 14:58:32 +00:00
|
|
|
QGridLayout * gridlay = new QGridLayout( gb );
|
|
|
|
QLabel * tmplabel = new QLabel( i18n( "Leader Line Length:" ), gb );
|
2008-04-18 21:56:17 +00:00
|
|
|
gridlay->addWidget( tmplabel, 0, 0, Qt::AlignRight );
|
2006-09-16 14:58:32 +00:00
|
|
|
m_spinLL = new QDoubleSpinBox( gb );
|
|
|
|
gridlay->addWidget( m_spinLL, 0, 1 );
|
|
|
|
tmplabel->setBuddy( m_spinLL );
|
|
|
|
tmplabel = new QLabel( i18n( "Leader Line Extensions Length:" ), gb );
|
2008-04-18 21:56:17 +00:00
|
|
|
gridlay->addWidget( tmplabel, 1, 0, Qt::AlignRight );
|
2006-09-16 14:58:32 +00:00
|
|
|
m_spinLLE = new QDoubleSpinBox( gb );
|
|
|
|
gridlay->addWidget( m_spinLLE, 1, 1 );
|
|
|
|
tmplabel->setBuddy( m_spinLLE );
|
2007-12-08 11:31:37 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
QGroupBox * gb2 = new QGroupBox( widget );
|
2007-12-08 11:31:37 +00:00
|
|
|
lay->addWidget( gb2 );
|
|
|
|
gb2->setTitle( i18n( "Style" ) );
|
|
|
|
QGridLayout * gridlay2 = new QGridLayout( gb2 );
|
|
|
|
QLabel * tmplabel2 = new QLabel( i18n( "&Size:" ), gb2 );
|
2008-04-18 21:56:17 +00:00
|
|
|
gridlay2->addWidget( tmplabel2, 0, 0, Qt::AlignRight );
|
2007-12-08 11:31:37 +00:00
|
|
|
m_spinSize = new QDoubleSpinBox( gb2 );
|
|
|
|
gridlay2->addWidget( m_spinSize, 0, 1 );
|
|
|
|
tmplabel2->setBuddy( m_spinSize );
|
2006-09-16 14:58:32 +00:00
|
|
|
|
2007-12-08 11:31:37 +00:00
|
|
|
if ( m_lineType == 0 )
|
|
|
|
{
|
2006-09-16 14:58:32 +00:00
|
|
|
m_spinLL->setRange( -500, 500 );
|
2006-12-11 07:59:02 +00:00
|
|
|
m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() );
|
2006-09-16 14:58:32 +00:00
|
|
|
m_spinLLE->setRange( 0, 500 );
|
2006-12-11 07:59:02 +00:00
|
|
|
m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() );
|
2007-12-08 11:31:37 +00:00
|
|
|
}
|
|
|
|
m_spinSize->setRange( 1, 100 );
|
|
|
|
m_spinSize->setValue( m_lineAnn->style().width() );
|
2006-09-16 14:58:32 +00:00
|
|
|
|
2007-12-08 11:31:37 +00:00
|
|
|
if ( m_lineType == 0 )
|
|
|
|
{
|
2006-09-16 14:58:32 +00:00
|
|
|
connect( m_spinLL, SIGNAL( valueChanged( double ) ), this, SIGNAL( dataChanged() ) );
|
|
|
|
connect( m_spinLLE, SIGNAL( valueChanged( double ) ), this, SIGNAL( dataChanged() ) );
|
2007-12-08 11:31:37 +00:00
|
|
|
}
|
|
|
|
connect( m_spinSize, SIGNAL( valueChanged( double ) ), this, SIGNAL( dataChanged() ) );
|
2006-09-16 14:58:32 +00:00
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
return widget;
|
2006-09-16 14:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotationWidget::applyChanges()
|
|
|
|
{
|
|
|
|
if ( m_lineType == 0 )
|
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
m_lineAnn->setLineLeadingForwardPoint( m_spinLL->value() );
|
|
|
|
m_lineAnn->setLineLeadingBackwardPoint( m_spinLLE->value() );
|
2006-09-16 14:58:32 +00:00
|
|
|
}
|
2007-12-08 11:31:37 +00:00
|
|
|
m_lineAnn->style().setWidth( m_spinSize->value() );
|
2006-09-16 14:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-11-18 20:37:03 +00:00
|
|
|
HighlightAnnotationWidget::HighlightAnnotationWidget( Okular::Annotation * ann )
|
2008-04-18 20:34:35 +00:00
|
|
|
: AnnotationWidget( ann )
|
2006-11-18 20:37:03 +00:00
|
|
|
{
|
|
|
|
m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann );
|
|
|
|
}
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * HighlightAnnotationWidget::createStyleWidget()
|
2006-11-18 20:37:03 +00:00
|
|
|
{
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * widget = new QWidget();
|
|
|
|
QVBoxLayout * lay = new QVBoxLayout( widget );
|
2006-11-18 20:37:03 +00:00
|
|
|
lay->setMargin( 0 );
|
|
|
|
QHBoxLayout * typelay = new QHBoxLayout();
|
|
|
|
lay->addLayout( typelay );
|
2008-04-18 20:34:35 +00:00
|
|
|
QLabel * tmplabel = new QLabel( i18n( "Type:" ), widget );
|
2008-04-18 21:56:17 +00:00
|
|
|
typelay->addWidget( tmplabel, 0, Qt::AlignRight );
|
2008-04-18 20:34:35 +00:00
|
|
|
m_typeCombo = new KComboBox( widget );
|
2006-11-18 20:37:03 +00:00
|
|
|
tmplabel->setBuddy( m_typeCombo );
|
|
|
|
typelay->addWidget( m_typeCombo );
|
|
|
|
|
|
|
|
m_typeCombo->addItem( i18n( "Highlight" ) );
|
|
|
|
m_typeCombo->addItem( i18n( "Squiggly" ) );
|
|
|
|
m_typeCombo->addItem( i18n( "Underline" ) );
|
2007-04-20 13:53:01 +00:00
|
|
|
m_typeCombo->addItem( i18n( "Strike out" ) );
|
2006-12-11 07:59:02 +00:00
|
|
|
m_typeCombo->setCurrentIndex( m_hlAnn->highlightType() );
|
2006-11-18 20:37:03 +00:00
|
|
|
|
|
|
|
connect( m_typeCombo, SIGNAL( currentIndexChanged ( int ) ), this, SIGNAL( dataChanged() ) );
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
return widget;
|
2006-11-18 20:37:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HighlightAnnotationWidget::applyChanges()
|
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
m_hlAnn->setHighlightType( (Okular::HighlightAnnotation::HighlightType)m_typeCombo->currentIndex() );
|
2006-11-18 20:37:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-11-19 00:46:01 +00:00
|
|
|
GeomAnnotationWidget::GeomAnnotationWidget( Okular::Annotation * ann )
|
2008-04-18 20:34:35 +00:00
|
|
|
: AnnotationWidget( ann )
|
2006-11-19 00:46:01 +00:00
|
|
|
{
|
|
|
|
m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann );
|
|
|
|
}
|
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * GeomAnnotationWidget::createStyleWidget()
|
2006-11-19 00:46:01 +00:00
|
|
|
{
|
2008-04-18 20:34:35 +00:00
|
|
|
QWidget * widget = new QWidget();
|
|
|
|
QGridLayout * lay = new QGridLayout( widget );
|
2006-11-19 00:46:01 +00:00
|
|
|
lay->setMargin( 0 );
|
2008-04-18 20:34:35 +00:00
|
|
|
QLabel * tmplabel = new QLabel( i18n( "Type:" ), widget );
|
2008-04-18 21:56:17 +00:00
|
|
|
lay->addWidget( tmplabel, 0, 0, Qt::AlignRight );
|
2008-04-18 20:34:35 +00:00
|
|
|
m_typeCombo = new KComboBox( widget );
|
2006-11-19 00:46:01 +00:00
|
|
|
tmplabel->setBuddy( m_typeCombo );
|
|
|
|
lay->addWidget( m_typeCombo, 0, 1 );
|
2008-04-18 20:34:35 +00:00
|
|
|
m_useColor = new QCheckBox( i18n( "Inner color:" ), widget );
|
2006-11-19 00:46:01 +00:00
|
|
|
lay->addWidget( m_useColor, 1, 0 );
|
2008-04-18 20:34:35 +00:00
|
|
|
m_innerColor = new KColorButton( widget );
|
2006-11-19 00:46:01 +00:00
|
|
|
lay->addWidget( m_innerColor, 1, 1 );
|
2008-04-18 20:34:35 +00:00
|
|
|
tmplabel = new QLabel( i18n( "&Size:" ), widget );
|
2008-04-18 21:56:17 +00:00
|
|
|
lay->addWidget( tmplabel, 2, 0, Qt::AlignRight );
|
2008-04-18 20:34:35 +00:00
|
|
|
m_spinSize = new QDoubleSpinBox( widget );
|
2008-04-06 23:14:33 +00:00
|
|
|
lay->addWidget( m_spinSize, 2, 1 );
|
|
|
|
tmplabel->setBuddy( m_spinSize );
|
2006-11-19 00:46:01 +00:00
|
|
|
|
|
|
|
m_typeCombo->addItem( i18n( "Rectangle" ) );
|
|
|
|
m_typeCombo->addItem( i18n( "Ellipse" ) );
|
2006-12-11 07:59:02 +00:00
|
|
|
m_typeCombo->setCurrentIndex( m_geomAnn->geometricalType() );
|
|
|
|
m_innerColor->setColor( m_geomAnn->geometricalInnerColor() );
|
|
|
|
if ( m_geomAnn->geometricalInnerColor().isValid() )
|
2006-11-19 00:46:01 +00:00
|
|
|
{
|
|
|
|
m_useColor->setChecked( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_innerColor->setEnabled( false );
|
|
|
|
}
|
2008-04-07 00:16:17 +00:00
|
|
|
m_spinSize->setRange( 0, 100 );
|
2008-04-06 23:14:33 +00:00
|
|
|
m_spinSize->setValue( m_geomAnn->style().width() );
|
2006-11-19 00:46:01 +00:00
|
|
|
|
|
|
|
connect( m_typeCombo, SIGNAL( currentIndexChanged ( int ) ), this, SIGNAL( dataChanged() ) );
|
|
|
|
connect( m_innerColor, SIGNAL( changed( const QColor & ) ), this, SIGNAL( dataChanged() ) );
|
|
|
|
connect( m_useColor, SIGNAL( toggled( bool ) ), this, SIGNAL( dataChanged() ) );
|
|
|
|
connect( m_useColor, SIGNAL( toggled( bool ) ), m_innerColor, SLOT( setEnabled( bool ) ) );
|
2008-04-06 23:14:33 +00:00
|
|
|
connect( m_spinSize, SIGNAL( valueChanged( double ) ), this, SIGNAL( dataChanged() ) );
|
2006-11-19 00:46:01 +00:00
|
|
|
|
2008-04-18 20:34:35 +00:00
|
|
|
return widget;
|
2006-11-19 00:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeomAnnotationWidget::applyChanges()
|
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
m_geomAnn->setGeometricalType( (Okular::GeomAnnotation::GeomType)m_typeCombo->currentIndex() );
|
2006-11-19 00:46:01 +00:00
|
|
|
if ( !m_useColor->isChecked() )
|
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
m_geomAnn->setGeometricalInnerColor( QColor() );
|
2006-11-19 00:46:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
m_geomAnn->setGeometricalInnerColor( m_innerColor->color() );
|
2006-11-19 00:46:01 +00:00
|
|
|
}
|
2008-04-06 23:14:33 +00:00
|
|
|
m_geomAnn->style().setWidth( m_spinSize->value() );
|
2006-11-19 00:46:01 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 21:37:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
FileAttachmentAnnotationWidget::FileAttachmentAnnotationWidget( Okular::Annotation * ann )
|
2008-04-19 10:00:19 +00:00
|
|
|
: AnnotationWidget( ann ), m_pixmapSelector( 0 )
|
2008-04-18 21:37:41 +00:00
|
|
|
{
|
|
|
|
m_attachAnn = static_cast< Okular::FileAttachmentAnnotation * >( ann );
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget * FileAttachmentAnnotationWidget::createStyleWidget()
|
|
|
|
{
|
2008-04-19 10:00:19 +00:00
|
|
|
QWidget * widget = new QWidget();
|
|
|
|
QVBoxLayout * lay = new QVBoxLayout( widget );
|
|
|
|
lay->setMargin( 0 );
|
|
|
|
QGroupBox * gb = new QGroupBox( widget );
|
|
|
|
lay->addWidget( gb );
|
|
|
|
gb->setTitle( i18n( "File Attachment Symbol" ) );
|
|
|
|
QHBoxLayout * gblay = new QHBoxLayout( gb );
|
|
|
|
m_pixmapSelector = new PixmapPreviewSelector( gb );
|
|
|
|
gblay->addWidget( m_pixmapSelector );
|
|
|
|
m_pixmapSelector->setEditable( true );
|
|
|
|
|
|
|
|
m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Graph" ), "graph" );
|
|
|
|
m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Push Pin" ), "pushpin" );
|
|
|
|
m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Paperclip" ), "paperclip" );
|
|
|
|
m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Tag" ), "tag" );
|
|
|
|
m_pixmapSelector->setIcon( m_attachAnn->fileIconName() );
|
|
|
|
|
|
|
|
connect( m_pixmapSelector, SIGNAL( iconChanged( const QString& ) ), this, SIGNAL( dataChanged() ) );
|
|
|
|
|
|
|
|
return widget;
|
2008-04-18 21:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget * FileAttachmentAnnotationWidget::createExtraWidget()
|
|
|
|
{
|
|
|
|
QWidget * widget = new QWidget();
|
|
|
|
widget->setWindowTitle( i18nc( "'File' as normal file, that can be opened, saved, etc..", "File" ) );
|
|
|
|
|
|
|
|
Okular::EmbeddedFile *ef = m_attachAnn->embeddedFile();
|
|
|
|
const int size = ef->size();
|
|
|
|
const QString sizeString = size <= 0 ? i18nc( "Not available size", "N/A" ) : KGlobal::locale()->formatByteSize( size );
|
2008-04-20 09:40:23 +00:00
|
|
|
const QString descString = ef->description().isEmpty() ? i18n( "No description available." ) : ef->description();
|
2008-04-18 21:37:41 +00:00
|
|
|
|
|
|
|
QGridLayout * lay = new QGridLayout( widget );
|
|
|
|
lay->setMargin( 0 );
|
|
|
|
QLabel * tmplabel = new QLabel( i18n( "Name: %1", ef->name() ), widget );
|
|
|
|
tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
|
|
|
|
lay->addWidget( tmplabel, 0, 0 );
|
|
|
|
|
|
|
|
tmplabel = new QLabel( i18n( "Size: %1", sizeString ), widget );
|
|
|
|
tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
|
|
|
|
lay->addWidget( tmplabel, 1, 0 );
|
|
|
|
|
|
|
|
tmplabel = new QLabel( i18n( "Description:" ), widget );
|
|
|
|
lay->addWidget( tmplabel, 2, 0 );
|
2008-04-20 22:09:34 +00:00
|
|
|
tmplabel = new QLabel( widget );
|
|
|
|
tmplabel->setTextFormat( Qt::PlainText );
|
|
|
|
tmplabel->setWordWrap( true );
|
|
|
|
tmplabel->setText( descString );
|
2008-04-18 21:37:41 +00:00
|
|
|
tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
|
|
|
|
lay->addWidget( tmplabel, 3, 0, 1, 2 );
|
|
|
|
|
|
|
|
KMimeType::Ptr mime = KMimeType::findByPath( ef->name(), 0, true );
|
|
|
|
if ( mime )
|
|
|
|
{
|
|
|
|
tmplabel = new QLabel( widget );
|
|
|
|
tmplabel->setPixmap( KIcon( mime->iconName() ).pixmap( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ) );
|
|
|
|
tmplabel->setFixedSize( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE );
|
|
|
|
lay->addWidget( tmplabel, 0, 1, 3, 1, Qt::AlignTop );
|
|
|
|
}
|
|
|
|
|
|
|
|
lay->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 4, 0 );
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileAttachmentAnnotationWidget::applyChanges()
|
|
|
|
{
|
2008-04-21 08:08:01 +00:00
|
|
|
m_attachAnn->setFileIconName( m_pixmapSelector->icon() );
|
2008-04-18 21:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-23 07:55:39 +00:00
|
|
|
|
|
|
|
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() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-12 20:21:34 +00:00
|
|
|
#include "annotationwidgets.moc"
|