no reason to provide 3 ways to do something when there are already 2 fine ways
This commit is contained in:
parent
7b1359d2d3
commit
dd95295cb0
@ -66,8 +66,7 @@ PlasmaKPart::PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this line initializes the corona.
|
initCorona();
|
||||||
corona();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaKPart::~PlasmaKPart()
|
PlasmaKPart::~PlasmaKPart()
|
||||||
@ -117,9 +116,12 @@ void PlasmaKPart::syncConfig()
|
|||||||
KGlobal::config()->sync();
|
KGlobal::config()->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaKPartCorona* PlasmaKPart::corona()
|
void PlasmaKPart::initCorona()
|
||||||
{
|
{
|
||||||
if (!m_corona) {
|
if (m_corona) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_corona = new PlasmaKPartCorona(this);
|
m_corona = new PlasmaKPartCorona(this);
|
||||||
connect(m_corona, SIGNAL(containmentAdded(Plasma::Containment*)), this, SLOT(createView(Plasma::Containment*)));
|
connect(m_corona, SIGNAL(containmentAdded(Plasma::Containment*)), this, SLOT(createView(Plasma::Containment*)));
|
||||||
connect(m_corona, SIGNAL(configSynced()), this, SLOT(syncConfig()));
|
connect(m_corona, SIGNAL(configSynced()), this, SLOT(syncConfig()));
|
||||||
@ -128,8 +130,10 @@ PlasmaKPartCorona* PlasmaKPart::corona()
|
|||||||
m_corona->initializeLayout();
|
m_corona->initializeLayout();
|
||||||
|
|
||||||
m_view->show();
|
m_view->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlasmaKPartCorona* PlasmaKPart::corona() const
|
||||||
|
{
|
||||||
return m_corona;
|
return m_corona;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,24 +153,14 @@ void PlasmaKPart::addApplet(const QString& name, const QVariantList& args, const
|
|||||||
containment()->addApplet(name, args, geometry);
|
containment()->addApplet(name, args, geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::Applet::List PlasmaKPart::listActiveApplets( )
|
Plasma::Applet::List PlasmaKPart::listActiveApplets() const
|
||||||
{
|
{
|
||||||
return containment()->applets();
|
return containment()->applets();
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::Containment* PlasmaKPart::containment()
|
Plasma::Containment* PlasmaKPart::containment() const
|
||||||
{
|
{
|
||||||
return corona()->containments().first();
|
return corona()->containments().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlasmaKPart::setPluginLoader(Plasma::PluginLoader *loader)
|
|
||||||
{
|
|
||||||
if (Plasma::PluginLoader::pluginLoader()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::PluginLoader::setPluginLoader(loader);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "plasmakpart.moc"
|
#include "plasmakpart.moc"
|
||||||
|
@ -47,13 +47,27 @@ class PlasmaKPart : public KParts::ReadOnlyPart
|
|||||||
Q_PROPERTY(Plasma::Applet::List activeApplets READ listActiveApplets)
|
Q_PROPERTY(Plasma::Applet::List activeApplets READ listActiveApplets)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* The default constructor.
|
||||||
|
* The args may contain a pointer to a Plasma::PluginLoader as the first parameter.
|
||||||
|
* Note that only one Plasma::PluginLoader can be active at a time, and that the
|
||||||
|
* prefered mechanism for registering the plugin loader is via
|
||||||
|
* Plasma::PluginLoader::setPluginLoader
|
||||||
|
*/
|
||||||
PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantList &args);
|
PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantList &args);
|
||||||
~PlasmaKPart();
|
~PlasmaKPart();
|
||||||
|
|
||||||
void notifyStartup(bool completed);
|
void notifyStartup(bool completed);
|
||||||
|
|
||||||
PlasmaKPartCorona *corona();
|
PlasmaKPartCorona *corona() const;
|
||||||
Plasma::Containment *containment();
|
Plasma::Containment *containment() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of active applets in the containment.
|
||||||
|
*
|
||||||
|
* @return A list of the containment's Applets
|
||||||
|
**/
|
||||||
|
Plasma::Applet::List listActiveApplets() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
@ -65,38 +79,12 @@ public Q_SLOTS:
|
|||||||
**/
|
**/
|
||||||
void addApplet(const QString &pluginName, const QVariantList &args = QVariantList(), const QRectF &dimensions = QRectF());
|
void addApplet(const QString &pluginName, const QVariantList &args = QVariantList(), const QRectF &dimensions = QRectF());
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the application-specific plugin loader. This allows
|
|
||||||
* applications which need to add internal applets (such
|
|
||||||
* as existing QWidget-based dashboard plugins), services or
|
|
||||||
* data engines to the Plasma dashboard. The preferred way to
|
|
||||||
* set this loader is by passing it to the KPart wrapped in a
|
|
||||||
* QVariant in the @p args parameter of the KPart constructor.
|
|
||||||
* This method is provided for applications which cannot set
|
|
||||||
* the loader in this method.
|
|
||||||
* The method will return false if Plasma already has a
|
|
||||||
* PluginLoader in memory, and will return true if the PluginLoader
|
|
||||||
* is successfully set.
|
|
||||||
*
|
|
||||||
* @param loader The loader which you want Plasma to query for
|
|
||||||
* new Applets, Data Engines and Services.
|
|
||||||
* @return True if the loader was successfully set, false otherwise
|
|
||||||
* (If Plasma already has a PluginLoader in memory)
|
|
||||||
*
|
|
||||||
* @short Set application-specific plugin loader
|
|
||||||
**/
|
|
||||||
bool setPluginLoader(Plasma::PluginLoader *loader);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of active applets in the containment.
|
|
||||||
*
|
|
||||||
* @return A list of the containment's Applets
|
|
||||||
**/
|
|
||||||
Plasma::Applet::List listActiveApplets();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void viewCreated();
|
void viewCreated();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initCorona();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void syncConfig();
|
void syncConfig();
|
||||||
|
Loading…
Reference in New Issue
Block a user