[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Re: [Panel-devel] Applet Manager Dialog
From: Chani <chanika () gmail ! com>
Date: 2007-12-07 7:13:28
Message-ID: 200712071513.29050.chanika () gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
On October 19, 2007 12:49:11 you wrote:
> > - i wonder if this should be a separate dialog or if it should actually
> > go into the applet dialog itself? so that the user can see feedback there
> > on applets that are running; it could then be another category to filter
> > on as well.
>
> I was wondering the same thing myself. if it could be brought into the
> applet dialog in a nice, usable way I think that would be best... anyone
> got thoughts on how the UI should behave?
I've begun work on doing this. attached is a patch of what I've got so far:
-filter on which applets are running
-show how many of an applet are running
not finished yet:
-make 'remove' actually remove every instance of that applet when clicked
I've got a few questions about how to continue with this code.
-how do I make the ui addition not horrifically ugly?
-what's the best way of making the 'remove' text clickable?
-what's the best way to keep updated on which applets are running? currently
I've just tossed a call to the general update function in a few places; this
sucks, but gets updates often enough for me to test other code. it would be
nice if there were some signals I could hook into on applet
creation/deletion. I'd prefer not to resort to using a timer. I haven't
actually looked into this deeply yet.
any comments on features that could be added are welcome too :)
--
This message brought to you by evyl bananas, and the number 3.
www.chani3.com
["appletbrowser.diff" (text/x-diff)]
Index: appletbrowser.cpp
===================================================================
--- appletbrowser.cpp (revision 745547)
+++ appletbrowser.cpp (working copy)
@@ -48,6 +48,7 @@
}
void initFilters();
+ void updateRunningApplets();
QString application;
Plasma::Corona *corona;
@@ -96,6 +97,9 @@
filterModel.addFilter(i18n("Widgets I Have Used Before"),
KCategorizedItemsViewModels::Filter("used", true),
new KIcon("history"));
+ filterModel.addFilter(i18n("Currently Running Widgets"),
+ KCategorizedItemsViewModels::Filter("running", true),
+ new KIcon("history"));
filterModel.addSeparator(i18n("Categories:"));
@@ -105,7 +109,35 @@
}
}
+void AppletBrowserWidget::Private::updateRunningApplets()
+{
+//get applets from corona, count them, send results to model
+//TODO save a reference to each in a hash
+ QHash<QString,int> apps;
+ Plasma::Corona *c=corona;
+ if (!c && containment) {
+ c=containment->corona();
+ }
+ //we've tried our best to get a corona
+ //we don't want just one containment, we want them all
+ if (!c) {
+ kDebug() << "can't happen";
+ return;
+ }
+ QList<Containment*>containments=c->containments();
+ foreach (Containment * containment,containments) {
+ //TODO track containments too?
+ kDebug() << containment->name();
+ QList<Applet*>applets=containment->applets();
+ foreach (Applet *applet,applets) {
+ apps[applet->name()]++;
+ }
+ }
+ kDebug() << apps;
+ itemModel.setRunningApplets(apps);
+}
+
AppletBrowserWidget::AppletBrowserWidget(Plasma::Corona * corona, bool showButtons, \
QWidget * parent, Qt::WindowFlags f) : QWidget(parent, f),
d(new Private(corona, 0, this)),
@@ -161,6 +193,7 @@
// Other models
d->appletList->setItemModel(&d->itemModel);
+ d->updateRunningApplets();
}
void AppletBrowserWidget::setApplication(const QString& app)
@@ -173,6 +206,7 @@
//FIXME: AFAIK this shouldn't be necessary ... but here it is. need to find out \
what in that // maze of models and views is screwing up
d->appletList->setItemModel(&d->itemModel);
+ d->updateRunningApplets();
}
QString AppletBrowserWidget::application()
@@ -197,6 +231,7 @@
}
}
+ d->updateRunningApplets();
}
void AppletBrowserWidget::downloadApplets()
Index: appletbrowser/kcategorizeditemsviewdelegate.cpp
===================================================================
--- appletbrowser/kcategorizeditemsviewdelegate.cpp (revision 745547)
+++ appletbrowser/kcategorizeditemsviewdelegate.cpp (working copy)
@@ -80,6 +80,7 @@
QString title = item->name();
QString description = item->description();
+ int running = item->data().toMap()["runningCount"].toInt();
// Painting
@@ -99,6 +100,19 @@
top + UNIVERSAL_PADDING + MAIN_ICON_SIZE / 2,
width - textInner, MAIN_ICON_SIZE / 2,
Qt::AlignTop | Qt::AlignLeft, description);
+ if (running) {
+ //removal text FIXME: overlap?
+ QString remove = i18n("Remove");
+ if (running > 1) {
+ remove += QString(" (%1)__").arg(running);
+ }
+ painter->setFont(local_option_normal.font);
+ painter->drawText(
+ left + (leftToRight ? textInner : 0),
+ top + UNIVERSAL_PADDING + MAIN_ICON_SIZE / 2,
+ width - textInner, MAIN_ICON_SIZE / 2,
+ Qt::AlignTop | Qt::AlignRight, remove);
+ }
// Main icon
item->icon().paint(painter,
Index: appletbrowser/plasmaappletitemmodel.cpp
===================================================================
--- appletbrowser/plasmaappletitemmodel.cpp (revision 745547)
+++ appletbrowser/plasmaappletitemmodel.cpp (working copy)
@@ -69,6 +69,15 @@
}
}
+void PlasmaAppletItem::setRunning(int count)
+{
+ kDebug() << name() << "has count" << count;
+ QMap<QString, QVariant> attrs = data().toMap();
+ attrs.insert("running", count > 0); //bool for the filter
+ attrs.insert("runningCount", count);
+ setData(QVariant(attrs));
+}
+
bool PlasmaAppletItem::passesFiltering(
const KCategorizedItemsViewModels::Filter & filter) const
{
@@ -138,6 +147,20 @@
}
}
+void PlasmaAppletItemModel::setRunningApplets(const QHash<QString, int> apps)
+{
+ //foreach item, find that string and set its count
+ for (int r=0; r<rowCount(); ++r)
+ {
+ QStandardItem *i = item(r);
+ PlasmaAppletItem *p = (PlasmaAppletItem *)i; //why doesn't qobject_cast \
work? + if (p)
+ {
+ p->setRunning(apps.value(p->name()));
+ }
+ }
+}
+
QStringList PlasmaAppletItemModel::mimeTypes() const
{
QStringList types;
Index: appletbrowser/plasmaappletitemmodel_p.h
===================================================================
--- appletbrowser/plasmaappletitemmodel_p.h (revision 745547)
+++ appletbrowser/plasmaappletitemmodel_p.h (working copy)
@@ -48,6 +48,8 @@
QString pluginName() const;
virtual QString description() const;
virtual void setFavorite(bool favorite);
+ //set how many instances of this applet are running
+ virtual void setRunning(int count);
virtual bool passesFiltering(
const KCategorizedItemsViewModels::Filter & filter) const;
virtual QVariantList arguments() const;
@@ -68,6 +70,7 @@
void setFavorite(QString plugin, bool favorite);
void setApplication(const QString& app);
+ void setRunningApplets(const QHash<QString, int> apps);
QString& Application();
private:
["signature.asc" (application/pgp-signature)]
_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic