Merge lp:~gerboland/qtubuntu/fix-click-packages into lp:qtubuntu

Proposed by Gerry Boland
Status: Merged
Approved by: Ricardo Mendoza
Approved revision: 176
Merged at revision: 175
Proposed branch: lp:~gerboland/qtubuntu/fix-click-packages
Merge into: lp:qtubuntu
Diff against target: 122 lines (+49/-6)
3 files modified
src/modules/application/application.cc (+10/-1)
src/modules/application/desktopdata.cpp (+36/-4)
src/modules/application/desktopdata.h (+3/-1)
To merge this branch: bzr merge lp:~gerboland/qtubuntu/fix-click-packages
Reviewer Review Type Date Requested Status
Ricardo Mendoza (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+185316@code.launchpad.net

Commit message

Fix click package execution, and correct icon path

Description of the change

Fix click package execution, and correct icon path

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Mendoza (ricmm) wrote :

Works fine, fixes launching.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/application/application.cc'
2--- src/modules/application/application.cc 2013-09-05 14:56:54 +0000
3+++ src/modules/application/application.cc 2013-09-12 16:26:50 +0000
4@@ -54,7 +54,16 @@
5 }
6
7 QUrl Application::icon() const {
8- return desktopData_->icon();
9+ QString iconString = desktopData_->icon().toString();
10+ QString pathString = desktopData_->path();
11+
12+ if (QFileInfo(iconString).exists()) {
13+ return desktopData_->icon();
14+ } else if (QFileInfo(pathString + '/' + iconString).exists()) {
15+ return QUrl(pathString + '/' + iconString);
16+ } else {
17+ return QUrl("image://theme/" + iconString);
18+ }
19 }
20
21 QString Application::exec() const {
22
23=== modified file 'src/modules/application/desktopdata.cpp'
24--- src/modules/application/desktopdata.cpp 2013-09-04 12:01:57 +0000
25+++ src/modules/application/desktopdata.cpp 2013-09-12 16:26:50 +0000
26@@ -16,6 +16,7 @@
27 #include "desktopdata.h"
28
29 #include <QFile>
30+#include <QDir>
31
32 #include "logging.h"
33
34@@ -23,10 +24,9 @@
35 #define ARRAY_SIZE(a) \
36 ((sizeof(a) / sizeof(*(a))) / static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
37
38-const QString desktopFilePath = "/usr/share/applications/";
39-
40 DesktopData::DesktopData(QString appId)
41 : appId_(appId)
42+ , file_(findDesktopFile(appId))
43 , entries_(DesktopData::kNumberOfEntries, "") {
44 DLOG("DesktopData::DesktopData (this=%p, appId='%s')", this, appId.toLatin1().data());
45 DASSERT(appId != NULL);
46@@ -38,13 +38,45 @@
47 entries_.clear();
48 }
49
50-QString DesktopData::file() const {
51- return desktopFilePath + appId_ + ".desktop";
52+QString DesktopData::findDesktopFile(const QString &appId) const
53+{
54+ int dashPos = -1;
55+ QString helper = appId;
56+
57+ QStringList searchDirs;
58+ searchDirs << QDir::homePath() + "/.local/share/applications";
59+ searchDirs << "/usr/share/applications";
60+
61+#ifdef TEST_MODE
62+ searchDirs << "";
63+#endif
64+
65+ do {
66+ if (dashPos != -1) {
67+ helper = helper.replace(dashPos, 1, '/');
68+ }
69+
70+ Q_FOREACH(const QString &searchDir, searchDirs) {
71+ QFileInfo fileInfo(QDir(searchDir), helper + ".desktop");
72+ if (fileInfo.exists()) {
73+ return fileInfo.absoluteFilePath();
74+ }
75+ }
76+
77+ dashPos = helper.indexOf("-");
78+ } while (dashPos != -1);
79+
80+ return QString();
81 }
82
83 bool DesktopData::load() {
84 DLOG("DesktopData::load (this=%p, appId='%s')", this, qPrintable(appId_));
85
86+ if (this->file().isNull() || this->file().isEmpty()) {
87+ DLOG("No desktop file found for appId: %s", qPrintable(appId_));
88+ return false;
89+ }
90+
91 const struct { const char* const name; int size; unsigned int flag; } kEntryNames[] = {
92 { "Name=", sizeof("Name=") - 1, 1 << DesktopData::kNameIndex },
93 { "Comment=", sizeof("Comment=") - 1, 1 << DesktopData::kCommentIndex },
94
95=== modified file 'src/modules/application/desktopdata.h'
96--- src/modules/application/desktopdata.h 2013-09-03 18:03:17 +0000
97+++ src/modules/application/desktopdata.h 2013-09-12 16:26:50 +0000
98@@ -26,7 +26,7 @@
99 ~DesktopData();
100
101 QString appId() const { return appId_; }
102- QString file() const;
103+ QString file() const { return file_; };
104 QString name() const { return entries_[kNameIndex]; }
105 QString comment() const { return entries_[kCommentIndex]; }
106 QUrl icon() const { return QUrl(entries_[kIconIndex]); }
107@@ -34,6 +34,7 @@
108 QString path() const { return entries_[kPathIndex]; }
109 QString stageHint() const { return entries_[kStageHintIndex]; }
110 bool loaded() const { return loaded_; }
111+ QString findDesktopFile(const QString &appId) const;
112
113 private:
114 static const int kNameIndex = 0,
115@@ -47,6 +48,7 @@
116 bool load();
117
118 QString appId_;
119+ QString file_;
120 QVector<QString> entries_;
121 bool loaded_;
122 };

Subscribers

People subscribed via source and target branches