mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-03 09:17:50 +03:00
support json files from indicators
--when an indicator provides only a json file for its metadata latte now is able to indentify it properly. BUG:455603
This commit is contained in:
parent
81e0f90f43
commit
ec51d21eae
@ -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();
|
||||
|
@ -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
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
// Qt
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QLatin1String>
|
||||
|
||||
// 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 {
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
// Qt
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QTimer>
|
||||
|
||||
// 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());
|
||||
|
Loading…
Reference in New Issue
Block a user