@@ -166,9 +166,7 @@ int LauncherBackend::progress(const QString &appId) const
167int LauncherBackend::count(const QString &appId) const
167int LauncherBackend::count(const QString &appId) const
169− // TODO: emit countChanged() when this value changes.
171− int count = 0;
169+ int count = -1;
172 LauncherBackendItem *item = m_itemCache.value(appId);
170 LauncherBackendItem *item = m_itemCache.value(appId);
173 if (!item) {
171 if (!item) {
174 QString df = findDesktopFile(appId);
172 QString df = findDesktopFile(appId);
@@ -187,6 +185,79 @@ int LauncherBackend::count(const QString &appId) const
187 return count;
185 return count;
188+void LauncherBackend::setCount(const QString &appId, int count) const
190+ LauncherBackendItem *item = m_itemCache.value(appId);
192+ QString df = findDesktopFile(appId);
193+ if (!df.isEmpty()) {
194+ item = parseDesktopFile(df);
195+ m_itemCache.insert(appId, item);
199+ bool emitchange = false;
201+ emitchange = (item->count != count);
202+ item->count = count;
206+ /* TODO: This needs to use the accessor to handle the visibility
207+ correctly, but when we have the two properties we can just use
209+ Q_EMIT countChanged(appId, this->count(appId));
210+ QVariant vcount(item->count);
211+ emitPropChangedDbus(appId, "count", vcount);
215+bool LauncherBackend::countVisible(const QString &appId) const
217+ bool visible = false;
218+ LauncherBackendItem *item = m_itemCache.value(appId);
220+ QString df = findDesktopFile(appId);
221+ if (!df.isEmpty()) {
222+ item = parseDesktopFile(df);
223+ m_itemCache.insert(appId, item);
228+ visible = item->countVisible;
234+void LauncherBackend::setCountVisible(const QString &appId, bool visible) const
236+ LauncherBackendItem *item = m_itemCache.value(appId);
238+ QString df = findDesktopFile(appId);
239+ if (!df.isEmpty()) {
240+ item = parseDesktopFile(df);
241+ m_itemCache.insert(appId, item);
245+ bool emitchange = false;
247+ emitchange = (item->countVisible != visible);
248+ item->countVisible = visible;
252+ /* TODO: Because we're using visible in determining the
253+ count we need to emit a count changed as well */
254+ Q_EMIT countChanged(appId, this->count(appId));
255+ Q_EMIT countVisibleChanged(appId, item->countVisible);
256+ QVariant vCountVisible(item->countVisible);
257+ emitPropChangedDbus(appId, "countVisible", vCountVisible);
190void LauncherBackend::setUser(const QString &username)
261void LauncherBackend::setUser(const QString &username)
192 if (qgetenv("USER") == "lightdm" && m_user != username) {
263 if (qgetenv("USER") == "lightdm" && m_user != username) {
@@ -470,3 +541,24 @@ QString LauncherBackend::encodeAppId (const QString& appId) const
471 return encoded;
542 return encoded;
545+void LauncherBackend::emitPropChangedDbus (const QString& appId, const QString& property, QVariant &value) const
547+ QString path("/com/canonical/unity/launcher/");
548+ path.append(encodeAppId(appId));
550+ QDBusMessage message = QDBusMessage::createSignal(path, "org.freedesktop.DBus.Properties", "PropertiesChanged");
552+ QList<QVariant> arguments;
553+ QVariantHash changedprops;
554+ changedprops[property] = value;
555+ QVariantList deletedprops;
557+ arguments.append(changedprops);
558+ arguments.append(deletedprops);
560+ message.setArguments(arguments);
562+ QDBusConnection con = QDBusConnection::sessionBus();