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
=== modified file 'src/modules/application/application.cc'
--- src/modules/application/application.cc 2013-09-05 14:56:54 +0000
+++ src/modules/application/application.cc 2013-09-12 16:26:50 +0000
@@ -54,7 +54,16 @@
54}54}
5555
56QUrl Application::icon() const {56QUrl Application::icon() const {
57 return desktopData_->icon();57 QString iconString = desktopData_->icon().toString();
58 QString pathString = desktopData_->path();
59
60 if (QFileInfo(iconString).exists()) {
61 return desktopData_->icon();
62 } else if (QFileInfo(pathString + '/' + iconString).exists()) {
63 return QUrl(pathString + '/' + iconString);
64 } else {
65 return QUrl("image://theme/" + iconString);
66 }
58}67}
5968
60QString Application::exec() const {69QString Application::exec() const {
6170
=== modified file 'src/modules/application/desktopdata.cpp'
--- src/modules/application/desktopdata.cpp 2013-09-04 12:01:57 +0000
+++ src/modules/application/desktopdata.cpp 2013-09-12 16:26:50 +0000
@@ -16,6 +16,7 @@
16#include "desktopdata.h"16#include "desktopdata.h"
1717
18#include <QFile>18#include <QFile>
19#include <QDir>
1920
20#include "logging.h"21#include "logging.h"
2122
@@ -23,10 +24,9 @@
23#define ARRAY_SIZE(a) \24#define ARRAY_SIZE(a) \
24 ((sizeof(a) / sizeof(*(a))) / static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))25 ((sizeof(a) / sizeof(*(a))) / static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
2526
26const QString desktopFilePath = "/usr/share/applications/";
27
28DesktopData::DesktopData(QString appId)27DesktopData::DesktopData(QString appId)
29 : appId_(appId)28 : appId_(appId)
29 , file_(findDesktopFile(appId))
30 , entries_(DesktopData::kNumberOfEntries, "") {30 , entries_(DesktopData::kNumberOfEntries, "") {
31 DLOG("DesktopData::DesktopData (this=%p, appId='%s')", this, appId.toLatin1().data());31 DLOG("DesktopData::DesktopData (this=%p, appId='%s')", this, appId.toLatin1().data());
32 DASSERT(appId != NULL);32 DASSERT(appId != NULL);
@@ -38,13 +38,45 @@
38 entries_.clear();38 entries_.clear();
39}39}
4040
41QString DesktopData::file() const {41QString DesktopData::findDesktopFile(const QString &appId) const
42 return desktopFilePath + appId_ + ".desktop";42{
43 int dashPos = -1;
44 QString helper = appId;
45
46 QStringList searchDirs;
47 searchDirs << QDir::homePath() + "/.local/share/applications";
48 searchDirs << "/usr/share/applications";
49
50#ifdef TEST_MODE
51 searchDirs << "";
52#endif
53
54 do {
55 if (dashPos != -1) {
56 helper = helper.replace(dashPos, 1, '/');
57 }
58
59 Q_FOREACH(const QString &searchDir, searchDirs) {
60 QFileInfo fileInfo(QDir(searchDir), helper + ".desktop");
61 if (fileInfo.exists()) {
62 return fileInfo.absoluteFilePath();
63 }
64 }
65
66 dashPos = helper.indexOf("-");
67 } while (dashPos != -1);
68
69 return QString();
43}70}
4471
45bool DesktopData::load() {72bool DesktopData::load() {
46 DLOG("DesktopData::load (this=%p, appId='%s')", this, qPrintable(appId_));73 DLOG("DesktopData::load (this=%p, appId='%s')", this, qPrintable(appId_));
4774
75 if (this->file().isNull() || this->file().isEmpty()) {
76 DLOG("No desktop file found for appId: %s", qPrintable(appId_));
77 return false;
78 }
79
48 const struct { const char* const name; int size; unsigned int flag; } kEntryNames[] = {80 const struct { const char* const name; int size; unsigned int flag; } kEntryNames[] = {
49 { "Name=", sizeof("Name=") - 1, 1 << DesktopData::kNameIndex },81 { "Name=", sizeof("Name=") - 1, 1 << DesktopData::kNameIndex },
50 { "Comment=", sizeof("Comment=") - 1, 1 << DesktopData::kCommentIndex },82 { "Comment=", sizeof("Comment=") - 1, 1 << DesktopData::kCommentIndex },
5183
=== modified file 'src/modules/application/desktopdata.h'
--- src/modules/application/desktopdata.h 2013-09-03 18:03:17 +0000
+++ src/modules/application/desktopdata.h 2013-09-12 16:26:50 +0000
@@ -26,7 +26,7 @@
26 ~DesktopData();26 ~DesktopData();
2727
28 QString appId() const { return appId_; }28 QString appId() const { return appId_; }
29 QString file() const;29 QString file() const { return file_; };
30 QString name() const { return entries_[kNameIndex]; }30 QString name() const { return entries_[kNameIndex]; }
31 QString comment() const { return entries_[kCommentIndex]; }31 QString comment() const { return entries_[kCommentIndex]; }
32 QUrl icon() const { return QUrl(entries_[kIconIndex]); }32 QUrl icon() const { return QUrl(entries_[kIconIndex]); }
@@ -34,6 +34,7 @@
34 QString path() const { return entries_[kPathIndex]; }34 QString path() const { return entries_[kPathIndex]; }
35 QString stageHint() const { return entries_[kStageHintIndex]; }35 QString stageHint() const { return entries_[kStageHintIndex]; }
36 bool loaded() const { return loaded_; }36 bool loaded() const { return loaded_; }
37 QString findDesktopFile(const QString &appId) const;
3738
38private:39private:
39 static const int kNameIndex = 0,40 static const int kNameIndex = 0,
@@ -47,6 +48,7 @@
47 bool load();48 bool load();
4849
49 QString appId_;50 QString appId_;
51 QString file_;
50 QVector<QString> entries_;52 QVector<QString> entries_;
51 bool loaded_;53 bool loaded_;
52};54};

Subscribers

People subscribed via source and target branches