logic to load Plasmoids

- add a mousearea to the delegate that calls
  widgetExplorer.addApplet(pluginName)
- in widgetsexplorer, locate the plasmoid, load it via
  Applet::loadPlasmoid(), then add it to the containment
- In showWidgetExplorer, we set the widgetExplorer's containment to the
  sender(), if there's no containment set, we can't add the applet. This
  way, the widgetexplorer knows which containment the applet should go to

This makes it possible to add Plasmoids via the GUI :-)
This commit is contained in:
Sebastian Kügler 2013-03-21 05:04:04 +01:00
parent 1619430697
commit 64b3812c05
3 changed files with 31 additions and 5 deletions

View File

@ -57,15 +57,13 @@ DesktopCorona::DesktopCorona(QObject *parent)
this, SLOT(updateScreenOwner(int, int, Plasma::Containment *)));
checkViews();
//QTimer::singleShot(1000, this, SLOT(showWidgetExplorer())); // just for easier debugging
//QTimer::singleShot(600, this, SLOT(showWidgetExplorer())); // just for easier debugging
}
DesktopCorona::~DesktopCorona()
{
}
void DesktopCorona::loadDefaultLayout()
{
WorkspaceScripting::DesktopScriptEngine scriptEngine(this, true);
@ -289,6 +287,14 @@ void DesktopCorona::showWidgetExplorer()
connect(m_widgetExplorerView, &QQuickView::statusChanged, this, &DesktopCorona::widgetExplorerStatusChanged);
connect(m_widgetExplorerView, &QQuickView::visibleChanged, this, &DesktopCorona::widgetExplorerClosed);
}
Plasma::Containment *c = 0;
c = dynamic_cast<Plasma::Containment*>(sender());
if (c) {
qDebug() << "Found containment.";
m_widgetExplorer->setContainment(c);
} else {
qDebug() << "containment not set";
}
m_widgetExplorerView->show();
}

View File

@ -36,6 +36,11 @@ Rectangle {
width: parent.width
height: 48
Text { text: "Applet: " + pluginName }
MouseArea {
anchors.fill: parent
onClicked: widgetExplorer.addApplet(pluginName)
}
}
}

View File

@ -456,8 +456,23 @@ Plasma::Corona *WidgetExplorer::corona() const
void WidgetExplorer::addApplet(const QString &pluginName)
{
qWarning() << "FIXME: add applet needs reimplementation";
//d->containment->addApplet(pluginName);
const QString p = "plasma/plasmoids/"+pluginName;
qWarning() << "--------> load applet: " << pluginName << " relpath: " << p;
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, p, QStandardPaths::LocateDirectory);
qDebug() << " .. pathes: " << dirs;
Plasma::Applet *applet = Plasma::Applet::loadPlasmoid(dirs.first());
if (applet) {
if (d->containment) {
d->containment->addApplet(applet);
} else {
qWarning() << "No containment set (but the applet loaded).";
}
} else {
qWarning() << "Failed to load applet" << pluginName << dirs;
}
}
void WidgetExplorer::immutabilityChanged(Plasma::ImmutabilityType type)