diff --git a/src/shell/widgetexplorer/widgetexplorer.cpp b/src/shell/widgetexplorer/widgetexplorer.cpp index 9a5e9c81f..dd40076c1 100644 --- a/src/shell/widgetexplorer/widgetexplorer.cpp +++ b/src/shell/widgetexplorer/widgetexplorer.cpp @@ -114,12 +114,28 @@ void WidgetExplorerPrivate::initFilters() QMap categories; QSet existingCategories = itemModel.categories(); //foreach (const QString &category, Plasma::Applet::listCategories(application)) { + QStringList cats; + KService::List services = KServiceTypeTrader::self()->query("Plasma/Applet", QString()); + + foreach (const KSharedPtr service, services) { + KPluginInfo info(service); + if (info.property("NoDisplay").toBool() || info.category() == i18n("Containments") || + info.category().isEmpty()) { + // we don't want to show the hidden category + continue; + } + const QString c = info.category(); + if (-1 == cats.indexOf(c)) { + cats << c; + } + } qWarning() << "TODO: port listCategories()"; - foreach (const QString &category, QStringList("FIXME")) { + foreach (const QString &category, cats) { const QString lowerCaseCat = category.toLower(); if (existingCategories.contains(lowerCaseCat)) { const QString trans = i18n(category.toLocal8Bit()); categories.insert(trans.toLower(), qMakePair(trans, lowerCaseCat)); + qDebug() << "Categories: << " << lowerCaseCat; } } diff --git a/src/shell/widgetexplorer/widgetexplorerview.cpp b/src/shell/widgetexplorer/widgetexplorerview.cpp index 5fd6a48c3..6c64e772c 100644 --- a/src/shell/widgetexplorer/widgetexplorerview.cpp +++ b/src/shell/widgetexplorer/widgetexplorerview.cpp @@ -55,21 +55,21 @@ WidgetExplorerView::~WidgetExplorerView() void WidgetExplorerView::init() { - setTitle(i18n("Add Widgets")); - setColor(Qt::transparent); + qDebug() << "Loading WidgetExplorer: " << m_qmlPath; m_widgetExplorer = new WidgetExplorer(this); m_widgetExplorer->populateWidgetList(); - rootContext()->setContextProperty("widgetExplorer", m_widgetExplorer); - connect(m_widgetExplorer, &WidgetExplorer::closeClicked, this, &QQuickView::close); + m_widgetExplorer->setContainment(m_containment); -// QString expqml = package().filePath("widgetexplorer"); - qDebug() << "Script to load for WidgetExplorer: " << m_qmlPath; + rootContext()->setContextProperty("widgetExplorer", m_widgetExplorer); + setTitle(i18n("Add Widgets")); + setColor(Qt::transparent); + setResizeMode(QQuickView::SizeRootObjectToView); setSource(QUrl::fromLocalFile(m_qmlPath)); + + connect(m_widgetExplorer, &WidgetExplorer::closeClicked, this, &QQuickView::close); connect(this, &QQuickView::statusChanged, this, &WidgetExplorerView::widgetExplorerStatusChanged); connect(this, &QQuickView::visibleChanged, this, &WidgetExplorerView::widgetExplorerClosed); - setResizeMode(QQuickView::SizeRootObjectToView); - m_widgetExplorer->setContainment(m_containment); } @@ -77,17 +77,6 @@ void WidgetExplorerView::setContainment(Plasma::Containment* c) { m_containment = c; m_widgetExplorer->setContainment(c); - -// QObject *graphicObject = m_containment->property("graphicObject").value(); -// -// if (graphicObject) { -// qDebug() << "using as graphic containment" << graphicObject << m_containment; -// -// rootObject()->setProperty("parent", QVariant::fromValue(graphicObject)); -// //rootObject()->setProperty("containment", QVariant::fromValue(graphicObject)); -// } else { -// qWarning() << "Containment graphic object not valid"; -// } }