on xenial help sign in
remove debug prints
216b5d6Michael Zanetti
plugins/Unity/Launcher/backend/launcherbackend.cpp+1−11
@@ -82,7 +82,7 @@ void LauncherBackend::setStoredApplications(const QStringList &appIds)
82 m_itemCache.insert(appId, item);
82 m_itemCache.insert(appId, item);
83 } else {
83 } else {
84 // Cannot find any data for that app... ignoring it.
84 // Cannot find any data for that app... ignoring it.
85− qDebug() << "cannot find desktop file for" << appId << ". discarding app";
85+ qWarning() << "cannot find desktop file for" << appId << ". discarding app.";
86 m_storedApps.removeAll(appId);
86 m_storedApps.removeAll(appId);
87 }
87 }
88 }
88 }
@@ -213,16 +213,12 @@ void LauncherBackend::syncFromAccounts()
213
213
214 m_storedApps.clear();
214 m_storedApps.clear();
215
215
216− qDebug() << "syncing from accounts" << m_accounts << m_user;
217−
218 if (m_accounts && !m_user.isEmpty()) {
216 if (m_accounts && !m_user.isEmpty()) {
219 QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");
217 QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");
220 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
218 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
221 defaults = isDefaultsItem(apps);
219 defaults = isDefaultsItem(apps);
222 }
220 }
223
221
224− qDebug() << "--------------------- should load defaults?" << defaults;
225−
226 if (m_accounts && defaults) { // Checking accounts as it'll be null when !useStorage
222 if (m_accounts && defaults) { // Checking accounts as it'll be null when !useStorage
227 QGSettings gSettings("com.canonical.Unity.Launcher", "/com/canonical/unity/launcher/");
223 QGSettings gSettings("com.canonical.Unity.Launcher", "/com/canonical/unity/launcher/");
228 Q_FOREACH(const QString &entry, gSettings.get("favorites").toStringList()) {
224 Q_FOREACH(const QString &entry, gSettings.get("favorites").toStringList()) {
@@ -243,7 +239,6 @@ void LauncherBackend::syncFromAccounts()
243 }
239 }
244 } else {
240 } else {
245 for (const QVariant &app: apps) {
241 for (const QVariant &app: apps) {
246− qDebug() << "should load app" << app;
247 loadFromVariant(app.toMap());
242 loadFromVariant(app.toMap());
248 }
243 }
249 }
244 }
@@ -251,19 +246,15 @@ void LauncherBackend::syncFromAccounts()
251
246
252void LauncherBackend::syncToAccounts()
247void LauncherBackend::syncToAccounts()
253{
248{
254− qDebug() << "syncing to accounts" << m_accounts << m_user << m_storedApps;
255 if (m_accounts && !m_user.isEmpty()) {
249 if (m_accounts && !m_user.isEmpty()) {
256 QList<QVariantMap> items;
250 QList<QVariantMap> items;
257
251
258 Q_FOREACH(const QString &appId, m_storedApps) {
252 Q_FOREACH(const QString &appId, m_storedApps) {
259− qDebug() << "appending item" << appId;
260 items << itemToVariant(appId);
253 items << itemToVariant(appId);
261 }
254 }
262
255
263− qDebug() << "syncing apps" << items;
264 m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
256 m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
265 }
257 }
266− qDebug() << "done synving";
267}
258}
268
259
269QString LauncherBackend::findDesktopFile(const QString &appId) const
260QString LauncherBackend::findDesktopFile(const QString &appId) const
@@ -340,6 +331,5 @@ bool LauncherBackend::isDefaultsItem(const QList<QVariantMap> &apps) const
340 // To differentiate between an empty list and a list that hasn't been set
331 // To differentiate between an empty list and a list that hasn't been set
341 // yet (and should thus be populated with the defaults), we use a special
332 // yet (and should thus be populated with the defaults), we use a special
342 // list of one item with the 'defaults' field set to true.
333 // list of one item with the 'defaults' field set to true.
343− qDebug() << "checking isDefaults" << apps;
344 return (apps.size() == 1 && apps[0].value("defaults").toBool());
334 return (apps.size() == 1 && apps[0].value("defaults").toBool());
345}
335}
plugins/Unity/Launcher/launchermodel.cpp+18−5
@@ -21,8 +21,6 @@
21#include "launcheritem.h"
21#include "launcheritem.h"
22#include "backend/launcherbackend.h"
22#include "backend/launcherbackend.h"
23
23
24−#include <QDebug>
25−
26LauncherModel::LauncherModel(QObject *parent):
24LauncherModel::LauncherModel(QObject *parent):
27 LauncherModelInterface(parent),
25 LauncherModelInterface(parent),
28 m_backend(new LauncherBackend(true, this))
26 m_backend(new LauncherBackend(true, this))
@@ -200,6 +198,8 @@ void LauncherModel::applicationFocused(const QString &appId)
200 if (index >= 0) {
198 if (index >= 0) {
201 // TODO: Mark application as focued
199 // TODO: Mark application as focued
202 } else {
200 } else {
201+ // Add app to recent apps
202+
203 // FIXME: The backend does not yet support this stuff
203 // FIXME: The backend does not yet support this stuff
204 // and currently the appId still is the desktopFile
204 // and currently the appId still is the desktopFile
205 //QString desktopFile = m_backend->desktopFile(appId);
205 //QString desktopFile = m_backend->desktopFile(appId);
@@ -213,6 +213,22 @@ void LauncherModel::applicationFocused(const QString &appId)
213 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
213 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
214 m_list.append(item);
214 m_list.append(item);
215 endInsertRows();
215 endInsertRows();
216+
217+ // Clean up old recent apps
218+ QList<int> recentAppIndices;
219+ for (int i = 0; i < m_list.count(); ++i) {
220+ if (m_list.at(i)->recent()) {
221+ recentAppIndices << i;
222+ }
223+ }
224+ int run = 0;
225+ while (recentAppIndices.count() > 5) {
226+ beginRemoveRows(QModelIndex(), recentAppIndices.first() - run, recentAppIndices.first() - run);
227+ m_list.takeAt(recentAppIndices.first() - run)->deleteLater();
228+ endRemoveRows();
229+ recentAppIndices.takeFirst();
230+ ++run;
231+ }
216 storeAppList();
232 storeAppList();
217 }
233 }
218}
234}
@@ -221,13 +237,10 @@ void LauncherModel::storeAppList()
221{
237{
222 QStringList appIds;
238 QStringList appIds;
223 Q_FOREACH(LauncherItem *item, m_list) {
239 Q_FOREACH(LauncherItem *item, m_list) {
224− qDebug() << "shouldI store app" << item->appId();
225 if (item->pinned() || item->recent()) {
240 if (item->pinned() || item->recent()) {
226− qDebug() << "yes";
227 appIds << item->appId();
241 appIds << item->appId();
228 }
242 }
229 }
243 }
230− qDebug() << "storing appids" << appIds;
231 m_backend->setStoredApplications(appIds);
244 m_backend->setStoredApplications(appIds);
232}
245}
233
246