kdeplasma-addons: use the package metadata to get the package name in qmlwallpapers plugin

much more reliable than chopping the path into pieces to figure out the
package name. also because KGlobal::dirs()->findDirs() returns paths with
trailing slash the previous method was returning empty string

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-08 15:12:00 +03:00
parent b9106628cd
commit ae086cf0b8
2 changed files with 2 additions and 2 deletions

View file

@ -83,7 +83,7 @@ QVariant WallpapersModel::data(const QModelIndex& index, int role) const
Plasma::Package* p = m_packages[index.row()]; Plasma::Package* p = m_packages[index.row()];
switch (role) { switch (role) {
case PackageNameRole: case PackageNameRole:
return KUrl(p->path()).fileName(KUrl::LeaveTrailingSlash); return p->metadata().pluginName();
case Qt::DisplayRole: case Qt::DisplayRole:
return p->metadata().name(); return p->metadata().name();
case Qt::ToolTipRole: case Qt::ToolTipRole:

View file

@ -173,7 +173,7 @@ QWidget* WallpaperQml::createConfigurationInterface(QWidget* parent)
v.m_view->setItemDelegate(new BackgroundDelegate(v.m_view)); v.m_view->setItemDelegate(new BackgroundDelegate(v.m_view));
if (m_package) { if (m_package) {
v.m_view->setCurrentIndex(m->indexForPackagePath(m_package->path())); v.m_view->setCurrentIndex(m->indexForPackagePath(m_package->path()));
m_packageName = KUrl(m_package->path()).fileName(KUrl::LeaveTrailingSlash); m_packageName = m_package->metadata().pluginName();
} }
v.m_color->setColor(m_scene->backgroundBrush().color()); v.m_color->setColor(m_scene->backgroundBrush().color());