on xenial help sign in
Fix application activation
d6c3f9dMichal Hruby
Dash/ScopeView.qml+9
@@ -31,6 +31,15 @@ FocusScope {
31 // FIXME delay the search so that daemons have time to settle
31 // FIXME delay the search so that daemons have time to settle
32 onScopeChanged: timer.restart()
32 onScopeChanged: timer.restart()
33
33
34+ Connections {
35+ target: scope
36+ onActivateApplication: activateApp
37+ }
38+
39+ function activateApp(desktopFilePath) {
40+ shell.activateApplication(desktopFilePath);
41+ }
42+
34 Timer {
43 Timer {
35 id: timer
44 id: timer
36 interval: 2000
45 interval: 2000
plugins/Unity/scope.cpp+20−9
@@ -35,6 +35,7 @@
35#include <UnityCore/Variant.h>
35#include <UnityCore/Variant.h>
36
36
37#include <libintl.h>
37#include <libintl.h>
38+#include <glib.h>
38
39
39Scope::Scope(QObject *parent) :
40Scope::Scope(QObject *parent) :
40 QObject(parent)
41 QObject(parent)
@@ -208,18 +209,11 @@ void Scope::onPreviewReady(unity::dash::LocalResult const& /* result */, unity::
208
209
209void Scope::fallbackActivate(const QString& uri)
210void Scope::fallbackActivate(const QString& uri)
210{
211{
211− /* FIXME: stripping all content before the first column because for some
212− reason the scopes give uri with junk content at their beginning.
213− */
214− QString tweakedUri = uri;
215− int firstColumnAt = tweakedUri.indexOf(":");
216− tweakedUri.remove(0, firstColumnAt+1);
217−
218 /* Tries various methods to trigger a sensible action for the given 'uri'.
212 /* Tries various methods to trigger a sensible action for the given 'uri'.
219 If it has no understanding of the given scheme it falls back on asking
213 If it has no understanding of the given scheme it falls back on asking
220 Qt to open the uri.
214 Qt to open the uri.
221 */
215 */
222− QUrl url(tweakedUri);
216+ QUrl url(uri);
223 if (url.scheme() == "file") {
217 if (url.scheme() == "file") {
224 /* Override the files place's default URI handler: we want the file
218 /* Override the files place's default URI handler: we want the file
225 manager to handle opening folders, not the dash.
219 manager to handle opening folders, not the dash.
@@ -230,7 +224,24 @@ void Scope::fallbackActivate(const QString& uri)
230 return;
224 return;
231 }
225 }
232 if (url.scheme() == "application") {
226 if (url.scheme() == "application") {
233− // TODO: implement application handling
227+ // get the full path to the desktop file
228+ QString path(url.authority());
229+ if (path.startsWith("/")) {
230+ Q_EMIT activateApplication(path);
231+ } else {
232+ gchar* full_path = nullptr;
233+ GKeyFile* key_file = g_key_file_new();
234+ QString apps_path = "applications/" + path;
235+ if (g_key_file_load_from_data_dirs(key_file, apps_path.toLocal8Bit().constData(), &full_path,
236+ G_KEY_FILE_NONE, nullptr)) {
237+ path = full_path;
238+ Q_EMIT activateApplication(path);
239+ } else {
240+ qWarning() << "Unable to activate " << path;
241+ }
242+ g_key_file_free(key_file);
243+ g_free(full_path);
244+ }
234 return;
245 return;
235 }
246 }
236
247
plugins/Unity/scope.h+2
@@ -105,6 +105,8 @@ Q_SIGNALS:
105 void hideDash();
105 void hideDash();
106 void gotoUri(const QString &uri);
106 void gotoUri(const QString &uri);
107
107
108+ void activateApplication(const QString &desktop);
109+
108private Q_SLOTS:
110private Q_SLOTS:
109 void synchronizeStates();
111 void synchronizeStates();
110 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);
112 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);