Merge lp:~gerboland/qtmir/desktopFileReader into lp:qtmir/rtm-14.09
- desktopFileReader
- Merge into rtm-14.09
Proposed by
Michał Sawicz
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Gerry Boland | ||||
Approved revision: | 268 | ||||
Merged at revision: | 270 | ||||
Proposed branch: | lp:~gerboland/qtmir/desktopFileReader | ||||
Merge into: | lp:qtmir/rtm-14.09 | ||||
Diff against target: |
946 lines (+678/-158) 8 files modified
src/modules/Unity/Application/Application.pro (+3/-2) src/modules/Unity/Application/desktopfilereader.cpp (+169/-115) src/modules/Unity/Application/desktopfilereader.h (+22/-40) src/modules/Unity/Application/gscopedpointer.h (+113/-0) tests/modules/DesktopFileReader/DesktopFileReader.pro (+15/-0) tests/modules/DesktopFileReader/calculator.desktop (+227/-0) tests/modules/DesktopFileReader/desktopfilereader_test.cpp (+128/-0) tests/modules/modules.pro (+1/-1) |
||||
To merge this branch: | bzr merge lp:~gerboland/qtmir/desktopFileReader | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland (community) | Approve | ||
Review via email:
|
Commit message
Rewrite DesktopFileReader to use GDesktopAppInfo, enables reading localized keys
Description of the change
Rewrite DesktopFileReader to use GDesktopAppInfo, enables reading localized keys
* Are there any related MPs required for this MP to build/function as expected? Please list.
N
* Did you perform an exploratory manual test run of your code change and any related functionality?
Y
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/modules/Unity/Application/Application.pro' | |||
2 | --- src/modules/Unity/Application/Application.pro 2014-09-11 16:18:40 +0000 | |||
3 | +++ src/modules/Unity/Application/Application.pro 2014-10-13 09:06:32 +0000 | |||
4 | @@ -12,7 +12,7 @@ | |||
5 | 12 | QMAKE_CXXFLAGS = -std=c++11 -Werror -Wall | 12 | QMAKE_CXXFLAGS = -std=c++11 -Werror -Wall |
6 | 13 | QMAKE_LFLAGS = -std=c++11 -Wl,-no-undefined | 13 | QMAKE_LFLAGS = -std=c++11 -Wl,-no-undefined |
7 | 14 | 14 | ||
9 | 15 | PKGCONFIG += mirserver glib-2.0 process-cpp ubuntu-app-launch-2 | 15 | PKGCONFIG += mirserver glib-2.0 gio-unix-2.0 process-cpp ubuntu-app-launch-2 |
10 | 16 | 16 | ||
11 | 17 | INCLUDEPATH += ../../../platforms/mirserver ../../../common | 17 | INCLUDEPATH += ../../../platforms/mirserver ../../../common |
12 | 18 | LIBS += -L../../../platforms/mirserver -lqpa-mirserver | 18 | LIBS += -L../../../platforms/mirserver -lqpa-mirserver |
13 | @@ -65,7 +65,8 @@ | |||
14 | 65 | session.h \ | 65 | session.h \ |
15 | 66 | session_interface.h \ | 66 | session_interface.h \ |
16 | 67 | sessionmodel.h \ | 67 | sessionmodel.h \ |
18 | 68 | upstart/applicationcontroller.h | 68 | upstart/applicationcontroller.h \ |
19 | 69 | gscopedpointer.h | ||
20 | 69 | 70 | ||
21 | 70 | LTTNG_TP_FILES += tracepoints.tp | 71 | LTTNG_TP_FILES += tracepoints.tp |
22 | 71 | 72 | ||
23 | 72 | 73 | ||
24 | === modified file 'src/modules/Unity/Application/desktopfilereader.cpp' | |||
25 | --- src/modules/Unity/Application/desktopfilereader.cpp 2014-08-07 18:15:45 +0000 | |||
26 | +++ src/modules/Unity/Application/desktopfilereader.cpp 2014-10-13 09:06:32 +0000 | |||
27 | @@ -16,142 +16,196 @@ | |||
28 | 16 | 16 | ||
29 | 17 | // local | 17 | // local |
30 | 18 | #include "desktopfilereader.h" | 18 | #include "desktopfilereader.h" |
31 | 19 | #include "gscopedpointer.h" | ||
32 | 19 | #include "logging.h" | 20 | #include "logging.h" |
33 | 20 | 21 | ||
34 | 21 | // Qt | 22 | // Qt |
35 | 22 | #include <QFile> | 23 | #include <QFile> |
36 | 24 | #include <QLocale> | ||
37 | 25 | |||
38 | 26 | // GIO | ||
39 | 27 | #include <gio/gdesktopappinfo.h> | ||
40 | 23 | 28 | ||
41 | 24 | namespace qtmir | 29 | namespace qtmir |
42 | 25 | { | 30 | { |
43 | 26 | 31 | ||
44 | 27 | DesktopFileReader::Factory::Factory() | ||
45 | 28 | { | ||
46 | 29 | } | ||
47 | 30 | |||
48 | 31 | DesktopFileReader::Factory::~Factory() | ||
49 | 32 | { | ||
50 | 33 | } | ||
51 | 34 | 32 | ||
52 | 35 | DesktopFileReader* DesktopFileReader::Factory::createInstance(const QString &appId, const QFileInfo& fi) | 33 | DesktopFileReader* DesktopFileReader::Factory::createInstance(const QString &appId, const QFileInfo& fi) |
53 | 36 | { | 34 | { |
54 | 37 | return new DesktopFileReader(appId, fi); | 35 | return new DesktopFileReader(appId, fi); |
55 | 38 | } | 36 | } |
56 | 39 | 37 | ||
60 | 40 | // Retrieves the size of an array at compile time. | 38 | typedef GObjectScopedPointer<GAppInfo> GAppInfoPointer; |
61 | 41 | #define ARRAY_SIZE(a) \ | 39 | |
62 | 42 | ((sizeof(a) / sizeof(*(a))) / static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) | 40 | struct DesktopFileReaderPrivate |
63 | 41 | { | ||
64 | 42 | DesktopFileReaderPrivate(DesktopFileReader *parent): | ||
65 | 43 | q_ptr( parent ) | ||
66 | 44 | {} | ||
67 | 45 | |||
68 | 46 | QString getKey(const char *key) const | ||
69 | 47 | { | ||
70 | 48 | if (!loaded()) return QString(); | ||
71 | 49 | |||
72 | 50 | return QString::fromUtf8(g_desktop_app_info_get_string((GDesktopAppInfo*)appInfo.data(), key)); | ||
73 | 51 | } | ||
74 | 52 | |||
75 | 53 | bool loaded() const | ||
76 | 54 | { | ||
77 | 55 | return !appInfo.isNull(); | ||
78 | 56 | } | ||
79 | 57 | |||
80 | 58 | DesktopFileReader * const q_ptr; | ||
81 | 59 | Q_DECLARE_PUBLIC(DesktopFileReader) | ||
82 | 60 | |||
83 | 61 | QString appId; | ||
84 | 62 | QString file; | ||
85 | 63 | GAppInfoPointer appInfo; // GAppInfo is actually implemented by GDesktopAppInfo | ||
86 | 64 | }; | ||
87 | 65 | |||
88 | 43 | 66 | ||
89 | 44 | DesktopFileReader::DesktopFileReader(const QString &appId, const QFileInfo &desktopFile) | 67 | DesktopFileReader::DesktopFileReader(const QString &appId, const QFileInfo &desktopFile) |
92 | 45 | : appId_(appId) | 68 | : d_ptr(new DesktopFileReaderPrivate(this)) |
91 | 46 | , entries_(DesktopFileReader::kNumberOfEntries, "") | ||
93 | 47 | { | 69 | { |
98 | 48 | qCDebug(QTMIR_APPLICATIONS) << "DesktopFileReader::DesktopFileReader - this=" << this << "appId=" << appId; | 70 | Q_D(DesktopFileReader); |
99 | 49 | 71 | ||
100 | 50 | file_ = desktopFile.absoluteFilePath(); | 72 | d->appId = appId; |
101 | 51 | loaded_ = loadDesktopFile(file_); | 73 | d->file = desktopFile.absoluteFilePath(); |
102 | 74 | d->appInfo.reset((GAppInfo*) g_desktop_app_info_new_from_filename(d->file.toUtf8().constData())); | ||
103 | 75 | |||
104 | 76 | if (!d->loaded()) { | ||
105 | 77 | if (!desktopFile.exists()) { | ||
106 | 78 | qCWarning(QTMIR_APPLICATIONS) << "Desktop file for appId:" << appId << "at:" << d->file | ||
107 | 79 | << "does not exist"; | ||
108 | 80 | } else { | ||
109 | 81 | qCWarning(QTMIR_APPLICATIONS) << "Desktop file for appId:" << appId << "at:" << d->file | ||
110 | 82 | << "is not valid - check its syntax, and that the binary specified" | ||
111 | 83 | << "by the Exec line is installed!"; | ||
112 | 84 | } | ||
113 | 85 | } | ||
114 | 52 | } | 86 | } |
115 | 53 | 87 | ||
116 | 54 | DesktopFileReader::~DesktopFileReader() | 88 | DesktopFileReader::~DesktopFileReader() |
117 | 55 | { | 89 | { |
217 | 56 | qCDebug(QTMIR_APPLICATIONS) << "DesktopFileReader::~DesktopFileReader"; | 90 | delete d_ptr; |
218 | 57 | entries_.clear(); | 91 | } |
219 | 58 | } | 92 | |
220 | 59 | 93 | QString DesktopFileReader::file() const | |
221 | 60 | bool DesktopFileReader::loadDesktopFile(QString desktopFile) | 94 | { |
222 | 61 | { | 95 | Q_D(const DesktopFileReader); |
223 | 62 | qCDebug(QTMIR_APPLICATIONS) << "DesktopFileReader::loadDesktopFile - this=" << this << "desktopFile=" << desktopFile; | 96 | return d->file; |
224 | 63 | 97 | } | |
225 | 64 | if (this->file().isNull() || this->file().isEmpty()) { | 98 | |
226 | 65 | qCritical() << "No desktop file found for appId:" << appId_; | 99 | QString DesktopFileReader::appId() const |
227 | 66 | return false; | 100 | { |
228 | 67 | } | 101 | Q_D(const DesktopFileReader); |
229 | 68 | 102 | return d->appId; | |
230 | 69 | Q_ASSERT(desktopFile != NULL); | 103 | } |
231 | 70 | const struct { const char* const name; int size; unsigned int flag; } kEntryNames[] = { | 104 | |
232 | 71 | { "Name=", sizeof("Name=") - 1, 1 << DesktopFileReader::kNameIndex }, | 105 | QString DesktopFileReader::name() const |
233 | 72 | { "Comment=", sizeof("Comment=") - 1, 1 << DesktopFileReader::kCommentIndex }, | 106 | { |
234 | 73 | { "Icon=", sizeof("Icon=") - 1, 1 << DesktopFileReader::kIconIndex }, | 107 | Q_D(const DesktopFileReader); |
235 | 74 | { "Exec=", sizeof("Exec=") - 1, 1 << DesktopFileReader::kExecIndex }, | 108 | if (!d->loaded()) return QString(); |
236 | 75 | { "Path=", sizeof("Path=") - 1, 1 << DesktopFileReader::kPathIndex }, | 109 | |
237 | 76 | { "X-Ubuntu-StageHint=", sizeof("X-Ubuntu-StageHint=") - 1, 1 << DesktopFileReader::kStageHintIndex }, | 110 | return QString::fromUtf8(g_app_info_get_name(d->appInfo.data())); |
238 | 77 | { "X-Ubuntu-Splash-Title=", sizeof("X-Ubuntu-Splash-Title=") - 1, 1 << DesktopFileReader::kSplashTitleIndex }, | 111 | } |
239 | 78 | { "X-Ubuntu-Splash-Image=", sizeof("X-Ubuntu-Splash-Image=") - 1, 1 << DesktopFileReader::kSplashImageIndex }, | 112 | |
240 | 79 | { "X-Ubuntu-Splash-Show-Header=", sizeof("X-Ubuntu-Splash-Show-Header=") - 1, 1 << DesktopFileReader::kSplashShowHeaderIndex }, | 113 | QString DesktopFileReader::comment() const |
241 | 80 | { "X-Ubuntu-Splash-Color=", sizeof("X-Ubuntu-Splash-Color=") - 1, 1 << DesktopFileReader::kSplashColorIndex }, | 114 | { |
242 | 81 | { "X-Ubuntu-Splash-Color-Header=", sizeof("X-Ubuntu-Splash-Color-Header=") - 1, 1 << DesktopFileReader::kSplashColorHeaderIndex }, | 115 | Q_D(const DesktopFileReader); |
243 | 82 | { "X-Ubuntu-Splash-Color-Footer=", sizeof("X-Ubuntu-Splash-Color-Footer=") - 1, 1 << DesktopFileReader::kSplashColorFooterIndex } | 116 | if (!d->loaded()) return QString(); |
244 | 83 | }; | 117 | |
245 | 84 | const unsigned int kAllEntriesMask = | 118 | return QString::fromUtf8(g_app_info_get_description(d->appInfo.data())); |
246 | 85 | (1 << DesktopFileReader::kNameIndex) | (1 << DesktopFileReader::kCommentIndex) | 119 | } |
247 | 86 | | (1 << DesktopFileReader::kIconIndex) | (1 << DesktopFileReader::kExecIndex) | 120 | |
248 | 87 | | (1 << DesktopFileReader::kPathIndex) | (1 << DesktopFileReader::kStageHintIndex) | 121 | QString DesktopFileReader::icon() const |
249 | 88 | | (1 << DesktopFileReader::kSplashTitleIndex) | (1 << DesktopFileReader::kSplashImageIndex) | 122 | { |
250 | 89 | | (1 << DesktopFileReader::kSplashShowHeaderIndex) | (1 << DesktopFileReader::kSplashColorIndex) | 123 | Q_D(const DesktopFileReader); |
251 | 90 | | (1 << DesktopFileReader::kSplashColorHeaderIndex) | (1 << DesktopFileReader::kSplashColorFooterIndex); | 124 | return d->getKey("Icon"); |
252 | 91 | const unsigned int kMandatoryEntriesMask = | 125 | } |
253 | 92 | (1 << DesktopFileReader::kNameIndex) | (1 << DesktopFileReader::kIconIndex) | 126 | |
254 | 93 | | (1 << DesktopFileReader::kExecIndex); | 127 | QString DesktopFileReader::exec() const |
255 | 94 | const int kEntriesCount = ARRAY_SIZE(kEntryNames); | 128 | { |
256 | 95 | const int kBufferSize = 256; | 129 | Q_D(const DesktopFileReader); |
257 | 96 | static char buffer[kBufferSize]; | 130 | if (!d->loaded()) return QString(); |
258 | 97 | QFile file(desktopFile); | 131 | |
259 | 98 | 132 | return QString::fromUtf8(g_app_info_get_commandline(d->appInfo.data())); | |
260 | 99 | // Open file. | 133 | } |
261 | 100 | if (!file.open(QFile::ReadOnly | QIODevice::Text)) { | 134 | |
262 | 101 | qWarning() << "Can't open file:" << file.errorString(); | 135 | QString DesktopFileReader::path() const |
263 | 102 | return false; | 136 | { |
264 | 103 | } | 137 | Q_D(const DesktopFileReader); |
265 | 104 | 138 | return d->getKey("Path"); | |
266 | 105 | // Validate "magic key" (standard group header). | 139 | } |
267 | 106 | if (file.readLine(buffer, kBufferSize) != -1) { | 140 | |
268 | 107 | if (strncmp(buffer, "[Desktop Entry]", sizeof("[Desktop Entry]") - 1)) { | 141 | QString DesktopFileReader::stageHint() const |
269 | 108 | qWarning() << "not a desktop file, unable to read it"; | 142 | { |
270 | 109 | return false; | 143 | Q_D(const DesktopFileReader); |
271 | 110 | } | 144 | return d->getKey("X-Ubuntu-StageHint"); |
272 | 111 | } | 145 | } |
273 | 112 | 146 | ||
274 | 113 | int length; | 147 | QString DesktopFileReader::splashTitle() const |
275 | 114 | unsigned int entryFlags = 0; | 148 | { |
276 | 115 | while ((length = file.readLine(buffer, kBufferSize)) != -1) { | 149 | Q_D(const DesktopFileReader); |
277 | 116 | // Skip empty lines. | 150 | if (!d->loaded()) return QString(); |
278 | 117 | if (length > 1) { | 151 | |
279 | 118 | // Stop when reaching unsupported next group header. | 152 | /* Sadly GDesktopAppInfo only considers Name, GenericName, Comments and Keywords to be keys |
280 | 119 | if (buffer[0] == '[') { | 153 | * which can have locale-specific entries. So we need to work to make X-Ubuntu-Splash-Title |
281 | 120 | qWarning() << "reached next group header, leaving loop"; | 154 | * locale-aware, by generating a locale-correct key name and seeing if that exists. If yes, |
282 | 121 | break; | 155 | * get the value and return it. Else fallback to the non-localized value. |
283 | 122 | } | 156 | */ |
284 | 123 | // Lookup entries ignoring duplicates if any. | 157 | GDesktopAppInfo *info = (GDesktopAppInfo*)d->appInfo.data(); |
285 | 124 | for (int i = 0; i < kEntriesCount; i++) { | 158 | QLocale defaultLocale; |
286 | 125 | if (!strncmp(buffer, kEntryNames[i].name, kEntryNames[i].size)) { | 159 | QStringList locales = defaultLocale.uiLanguages(); |
287 | 126 | if (~entryFlags & kEntryNames[i].flag) { | 160 | |
288 | 127 | buffer[length-1] = '\0'; | 161 | QString keyTemplate("X-Ubuntu-Splash-Title[%1]"); |
289 | 128 | entries_[i] = QString::fromUtf8(&buffer[kEntryNames[i].size]); | 162 | for (QString locale: locales) { |
290 | 129 | entryFlags |= kEntryNames[i].flag; | 163 | // Desktop files use local specifiers with underscore separators but Qt uses hyphens |
291 | 130 | break; | 164 | locale = locale.replace('-', '_'); |
292 | 131 | } | 165 | const char* key = keyTemplate.arg(locale).toUtf8().constData(); |
293 | 132 | } | 166 | if (g_desktop_app_info_has_key(info, key)) { |
294 | 133 | } | 167 | return d->getKey(key); |
295 | 134 | // Stop when matching the right number of entries. | 168 | } |
296 | 135 | if (entryFlags == kAllEntriesMask) { | 169 | } |
297 | 136 | break; | 170 | |
298 | 137 | } | 171 | // Fallback to the non-localized string, if available |
299 | 138 | } | 172 | return d->getKey("X-Ubuntu-Splash-Title"); |
300 | 139 | } | 173 | } |
301 | 140 | 174 | ||
302 | 141 | // Check that the mandatory entries are set. | 175 | QString DesktopFileReader::splashImage() const |
303 | 142 | if ((entryFlags & kMandatoryEntriesMask) == kMandatoryEntriesMask) { | 176 | { |
304 | 143 | qDebug("loaded desktop file with name='%s', comment='%s', icon='%s', exec='%s', path='%s', stagehint='%s'", | 177 | Q_D(const DesktopFileReader); |
305 | 144 | qPrintable(entries_[DesktopFileReader::kNameIndex]), | 178 | return d->getKey("X-Ubuntu-Splash-Image"); |
306 | 145 | qPrintable(entries_[DesktopFileReader::kCommentIndex]), | 179 | } |
307 | 146 | qPrintable(entries_[DesktopFileReader::kIconIndex]), | 180 | |
308 | 147 | qPrintable(entries_[DesktopFileReader::kExecIndex]), | 181 | QString DesktopFileReader::splashShowHeader() const |
309 | 148 | qPrintable(entries_[DesktopFileReader::kPathIndex]), | 182 | { |
310 | 149 | qPrintable(entries_[DesktopFileReader::kStageHintIndex])); | 183 | Q_D(const DesktopFileReader); |
311 | 150 | return true; | 184 | return d->getKey("X-Ubuntu-Splash-Show-Header"); |
312 | 151 | } else { | 185 | } |
313 | 152 | qWarning() << "not a valid desktop file, missing mandatory entries in the standard group header"; | 186 | |
314 | 153 | return false; | 187 | QString DesktopFileReader::splashColor() const |
315 | 154 | } | 188 | { |
316 | 189 | Q_D(const DesktopFileReader); | ||
317 | 190 | return d->getKey("X-Ubuntu-Splash-Color"); | ||
318 | 191 | } | ||
319 | 192 | |||
320 | 193 | QString DesktopFileReader::splashColorHeader() const | ||
321 | 194 | { | ||
322 | 195 | Q_D(const DesktopFileReader); | ||
323 | 196 | return d->getKey("X-Ubuntu-Splash-Color-Header"); | ||
324 | 197 | } | ||
325 | 198 | |||
326 | 199 | QString DesktopFileReader::splashColorFooter() const | ||
327 | 200 | { | ||
328 | 201 | Q_D(const DesktopFileReader); | ||
329 | 202 | return d->getKey("X-Ubuntu-Splash-Color-Footer"); | ||
330 | 203 | } | ||
331 | 204 | |||
332 | 205 | bool DesktopFileReader::loaded() const | ||
333 | 206 | { | ||
334 | 207 | Q_D(const DesktopFileReader); | ||
335 | 208 | return d->loaded(); | ||
336 | 155 | } | 209 | } |
337 | 156 | 210 | ||
338 | 157 | } // namespace qtmir | 211 | } // namespace qtmir |
339 | 158 | 212 | ||
340 | === modified file 'src/modules/Unity/Application/desktopfilereader.h' | |||
341 | --- src/modules/Unity/Application/desktopfilereader.h 2014-08-07 18:15:45 +0000 | |||
342 | +++ src/modules/Unity/Application/desktopfilereader.h 2014-10-13 09:06:32 +0000 | |||
343 | @@ -18,20 +18,19 @@ | |||
344 | 18 | #define DESKTOPFILEREADER_H | 18 | #define DESKTOPFILEREADER_H |
345 | 19 | 19 | ||
346 | 20 | #include <QString> | 20 | #include <QString> |
347 | 21 | #include <QVector> | ||
348 | 22 | #include <QFileInfo> | 21 | #include <QFileInfo> |
349 | 23 | 22 | ||
350 | 24 | namespace qtmir | 23 | namespace qtmir |
351 | 25 | { | 24 | { |
352 | 26 | 25 | ||
353 | 26 | class DesktopFileReaderPrivate; | ||
354 | 27 | class DesktopFileReader { | 27 | class DesktopFileReader { |
355 | 28 | public: | 28 | public: |
356 | 29 | class Factory | 29 | class Factory |
357 | 30 | { | 30 | { |
358 | 31 | public: | 31 | public: |
360 | 32 | Factory(); | 32 | Factory() = default; |
361 | 33 | Factory(const Factory&) = delete; | 33 | Factory(const Factory&) = delete; |
362 | 34 | virtual ~Factory(); | ||
363 | 35 | 34 | ||
364 | 36 | Factory& operator=(const Factory&) = delete; | 35 | Factory& operator=(const Factory&) = delete; |
365 | 37 | 36 | ||
366 | @@ -40,48 +39,31 @@ | |||
367 | 40 | 39 | ||
368 | 41 | virtual ~DesktopFileReader(); | 40 | virtual ~DesktopFileReader(); |
369 | 42 | 41 | ||
385 | 43 | virtual QString file() const { return file_; } | 42 | virtual QString file() const; |
386 | 44 | virtual QString appId() const { return appId_; } | 43 | virtual QString appId() const; |
387 | 45 | virtual QString name() const { return entries_[kNameIndex]; } | 44 | virtual QString name() const; |
388 | 46 | virtual QString comment() const { return entries_[kCommentIndex]; } | 45 | virtual QString comment() const; |
389 | 47 | virtual QString icon() const { return entries_[kIconIndex]; } | 46 | virtual QString icon() const; |
390 | 48 | virtual QString exec() const { return entries_[kExecIndex]; } | 47 | virtual QString exec() const; |
391 | 49 | virtual QString path() const { return entries_[kPathIndex]; } | 48 | virtual QString path() const; |
392 | 50 | virtual QString stageHint() const { return entries_[kStageHintIndex]; } | 49 | virtual QString stageHint() const; |
393 | 51 | virtual QString splashTitle() const { return entries_[kSplashTitleIndex]; } | 50 | virtual QString splashTitle() const; |
394 | 52 | virtual QString splashImage() const { return entries_[kSplashImageIndex]; } | 51 | virtual QString splashImage() const; |
395 | 53 | virtual QString splashShowHeader() const { return entries_[kSplashShowHeaderIndex]; } | 52 | virtual QString splashShowHeader() const; |
396 | 54 | virtual QString splashColor() const { return entries_[kSplashColorIndex]; } | 53 | virtual QString splashColor() const; |
397 | 55 | virtual QString splashColorHeader() const { return entries_[kSplashColorHeaderIndex]; } | 54 | virtual QString splashColorHeader() const; |
398 | 56 | virtual QString splashColorFooter() const { return entries_[kSplashColorFooterIndex]; } | 55 | virtual QString splashColorFooter() const; |
399 | 57 | virtual bool loaded() const { return loaded_; } | 56 | virtual bool loaded() const; |
400 | 58 | 57 | ||
401 | 59 | protected: | 58 | protected: |
402 | 59 | DesktopFileReader(const QString &appId, const QFileInfo &desktopFile); | ||
403 | 60 | |||
404 | 61 | DesktopFileReaderPrivate * const d_ptr; | ||
405 | 62 | |||
406 | 60 | friend class DesktopFileReaderFactory; | 63 | friend class DesktopFileReaderFactory; |
407 | 61 | 64 | ||
408 | 62 | DesktopFileReader(const QString &appId, const QFileInfo &desktopFile); | ||
409 | 63 | |||
410 | 64 | private: | 65 | private: |
431 | 65 | static const int kNameIndex = 0, | 66 | Q_DECLARE_PRIVATE(DesktopFileReader) |
412 | 66 | kCommentIndex = 1, | ||
413 | 67 | kIconIndex = 2, | ||
414 | 68 | kExecIndex = 3, | ||
415 | 69 | kPathIndex = 4, | ||
416 | 70 | kStageHintIndex = 5, | ||
417 | 71 | kSplashTitleIndex = 6, | ||
418 | 72 | kSplashImageIndex = 7, | ||
419 | 73 | kSplashShowHeaderIndex = 8, | ||
420 | 74 | kSplashColorIndex = 9, | ||
421 | 75 | kSplashColorHeaderIndex = 10, | ||
422 | 76 | kSplashColorFooterIndex = 11, | ||
423 | 77 | kNumberOfEntries = 12; | ||
424 | 78 | |||
425 | 79 | virtual bool loadDesktopFile(QString desktopFile); | ||
426 | 80 | |||
427 | 81 | QString appId_; | ||
428 | 82 | QString file_; | ||
429 | 83 | QVector<QString> entries_; | ||
430 | 84 | bool loaded_; | ||
432 | 85 | }; | 67 | }; |
433 | 86 | 68 | ||
434 | 87 | } // namespace qtmir | 69 | } // namespace qtmir |
435 | 88 | 70 | ||
436 | === added file 'src/modules/Unity/Application/gscopedpointer.h' | |||
437 | --- src/modules/Unity/Application/gscopedpointer.h 1970-01-01 00:00:00 +0000 | |||
438 | +++ src/modules/Unity/Application/gscopedpointer.h 2014-10-13 09:06:32 +0000 | |||
439 | @@ -0,0 +1,113 @@ | |||
440 | 1 | /* | ||
441 | 2 | * Copyright (C) 2011-2014 Canonical, Ltd. | ||
442 | 3 | * | ||
443 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
444 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
445 | 6 | * the Free Software Foundation. | ||
446 | 7 | * | ||
447 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
448 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
449 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
450 | 11 | * Lesser General Public License for more details. | ||
451 | 12 | * | ||
452 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
453 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
454 | 15 | * | ||
455 | 16 | * Authors: | ||
456 | 17 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
457 | 18 | */ | ||
458 | 19 | |||
459 | 20 | #ifndef GSCOPEDPOINTER_H | ||
460 | 21 | #define GSCOPEDPOINTER_H | ||
461 | 22 | |||
462 | 23 | // Local | ||
463 | 24 | |||
464 | 25 | // Qt | ||
465 | 26 | #include <QScopedPointer> | ||
466 | 27 | |||
467 | 28 | // GLib | ||
468 | 29 | #include <glib-object.h> | ||
469 | 30 | |||
470 | 31 | /** | ||
471 | 32 | * Helper class for GScopedPointer | ||
472 | 33 | */ | ||
473 | 34 | template <class T, void (*cleanup_fcn)(T*)> | ||
474 | 35 | class GScopedPointerDeleter | ||
475 | 36 | { | ||
476 | 37 | public: | ||
477 | 38 | static void cleanup(T* ptr) | ||
478 | 39 | { | ||
479 | 40 | if (ptr) { | ||
480 | 41 | cleanup_fcn(ptr); | ||
481 | 42 | } | ||
482 | 43 | } | ||
483 | 44 | }; | ||
484 | 45 | |||
485 | 46 | /** | ||
486 | 47 | * A GScopedPointer works like a QScopedPointer, except the cleanup static | ||
487 | 48 | * method is replaced with a cleanup function, making it useful to handle C | ||
488 | 49 | * structs whose cleanup function prototype is "void cleanup(T*)" | ||
489 | 50 | * | ||
490 | 51 | * Best way to use it is to define a typedef for your C struct, like this: | ||
491 | 52 | * | ||
492 | 53 | * typedef GScopedPointer<Foo, foo_free> GFooPointer; | ||
493 | 54 | */ | ||
494 | 55 | template <class T, void (*cleanup)(T*)> | ||
495 | 56 | class GScopedPointer : public QScopedPointer<T, GScopedPointerDeleter<T, cleanup> > | ||
496 | 57 | { | ||
497 | 58 | public: | ||
498 | 59 | GScopedPointer(T* ptr = 0) | ||
499 | 60 | : QScopedPointer<T, GScopedPointerDeleter<T, cleanup> >(ptr) | ||
500 | 61 | {} | ||
501 | 62 | }; | ||
502 | 63 | |||
503 | 64 | |||
504 | 65 | /** | ||
505 | 66 | * Helper class for GObjectScopedPointer | ||
506 | 67 | */ | ||
507 | 68 | template <class T, void (*cleanup_fcn)(gpointer)> | ||
508 | 69 | class GObjectScopedPointerDeleter | ||
509 | 70 | { | ||
510 | 71 | public: | ||
511 | 72 | static void cleanup(T* ptr) | ||
512 | 73 | { | ||
513 | 74 | if (ptr) { | ||
514 | 75 | cleanup_fcn(ptr); | ||
515 | 76 | } | ||
516 | 77 | } | ||
517 | 78 | }; | ||
518 | 79 | |||
519 | 80 | /** | ||
520 | 81 | * A GObjectScopedPointer is similar to a GScopedPointer. The only difference | ||
521 | 82 | * is its cleanup function signature is "void cleanup(gpointer)" and defaults to | ||
522 | 83 | * g_object_unref(), making it useful for GObject-based classes. | ||
523 | 84 | * | ||
524 | 85 | * You can use it directly like this: | ||
525 | 86 | * | ||
526 | 87 | * GObjectScopedPointer<GFoo> foo; | ||
527 | 88 | * | ||
528 | 89 | * Or define a typedef for your class: | ||
529 | 90 | * | ||
530 | 91 | * typedef GObjectScopedPointer<GFoo> GFooPointer; | ||
531 | 92 | * | ||
532 | 93 | * Note: GObjectScopedPointer does *not* call gobject_ref() when assigned a | ||
533 | 94 | * pointer. | ||
534 | 95 | */ | ||
535 | 96 | template <class T, void (*cleanup)(gpointer) = g_object_unref> | ||
536 | 97 | class GObjectScopedPointer : public QScopedPointer<T, GObjectScopedPointerDeleter<T, cleanup> > | ||
537 | 98 | { | ||
538 | 99 | public: | ||
539 | 100 | GObjectScopedPointer(T* ptr = 0) | ||
540 | 101 | : QScopedPointer<T, GObjectScopedPointerDeleter<T, cleanup> >(ptr) | ||
541 | 102 | {} | ||
542 | 103 | }; | ||
543 | 104 | |||
544 | 105 | // A Generic GObject pointer | ||
545 | 106 | typedef GObjectScopedPointer<GObject> GObjectPointer; | ||
546 | 107 | |||
547 | 108 | // Take advantage of the cleanup signature of GObjectScopedPointer to define | ||
548 | 109 | // a GCharPointer | ||
549 | 110 | typedef GObjectScopedPointer<gchar, g_free> GCharPointer; | ||
550 | 111 | |||
551 | 112 | #endif /* GSCOPEDPOINTER_H */ | ||
552 | 113 | |||
553 | 0 | 114 | ||
554 | === added directory 'tests/modules/DesktopFileReader' | |||
555 | === added file 'tests/modules/DesktopFileReader/DesktopFileReader.pro' | |||
556 | --- tests/modules/DesktopFileReader/DesktopFileReader.pro 1970-01-01 00:00:00 +0000 | |||
557 | +++ tests/modules/DesktopFileReader/DesktopFileReader.pro 2014-10-13 09:06:32 +0000 | |||
558 | @@ -0,0 +1,15 @@ | |||
559 | 1 | include(../../test-includes.pri) | ||
560 | 2 | include(../common/common.pri) | ||
561 | 3 | |||
562 | 4 | TARGET = desktopfilereader_test | ||
563 | 5 | |||
564 | 6 | SOURCES += \ | ||
565 | 7 | desktopfilereader_test.cpp | ||
566 | 8 | |||
567 | 9 | OTHER_FILES += \ | ||
568 | 10 | calculator.desktop | ||
569 | 11 | |||
570 | 12 | # Copy to build directory | ||
571 | 13 | for(FILE, OTHER_FILES){ | ||
572 | 14 | QMAKE_POST_LINK += $$quote(cp $${PWD}/$${FILE} $${OUT_PWD}$$escape_expand(\\n\\t)) | ||
573 | 15 | } | ||
574 | 0 | 16 | ||
575 | === added file 'tests/modules/DesktopFileReader/calculator.desktop' | |||
576 | --- tests/modules/DesktopFileReader/calculator.desktop 1970-01-01 00:00:00 +0000 | |||
577 | +++ tests/modules/DesktopFileReader/calculator.desktop 2014-10-13 09:06:32 +0000 | |||
578 | @@ -0,0 +1,227 @@ | |||
579 | 1 | [Desktop Entry] | ||
580 | 2 | Name=Calculator | ||
581 | 3 | Name[am]=መደመሪያ | ||
582 | 4 | Name[ar]=الآلة الحاسبة | ||
583 | 5 | Name[ast]=Calculadora | ||
584 | 6 | Name[az]=Kalkulyator | ||
585 | 7 | Name[be]=Калькулятар | ||
586 | 8 | Name[bg]=Калкулатор | ||
587 | 9 | Name[br]=Jederez | ||
588 | 10 | Name[bs]=Kalkulator | ||
589 | 11 | Name[ca]=Calculadora | ||
590 | 12 | Name[cs]=Kalkulačka | ||
591 | 13 | Name[cy]=Cyfrifiannell | ||
592 | 14 | Name[da]=Lommeregner | ||
593 | 15 | Name[de]=Taschenrechner | ||
594 | 16 | Name[el]=Αριθμομηχανή | ||
595 | 17 | Name[en_AU]=Calculator | ||
596 | 18 | Name[en_CA]=Calculator | ||
597 | 19 | Name[en_GB]=Calculator | ||
598 | 20 | Name[es]=Calculadora | ||
599 | 21 | Name[eu]=Kalkulagailua | ||
600 | 22 | Name[fa]=ماشینحساب | ||
601 | 23 | Name[fi]=Laskin | ||
602 | 24 | Name[fr]=Calculatrice | ||
603 | 25 | Name[gd]=An t-àireamhair | ||
604 | 26 | Name[gl]=Calculadora | ||
605 | 27 | Name[gu]=કેલ્ક્યુલેટર | ||
606 | 28 | Name[he]=מחשבון | ||
607 | 29 | Name[hi]=कैलकुलेटर | ||
608 | 30 | Name[hu]=Számológép | ||
609 | 31 | Name[id]=Kalkulator | ||
610 | 32 | Name[is]=Reiknivél | ||
611 | 33 | Name[it]=Calcolatrice | ||
612 | 34 | Name[ja]=電卓 | ||
613 | 35 | Name[km]=ម៉ាស៊ីនគិតលេខ | ||
614 | 36 | Name[ko]=계산기 | ||
615 | 37 | Name[lv]=Kalkulators | ||
616 | 38 | Name[mr]=गणनयंत्र | ||
617 | 39 | Name[ms]=Kalkulator | ||
618 | 40 | Name[my]=ဂဏန်းတွက်စက် | ||
619 | 41 | Name[nb]=Kalkulator | ||
620 | 42 | Name[ne]=क्याल्कुलेटर | ||
621 | 43 | Name[nl]=Rekenmachine | ||
622 | 44 | Name[pa]=ਕੈਲਕੂਲੇਟਰ | ||
623 | 45 | Name[pl]=Kalkulator | ||
624 | 46 | Name[pt]=Calculadora | ||
625 | 47 | Name[pt_BR]=Calculadora | ||
626 | 48 | Name[ro]=Calculator | ||
627 | 49 | Name[ru]=Калькулятор | ||
628 | 50 | Name[sa]=सङ्कलकम् | ||
629 | 51 | Name[shn]=ၸၢၵ်ႈၼပ့်သွၼ် | ||
630 | 52 | Name[sl]=Računalo | ||
631 | 53 | Name[sr]=Калкулатор | ||
632 | 54 | Name[sv]=Kalkylator | ||
633 | 55 | Name[ta]=கணிப்பான் | ||
634 | 56 | Name[te]=గణన పరికరం | ||
635 | 57 | Name[tr]=Hesap Makinesi | ||
636 | 58 | Name[ug]=ھېسابلىغۇچ | ||
637 | 59 | Name[uk]=Калькулятор | ||
638 | 60 | Name[zh_CN]=计算器 | ||
639 | 61 | Name[zh_HK]=計數機 | ||
640 | 62 | Name[zh_TW]=計算機 | ||
641 | 63 | Comment=A simple calculator for Ubuntu. | ||
642 | 64 | Comment[am]=ለ ኡቡንቱ ቀላል መደመሪያ | ||
643 | 65 | Comment[ar]=آلة حاسبة بسيطة لأوبونتو. | ||
644 | 66 | Comment[ast]=Una calculadora cenciella pa Ubuntu. | ||
645 | 67 | Comment[az]=Ubuntu üçün sadә kalkulyator. | ||
646 | 68 | Comment[br]=Ur jederez eeun evit Ubuntu. | ||
647 | 69 | Comment[ca]=Una calculadora simple per a l'Ubuntu. | ||
648 | 70 | Comment[cy]=Cyfrifiannell hawdd ar gyfer Ubuntu. | ||
649 | 71 | Comment[da]=En simpel lommeregner til Ubuntu. | ||
650 | 72 | Comment[de]=Ein einfach Tachenrechner für Ubuntu. | ||
651 | 73 | Comment[el]=Μια απλή αριθμομηχανή για το Ubuntu | ||
652 | 74 | Comment[en_AU]=A simple calculator for Ubuntu. | ||
653 | 75 | Comment[en_GB]=A simple calculator for Ubuntu. | ||
654 | 76 | Comment[es]=Una calculadora sencilla para Ubuntu. | ||
655 | 77 | Comment[eu]=Ubunturako kalkulagailu sinplea. | ||
656 | 78 | Comment[fa]=یک ماشین حساب ساده برای اوبونتو. | ||
657 | 79 | Comment[fi]=Laskin Ubuntulle. | ||
658 | 80 | Comment[fr]=Une calculatrice simple pour Ubuntu. | ||
659 | 81 | Comment[gd]=Àireamhair simplidh airson Ubuntu. | ||
660 | 82 | Comment[gl]=Calculadora sinxela para Ubuntu. | ||
661 | 83 | Comment[he]=מחשבון פשוט לאובונטו. | ||
662 | 84 | Comment[hu]=Egyszerű számológép Ubuntuhoz. | ||
663 | 85 | Comment[is]=Einföld reiknivél | ||
664 | 86 | Comment[it]=Una semplice calcolatrice per Ubuntu. | ||
665 | 87 | Comment[ja]=Ubuntu用のシンプルな電卓です。 | ||
666 | 88 | Comment[km]=ម៉ាស៊ីនគិតលេខធម្មតាសម្រាប់ Ubuntu ។ | ||
667 | 89 | Comment[ko]=우분투를 위한 간단한 계산기 | ||
668 | 90 | Comment[lv]=Vienkāršs kalkulators priekš Ubuntu | ||
669 | 91 | Comment[nb]=En enkel kalkulator for Ubuntu. | ||
670 | 92 | Comment[ne]=Ubuntu को लागि एक सरल कैलकुलेटर। | ||
671 | 93 | Comment[nl]=Een eenvoudige rekenmachine voor Ubuntu. | ||
672 | 94 | Comment[pa]=ਉਬੰਤੂ ਲਈ ਇੱਕ ਸਧਾਰਨ ਕੈਲਕੂਲੇਟਰ | ||
673 | 95 | Comment[pl]=Prosty kalkulator dla Ubuntu | ||
674 | 96 | Comment[pt]=Uma calculadora simples para o Ubuntu. | ||
675 | 97 | Comment[pt_BR]=Uma simples calculadora para Ubuntu | ||
676 | 98 | Comment[ro]=Un calculator simplu pentru Ubuntu. | ||
677 | 99 | Comment[ru]=Простой калькулятор для Ubuntu | ||
678 | 100 | Comment[sa]=Ubuntu इत्यस्मा एकं सरलं सङ्कलकम्। | ||
679 | 101 | Comment[sl]=Preprost kalkulator za Ubuntu. | ||
680 | 102 | Comment[sr]=Једноставан калкулатор за Убунту | ||
681 | 103 | Comment[sv]=En enkel kalkylator för Ubuntu. | ||
682 | 104 | Comment[tr]=Ubuntu için sade bir hesap makinesi. | ||
683 | 105 | Comment[ug]=ئاددىي ھېسابلىغۇچى | ||
684 | 106 | Comment[uk]=Простий калькулятор для Ubuntu. | ||
685 | 107 | Comment[zh_CN]=Ubuntu 简易计算器 | ||
686 | 108 | Comment[zh_TW]=Ubuntu 簡易計算機。 | ||
687 | 109 | Keywords=math;addition;subtraction;multiplication;division; | ||
688 | 110 | Keywords[am]=ሂሳብ;መደመሪያ;መቀነሻ;ማባዣ;ማካፈያ; | ||
689 | 111 | Keywords[ar]=رياضة;ياضيات;حساب;حسابات;جمع;طرح;ضرب;قسمة; | ||
690 | 112 | Keywords[ast]=matemática;suma;resta;multiplicación;división; | ||
691 | 113 | Keywords[az]=riyaziyyat;әlavә etmә;çıxma;vurma;bölmә;toplama; | ||
692 | 114 | Keywords[br]=matematikoù;sammadenn;lamadenn;lieskementadenn;rannadenn; | ||
693 | 115 | Keywords[ca]=suma;resta;calculadora;multiplica;divideix | ||
694 | 116 | Keywords[da]=matematik;plus;minus;gange;dividere;beregning;lommeregner; | ||
695 | 117 | Keywords[de]=Mathe;Mathematik;Multiplikation;Subtraktion;Addition;Division; | ||
696 | 118 | Keywords[en_AU]=math;addition;subtraction;multiplication;division; | ||
697 | 119 | Keywords[en_GB]=maths;addition;subtraction;multiplication;division; | ||
698 | 120 | Keywords[es]=matemática;suma;resta;multiplicación;división; | ||
699 | 121 | Keywords[eu]=matematikak;gehitu;kendu;biderkatu;zatitu; | ||
700 | 122 | Keywords[fa]=حساب;جمع;تفریق;ضرب;تقسیم | ||
701 | 123 | Keywords[fi]=math;addition;subtraction;multiplication;division;matematiikka;lisäys;vähennys;kertaus;jakaminen; | ||
702 | 124 | Keywords[fr]=math;addition;soustraction;multiplication;division; | ||
703 | 125 | Keywords[gd]=math;addition;subtraction;multiplication;division;matamataig;roinneadh;toirt air falbh;cur ris;iomadadh | ||
704 | 126 | Keywords[gl]=matemáticas;suma;resta;multiplicación;división; | ||
705 | 127 | Keywords[he]=מתמטיקה;חשבון;חיבור;חיסור;כפל;חילוק; | ||
706 | 128 | Keywords[hu]=számolás;összeadás;kivonás;szorzás;osztás; | ||
707 | 129 | Keywords[is]=reikna;samlagning;frádráttur;margföldun;deiling | ||
708 | 130 | Keywords[it]=matematica;addizioni;sottrazioni;moltiplicazioni;divisioni; | ||
709 | 131 | Keywords[ja]=math;addition;subtraction;multiplication;division;計算;電卓;足し算;引き算;かけ算;わり算; | ||
710 | 132 | Keywords[km]=math;addition;subtraction;multiplication;division; | ||
711 | 133 | Keywords[ko]=수학;덧셈;뺄셈;곱셈;나눗셈; | ||
712 | 134 | Keywords[nb]=matte;addisjon;subtraksjon;multiplikasjon;divisjon; | ||
713 | 135 | Keywords[ne]=गणित; जोड्; घटाउ; गुणन; विभाजन; | ||
714 | 136 | Keywords[nl]=math;addition;subtraction;multiplication;division;optellen;aftrekken;vermenigvuldigen;delen; | ||
715 | 137 | Keywords[pa]=ਹਿਸਾਬ;ਜੋੜ;ਘਟਾਉ;ਗੁਣਾ;ਭਾਗ; | ||
716 | 138 | Keywords[pl]=liczenie;dodawanie;odejmowanie;mnożenie;dzielenie; | ||
717 | 139 | Keywords[pt]=matemática;soma;subtracção;multiplicação;divisão; | ||
718 | 140 | Keywords[pt_BR]=matemática;adição;subtração;multiplicação;divisão | ||
719 | 141 | Keywords[ro]=matematică;adunare;scădere;înmulțire;împărțire | ||
720 | 142 | Keywords[ru]=математика;сложение;умножение;деление; | ||
721 | 143 | Keywords[sa]=गणितम्;योजनम्;वियोजनम्;गुणनम्;विभाजनम्; | ||
722 | 144 | Keywords[sl]=matematika;seštevanje;odštevanje;množenje;deljenje; | ||
723 | 145 | Keywords[sr]=математика;сабирање;одузимање;множење;дељење;рачунање;дигитрон; | ||
724 | 146 | Keywords[sv]=matematik;addition;substraktion;multiplikation;division | ||
725 | 147 | Keywords[tr]=matematik;ekleme;çıkarma;çarpma;bölme;toplama | ||
726 | 148 | Keywords[ug]=ماتېماتىكا;قوشۇش;ئېلىش;كۆپەيتىش;بۆلۈش; | ||
727 | 149 | Keywords[uk]=math;addition;subtraction;multiplication;division;математика;додавання;віднімання;множення;ділення;калькулятор; | ||
728 | 150 | Keywords[zh_CN]=数学;加;减;乘;除; | ||
729 | 151 | Keywords[zh_TW]=math;addition;subtraction;multiplication;division;數學;加;減;乘;除; | ||
730 | 152 | Type=Application | ||
731 | 153 | Terminal=false | ||
732 | 154 | Exec=yes -p com.ubuntu.calculator_calculator_1.3.329 -- qmlscene -qt5 ubuntu-calculator-app.qml | ||
733 | 155 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png | ||
734 | 156 | X-Ubuntu-Touch=true | ||
735 | 157 | X-Ubuntu-StageHint=SideStage | ||
736 | 158 | X-Ubuntu-Default-Department-ID=accessories | ||
737 | 159 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator | ||
738 | 160 | X-Ubuntu-Old-Icon=calculator-app@30.png | ||
739 | 161 | X-Ubuntu-Application-ID=com.ubuntu.calculator_calculator_1.3.329 | ||
740 | 162 | X-Ubuntu-Splash-Show-Header=True | ||
741 | 163 | X-Ubuntu-Splash-Color=#aabbcc | ||
742 | 164 | X-Ubuntu-Splash-Color-Header=purple | ||
743 | 165 | X-Ubuntu-Splash-Color-Footer=#deadbeefda | ||
744 | 166 | X-Ubuntu-Splash-Image=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png | ||
745 | 167 | X-Ubuntu-Splash-Title=Calculator 2.0 | ||
746 | 168 | X-Ubuntu-Splash-Title[am]=መደመሪያ 2.0 | ||
747 | 169 | X-Ubuntu-Splash-Title[ar]=الآلة 2.0الحاسبة | ||
748 | 170 | X-Ubuntu-Splash-Title[ast]=Calculadora 2.0 | ||
749 | 171 | X-Ubuntu-Splash-Title[az]=Kalkulyator 2.0 | ||
750 | 172 | X-Ubuntu-Splash-Title[be]=Калькулятар 2.0 | ||
751 | 173 | X-Ubuntu-Splash-Title[bg]=Калкулатор 2.0 | ||
752 | 174 | X-Ubuntu-Splash-Title[br]=Jederez 2.0 | ||
753 | 175 | X-Ubuntu-Splash-Title[bs]=Kalkulator 2.0 | ||
754 | 176 | X-Ubuntu-Splash-Title[ca]=Calculadora 2.0 | ||
755 | 177 | X-Ubuntu-Splash-Title[cs]=Kalkulačka 2.0 | ||
756 | 178 | X-Ubuntu-Splash-Title[cy]=Cyfrifiannell 2.0 | ||
757 | 179 | X-Ubuntu-Splash-Title[da]=Lommeregner 2.0 | ||
758 | 180 | X-Ubuntu-Splash-Title[de]=Taschenrechner 2.0 | ||
759 | 181 | X-Ubuntu-Splash-Title[el]=Αριθμομηχανή 2.0 | ||
760 | 182 | X-Ubuntu-Splash-Title[en_AU]=Calculator 2.0 | ||
761 | 183 | X-Ubuntu-Splash-Title[en_CA]=Calculator 2.0 | ||
762 | 184 | X-Ubuntu-Splash-Title[en_GB]=Calculator 2.0 | ||
763 | 185 | X-Ubuntu-Splash-Title[es]=Calculadora 2.0 | ||
764 | 186 | X-Ubuntu-Splash-Title[eu]=Kalkulagailua 2.0 | ||
765 | 187 | X-Ubuntu-Splash-Title[fa]= 2.0ماشینحساب | ||
766 | 188 | X-Ubuntu-Splash-Title[fi]=Laskin 2.0 | ||
767 | 189 | X-Ubuntu-Splash-Title[fr]=Calculatrice 2.0 | ||
768 | 190 | X-Ubuntu-Splash-Title[gd]=An t-àireamhair 2.0 | ||
769 | 191 | X-Ubuntu-Splash-Title[gl]=Calculadora 2.0 | ||
770 | 192 | X-Ubuntu-Splash-Title[gu]=કેલ્ક્યુલેટર 2.0 | ||
771 | 193 | X-Ubuntu-Splash-Title[he]= 2.0מחשבון | ||
772 | 194 | X-Ubuntu-Splash-Title[hi]=कैलकुलेटर 2.0 | ||
773 | 195 | X-Ubuntu-Splash-Title[hu]=Számológép 2.0 | ||
774 | 196 | X-Ubuntu-Splash-Title[id]=Kalkulator 2.0 | ||
775 | 197 | X-Ubuntu-Splash-Title[is]=Reiknivél 2.0 | ||
776 | 198 | X-Ubuntu-Splash-Title[it]=Calcolatrice 2.0 | ||
777 | 199 | X-Ubuntu-Splash-Title[ja]=電卓 2.0 | ||
778 | 200 | X-Ubuntu-Splash-Title[km]=ម៉ាស៊ីនគិតលេខ 2.0 | ||
779 | 201 | X-Ubuntu-Splash-Title[ko]=계산기 2.0 | ||
780 | 202 | X-Ubuntu-Splash-Title[lv]=Kalkulators 2.0 | ||
781 | 203 | X-Ubuntu-Splash-Title[mr]=गणनयंत्र 2.0 | ||
782 | 204 | X-Ubuntu-Splash-Title[ms]=Kalkulator 2.0 | ||
783 | 205 | X-Ubuntu-Splash-Title[my]=ဂဏန်းတွက်စက် 2.0 | ||
784 | 206 | X-Ubuntu-Splash-Title[nb]=Kalkulator 2.0 | ||
785 | 207 | X-Ubuntu-Splash-Title[ne]=क्याल्कुलेटर 2.0 | ||
786 | 208 | X-Ubuntu-Splash-Title[nl]=Rekenmachine 2.0 | ||
787 | 209 | X-Ubuntu-Splash-Title[pa]=ਕੈਲਕੂਲੇਟਰ 2.0 | ||
788 | 210 | X-Ubuntu-Splash-Title[pl]=Kalkulator 2.0 | ||
789 | 211 | X-Ubuntu-Splash-Title[pt]=Calculadora 2.0 | ||
790 | 212 | X-Ubuntu-Splash-Title[pt_BR]=Calculadora 2.0 | ||
791 | 213 | X-Ubuntu-Splash-Title[ro]=Calculator 2.0 | ||
792 | 214 | X-Ubuntu-Splash-Title[ru]=Калькулятор 2.0 | ||
793 | 215 | X-Ubuntu-Splash-Title[sa]=सङ्कलकम् 2.0 | ||
794 | 216 | X-Ubuntu-Splash-Title[shn]=ၸၢၵ်ႈၼပ့်သွၼ် 2.0 | ||
795 | 217 | X-Ubuntu-Splash-Title[sl]=Računalo 2.0 | ||
796 | 218 | X-Ubuntu-Splash-Title[sr]=Калкулатор 2.0 | ||
797 | 219 | X-Ubuntu-Splash-Title[sv]=Kalkylator 2.0 | ||
798 | 220 | X-Ubuntu-Splash-Title[ta]=கணிப்பான் 2.0 | ||
799 | 221 | X-Ubuntu-Splash-Title[te]=గణన పరికరం 2.0 | ||
800 | 222 | X-Ubuntu-Splash-Title[tr]=Hesap Makinesi 2.0 | ||
801 | 223 | X-Ubuntu-Splash-Title[ug]= 2.0ھېسابلىغۇچ | ||
802 | 224 | X-Ubuntu-Splash-Title[uk]=Калькулятор 2.0 | ||
803 | 225 | X-Ubuntu-Splash-Title[zh_CN]=计算器 2.0 | ||
804 | 226 | X-Ubuntu-Splash-Title[zh_HK]=計數機 2.0 | ||
805 | 227 | X-Ubuntu-Splash-Title[zh_TW]=計算機 2.0 | ||
806 | 0 | 228 | ||
807 | === added file 'tests/modules/DesktopFileReader/desktopfilereader_test.cpp' | |||
808 | --- tests/modules/DesktopFileReader/desktopfilereader_test.cpp 1970-01-01 00:00:00 +0000 | |||
809 | +++ tests/modules/DesktopFileReader/desktopfilereader_test.cpp 2014-10-13 09:06:32 +0000 | |||
810 | @@ -0,0 +1,128 @@ | |||
811 | 1 | /* | ||
812 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
813 | 3 | * | ||
814 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
815 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
816 | 6 | * the Free Software Foundation. | ||
817 | 7 | * | ||
818 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
819 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
820 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
821 | 11 | * Lesser General Public License for more details. | ||
822 | 12 | * | ||
823 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
824 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
825 | 15 | * | ||
826 | 16 | */ | ||
827 | 17 | |||
828 | 18 | #include <Unity/Application/desktopfilereader.h> | ||
829 | 19 | |||
830 | 20 | #include <gtest/gtest.h> | ||
831 | 21 | |||
832 | 22 | #include <QDir> | ||
833 | 23 | #include <QFileInfo> | ||
834 | 24 | #include <QLocale> | ||
835 | 25 | #include <QtGlobal> | ||
836 | 26 | #include <QString> | ||
837 | 27 | |||
838 | 28 | using namespace qtmir; | ||
839 | 29 | |||
840 | 30 | namespace { | ||
841 | 31 | static void setLocale(const char *locale) | ||
842 | 32 | { | ||
843 | 33 | qputenv("LANGUAGE", locale); | ||
844 | 34 | qputenv("LC_ALL", locale); // set these for GIO | ||
845 | 35 | QLocale::setDefault(QString(locale)); // set for Qt | ||
846 | 36 | } | ||
847 | 37 | } | ||
848 | 38 | |||
849 | 39 | TEST(DesktopFileReader, testReadsDesktopFile) | ||
850 | 40 | { | ||
851 | 41 | using namespace ::testing; | ||
852 | 42 | setLocale("C"); | ||
853 | 43 | |||
854 | 44 | QFileInfo fileInfo(QDir::currentPath() + "/calculator.desktop"); | ||
855 | 45 | DesktopFileReader::Factory readerFactory; | ||
856 | 46 | DesktopFileReader *reader = readerFactory.createInstance("calculator", fileInfo); | ||
857 | 47 | |||
858 | 48 | EXPECT_EQ(reader->loaded(), true); | ||
859 | 49 | EXPECT_EQ(reader->appId(), "calculator"); | ||
860 | 50 | EXPECT_EQ(reader->name(), "Calculator"); | ||
861 | 51 | EXPECT_EQ(reader->exec(), "yes -p com.ubuntu.calculator_calculator_1.3.329 -- qmlscene -qt5 ubuntu-calculator-app.qml"); | ||
862 | 52 | EXPECT_EQ(reader->icon(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png"); | ||
863 | 53 | EXPECT_EQ(reader->path(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator"); | ||
864 | 54 | EXPECT_EQ(reader->comment(), "A simple calculator for Ubuntu."); | ||
865 | 55 | EXPECT_EQ(reader->stageHint(), "SideStage"); | ||
866 | 56 | EXPECT_EQ(reader->splashColor(), "#aabbcc"); | ||
867 | 57 | EXPECT_EQ(reader->splashColorFooter(), "#deadbeefda"); | ||
868 | 58 | EXPECT_EQ(reader->splashColorHeader(), "purple"); | ||
869 | 59 | EXPECT_EQ(reader->splashImage(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png"); | ||
870 | 60 | EXPECT_EQ(reader->splashShowHeader(), "True"); | ||
871 | 61 | EXPECT_EQ(reader->splashTitle(), "Calculator 2.0"); | ||
872 | 62 | } | ||
873 | 63 | |||
874 | 64 | TEST(DesktopFileReader, testReadsLocalizedDesktopFile) | ||
875 | 65 | { | ||
876 | 66 | using namespace ::testing; | ||
877 | 67 | setLocale("de"); | ||
878 | 68 | |||
879 | 69 | QFileInfo fileInfo(QDir::currentPath() + "/calculator.desktop"); | ||
880 | 70 | DesktopFileReader::Factory readerFactory; | ||
881 | 71 | DesktopFileReader *reader = readerFactory.createInstance("calculator", fileInfo); | ||
882 | 72 | |||
883 | 73 | EXPECT_EQ(reader->loaded(), true); | ||
884 | 74 | EXPECT_EQ(reader->appId(), "calculator"); | ||
885 | 75 | EXPECT_EQ(reader->name(), "Taschenrechner"); | ||
886 | 76 | EXPECT_EQ(reader->exec(), "yes -p com.ubuntu.calculator_calculator_1.3.329 -- qmlscene -qt5 ubuntu-calculator-app.qml"); | ||
887 | 77 | EXPECT_EQ(reader->icon(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png"); | ||
888 | 78 | EXPECT_EQ(reader->path(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator"); | ||
889 | 79 | EXPECT_EQ(reader->comment(), "Ein einfach Tachenrechner für Ubuntu."); | ||
890 | 80 | EXPECT_EQ(reader->stageHint(), "SideStage"); | ||
891 | 81 | EXPECT_EQ(reader->splashColor(), "#aabbcc"); | ||
892 | 82 | EXPECT_EQ(reader->splashColorFooter(), "#deadbeefda"); | ||
893 | 83 | EXPECT_EQ(reader->splashColorHeader(), "purple"); | ||
894 | 84 | EXPECT_EQ(reader->splashImage(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png"); | ||
895 | 85 | EXPECT_EQ(reader->splashShowHeader(), "True"); | ||
896 | 86 | EXPECT_EQ(reader->splashTitle(), "Taschenrechner 2.0"); | ||
897 | 87 | } | ||
898 | 88 | |||
899 | 89 | TEST(DesktopFileReader, testMissingDesktopFile) | ||
900 | 90 | { | ||
901 | 91 | using namespace ::testing; | ||
902 | 92 | setLocale("C"); | ||
903 | 93 | |||
904 | 94 | QFileInfo fileInfo(QDir::currentPath() + "/missing.desktop"); | ||
905 | 95 | DesktopFileReader::Factory readerFactory; | ||
906 | 96 | DesktopFileReader *reader = readerFactory.createInstance("calculator", fileInfo); | ||
907 | 97 | |||
908 | 98 | EXPECT_EQ(reader->loaded(), false); | ||
909 | 99 | EXPECT_EQ(reader->appId(), "calculator"); | ||
910 | 100 | EXPECT_EQ(reader->name(), ""); | ||
911 | 101 | EXPECT_EQ(reader->exec(), ""); | ||
912 | 102 | EXPECT_EQ(reader->icon(), ""); | ||
913 | 103 | EXPECT_EQ(reader->path(), ""); | ||
914 | 104 | EXPECT_EQ(reader->comment(), ""); | ||
915 | 105 | EXPECT_EQ(reader->stageHint(), ""); | ||
916 | 106 | EXPECT_EQ(reader->splashColor(), ""); | ||
917 | 107 | EXPECT_EQ(reader->splashColorFooter(), ""); | ||
918 | 108 | EXPECT_EQ(reader->splashColorHeader(), ""); | ||
919 | 109 | EXPECT_EQ(reader->splashImage(), ""); | ||
920 | 110 | EXPECT_EQ(reader->splashShowHeader(), ""); | ||
921 | 111 | EXPECT_EQ(reader->splashTitle(), ""); | ||
922 | 112 | } | ||
923 | 113 | |||
924 | 114 | TEST(DesktopFileReader, testUTF8Characters) | ||
925 | 115 | { | ||
926 | 116 | using namespace ::testing; | ||
927 | 117 | setLocale("zh_CN"); | ||
928 | 118 | |||
929 | 119 | QFileInfo fileInfo(QDir::currentPath() + "/calculator.desktop"); | ||
930 | 120 | DesktopFileReader::Factory readerFactory; | ||
931 | 121 | DesktopFileReader *reader = readerFactory.createInstance("calculator", fileInfo); | ||
932 | 122 | |||
933 | 123 | EXPECT_EQ(reader->loaded(), true); | ||
934 | 124 | EXPECT_EQ(reader->appId(), "calculator"); | ||
935 | 125 | EXPECT_EQ(reader->name(), "计算器"); | ||
936 | 126 | EXPECT_EQ(reader->comment(), "Ubuntu 简易计算器"); | ||
937 | 127 | EXPECT_EQ(reader->splashTitle(), "计算器 2.0"); | ||
938 | 128 | } | ||
939 | 0 | 129 | ||
940 | === modified file 'tests/modules/modules.pro' | |||
941 | --- tests/modules/modules.pro 2014-09-11 16:18:40 +0000 | |||
942 | +++ tests/modules/modules.pro 2014-10-13 09:06:32 +0000 | |||
943 | @@ -1,2 +1,2 @@ | |||
944 | 1 | TEMPLATE = subdirs | 1 | TEMPLATE = subdirs |
946 | 2 | SUBDIRS = ApplicationManager General MirSurfaceItem SessionManager TaskController | 2 | SUBDIRS = ApplicationManager General MirSurfaceItem SessionManager TaskController DesktopFileReader |
LGTM