From 09992c654db860b22d6b109707462346bfb5ca26 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 27 May 2012 07:41:02 +0200 Subject: [PATCH] Remove QFactoryInterface from style plugins Change-Id: I5c41f1c8b91b5e1117b9163c137de4bf5f51099c Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/widgets/styles/qstylefactory.cpp | 2 +- src/widgets/styles/qstyleplugin.cpp | 22 +++++++++------------- src/widgets/styles/qstyleplugin.h | 11 +---------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp index ec29ae7b99..479cc1aab9 100644 --- a/src/widgets/styles/qstylefactory.cpp +++ b/src/widgets/styles/qstylefactory.cpp @@ -182,7 +182,7 @@ QStyle *QStyleFactory::create(const QString& key) { } // Keep these here - they make the #ifdefery above work #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) if (!ret) - ret = qLoadPlugin(loader(), style); + ret = qLoadPlugin(loader(), style); #endif if(ret) ret->setObjectName(style); diff --git a/src/widgets/styles/qstyleplugin.cpp b/src/widgets/styles/qstyleplugin.cpp index b36ffcf181..be3ea3ca64 100644 --- a/src/widgets/styles/qstyleplugin.cpp +++ b/src/widgets/styles/qstyleplugin.cpp @@ -56,24 +56,20 @@ QT_BEGIN_NAMESPACE applications using the QStyleFactory class. Writing a style plugin is achieved by subclassing this base class, - reimplementing the pure virtual keys() and create() functions, and - exporting the class using the Q_EXPORT_PLUGIN2() macro. See \l + reimplementing the pure virtual create() function, and + exporting the class using the Q_PLUGIN_METADATA() macro. See \l {How to Create Qt Plugins} for details. + The json metadata file for the plugin needs to contain information + about the names of the styles the plugins supports as follows: + + \code + { "Keys": [ "mystyle" ] } + \endcode + \sa QStyleFactory, QStyle */ -/*! - \fn QStringList QStylePlugin::keys() const - - Returns the list of style keys this plugin supports. - - These keys are usually the class names of the custom styles that - are implemented in the plugin. - - \sa create() -*/ - /*! \fn QStyle *QStylePlugin::create(const QString& key) diff --git a/src/widgets/styles/qstyleplugin.h b/src/widgets/styles/qstyleplugin.h index 883952eced..2393080aa7 100644 --- a/src/widgets/styles/qstyleplugin.h +++ b/src/widgets/styles/qstyleplugin.h @@ -52,24 +52,15 @@ QT_BEGIN_NAMESPACE class QStyle; -struct Q_WIDGETS_EXPORT QStyleFactoryInterface : public QFactoryInterface -{ - virtual QStyle *create(const QString &key) = 0; -}; - #define QStyleFactoryInterface_iid "org.qt-project.Qt.QStyleFactoryInterface" -Q_DECLARE_INTERFACE(QStyleFactoryInterface, QStyleFactoryInterface_iid) - -class Q_WIDGETS_EXPORT QStylePlugin : public QObject, public QStyleFactoryInterface +class Q_WIDGETS_EXPORT QStylePlugin : public QObject { Q_OBJECT - Q_INTERFACES(QStyleFactoryInterface:QFactoryInterface) public: explicit QStylePlugin(QObject *parent = 0); ~QStylePlugin(); - virtual QStringList keys() const = 0; virtual QStyle *create(const QString &key) = 0; };