on xenial help sign in
Changed DBus-interface for launcher-item from alert-flag to alert-method upon request in MP-comment.
4a5f0b1Mirco Müller
plugins/Unity/Launcher/dbusinterface.cpp+21−21
@@ -66,7 +66,7 @@ QString DBusInterface::introspect(const QString &path) const
66 "<interface name=\"com.canonical.Unity.Launcher.Item\">"
66 "<interface name=\"com.canonical.Unity.Launcher.Item\">"
67 "<property name=\"count\" type=\"i\" access=\"readwrite\" />"
67 "<property name=\"count\" type=\"i\" access=\"readwrite\" />"
68 "<property name=\"countVisible\" type=\"b\" access=\"readwrite\" />"
68 "<property name=\"countVisible\" type=\"b\" access=\"readwrite\" />"
69− "<property name=\"alerting\" type=\"b\" access=\"readwrite\" />"
69+ "<method name=\"Alert\" />"
70 "</interface>";
70 "</interface>";
71 return nodeiface;
71 return nodeiface;
72}
72}
@@ -127,6 +127,19 @@ bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnec
127 return false;
127 return false;
128 }
128 }
129
129
130+ /* Break down the path to just the app id */
131+ QString pathtemp = message.path();
132+ if (!pathtemp.startsWith("/com/canonical/Unity/Launcher/")) {
133+ return false;
134+ }
135+ pathtemp.remove("/com/canonical/Unity/Launcher/");
136+ if (pathtemp.indexOf('/') >= 0) {
137+ return false;
138+ }
139+
140+ /* Find ourselves an appid */
141+ QString appid = decodeAppId(pathtemp);
142+
130 // First handle methods of the Launcher interface
143 // First handle methods of the Launcher interface
131 if (message.interface() == "com.canonical.Unity.Launcher") {
144 if (message.interface() == "com.canonical.Unity.Launcher") {
132 if (message.member() == "Refresh") {
145 if (message.member() == "Refresh") {
@@ -134,6 +147,13 @@ bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnec
134 Q_EMIT refreshCalled();
147 Q_EMIT refreshCalled();
135 return connection.send(reply);
148 return connection.send(reply);
136 }
149 }
150+ } else if (message.interface() == "com.canonical.Unity.Launcher.Item") {
151+ // Handle methods of the Launcher-Item interface
152+ if (message.member() == "Alert") {
153+ QDBusMessage reply = message.createReply();
154+ Q_EMIT alertCalled(appid);
155+ return connection.send(reply);
156+ }
137 }
157 }
138
158
139 // Now handle dynamic properties (for launcher emblems)
159 // Now handle dynamic properties (for launcher emblems)
@@ -145,18 +165,6 @@ bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnec
145 return false;
165 return false;
146 }
166 }
147
167
148− /* Break down the path to just the app id */
149− QString pathtemp = message.path();
150− if (!pathtemp.startsWith("/com/canonical/Unity/Launcher/")) {
151− return false;
152− }
153− pathtemp.remove("/com/canonical/Unity/Launcher/");
154− if (pathtemp.indexOf('/') >= 0) {
155− return false;
156− }
157−
158− /* Find ourselves an appid */
159− QString appid = decodeAppId(pathtemp);
160 int index = m_launcherModel->findApplication(appid);
168 int index = m_launcherModel->findApplication(appid);
161 LauncherItem *item = static_cast<LauncherItem*>(m_launcherModel->get(index));
169 LauncherItem *item = static_cast<LauncherItem*>(m_launcherModel->get(index));
162
170
@@ -169,8 +177,6 @@ bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnec
169 retval.append(QVariant::fromValue(QDBusVariant(item->count())));
177 retval.append(QVariant::fromValue(QDBusVariant(item->count())));
170 } else if (message.arguments()[1].toString() == "countVisible") {
178 } else if (message.arguments()[1].toString() == "countVisible") {
171 retval.append(QVariant::fromValue(QDBusVariant(item->countVisible())));
179 retval.append(QVariant::fromValue(QDBusVariant(item->countVisible())));
172− } else if (message.arguments()[1].toString() == "alerting") {
173− retval.append(QVariant::fromValue(QDBusVariant(item->alerting())));
174 }
180 }
175 } else if (message.member() == "Set") {
181 } else if (message.member() == "Set") {
176 if (message.arguments()[1].toString() == "count") {
182 if (message.arguments()[1].toString() == "count") {
@@ -185,12 +191,6 @@ bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnec
185 Q_EMIT countVisibleChanged(appid, newVisible);
191 Q_EMIT countVisibleChanged(appid, newVisible);
186 notifyPropertyChanged("com.canonical.Unity.Launcher.Item", encodeAppId(appid), "countVisible", newVisible);
192 notifyPropertyChanged("com.canonical.Unity.Launcher.Item", encodeAppId(appid), "countVisible", newVisible);
187 }
193 }
188− } else if (message.arguments()[1].toString() == "alerting") {
189− bool newAlerting = message.arguments()[2].value<QDBusVariant>().variant().toBool();
190− if (!item || newAlerting != item->alerting()) {
191− Q_EMIT alertingChanged(appid, newAlerting);
192− notifyPropertyChanged("com.canonical.Unity.Launcher.Item", encodeAppId(appid), "alerting", newAlerting);
193− }
194 }
194 }
195 } else if (message.member() == "GetAll") {
195 } else if (message.member() == "GetAll") {
196 if (item) {
196 if (item) {
plugins/Unity/Launcher/dbusinterface.h+1−1
@@ -36,8 +36,8 @@ public:
36Q_SIGNALS:
36Q_SIGNALS:
37 void countChanged(const QString &appId, int count);
37 void countChanged(const QString &appId, int count);
38 void countVisibleChanged(const QString &appId, bool countVisible);
38 void countVisibleChanged(const QString &appId, bool countVisible);
39− void alertingChanged(const QString &appId, bool alerting);
40 void refreshCalled();
39 void refreshCalled();
40+ void alertCalled(const QString &appId);
41
41
42private:
42private:
43 static QString decodeAppId(const QString& path);
43 static QString decodeAppId(const QString& path);
plugins/Unity/Launcher/launchermodel.cpp+11
@@ -41,6 +41,7 @@ LauncherModel::LauncherModel(QObject *parent):
41 connect(m_dbusIface, &DBusInterface::countChanged, this, &LauncherModel::countChanged);
41 connect(m_dbusIface, &DBusInterface::countChanged, this, &LauncherModel::countChanged);
42 connect(m_dbusIface, &DBusInterface::countVisibleChanged, this, &LauncherModel::countVisibleChanged);
42 connect(m_dbusIface, &DBusInterface::countVisibleChanged, this, &LauncherModel::countVisibleChanged);
43 connect(m_dbusIface, &DBusInterface::refreshCalled, this, &LauncherModel::refresh);
43 connect(m_dbusIface, &DBusInterface::refreshCalled, this, &LauncherModel::refresh);
44+ connect(m_dbusIface, &DBusInterface::alertCalled, this, &LauncherModel::alert);
44
45
45 connect(m_settings, &GSettings::changed, this, &LauncherModel::refresh);
46 connect(m_settings, &GSettings::changed, this, &LauncherModel::refresh);
46
47
@@ -473,6 +474,16 @@ void LauncherModel::refresh()
473 m_asAdapter->syncItems(m_list);
474 m_asAdapter->syncItems(m_list);
474}
475}
475
476
477+void LauncherModel::alert(const QString &appId)
478+{
479+ int idx = findApplication(appId);
480+ if (idx >= 0) {
481+ LauncherItem *item = m_list.at(idx);
482+ setAlerting(item->appId(), true);
483+ Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleAlerting);
484+ }
485+}
486+
476void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
487void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
477{
488{
478 Q_UNUSED(parent);
489 Q_UNUSED(parent);
plugins/Unity/Launcher/launchermodel.h+1
@@ -64,6 +64,7 @@ public:
64public Q_SLOTS:
64public Q_SLOTS:
65 void requestRemove(const QString &appId) override;
65 void requestRemove(const QString &appId) override;
66 Q_INVOKABLE void refresh();
66 Q_INVOKABLE void refresh();
67+ Q_INVOKABLE void alert(const QString &appId);
67
68
68private:
69private:
69 void storeAppList();
70 void storeAppList();