add support for filtering applets based on specified application. useful for non-plasma targets (e.g. amarok). default behavious remains the same.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=733292
This commit is contained in:
parent
0f889fd7c8
commit
845139ae0a
@ -36,17 +36,19 @@ namespace Plasma
|
||||
class AppletBrowser::Private
|
||||
{
|
||||
public:
|
||||
Private(Corona* co, Containment* cont, AppletBrowser* q)
|
||||
: corona(co),
|
||||
Private(Corona* co, Containment* cont, AppletBrowser* q, const QString& app)
|
||||
: application( app ),
|
||||
corona(co),
|
||||
containment(cont),
|
||||
appletList(0),
|
||||
config("plasmarc"),
|
||||
configGroup(&config, "Applet Browser"),
|
||||
itemModel(configGroup, q),
|
||||
itemModel(configGroup, app, q),
|
||||
filterModel(q)
|
||||
{
|
||||
}
|
||||
|
||||
QString application;
|
||||
Plasma::Corona *corona;
|
||||
Plasma::Containment *containment;
|
||||
KCategorizedItemsView *appletList;
|
||||
@ -58,16 +60,16 @@ public:
|
||||
KCategorizedItemsViewModels::DefaultFilterModel filterModel;
|
||||
};
|
||||
|
||||
AppletBrowser::AppletBrowser(Plasma::Corona * corona, QWidget * parent, Qt::WindowFlags f)
|
||||
AppletBrowser::AppletBrowser(Plasma::Corona * corona, const QString& application, QWidget * parent, Qt::WindowFlags f)
|
||||
: KDialog(parent, f),
|
||||
d(new Private(corona, 0, this))
|
||||
d(new Private(corona, 0, this, application))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
AppletBrowser::AppletBrowser(Plasma::Containment * containment, QWidget * parent, Qt::WindowFlags f)
|
||||
AppletBrowser::AppletBrowser(Plasma::Containment * containment, const QString& application, QWidget * parent, Qt::WindowFlags f)
|
||||
: KDialog(parent, f),
|
||||
d(new Private(0, containment, this))
|
||||
d(new Private(0, containment, this, application))
|
||||
{
|
||||
init();
|
||||
}
|
||||
@ -127,8 +129,8 @@ void AppletBrowser::init()
|
||||
|
||||
d->filterModel.addSeparator(i18n("Categories:"));
|
||||
|
||||
// Filters: Categories
|
||||
foreach (const QString& category, Plasma::Applet::knownCategories()) {
|
||||
|
||||
foreach (const QString& category, Plasma::Applet::knownCategories(d->application)) {
|
||||
d->filterModel.addFilter(category,
|
||||
KCategorizedItemsViewModels::Filter("category", category));
|
||||
}
|
||||
@ -144,6 +146,17 @@ AppletBrowser::~AppletBrowser()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void AppletBrowser::setApplication( const QString& app )
|
||||
{
|
||||
d->application = app;
|
||||
d->itemModel.setApplication( app );
|
||||
}
|
||||
|
||||
QString AppletBrowser::Application()
|
||||
{
|
||||
return d->application;
|
||||
}
|
||||
|
||||
void AppletBrowser::addApplet()
|
||||
{
|
||||
kDebug() << "Button ADD clicked";
|
||||
|
@ -34,10 +34,13 @@ class PLASMA_EXPORT AppletBrowser: public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppletBrowser(Plasma::Corona *corona, QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
explicit AppletBrowser(Plasma::Containment *containment, QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
explicit AppletBrowser(Plasma::Corona *corona, const QString& app = QString(), QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
explicit AppletBrowser(Plasma::Containment *containment, const QString& = QString(), QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
virtual ~AppletBrowser();
|
||||
|
||||
void setApplication( const QString& application );
|
||||
QString Application();
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* Adds currently selected applets
|
||||
|
@ -80,8 +80,9 @@ QVariantList PlasmaAppletItem::arguments() const
|
||||
return qvariant_cast<QVariantList>(data().toMap()["arguments"]);
|
||||
}
|
||||
|
||||
PlasmaAppletItemModel::PlasmaAppletItemModel(KConfigGroup configGroup, QObject * parent) :
|
||||
PlasmaAppletItemModel::PlasmaAppletItemModel(KConfigGroup configGroup, QString app, QObject * parent) :
|
||||
KCategorizedItemsViewModels::DefaultItemModel(parent),
|
||||
m_application( app ),
|
||||
m_configGroup(configGroup)
|
||||
{
|
||||
|
||||
@ -103,7 +104,7 @@ PlasmaAppletItemModel::PlasmaAppletItemModel(KConfigGroup configGroup, QObject *
|
||||
m_used = m_configGroup.readEntry("used").split(",");
|
||||
|
||||
//TODO: get recommended, favorit, used, etc out of knownApplets()
|
||||
foreach (const KPluginInfo& info, Plasma::Applet::knownApplets()) {
|
||||
foreach (const KPluginInfo& info, Plasma::Applet::knownApplets( QString(), m_application)) {
|
||||
//kDebug() << info.pluginName() << "NoDisplay" << info.property("NoDisplay").toBool();
|
||||
if (info.property("NoDisplay").toBool()) {
|
||||
// we don't want to show the hidden category
|
||||
@ -181,6 +182,16 @@ void PlasmaAppletItemModel::setFavorite(QString plugin, bool favorite)
|
||||
|
||||
}
|
||||
|
||||
void PlasmaAppletItemModel::setApplication(const QString& app)
|
||||
{
|
||||
m_application = app;
|
||||
}
|
||||
|
||||
QString& PlasmaAppletItemModel::Application()
|
||||
{
|
||||
return m_application;
|
||||
}
|
||||
|
||||
/*
|
||||
* Define function type to get the SuperKaramba themes
|
||||
* from skapplet (see skapplet.cpp in kdeutils/superkaramba)
|
||||
@ -223,4 +234,3 @@ void PlasmaAppletItemModel::loadSuperKarambaThemes(const KPluginInfo &info)
|
||||
kWarning() << "Could not load" << libName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,15 +60,18 @@ class PlasmaAppletItemModel :
|
||||
public KCategorizedItemsViewModels::DefaultItemModel
|
||||
{
|
||||
public:
|
||||
PlasmaAppletItemModel(KConfigGroup configGroup, QObject * parent = 0);
|
||||
PlasmaAppletItemModel(KConfigGroup configGroup, QString parentApp = QString(), QObject * parent = 0);
|
||||
|
||||
QStringList mimeTypes() const;
|
||||
|
||||
QMimeData* mimeData(const QModelIndexList & indexes) const;
|
||||
|
||||
void setFavorite(QString plugin, bool favorite);
|
||||
void setApplication(const QString& app);
|
||||
|
||||
QString& Application();
|
||||
private:
|
||||
QString m_application;
|
||||
QStringList m_favorites;
|
||||
QStringList m_used;
|
||||
KConfigGroup m_configGroup;
|
||||
|
Loading…
Reference in New Issue
Block a user