Fix loading plasmoids by absolute path

We were not looking into the plugin directory when figuring out the applet
path when it's load from an absolute path.
Fixes configmodeltest

REVIEW: 129101
This commit is contained in:
Aleix Pol 2016-10-10 21:30:02 +02:00
parent 4a9d5cff2a
commit 2ed819f37d
2 changed files with 7 additions and 2 deletions

View File

@ -29,7 +29,9 @@
#include <qstandardpaths.h>
#include <QTimer>
#include <QJsonArray>
#include <QDir>
#include <QDebug>
#include <QFileInfo>
#include <QMessageBox>
#include <klocalizedstring.h>
@ -113,8 +115,9 @@ AppletPrivate::~AppletPrivate()
delete modificationsTimer;
}
void AppletPrivate::init(const QString &packagePath, const QVariantList &args)
void AppletPrivate::init(const QString &_packagePath, const QVariantList &args)
{
const QString packagePath = _packagePath.isEmpty() ? QFileInfo(appletDescription.metaDataFileName()).dir().path() : _packagePath;
// WARNING: do not access config() OR globalConfig() in this method!
// that requires a Corona, which is not available at this point
q->setHasConfigurationInterface(true);

View File

@ -199,7 +199,9 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
const QString source = d->categories.at(index.row())->source();
// Quick check if source is an absolute path or not
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 {
return source;
}