check all shell directories

BUG: 348056
REVIEW: 123870
wilder-5.14
David Edmundson 11 years ago
parent 39280d242c
commit f59164914c
  1. 38
      shell/shellmanager.cpp

@ -39,7 +39,7 @@
#include <KLocalizedString> #include <KLocalizedString>
#include <kcrash.h> #include <kcrash.h>
static const QString s_shellsDir(QStandardPaths::locate(QStandardPaths::QStandardPaths::GenericDataLocation, static const QStringList s_shellsDirs(QStandardPaths::locateAll(QStandardPaths::QStandardPaths::GenericDataLocation,
PLASMA_RELATIVE_DATA_INSTALL_DIR "/shells/", PLASMA_RELATIVE_DATA_INSTALL_DIR "/shells/",
QStandardPaths::LocateDirectory)); QStandardPaths::LocateDirectory));
static const QString s_shellLoaderPath = QStringLiteral("/contents/loader.qml"); static const QString s_shellLoaderPath = QStringLiteral("/contents/loader.qml");
@ -110,26 +110,28 @@ void ShellManager::loadHandlers()
// TODO: Use corona's qml engine when it switches from QScriptEngine // TODO: Use corona's qml engine when it switches from QScriptEngine
static QQmlEngine * engine = new QQmlEngine(this); static QQmlEngine * engine = new QQmlEngine(this);
for (const auto & dir: QDir(s_shellsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { for (const QString &shellsDir: s_shellsDirs) {
const QString qmlFile = s_shellsDir + dir + s_shellLoaderPath; for (const auto & dir: QDir(shellsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
// qDebug() << "Making a new instance of " << qmlFile; const QString qmlFile = shellsDir + dir + s_shellLoaderPath;
// qDebug() << "Making a new instance of " << qmlFile;
QQmlComponent handlerComponent(engine, QQmlComponent handlerComponent(engine,
QUrl::fromLocalFile(qmlFile) QUrl::fromLocalFile(qmlFile)
); );
auto handler = handlerComponent.create(); auto handler = handlerComponent.create();
// Writing out the errors // Writing out the errors
for (const auto & error: handlerComponent.errors()) { for (const auto & error: handlerComponent.errors()) {
qWarning() << "Error: " << error; qWarning() << "Error: " << error;
} }
if (handler) { if (handler) {
handler->setProperty("pluginName", dir); handler->setProperty("pluginName", dir);
// This property is useful for shells to launch themselves in some specific sessions // This property is useful for shells to launch themselves in some specific sessions
// For example mediacenter shell can be launched when in plasma-mediacenter session // For example mediacenter shell can be launched when in plasma-mediacenter session
handler->setProperty("currentSession", QString::fromUtf8(qgetenv("DESKTOP_SESSION"))); handler->setProperty("currentSession", QString::fromUtf8(qgetenv("DESKTOP_SESSION")));
registerHandler(handler); registerHandler(handler);
}
} }
} }

Loading…
Cancel
Save