Remove QFactoryInterface dependency from icon plugins

Change-Id: I65bed1646f3c5e89329a6bbe3dcdbdb5660b7004
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Lars Knoll 2012-05-27 04:02:09 +02:00 committed by Qt by Nokia
parent 2903db8b4c
commit dcf3c95175
3 changed files with 16 additions and 21 deletions

View File

@ -833,7 +833,7 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
// first try version 2 engines..
const int index = loader()->indexOf(suffix);
if (index != -1) {
if (QIconEngineFactoryInterface *factory = qobject_cast<QIconEngineFactoryInterface*>(loader()->instance(index))) {
if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))) {
if (QIconEngine *engine = factory->create(fileName)) {
d = new QIconPrivate;
d->engine = engine;
@ -1089,7 +1089,7 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon)
} else {
const int index = loader()->indexOf(key);
if (index != -1) {
if (QIconEngineFactoryInterface *factory = qobject_cast<QIconEngineFactoryInterface*>(loader()->instance(index))) {
if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))) {
if (QIconEngine *engine= factory->create()) {
icon.d = new QIconPrivate;
icon.d->engine = engine;

View File

@ -51,16 +51,22 @@ QT_BEGIN_NAMESPACE
\ingroup plugins
\inmodule QtGui
\b {Use QIconEnginePluginV2 instead.}
The icon engine plugin is a simple plugin interface that makes it easy to
create custom icon engines that can be loaded dynamically into applications
through QIcon. QIcon uses the file or resource name's suffix to determine
what icon engine to use.
Writing a icon engine plugin is achieved by subclassing this base class,
reimplementing the pure virtual functions keys() and create(), and
exporting the class with the Q_EXPORT_PLUGIN2() macro.
reimplementing the pure virtual function create(), and
exporting the class with the Q_PLUGIN_METADATA() macro.
The json metadata should contain a list of icon engine keys that this plugin supports.
The keys correspond to the suffix of the file or resource name used when the plugin was
created. Keys are case insensitive.
\code
{ "Keys": [ "myiconengine" ] }
\endcode
\sa {How to Create Qt Plugins}
*/
@ -68,9 +74,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn QStringList QIconEnginePlugin::keys() const
Returns a list of icon engine keys that this plugin supports. The keys correspond
to the suffix of the file or resource name used when the plugin was created.
Keys are case insensitive.
Returns
\sa create()
*/
@ -86,7 +90,7 @@ QT_BEGIN_NAMESPACE
/*!
Constructs a icon engine plugin with the given \a parent. This is invoked
automatically by the Q_EXPORT_PLUGIN2() macro.
automatically by the plugin loader.
*/
QIconEnginePlugin::QIconEnginePlugin(QObject *parent)
: QObject(parent)

View File

@ -52,24 +52,15 @@ QT_BEGIN_NAMESPACE
class QIconEngine;
struct Q_GUI_EXPORT QIconEngineFactoryInterface : public QFactoryInterface
{
virtual QIconEngine *create(const QString &filename = QString()) = 0;
};
#define QIconEngineFactoryInterface_iid "org.qt-project.Qt.QIconEngineFactoryInterface"
#define QIconEngineFactoryInterface_iid \
"org.qt-project.Qt.QIconEngineFactoryInterface"
Q_DECLARE_INTERFACE(QIconEngineFactoryInterface, QIconEngineFactoryInterface_iid)
class Q_GUI_EXPORT QIconEnginePlugin : public QObject, public QIconEngineFactoryInterface
class Q_GUI_EXPORT QIconEnginePlugin : public QObject
{
Q_OBJECT
Q_INTERFACES(QIconEngineFactoryInterface:QFactoryInterface)
public:
QIconEnginePlugin(QObject *parent = 0);
~QIconEnginePlugin();
virtual QStringList keys() const = 0;
virtual QIconEngine *create(const QString &filename = QString()) = 0;
};