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>
|
2006-09-05 20:22:19 +00:00
|
|
|
#include <qlineedit.h>
|
2006-08-08 15:42:12 +00:00
|
|
|
#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>
|
|
|
|
#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;
|
|
|
|
setCaptionTextbyAnnotType();
|
2006-08-08 15:42:12 +00:00
|
|
|
setButtons( Ok | Apply | Cancel );
|
2006-09-13 19:52:46 +00:00
|
|
|
enableButton( Apply, false );
|
2006-08-10 15:12:37 +00:00
|
|
|
connect( this, SIGNAL( applyClicked() ), this, SLOT( slotapply() ) );
|
|
|
|
connect( this, SIGNAL( okClicked() ), this, SLOT( slotapply() ) );
|
|
|
|
|
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
|
2006-09-05 20:22:19 +00:00
|
|
|
QFrame *page = new QFrame();
|
|
|
|
addPage( page, i18n( "&Appearance" ) );
|
|
|
|
QVBoxLayout * lay = new QVBoxLayout( page );
|
2006-08-08 15:42:12 +00:00
|
|
|
|
2006-09-05 20:22:19 +00:00
|
|
|
QHBoxLayout * hlay = new QHBoxLayout();
|
|
|
|
lay->addLayout( hlay );
|
|
|
|
tmplabel = new QLabel( i18n( "&Color:" ), page );
|
|
|
|
hlay->addWidget( tmplabel );
|
|
|
|
colorBn = new KColorButton( page );
|
2006-12-05 11:05:50 +00:00
|
|
|
colorBn->setColor( ann->style().color() );
|
2006-09-05 20:22:19 +00:00
|
|
|
tmplabel->setBuddy( colorBn );
|
|
|
|
hlay->addWidget( colorBn );
|
|
|
|
|
|
|
|
hlay = new QHBoxLayout();
|
|
|
|
lay->addLayout( hlay );
|
|
|
|
tmplabel = new QLabel( i18n( "&Opacity:" ), page );
|
|
|
|
hlay->addWidget( tmplabel );
|
|
|
|
m_opacity = new KIntNumInput( page );
|
|
|
|
m_opacity->setRange( 0, 100, 1, true );
|
2006-12-05 11:05:50 +00:00
|
|
|
m_opacity->setValue( (int)( ann->style().opacity() * 100 ) );
|
2006-09-05 20:22:19 +00:00
|
|
|
tmplabel->setBuddy( m_opacity );
|
|
|
|
hlay->addWidget( m_opacity );
|
|
|
|
|
2006-09-12 20:21:34 +00:00
|
|
|
if ( m_annotWidget )
|
|
|
|
lay->addWidget( m_annotWidget->widget() );
|
|
|
|
|
2006-09-05 20:22:19 +00:00
|
|
|
lay->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::Expanding ) );
|
2006-08-10 06:32:03 +00:00
|
|
|
//END tab1
|
|
|
|
|
|
|
|
//BEGIN tab 2
|
2006-09-05 20:22:19 +00:00
|
|
|
page = new QFrame();
|
|
|
|
addPage( page, i18n( "&General" ) );
|
2006-08-10 06:32:03 +00:00
|
|
|
// m_tabitem[1]->setIcon( KIcon( "fonts" ) );
|
2006-09-05 20:22:19 +00:00
|
|
|
QGridLayout * gridlayout = new QGridLayout( page );
|
|
|
|
tmplabel = new QLabel( i18n( "&Author:" ), page );
|
2006-12-05 11:05:50 +00:00
|
|
|
AuthorEdit = new QLineEdit( ann->author(), page );
|
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
|
|
|
|
2006-09-05 20:22:19 +00:00
|
|
|
tmplabel = new QLabel( i18n( "Created:" ), page );
|
|
|
|
gridlayout->addWidget( tmplabel, 1, 0 );
|
2007-04-09 23:36:26 +00:00
|
|
|
tmplabel = new QLabel( KGlobal::locale()->formatDateTime( ann->creationDate(), KLocale::LongDate, true ), page );//time
|
2006-09-05 20:22:19 +00:00
|
|
|
gridlayout->addWidget( tmplabel, 1, 1 );
|
2006-08-08 15:42:12 +00:00
|
|
|
|
2007-07-15 15:17:25 +00:00
|
|
|
tmplabel = new QLabel( i18n( "Modified:" ), page );
|
|
|
|
gridlayout->addWidget( tmplabel, 2, 0 );
|
2007-04-09 23:36:26 +00:00
|
|
|
m_modifyDateLabel = new QLabel( KGlobal::locale()->formatDateTime( ann->modificationDate(), KLocale::LongDate, true ), page );//time
|
2006-09-17 09:27:01 +00:00
|
|
|
gridlayout->addWidget( m_modifyDateLabel, 2, 1 );
|
2006-09-05 20:22:19 +00:00
|
|
|
|
|
|
|
gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::Expanding ), 3, 0 );
|
2006-08-10 06:32:03 +00:00
|
|
|
//END tab 2
|
|
|
|
//BEGIN advance properties:
|
2006-09-05 20:22:19 +00:00
|
|
|
page = new QFrame();
|
|
|
|
addPage( page, i18n( "&Advanced" ) );
|
|
|
|
gridlayout = new QGridLayout( page );
|
2006-08-08 15:42:12 +00:00
|
|
|
|
2007-07-15 20:28:37 +00:00
|
|
|
tmplabel = new QLabel( i18n( "Contents:" ), page );
|
|
|
|
gridlayout->addWidget( tmplabel, 0, 0 );
|
|
|
|
m_contents = new QTextEdit( page );
|
|
|
|
gridlayout->addWidget( m_contents, 1, 0 );
|
|
|
|
m_contents->setAcceptRichText( false );
|
|
|
|
m_contents->setReadOnly( true );
|
|
|
|
m_contents->setPlainText( ann->contents() );
|
2006-09-05 20:22:19 +00:00
|
|
|
|
|
|
|
gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::Expanding ), 4, 0 );
|
2006-08-10 06:32:03 +00:00
|
|
|
//END advance
|
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
|
2006-09-05 20:40:39 +00:00
|
|
|
captiontext = i18n( "FreeText 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:
|
2006-09-05 20:40:39 +00:00
|
|
|
captiontext = i18n( "Geom 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-04-09 23:36:26 +00:00
|
|
|
m_modifyDateLabel->setText( 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"
|
|
|
|
|