diff --git a/app/indicator/factory.cpp b/app/indicator/factory.cpp index 1677ee4ab..14c430877 100644 --- a/app/indicator/factory.cpp +++ b/app/indicator/factory.cpp @@ -115,10 +115,10 @@ void Factory::reload(const QString &indicatorPath) QString pluginChangedId; if (!indicatorPath.isEmpty() && indicatorPath != "." && indicatorPath != "..") { - QString metadataFile = indicatorPath + "/metadata.desktop"; + QString metadataFile = metadataFileAbsolutePath(indicatorPath); if(QFileInfo(metadataFile).exists()) { - KPluginMetaData metadata = KPluginMetaData::fromDesktopFile(metadataFile); + KPluginMetaData metadata = KPluginMetaData(metadataFile); if (metadataAreValid(metadata)) { pluginChangedId = metadata.pluginId(); @@ -244,7 +244,7 @@ bool Factory::metadataAreValid(KPluginMetaData &metadata) bool Factory::metadataAreValid(QString &file) { if (QFileInfo(file).exists()) { - KPluginMetaData metadata = KPluginMetaData::fromDesktopFile(file); + KPluginMetaData metadata(file); return metadata.isValid(); } @@ -260,6 +260,23 @@ QString Factory::uiPath(QString pluginName) const return m_pluginUiPaths[pluginName]; } +QString Factory::metadataFileAbsolutePath(const QString &directoryPath) +{ + QString metadataFile = directoryPath + "/metadata.json"; + + if(QFileInfo(metadataFile).exists()) { + return metadataFile; + } + + metadataFile = directoryPath + "/metadata.desktop"; + + if(QFileInfo(metadataFile).exists()) { + return metadataFile; + } + + return QString(); +} + Latte::ImportExport::State Factory::importIndicatorFile(QString compressedFile) { auto showNotificationError = []() { @@ -303,7 +320,7 @@ Latte::ImportExport::State Factory::importIndicatorFile(QString compressedFile) //metadata file QString packagePath = archiveTempDir.path(); - QString metadataFile = archiveTempDir.path() + "/metadata.desktop"; + QString metadataFile = metadataFileAbsolutePath(archiveTempDir.path()); if (!QFileInfo(metadataFile).exists()){ QDirIterator iter(archiveTempDir.path(), QDir::Dirs | QDir::NoDotAndDotDot); @@ -311,7 +328,7 @@ Latte::ImportExport::State Factory::importIndicatorFile(QString compressedFile) while(iter.hasNext() ) { QString currentPath = iter.next(); - QString tempMetadata = currentPath + "/metadata.desktop"; + QString tempMetadata = metadataFileAbsolutePath(currentPath); if (QFileInfo(tempMetadata).exists()) { metadataFile = tempMetadata; @@ -320,7 +337,7 @@ Latte::ImportExport::State Factory::importIndicatorFile(QString compressedFile) } } - KPluginMetaData metadata = KPluginMetaData::fromDesktopFile(metadataFile); + KPluginMetaData metadata = KPluginMetaData(metadataFile); if (metadataAreValid(metadata)) { QStringList standardPaths = Latte::Layouts::Importer::standardPaths(); diff --git a/app/indicator/factory.h b/app/indicator/factory.h index ec67b6cf5..b4790c395 100644 --- a/app/indicator/factory.h +++ b/app/indicator/factory.h @@ -42,6 +42,8 @@ public: QString uiPath(QString pluginName) const; + static QString metadataFileAbsolutePath(const QString &directoryPath); + //! metadata record static bool metadataAreValid(KPluginMetaData &metadata); //! metadata file diff --git a/app/view/indicator/indicator.cpp b/app/view/indicator/indicator.cpp index afd9329ef..77819a52c 100644 --- a/app/view/indicator/indicator.cpp +++ b/app/view/indicator/indicator.cpp @@ -15,6 +15,7 @@ // Qt #include +#include #include // KDE @@ -243,9 +244,7 @@ void Indicator::load(QString type) m_metadata = metadata; m_type = type; - - QString path = m_metadata.fileName(); - m_pluginPath = path.remove("metadata.desktop"); + m_pluginPath = QFileInfo(m_metadata.fileName()).absolutePath(); if (m_corona && m_corona->indicatorFactory()->isCustomType(type)) { setCustomType(type); @@ -271,7 +270,7 @@ void Indicator::updateComponent() QString uiPath = m_metadata.value("X-Latte-MainScript"); if (!uiPath.isEmpty()) { - uiPath = m_pluginPath + "package/" + uiPath; + uiPath = m_pluginPath + "/package/" + uiPath; m_component = new QQmlComponent(m_view->engine(), uiPath); } @@ -288,10 +287,7 @@ void Indicator::loadPlasmaComponent() QString uiPath = metadata.value("X-Latte-MainScript"); if (!uiPath.isEmpty()) { - QString path = metadata.fileName(); - path = path.remove("metadata.desktop"); - - uiPath = path + "package/" + uiPath; + uiPath = QFileInfo(metadata.fileName()).absolutePath() + "/package/" + uiPath; m_plasmaComponent = new QQmlComponent(m_view->engine(), uiPath); } @@ -315,7 +311,7 @@ void Indicator::updateScheme() QString xmlPath = m_metadata.value("X-Latte-ConfigXml"); if (!xmlPath.isEmpty()) { - QFile file(m_pluginPath + "package/" + xmlPath); + QFile file(m_pluginPath + "/package/" + xmlPath); m_configLoader = new KConfigLoader(m_view->containment()->config().group("Indicator").group(m_metadata.pluginId()), &file); m_configuration = new KDeclarative::ConfigPropertyMap(m_configLoader, this); } else { diff --git a/app/view/settings/indicatoruimanager.cpp b/app/view/settings/indicatoruimanager.cpp index 0c85706f1..4705f9eec 100644 --- a/app/view/settings/indicatoruimanager.cpp +++ b/app/view/settings/indicatoruimanager.cpp @@ -14,6 +14,7 @@ // Qt #include +#include #include // KDE @@ -112,7 +113,7 @@ void IndicatorUiManager::ui(const QString &type, Latte::View *view) } //! type needs to be created again - KPluginMetaData metadata = m_primary->corona()->indicatorFactory()->metadata(type);; + KPluginMetaData metadata = m_primary->corona()->indicatorFactory()->metadata(type); if (metadata.isValid()) { QString uiPath = metadata.value("X-Latte-ConfigUi"); @@ -121,13 +122,13 @@ void IndicatorUiManager::ui(const QString &type, Latte::View *view) IndicatorUiData uidata; uidata.ui = new KDeclarative::QmlObjectSharedEngine(this); - uidata.pluginPath = metadata.fileName().remove("metadata.desktop"); + uidata.pluginPath = QFileInfo(metadata.fileName()).absolutePath(); uidata.type = type; uidata.view = view; uidata.ui->setTranslationDomain(QLatin1String("latte_indicator_") + metadata.pluginId()); uidata.ui->setInitializationDelayed(true); - uiPath = uidata.pluginPath + "package/" + uiPath; + uiPath = uidata.pluginPath + "/package/" + uiPath; uidata.ui->setSource(QUrl::fromLocalFile(uiPath)); uidata.ui->rootContext()->setContextProperty(QStringLiteral("dialog"), m_parentItem); uidata.ui->rootContext()->setContextProperty(QStringLiteral("indicator"), view->indicator());