Remove the PluginSystem

But keep the Interface so it's still userfull to create a new
SocialNetwork  when needed, but it will be part of the code,
and not a plugin.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-11-09 18:14:20 -02:00 committed by Dirk Hohndel
parent 66091ff853
commit f5f2c37184
5 changed files with 11 additions and 10 deletions

View file

@ -260,15 +260,16 @@ void MainWindow::setupSocialNetworkMenu()
QMenu *connections = new QMenu(tr("Connect to")); QMenu *connections = new QMenu(tr("Connect to"));
FacebookPlugin *facebookPlugin = new FacebookPlugin(); FacebookPlugin *facebookPlugin = new FacebookPlugin();
QAction *toggle_connection = new QAction(this); QAction *toggle_connection = new QAction(this);
QObject *obj = qobject_cast<QObject*>(facebookPlugin);
toggle_connection->setText(facebookPlugin->socialNetworkName()); toggle_connection->setText(facebookPlugin->socialNetworkName());
toggle_connection->setIcon(QIcon(facebookPlugin->socialNetworkIcon())); toggle_connection->setIcon(QIcon(facebookPlugin->socialNetworkIcon()));
toggle_connection->setData(QVariant::fromValue(facebookPlugin)); toggle_connection->setData(QVariant::fromValue(obj));
connect(toggle_connection, SIGNAL(triggered()), this, SLOT(socialNetworkRequestConnect())); connect(toggle_connection, SIGNAL(triggered()), this, SLOT(socialNetworkRequestConnect()));
QAction *share_on = new QAction(this); QAction *share_on = new QAction(this);
share_on->setText(facebookPlugin->socialNetworkName()); share_on->setText(facebookPlugin->socialNetworkName());
share_on->setIcon(QIcon(facebookPlugin->socialNetworkIcon())); share_on->setIcon(QIcon(facebookPlugin->socialNetworkIcon()));
share_on->setData(QVariant::fromValue(facebookPlugin)); share_on->setData(QVariant::fromValue(obj));
ui.menuShare_on->addAction(share_on); ui.menuShare_on->addAction(share_on);
connections->addAction(toggle_connection); connections->addAction(toggle_connection);
connect(share_on, SIGNAL(triggered()), this, SLOT(socialNetworkRequestUpload())); connect(share_on, SIGNAL(triggered()), this, SLOT(socialNetworkRequestUpload()));
@ -280,7 +281,7 @@ void MainWindow::setupSocialNetworkMenu()
void MainWindow::socialNetworkRequestConnect() void MainWindow::socialNetworkRequestConnect()
{ {
QAction *action = qobject_cast<QAction*>(sender()); QAction *action = qobject_cast<QAction*>(sender());
FacebookPlugin *plugin = action->data().value<FacebookPlugin*>(); ISocialNetworkIntegration *plugin = qobject_cast<ISocialNetworkIntegration*>(action->data().value<QObject*>());
if (plugin->isConnected()) if (plugin->isConnected())
plugin->requestLogoff(); plugin->requestLogoff();
else else

View file

@ -3,7 +3,7 @@
#include <QDebug> #include <QDebug>
FacebookPlugin::FacebookPlugin(QObject* parent): QObject(parent), FacebookPlugin::FacebookPlugin(QObject* parent) :
fbConnectWidget(new FacebookConnectWidget()), fbConnectWidget(new FacebookConnectWidget()),
fbUploadDialog(new SocialNetworkDialog()) fbUploadDialog(new SocialNetworkDialog())
{ {

View file

@ -8,10 +8,8 @@ class FacebookConnectWidget;
class SocialNetworkDialog; class SocialNetworkDialog;
class FacebookManager; class FacebookManager;
class FacebookPlugin : public QObject, public ISocialNetworkIntegration { class FacebookPlugin : public ISocialNetworkIntegration {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.subsurface.plugins.ISocialNetworkIntegration")
Q_INTERFACES(ISocialNetworkIntegration)
public: public:
explicit FacebookPlugin(QObject* parent = 0); explicit FacebookPlugin(QObject* parent = 0);
virtual bool isConnected(); virtual bool isConnected();

View file

@ -79,6 +79,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
color.cpp color.cpp
pluginmanager.cpp pluginmanager.cpp
imagedownloader.cpp imagedownloader.cpp
isocialnetworkintegration.cpp
${SERIAL_FTDI} ${SERIAL_FTDI}
${PLATFORM_SRC} ${PLATFORM_SRC}
${BT_CORE_SRC_FILES} ${BT_CORE_SRC_FILES}

View file

@ -10,8 +10,11 @@
* We bundle facebook integration as an example. * We bundle facebook integration as an example.
*/ */
class ISocialNetworkIntegration { class ISocialNetworkIntegration : public QObject {
Q_OBJECT
public: public:
ISocialNetworkIntegration(QObject* parent = 0);
/*! /*!
* @name socialNetworkName * @name socialNetworkName
* @brief The name of this social network * @brief The name of this social network
@ -67,6 +70,4 @@ public:
virtual void requestUpload() = 0; virtual void requestUpload() = 0;
}; };
Q_DECLARE_INTERFACE(ISocialNetworkIntegration, "org.subsurface.ISocialNetworkIntegration.v1")
Q_DECLARE_METATYPE(ISocialNetworkIntegration*);
#endif #endif