mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 11:40:07 +00:00
Add support to set read only from scripts
Summary: This makes it possible to set the read only state from scripts. Requires Poppler master with the patch attached to the parent task. Reviewers: #okular Subscribers: aacid Tags: #okular Maniphest Tasks: T8097 Differential Revision: https://phabricator.kde.org/D10867
This commit is contained in:
parent
adfb3cc2d6
commit
6897e042df
|
@ -55,6 +55,10 @@ bool FormField::isReadOnly() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void FormField::setReadOnly( bool )
|
||||
{
|
||||
}
|
||||
|
||||
bool FormField::isVisible() const
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -86,6 +86,13 @@ class OKULARCORE_EXPORT FormField
|
|||
*/
|
||||
virtual bool isReadOnly() const;
|
||||
|
||||
/**
|
||||
* Whether the field is read-only.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
virtual void setReadOnly( bool value );
|
||||
|
||||
/**
|
||||
* Whether this form field is visible.
|
||||
*/
|
||||
|
|
|
@ -31,6 +31,23 @@ static KJSPrototype *g_fieldProto;
|
|||
typedef QHash< FormField *, Page * > FormCache;
|
||||
Q_GLOBAL_STATIC( FormCache, g_fieldCache )
|
||||
|
||||
|
||||
// Helper for modified fields
|
||||
static void updateField( FormField *field )
|
||||
{
|
||||
Page *page = g_fieldCache->value( field );
|
||||
if (page)
|
||||
{
|
||||
Document *doc = PagePrivate::get( page )->m_doc->m_parent;
|
||||
QMetaObject::invokeMethod( doc, "refreshPixmaps", Qt::QueuedConnection, Q_ARG( int, page->number() ) );
|
||||
emit doc->refreshFormWidget( field );
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Could not get page of field" << field;
|
||||
}
|
||||
}
|
||||
|
||||
// Field.doc
|
||||
static KJSObject fieldGetDoc( KJSContext *context, void * )
|
||||
{
|
||||
|
@ -54,16 +71,11 @@ static KJSObject fieldGetReadOnly( KJSContext *, void *object )
|
|||
// Field.readonly (setter)
|
||||
static void fieldSetReadOnly( KJSContext *context, void *object, KJSObject value )
|
||||
{
|
||||
#if 0
|
||||
FormField *field = reinterpret_cast< FormField * >( object );
|
||||
bool b = value.toBoolean( context );
|
||||
field->setReadOnly( b );
|
||||
#else
|
||||
Q_UNUSED( context );
|
||||
Q_UNUSED( object );
|
||||
Q_UNUSED( value );
|
||||
qCDebug(OkularCoreDebug) << "Not implemented: setting readonly property";
|
||||
#endif
|
||||
|
||||
updateField( field );
|
||||
}
|
||||
|
||||
static QString fieldGetTypeHelper( const FormField *field )
|
||||
|
@ -165,18 +177,7 @@ static void fieldSetValue( KJSContext *context, void *object, KJSObject value )
|
|||
if ( text != textField->text() )
|
||||
{
|
||||
textField->setText( text );
|
||||
|
||||
Page *page = g_fieldCache->value( field );
|
||||
if (page)
|
||||
{
|
||||
Document *doc = PagePrivate::get( page )->m_doc->m_parent;
|
||||
QMetaObject::invokeMethod( doc, "refreshPixmaps", Qt::QueuedConnection, Q_ARG( int, page->number() ) );
|
||||
emit doc->refreshFormWidget( field );
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Could not get page of field" << field;
|
||||
}
|
||||
updateField( field );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,15 @@ bool PopplerFormFieldButton::isReadOnly() const
|
|||
return m_field->isReadOnly();
|
||||
}
|
||||
|
||||
void PopplerFormFieldButton::setReadOnly( bool value )
|
||||
{
|
||||
#ifdef HAVE_POPPLER_0_64
|
||||
m_field->setReadOnly( value );
|
||||
#else
|
||||
Q_UNUSED( value );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PopplerFormFieldButton::isVisible() const
|
||||
{
|
||||
return m_field->isVisible();
|
||||
|
@ -145,6 +154,15 @@ bool PopplerFormFieldText::isReadOnly() const
|
|||
return m_field->isReadOnly();
|
||||
}
|
||||
|
||||
void PopplerFormFieldText::setReadOnly( bool value )
|
||||
{
|
||||
#ifdef HAVE_POPPLER_0_64
|
||||
m_field->setReadOnly( value );
|
||||
#else
|
||||
Q_UNUSED( value );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PopplerFormFieldText::isVisible() const
|
||||
{
|
||||
return m_field->isVisible();
|
||||
|
@ -238,6 +256,15 @@ bool PopplerFormFieldChoice::isReadOnly() const
|
|||
return m_field->isReadOnly();
|
||||
}
|
||||
|
||||
void PopplerFormFieldChoice::setReadOnly( bool value )
|
||||
{
|
||||
#ifdef HAVE_POPPLER_0_64
|
||||
m_field->setReadOnly( value );
|
||||
#else
|
||||
Q_UNUSED( value );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PopplerFormFieldChoice::isVisible() const
|
||||
{
|
||||
return m_field->isVisible();
|
||||
|
|
|
@ -25,6 +25,7 @@ class PopplerFormFieldButton : public Okular::FormFieldButton
|
|||
QString name() const override;
|
||||
QString uiName() const override;
|
||||
bool isReadOnly() const override;
|
||||
void setReadOnly( bool value ) override;
|
||||
bool isVisible() const override;
|
||||
|
||||
// inherited from Okular::FormFieldButton
|
||||
|
@ -53,6 +54,7 @@ class PopplerFormFieldText : public Okular::FormFieldText
|
|||
QString name() const override;
|
||||
QString uiName() const override;
|
||||
bool isReadOnly() const override;
|
||||
void setReadOnly( bool value ) override;
|
||||
bool isVisible() const override;
|
||||
|
||||
// inherited from Okular::FormFieldText
|
||||
|
@ -84,6 +86,7 @@ class PopplerFormFieldChoice : public Okular::FormFieldChoice
|
|||
QString name() const override;
|
||||
QString uiName() const override;
|
||||
bool isReadOnly() const override;
|
||||
void setReadOnly( bool value ) override;
|
||||
bool isVisible() const override;
|
||||
|
||||
// inherited from Okular::FormFieldChoice
|
||||
|
|
Loading…
Reference in a new issue