From 8b0a80ba4bc240101a4804ba5ebf72922a9937ea Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 27 Aug 2007 22:11:18 +0000 Subject: [PATCH] Start making the annotation system DRM-aware. In case the document does not want changes to its annotations (and okular is set to obey), - disable the review toolbar - make the annotation prioerties dialog read-only - disable the removal svn path=/trunk/KDE/kdegraphics/okular/; revision=705415 --- ui/annotationpopup.cpp | 1 + ui/annotationpropertiesdialog.cpp | 27 ++++++++++++++++++++++----- ui/pageview.cpp | 13 ++++++++++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/ui/annotationpopup.cpp b/ui/annotationpopup.cpp index d3acc3947..6987f9572 100644 --- a/ui/annotationpopup.cpp +++ b/ui/annotationpopup.cpp @@ -41,6 +41,7 @@ void AnnotationPopup::exec( const QPoint &point ) menu.addTitle( i18n( "Annotation" ) ); popoutWindow = menu.addAction( KIcon( "comment" ), i18n( "&Open Pop-up Note" ) ); deleteNote = menu.addAction( KIcon( "list-remove" ), i18n( "&Delete" ) ); + deleteNote->setEnabled( mDocument->isAllowed( Okular::AllowNotes ) ); if ( mAnnotation->flags() & Okular::Annotation::DenyDelete ) deleteNote->setEnabled( false ); diff --git a/ui/annotationpropertiesdialog.cpp b/ui/annotationpropertiesdialog.cpp index 5a3cd1f14..596e2e160 100644 --- a/ui/annotationpropertiesdialog.cpp +++ b/ui/annotationpropertiesdialog.cpp @@ -34,11 +34,20 @@ AnnotsPropertiesDialog::AnnotsPropertiesDialog( QWidget *parent, Okular::Documen { setFaceType( Tabbed ); m_annot=ann; + bool canEditAnnotations = m_document->isAllowed( Okular::AllowNotes ); setCaptionTextbyAnnotType(); - setButtons( Ok | Apply | Cancel ); - enableButton( Apply, false ); - connect( this, SIGNAL( applyClicked() ), this, SLOT( slotapply() ) ); - connect( this, SIGNAL( okClicked() ), this, SLOT( slotapply() ) ); + 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 ); + } m_annotWidget = AnnotationWidgetFactory::widgetFor( ann ); @@ -55,6 +64,7 @@ AnnotsPropertiesDialog::AnnotsPropertiesDialog( QWidget *parent, Okular::Documen hlay->addWidget( tmplabel ); colorBn = new KColorButton( page ); colorBn->setColor( ann->style().color() ); + colorBn->setEnabled( canEditAnnotations ); tmplabel->setBuddy( colorBn ); hlay->addWidget( colorBn ); @@ -65,11 +75,16 @@ AnnotsPropertiesDialog::AnnotsPropertiesDialog( QWidget *parent, Okular::Documen m_opacity = new KIntNumInput( page ); m_opacity->setRange( 0, 100, 1, true ); m_opacity->setValue( (int)( ann->style().opacity() * 100 ) ); + m_opacity->setEnabled( canEditAnnotations ); tmplabel->setBuddy( m_opacity ); hlay->addWidget( m_opacity ); if ( m_annotWidget ) - lay->addWidget( m_annotWidget->widget() ); + { + QWidget * configWidget = m_annotWidget->widget(); + lay->addWidget( configWidget ); + configWidget->setEnabled( canEditAnnotations ); + } lay->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); //END tab1 @@ -81,6 +96,7 @@ AnnotsPropertiesDialog::AnnotsPropertiesDialog( QWidget *parent, Okular::Documen QGridLayout * gridlayout = new QGridLayout( page ); tmplabel = new QLabel( i18n( "&Author:" ), page ); AuthorEdit = new QLineEdit( ann->author(), page ); + AuthorEdit->setEnabled( canEditAnnotations ); tmplabel->setBuddy( AuthorEdit ); gridlayout->addWidget( tmplabel, 0, 0 ); gridlayout->addWidget( AuthorEdit, 0, 1 ); @@ -109,6 +125,7 @@ AnnotsPropertiesDialog::AnnotsPropertiesDialog( QWidget *parent, Okular::Documen m_contents->setAcceptRichText( false ); m_contents->setReadOnly( true ); m_contents->setPlainText( ann->contents() ); + m_contents->setEnabled( canEditAnnotations ); gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::Expanding ), 4, 0 ); //END advance diff --git a/ui/pageview.cpp b/ui/pageview.cpp index beff98b99..2fcba068b 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -714,8 +714,19 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, bool docu { // may be null if dummy mode is on d->aToggleForms->setEnabled( !pageSet.isEmpty() && hasformwidgets ); } + bool allowAnnotations = d->document->isAllowed( Okular::AllowNotes ); if ( d->annotator ) - d->annotator->setTextToolsEnabled( d->document->supportsSearching() ); + { + if ( allowAnnotations ) + { + d->annotator->setTextToolsEnabled( d->document->supportsSearching() ); + } + else if ( d->aToggleAnnotator->isChecked() ) + { + d->aToggleAnnotator->trigger(); + } + } + d->aToggleAnnotator->setEnabled( allowAnnotations ); } void PageView::notifyViewportChanged( bool smoothMove )