display plugin type

This commit is contained in:
Patrick von Reth 2015-02-03 12:21:12 +01:00
parent 331e9faaf1
commit 3e8c809089
4 changed files with 21 additions and 3 deletions

View File

@ -56,6 +56,7 @@ SnorePlugin *PluginContainer::load()
}
SnorePlugin *plugin = qobject_cast<SnorePlugin *> (m_loader.instance());
Q_ASSERT_X(m_pluginName == plugin->name(),Q_FUNC_INFO, "The plugin name is different to the one in the meta data.");
plugin->m_type = type();
return plugin;
}

View File

@ -21,6 +21,7 @@
#include "snorebackend.h"
#include "snorefrontend.h"
#include "../notification/notification_p.h"
#include "plugincontainer.h"
#include <QTimer>
#include <QPluginLoader>
@ -33,8 +34,7 @@
using namespace Snore;
SnorePlugin::SnorePlugin(const QString &name) :
m_name(name),
m_initialized(false)
m_name(name)
{
if (thread() != qApp->thread()) {
moveToThread(qApp->thread());
@ -107,6 +107,16 @@ const QString &SnorePlugin::name() const
return m_name;
}
SnorePlugin::PluginTypes SnorePlugin::type() const
{
return m_type;
}
const QString SnorePlugin::typeName() const
{
return PluginContainer::typeToString(m_type);
}
bool SnorePlugin::deinitialize()
{
if (m_initialized) {

View File

@ -38,6 +38,7 @@ class SNORE_EXPORT SnorePlugin : public QObject
Q_OBJECT
public:
enum PluginType {
NONE = 0,
ALL = 0xFFFFF,//for loading plugins
BACKEND = 0x1,
SECONDARY_BACKEND = 0x2,
@ -56,6 +57,9 @@ public:
const SnoreCore *snore() const;
const QString &name() const;
PluginTypes type() const;
const QString typeName() const;
QVariant value(const QString &key) const;
void setValue(const QString &key, const QVariant &value);
@ -68,7 +72,9 @@ private:
QString normaliseKey(const QString &key) const;
QString m_name;
bool m_initialized;
bool m_initialized = false;
PluginTypes m_type = NONE;
friend class PluginContainer;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::SnorePlugin::PluginTypes)

View File

@ -31,6 +31,7 @@ PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *pa
m_enabled(new QCheckBox)
{
setLayout(m_layout);
addRow(snorePlugin->typeName(),nullptr);
addRow("Enabled:",m_enabled);
}