Fix loading plasmoids by absolute path

We were not looking into the plugin directory when figuring out the applet
path.
Fixes configmodeltest

REVIEW: 129143
This commit is contained in:
Aleix Pol 2016-10-11 15:22:41 +02:00
parent 98b7f48a89
commit ba9a8a16ab
2 changed files with 7 additions and 2 deletions

View File

@ -29,7 +29,9 @@
#include <qstandardpaths.h> #include <qstandardpaths.h>
#include <QTimer> #include <QTimer>
#include <QJsonArray> #include <QJsonArray>
#include <QDir>
#include <QDebug> #include <QDebug>
#include <QFileInfo>
#include <QMessageBox> #include <QMessageBox>
#include <klocalizedstring.h> #include <klocalizedstring.h>
@ -113,7 +115,7 @@ AppletPrivate::~AppletPrivate()
delete modificationsTimer; delete modificationsTimer;
} }
void AppletPrivate::init(const QString &packagePath, const QVariantList &args) void AppletPrivate::init(const QString &_packagePath, const QVariantList &args)
{ {
// WARNING: do not access config() OR globalConfig() in this method! // WARNING: do not access config() OR globalConfig() in this method!
// that requires a Corona, which is not available at this point // that requires a Corona, which is not available at this point
@ -145,6 +147,7 @@ void AppletPrivate::init(const QString &packagePath, const QVariantList &args)
return; return;
} }
const QString packagePath = _packagePath.isEmpty() && !appletDescription.metaDataFileName().isEmpty() ? QFileInfo(appletDescription.metaDataFileName()).dir().path() : _packagePath;
QString path = appletDescription.rawData().value(QStringLiteral("X-Plasma-RootPath")).toString(); QString path = appletDescription.rawData().value(QStringLiteral("X-Plasma-RootPath")).toString();
if (path.isEmpty()) { if (path.isEmpty()) {
path = packagePath.isEmpty() ? appletDescription.pluginId() : packagePath; path = packagePath.isEmpty() ? appletDescription.pluginId() : packagePath;

View File

@ -199,7 +199,9 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
const QString source = d->categories.at(index.row())->source(); const QString source = d->categories.at(index.row())->source();
// Quick check if source is an absolute path or not // Quick check if source is an absolute path or not
if (d->appletInterface && !source.isEmpty() && !(source.startsWith('/') && source.endsWith(QLatin1String("qml")))) { if (d->appletInterface && !source.isEmpty() && !(source.startsWith('/') && source.endsWith(QLatin1String("qml")))) {
return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", source)); if(!d->appletInterface.data()->kPackage().isValid())
qWarning() << "wrong applet" << d->appletInterface.data()->pluginMetaData().name();
return QUrl::fromLocalFile(d->appletInterface.data()->kPackage().filePath("ui", source));
} else { } else {
return source; return source;
} }