CopperSpice API  1.9.1
QWebPluginFactory Class Referenceabstract

The QWebPluginFactory class is used to embed custom data types in web pages. More...

Inheritance diagram for QWebPluginFactory:
QObject

Classes

class  MimeType
 The QWebPluginFactory::MimeType structure describes a mime type supported by a plugin More...
 
class  Plugin
 This structure describes the properties of a plugin a QWebPluginFactory can create More...
 

Public Methods

 QWebPluginFactory (QObject *parent=0)
 
virtual ~QWebPluginFactory ()
 
virtual QObjectcreate (const QString &mimeType, const QUrl &url, const QStringList &argumentNames, const QStringList &argumentValues) const = 0
 
virtual QList< Pluginplugins () const = 0
 
virtual void refreshPlugins ()
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Additional Inherited Members

- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QWebPluginFactory class is used to embed custom data types in web pages. The HTML <object> tag is used to embed arbitrary content into a web page.

<object type="application/x-pdf" data="https://www.copperspice.com/sample.pdf" width="500" height="400"></object>

CsWebKit will natively handle the most basic data types like text/html and image/jpeg, but for any advanced or custom data types you will need to provide a handler yourself. QWebPluginFactory is a factory for creating plugins for QWebPage, where each plugin provides support for one or more data types. A plugin factory can be installed on a QWebPage using QWebPage::setPluginFactory().

Note
The plugin factory is only used if plugins are enabled through QWebSettings.

You provide a QWebPluginFactory by implementing the plugins() and the create() methods. For plugins() it is necessary to describe the plugins the factory can create, including a description and the supported MIME types. The MIME types each plugin can handle should match the ones specified in the HTML <object> tag of your content.

The create() method is called if the requested MIME type is supported. The implementation has to return a new instance of the plugin requested for the given MIME type and the specified URL.

The plugins themselves are subclasses of QObject, but currently only plugins which are based on either QWidget or QGraphicsWidget are supported.

Constructor & Destructor Documentation

QWebPluginFactory::QWebPluginFactory ( QObject parent = 0)
explicit

Constructs a QWebPluginFactory with the given parent.

QWebPluginFactory::~QWebPluginFactory ( )
virtual

Destructor.

Method Documentation

QObject * QWebPluginFactory::create ( const QString mimeType,
const QUrl url,
const QStringList argumentNames,
const QStringList argumentValues 
) const
pure virtual

Implemented in subclasses to create a new plugin that can display content of the MIME type given by mimeType. The URL of the content is provided in url. The returned object should be a QWidget.

The HTML object element can provide parameters through the <param> tag. The name and the value attributes of these tags are specified by the argumentNames and argumentValues string lists.

<object type="application/x-pdf" data="https://www.copperspice.com/sample.pdf" width="500" height="400">
<param name="showTableOfContents" value="true" />
<param name="hideThumbnails" value="false" />
</object>

The above object element will result in a call to create() with the following arguments:

ParameterValue
mimeType"application/x-pdf"
url"https://www.copperspice.com/sample.pdf&quot;
argumentNames"showTableOfContents" "hideThumbnails"
argumentValues"true" "false"
Note
Ownership of the returned object will be transferred to the caller.
QList< Plugin > QWebPluginFactory::plugins ( ) const
pure virtual

This function is reimplemented in subclasses to return a list of supported plugins the factory can create.

Note
Currently, this function is only called when JavaScript programs access the global plugins or mimetypes objects.
void QWebPluginFactory::refreshPlugins ( )
virtual

This function is called to refresh the list of supported plugins. It may be called after a new plugin has been installed in the system.