on xenial help sign in
Fix application activation
commitd6c3f9dbc635b24205ed5c2a7f9eeda3a28ce967 authorMichal Hruby <michal.mhr@gmail.com> dateFri 9 Aug 2013, 12:26 (13 years ago) parent1cc7367
3 files changed+31−9
Dash/ScopeView.qml+9 plugins/Unity/scope.cpp+20−9 plugins/Unity/scope.h+2
Dash/ScopeView.qml+9
@@ -31,6 +31,15 @@ FocusScope {
3131 // FIXME delay the search so that daemons have time to settle
3232 onScopeChanged: timer.restart()
3333
34+ Connections {
35+ target: scope
36+ onActivateApplication: activateApp
37+ }
38+
39+ function activateApp(desktopFilePath) {
40+ shell.activateApplication(desktopFilePath);
41+ }
42+
3443 Timer {
3544 id: timer
3645 interval: 2000
plugins/Unity/scope.cpp+20−9
@@ -35,6 +35,7 @@
3535#include <UnityCore/Variant.h>
3636
3737#include <libintl.h>
38+#include <glib.h>
3839
3940Scope::Scope(QObject *parent) :
4041 QObject(parent)
@@ -208,18 +209,11 @@ void Scope::onPreviewReady(unity::dash::LocalResult const& /* result */, unity::
208209
209210void Scope::fallbackActivate(const QString& uri)
210211{
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−
218212 /* Tries various methods to trigger a sensible action for the given 'uri'.
219213 If it has no understanding of the given scheme it falls back on asking
220214 Qt to open the uri.
221215 */
222− QUrl url(tweakedUri);
216+ QUrl url(uri);
223217 if (url.scheme() == "file") {
224218 /* Override the files place's default URI handler: we want the file
225219 manager to handle opening folders, not the dash.
@@ -230,7 +224,24 @@ void Scope::fallbackActivate(const QString& uri)
230224 return;
231225 }
232226 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+ }
234245 return;
235246 }
236247
plugins/Unity/scope.h+2
@@ -105,6 +105,8 @@ Q_SIGNALS:
105105 void hideDash();
106106 void gotoUri(const QString &uri);
107107
108+ void activateApplication(const QString &desktop);
109+
108110private Q_SLOTS:
109111 void synchronizeStates();
110112 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);