2006-08-08 15:42:12 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2006 by Chu Xiaodong <xiaodongchu@gmail.com> *
|
|
|
|
* *
|
|
|
|
* 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 "annotationpropertiesdialog.h"
|
|
|
|
|
2006-08-08 15:42:12 +00:00
|
|
|
// qt/kde includes
|
2006-09-05 20:22:19 +00:00
|
|
|
#include <qframe.h>
|
2006-08-08 15:42:12 +00:00
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qheaderview.h>
|
2007-07-15 20:28:37 +00:00
|
|
|
#include <qtextedit.h>
|
2006-09-05 20:22:19 +00:00
|
|
|
#include <kcolorbutton.h>
|
2006-08-08 15:42:12 +00:00
|
|
|
#include <kicon.h>
|
2008-01-12 19:06:46 +00:00
|
|
|
#include <klineedit.h>
|
2006-08-08 15:42:12 +00:00
|
|
|
#include <klocale.h>
|
2006-09-05 20:22:19 +00:00
|
|
|
#include <knuminput.h>
|
2006-12-19 12:23:43 +00:00
|
|
|
#include <kglobal.h>
|
2006-08-08 15:42:12 +00:00
|
|
|
|
|
|
|
// local includes
|
|
|
|
#include "core/document.h"
|
|
|
|
#include "core/page.h"
|
|
|
|
#include "core/annotations.h"
|
2006-09-12 20:21:34 +00:00
|
|
|
#include "annotationwidgets.h"
|
2006-08-08 15:42:12 +00:00
|
|
|
|
2006-08-10 06:32:03 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
AnnotsPropertiesDialog::AnnotsPropertiesDialog( QWidget *parent, Okular::Document *document, int docpage, Okular::Annotation *ann )
|
2006-09-13 19:52:46 +00:00
|
|
|
: KPageDialog( parent ), m_document( document ), m_page( docpage ), modified( false )
|
2006-08-08 15:42:12 +00:00
|
|
|
{
|
|
|
|
setFaceType( Tabbed );
|
2006-08-10 06:32:03 +00:00
|
|
|
m_annot=ann;
|
2007-12-08 12:45:44 +00:00
|
|
|
bool canEditAnnotations = !(ann->flags() & Okular::Annotation::External) && m_document->isAllowed( Okular::AllowNotes );
|
2006-08-10 06:32:03 +00:00
|
|
|
setCaptionTextbyAnnotType();
|
2007-08-27 22:11:18 +00:00
|
|
|
if ( canEditAnnotations )
|
|
|
|
{
|
|
|
|
setButtons( Ok | Apply | Cancel );
|
|
|
|
enableButton( Apply, false );
|
|
|
|
connect( this, SIGNAL( applyClicked() ), this, SLOT( slotapply() ) );
|
|
|
|
connect( this, SIGNAL( okClicked() ), this, SLOT( slotapply() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setButtons( Close );
|
|
|
|
setDefaultButton( Close );
|
|
|
|
}
|
2006-08-10 15:12:37 +00:00
|
|
|
|
2006-09-12 20:21:34 +00:00
|
|
|
m_annotWidget = AnnotationWidgetFactory::widgetFor( ann );
|
2006-08-08 15:42:12 +00:00
|
|
|
|
2006-08-10 06:32:03 +00:00
|
|
|
QLabel* tmplabel;
|
2006-08-08 15:42:12 +00:00
|
|
|
//1. Appearance
|
2006-08-10 06:32:03 +00:00
|
|
|
//BEGIN tab1
|
2007-09-11 22:27:39 +00:00
|
|
|
QFrame *page = new QFrame( this );
|
2006-09-05 20:22:19 +00:00
|
|
|
addPage( page, i18n( "&Appearance" ) );
|
2007-10-04 15:00:39 +00:00
|
|
|
QGridLayout * gridlayout = new QGridLayout( page );
|
2006-08-08 15:42:12 +00:00
|
|
|
|
2006-09-05 20:22:19 +00:00
|
|
|
tmplabel = new QLabel( i18n( "&Color:" ), page );
|
2007-10-04 15:00:39 +00:00
|
|
|
tmplabel->setAlignment( ( tmplabel->alignment() & ~Qt::AlignHorizontal_Mask ) | Qt::AlignRight );
|
|
|
|
gridlayout->addWidget( tmplabel, 0, 0 );
|
2006-09-05 20:22:19 +00:00
|
|
|
colorBn = new KColorButton( page );
|
2006-12-05 11:05:50 +00:00
|
|
|
colorBn->setColor( ann->style().color() );
|
2007-08-27 22:11:18 +00:00
|
|
|
colorBn->setEnabled( canEditAnnotations );
|
2006-09-05 20:22:19 +00:00
|
|
|
tmplabel->setBuddy( colorBn );
|
2007-10-04 15:00:39 +00:00
|
|
|
gridlayout->addWidget( colorBn, 0, 1 );
|
2006-09-05 20:22:19 +00:00
|
|
|
|
|
|
|
tmplabel = new QLabel( i18n( "&Opacity:" ), page );
|
2007-10-04 15:00:39 +00:00
|
|
|
tmplabel->setAlignment( ( tmplabel->alignment() & ~Qt::AlignHorizontal_Mask ) | Qt::AlignRight );
|
|
|
|
gridlayout->addWidget( tmplabel, 1, 0 );
|
2006-09-05 20:22:19 +00:00
|
|
|
m_opacity = new KIntNumInput( page );
|
2007-11-02 21:56:52 +00:00
|
|
|
m_opacity->setRange( 0, 100 );
|
2006-12-05 11:05:50 +00:00
|
|
|
m_opacity->setValue( (int)( ann->style().opacity() * 100 ) );
|
2007-10-03 22:44:11 +00:00
|
|
|
m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) );
|
2007-08-27 22:11:18 +00:00
|
|
|
m_opacity->setEnabled( canEditAnnotations );
|
2006-09-05 20:22:19 +00:00
|
|
|
tmplabel->setBuddy( m_opacity );
|
2007-10-04 15:00:39 +00:00
|
|
|
gridlayout->addWidget( m_opacity, 1, 1 );
|
2006-09-05 20:22:19 +00:00
|
|
|
|
2007-09-04 17:02:30 +00:00
|
|
|
QWidget * configWidget = 0;
|
|
|
|
if ( m_annotWidget && ( configWidget = m_annotWidget->widget() ) )
|
2007-08-27 22:11:18 +00:00
|
|
|
{
|
2007-10-04 15:00:39 +00:00
|
|
|
gridlayout->addWidget( configWidget, 2, 0, 1, 2 );
|
2007-08-27 22:11:18 +00:00
|
|
|
configWidget->setEnabled( canEditAnnotations );
|
|
|
|
}
|
2006-09-12 20:21:34 +00:00
|
|
|
|
2007-10-04 15:00:39 +00:00
|
|
|
gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 3, 0 );
|
2006-08-10 06:32:03 +00:00
|
|
|
//END tab1
|
|
|
|
|
|
|
|
//BEGIN tab 2
|
2007-09-11 22:27:39 +00:00
|
|
|
page = new QFrame( this );
|
2006-09-05 20:22:19 +00:00
|
|
|
addPage( page, i18n( "&General" ) );
|
2006-08-10 06:32:03 +00:00
|
|
|
// m_tabitem[1]->setIcon( KIcon( "fonts" ) );
|
2007-10-04 15:00:39 +00:00
|
|
|
gridlayout = new QGridLayout( page );
|
2006-09-05 20:22:19 +00:00
|
|
|
tmplabel = new QLabel( i18n( "&Author:" ), page );
|
2007-10-04 15:00:39 +00:00
|
|
|
tmplabel->setAlignment( ( tmplabel->alignment() & ~Qt::AlignHorizontal_Mask ) | Qt::AlignRight );
|
2008-01-12 19:06:46 +00:00
|
|
|
AuthorEdit = new KLineEdit( ann->author(), page );
|
2007-08-27 22:11:18 +00:00
|
|
|
AuthorEdit->setEnabled( canEditAnnotations );
|
2006-09-05 20:22:19 +00:00
|
|
|
tmplabel->setBuddy( AuthorEdit );
|
|
|
|
gridlayout->addWidget( tmplabel, 0, 0 );
|
|
|
|
gridlayout->addWidget( AuthorEdit, 0, 1 );
|
2006-08-08 15:42:12 +00:00
|
|
|
|
2007-10-04 20:15:43 +00:00
|
|
|
tmplabel = new QLabel( page );
|
|
|
|
tmplabel->setText( i18n( "Created: %1", KGlobal::locale()->formatDateTime( ann->creationDate(), KLocale::LongDate, true ) ) );
|
|
|
|
gridlayout->addWidget( tmplabel, 1, 0, 1, 2 );
|
2006-08-08 15:42:12 +00:00
|
|
|
|
2007-10-04 20:15:43 +00:00
|
|
|
m_modifyDateLabel = new QLabel( page );
|
|
|
|
m_modifyDateLabel->setText( i18n( "Modified: %1", KGlobal::locale()->formatDateTime( ann->modificationDate(), KLocale::LongDate, true ) ) );
|
|
|
|
gridlayout->addWidget( m_modifyDateLabel, 2, 0, 1, 2 );
|
2006-09-05 20:22:19 +00:00
|
|
|
|
2007-09-04 17:02:30 +00:00
|
|
|
gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 3, 0 );
|
2006-08-10 06:32:03 +00:00
|
|
|
//END tab 2
|
2006-09-05 20:22:19 +00:00
|
|
|
|
2006-09-13 19:52:46 +00:00
|
|
|
//BEGIN connections
|
|
|
|
connect( colorBn, SIGNAL( changed( const QColor& ) ), this, SLOT( setModified() ) );
|
|
|
|
connect( m_opacity, SIGNAL( valueChanged( int ) ), this, SLOT( setModified() ) );
|
|
|
|
connect( AuthorEdit, SIGNAL( textChanged ( const QString& ) ), this, SLOT( setModified() ) );
|
|
|
|
if ( m_annotWidget )
|
|
|
|
{
|
|
|
|
connect( m_annotWidget, SIGNAL( dataChanged() ), this, SLOT( setModified() ) );
|
|
|
|
}
|
|
|
|
//END
|
|
|
|
|
2007-07-15 15:17:25 +00:00
|
|
|
#if 0
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug() << "Annotation details:";
|
|
|
|
kDebug().nospace() << " => unique name: '" << ann->uniqueName() << "'";
|
|
|
|
kDebug() << " => flags:" << QString::number( m_annot->flags(), 2 );
|
2007-07-15 15:17:25 +00:00
|
|
|
#endif
|
|
|
|
|
2006-09-05 20:22:19 +00:00
|
|
|
resize( sizeHint() );
|
2006-08-08 15:42:12 +00:00
|
|
|
}
|
2006-08-10 06:32:03 +00:00
|
|
|
AnnotsPropertiesDialog::~AnnotsPropertiesDialog()
|
|
|
|
{
|
2006-11-19 11:36:06 +00:00
|
|
|
delete m_annotWidget;
|
2006-08-10 06:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AnnotsPropertiesDialog::setCaptionTextbyAnnotType()
|
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::Annotation::SubType type=m_annot->subType();
|
2006-08-10 06:32:03 +00:00
|
|
|
QString captiontext;
|
|
|
|
switch(type)
|
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::AText:
|
2006-12-11 07:59:02 +00:00
|
|
|
if(((Okular::TextAnnotation*)m_annot)->textType()==Okular::TextAnnotation::Linked)
|
2006-09-05 20:40:39 +00:00
|
|
|
captiontext = i18n( "Note Properties" );
|
2006-08-10 06:32:03 +00:00
|
|
|
else
|
2007-08-19 16:15:55 +00:00
|
|
|
captiontext = i18n( "Inline Note Properties" );
|
2006-08-10 06:32:03 +00:00
|
|
|
break;
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::ALine:
|
2006-09-05 20:40:39 +00:00
|
|
|
captiontext = i18n( "Line Properties" );
|
2006-08-10 06:32:03 +00:00
|
|
|
break;
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::AGeom:
|
2007-08-19 16:15:55 +00:00
|
|
|
captiontext = i18n( "Geometry Properties" );
|
2006-08-10 06:32:03 +00:00
|
|
|
break;
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::AHighlight:
|
2006-09-05 20:40:39 +00:00
|
|
|
captiontext = i18n( "Highlight Properties" );
|
2006-08-10 06:32:03 +00:00
|
|
|
break;
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::AStamp:
|
2006-09-05 20:40:39 +00:00
|
|
|
captiontext = i18n( "Stamp Properties" );
|
2006-08-10 06:32:03 +00:00
|
|
|
break;
|
2006-09-21 08:45:36 +00:00
|
|
|
case Okular::Annotation::AInk:
|
2006-09-05 20:40:39 +00:00
|
|
|
captiontext = i18n( "Ink Properties" );
|
2006-08-10 06:32:03 +00:00
|
|
|
break;
|
|
|
|
default:
|
2006-09-05 20:40:39 +00:00
|
|
|
captiontext = i18n( "Annotation Properties" );
|
2006-08-10 06:32:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
setCaption( captiontext );
|
|
|
|
}
|
2006-09-05 20:22:19 +00:00
|
|
|
|
2006-09-13 19:52:46 +00:00
|
|
|
void AnnotsPropertiesDialog::setModified()
|
|
|
|
{
|
|
|
|
modified = true;
|
|
|
|
enableButton( Apply, true );
|
|
|
|
}
|
|
|
|
|
2006-08-10 15:12:37 +00:00
|
|
|
void AnnotsPropertiesDialog::slotapply()
|
|
|
|
{
|
2006-09-13 19:52:46 +00:00
|
|
|
if ( !modified )
|
|
|
|
return;
|
|
|
|
|
2006-12-05 11:05:50 +00:00
|
|
|
m_annot->setAuthor( AuthorEdit->text() );
|
|
|
|
m_annot->setModificationDate( QDateTime::currentDateTime() );
|
|
|
|
m_annot->style().setColor( colorBn->color() );
|
|
|
|
m_annot->style().setOpacity( (double)m_opacity->value() / 100.0 );
|
2006-09-12 20:21:34 +00:00
|
|
|
|
|
|
|
if ( m_annotWidget )
|
|
|
|
m_annotWidget->applyChanges();
|
2006-09-13 19:52:46 +00:00
|
|
|
|
|
|
|
m_document->modifyPageAnnotation( m_page, m_annot );
|
2006-09-14 10:36:15 +00:00
|
|
|
|
2007-10-04 20:15:43 +00:00
|
|
|
m_modifyDateLabel->setText( i18n( "Modified: %1", KGlobal::locale()->formatDateTime( m_annot->modificationDate(), KLocale::LongDate, true ) ) );
|
2006-09-17 09:27:01 +00:00
|
|
|
|
2006-09-14 10:36:15 +00:00
|
|
|
modified = false;
|
|
|
|
enableButton( Apply, false );
|
2006-08-08 15:42:12 +00:00
|
|
|
}
|
2006-12-05 11:05:50 +00:00
|
|
|
|
2006-08-08 15:42:12 +00:00
|
|
|
#include "annotationpropertiesdialog.moc"
|
|
|
|
|