diff --git a/plasma/applet.cpp b/plasma/applet.cpp index ce5252ea6..50b72666d 100644 --- a/plasma/applet.cpp +++ b/plasma/applet.cpp @@ -971,4 +971,3 @@ void ContainmentPrivate::checkRemoveAction() } // Plasma namespace #include "moc_applet.cpp" -#include "private/moc_applet_p.cpp" diff --git a/plasma/pluginloader.cpp b/plasma/pluginloader.cpp index b212917de..cc0a29c84 100644 --- a/plasma/pluginloader.cpp +++ b/plasma/pluginloader.cpp @@ -50,10 +50,61 @@ static PluginLoader *s_pluginLoader = 0; class PluginLoaderPrivate { public: + static QSet knownCategories(); + static QString parentAppConstraint(const QString &parentApp = QString()); + + static QSet s_customCategories; QHash > structures; bool isDefaultLoader; }; +QSet PluginLoaderPrivate::s_customCategories; + +QSet PluginLoaderPrivate::knownCategories() +{ + // this is to trick the tranlsation tools into making the correct + // strings for translation + QSet categories = s_customCategories; + categories << QString(I18N_NOOP("Accessibility")).toLower() + << QString(I18N_NOOP("Application Launchers")).toLower() + << QString(I18N_NOOP("Astronomy")).toLower() + << QString(I18N_NOOP("Date and Time")).toLower() + << QString(I18N_NOOP("Development Tools")).toLower() + << QString(I18N_NOOP("Education")).toLower() + << QString(I18N_NOOP("Environment and Weather")).toLower() + << QString(I18N_NOOP("Examples")).toLower() + << QString(I18N_NOOP("File System")).toLower() + << QString(I18N_NOOP("Fun and Games")).toLower() + << QString(I18N_NOOP("Graphics")).toLower() + << QString(I18N_NOOP("Language")).toLower() + << QString(I18N_NOOP("Mapping")).toLower() + << QString(I18N_NOOP("Miscellaneous")).toLower() + << QString(I18N_NOOP("Multimedia")).toLower() + << QString(I18N_NOOP("Online Services")).toLower() + << QString(I18N_NOOP("Productivity")).toLower() + << QString(I18N_NOOP("System Information")).toLower() + << QString(I18N_NOOP("Utilities")).toLower() + << QString(I18N_NOOP("Windows and Tasks")).toLower(); + return categories; +} + +QString PluginLoaderPrivate::parentAppConstraint(const QString &parentApp) +{ + if (parentApp.isEmpty()) { + QCoreApplication *app = QCoreApplication::instance(); + if (!app) { + return QString(); + } + + return QString("((not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '') or [X-KDE-ParentApp] == '%1')") + .arg(app->applicationName()); + } + + return QString("[X-KDE-ParentApp] == '%1'").arg(parentApp); +} + + + PluginLoader::PluginLoader() : d(new PluginLoaderPrivate) { @@ -398,7 +449,7 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS list = internalAppletInfo(category); } - QString constraint = AppletPrivate::parentAppConstraint(parentApp); + QString constraint = PluginLoaderPrivate::parentAppConstraint(parentApp); //note: constraint guaranteed non-empty from here down if (category.isEmpty()) { //use all but the excluded categories @@ -423,7 +474,7 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS KPluginInfo::List PluginLoader::listAppletInfoForMimeType(const QString &mimeType) { - QString constraint = AppletPrivate::parentAppConstraint(); + QString constraint = PluginLoaderPrivate::parentAppConstraint(); constraint.append(QString(" and '%1' in [X-Plasma-DropMimeTypes]").arg(mimeType)); //kDebug() << "listAppletInfoForMimetype with" << mimeType << constraint; KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); @@ -432,7 +483,7 @@ KPluginInfo::List PluginLoader::listAppletInfoForMimeType(const QString &mimeTyp KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url) { - QString constraint = AppletPrivate::parentAppConstraint(); + QString constraint = PluginLoaderPrivate::parentAppConstraint(); constraint.append(" and exist [X-Plasma-DropUrlPatterns]"); KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); @@ -457,7 +508,7 @@ KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url) QStringList PluginLoader::listAppletCategories(const QString &parentApp, bool visibleOnly) { - QString constraint = AppletPrivate::parentAppConstraint(parentApp); + QString constraint = PluginLoaderPrivate::parentAppConstraint(parentApp); constraint.append(" and exist [X-KDE-PluginInfo-Category]"); KConfigGroup group(KSharedConfig::openConfig(), "General"); @@ -469,7 +520,7 @@ QStringList PluginLoader::listAppletCategories(const QString &parentApp, bool vi KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); QStringList categories; - QSet known = AppletPrivate::knownCategories(); + QSet known = PluginLoaderPrivate::knownCategories(); foreach (const KService::Ptr &applet, offers) { QString appletCategory = applet->property("X-KDE-PluginInfo-Category").toString(); if (visibleOnly && applet->noDisplay()) { @@ -501,12 +552,12 @@ QStringList PluginLoader::listAppletCategories(const QString &parentApp, bool vi void PluginLoader::setCustomAppletCategories(const QStringList &categories) { - AppletPrivate::s_customCategories = QSet::fromList(categories); + PluginLoaderPrivate::s_customCategories = QSet::fromList(categories); } QStringList PluginLoader::customAppletCategories() const { - return AppletPrivate::s_customCategories.toList(); + return PluginLoaderPrivate::s_customCategories.toList(); } QString PluginLoader::appletCategory(const QString& appletName) diff --git a/plasma/private/applet_p.cpp b/plasma/private/applet_p.cpp index f92872ef9..545e96d9b 100644 --- a/plasma/private/applet_p.cpp +++ b/plasma/private/applet_p.cpp @@ -228,34 +228,6 @@ QString AppletPrivate::configWindowTitle() const return i18nc("@title:window", "%1 Settings", q->title()); } -QSet AppletPrivate::knownCategories() -{ - // this is to trick the tranlsation tools into making the correct - // strings for translation - QSet categories = s_customCategories; - categories << QString(I18N_NOOP("Accessibility")).toLower() - << QString(I18N_NOOP("Application Launchers")).toLower() - << QString(I18N_NOOP("Astronomy")).toLower() - << QString(I18N_NOOP("Date and Time")).toLower() - << QString(I18N_NOOP("Development Tools")).toLower() - << QString(I18N_NOOP("Education")).toLower() - << QString(I18N_NOOP("Environment and Weather")).toLower() - << QString(I18N_NOOP("Examples")).toLower() - << QString(I18N_NOOP("File System")).toLower() - << QString(I18N_NOOP("Fun and Games")).toLower() - << QString(I18N_NOOP("Graphics")).toLower() - << QString(I18N_NOOP("Language")).toLower() - << QString(I18N_NOOP("Mapping")).toLower() - << QString(I18N_NOOP("Miscellaneous")).toLower() - << QString(I18N_NOOP("Multimedia")).toLower() - << QString(I18N_NOOP("Online Services")).toLower() - << QString(I18N_NOOP("Productivity")).toLower() - << QString(I18N_NOOP("System Information")).toLower() - << QString(I18N_NOOP("Utilities")).toLower() - << QString(I18N_NOOP("Windows and Tasks")).toLower(); - return categories; -} - KConfigDialog *AppletPrivate::generateGenericConfigDialog() { KConfigSkeleton *nullManager = new KConfigSkeleton(0); @@ -359,21 +331,6 @@ void AppletPrivate::propagateConfigChanged() q->configChanged(); } -QString AppletPrivate::parentAppConstraint(const QString &parentApp) -{ - if (parentApp.isEmpty()) { - QCoreApplication *app = QCoreApplication::instance(); - if (!app) { - return QString(); - } - - return QString("((not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '') or [X-KDE-ParentApp] == '%1')") - .arg(app->applicationName()); - } - - return QString("[X-KDE-ParentApp] == '%1'").arg(parentApp); -} - void AppletPrivate::setIsContainment(bool nowIsContainment, bool forceUpdate) { if (isContainment == nowIsContainment && !forceUpdate) { @@ -525,6 +482,5 @@ void AppletPrivate::resetConfigurationObject() } uint AppletPrivate::s_maxAppletId = 0; -QSet AppletPrivate::s_customCategories; } //namespace Plasma diff --git a/plasma/private/applet_p.h b/plasma/private/applet_p.h index 88868fcf9..5c68651df 100644 --- a/plasma/private/applet_p.h +++ b/plasma/private/applet_p.h @@ -105,11 +105,9 @@ public: void propagateConfigChanged(); static KActionCollection* defaultActions(QObject *parent); - static QSet knownCategories(); - static QString parentAppConstraint(const QString &parentApp = QString()); + static uint s_maxAppletId; - static QSet s_customCategories; // number of members at this point. uint appletId;