Merge lp:~mzanetti/reminders-app/qmlfile-param into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 87
Merged at revision: 86
Proposed branch: lp:~mzanetti/reminders-app/qmlfile-param
Merge into: lp:reminders-app
Diff against target: 51 lines (+17/-6)
1 file modified
src/app/main.cpp (+17/-6)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/qmlfile-param
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Ubuntu Notes app developers Pending
Review via email: mp+210891@code.launchpad.net

Commit message

Add command line option -q <qmlfile> to load the main qml file from some other place

Also make it a bit more flexible by unhardcoding the fallback searchpath for /usr/share

To post a comment you must log in.
87. By Michael Zanetti

add it to -h

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

So you won't look at /usr/share anymore at all? I can't review too much from a qml perspective, but thank you for making this a bit easier to launch :-)

Anyways, code reads fine to me, I'd like to make sure it works before I +1.

Revision history for this message
David Planella (dpm) wrote :

On Fri, Mar 14, 2014 at 1:49 AM, Nicholas Skaggs <
<email address hidden>> wrote:

> So you won't look at /usr/share anymore at all? I can't review too much
> from a qml perspective, but thank you for making this a bit easier to
> launch :-)
>
>
Hi Nick, that's exactly what this line does. The difference is that now the
directory name is not hardcoded, and we're using the Qt API to resolve it:

+ QStringList paths =
QStandardPaths::standardLocations(QStandardPaths::DataLocation);

That resolves ultimately to /usr/share/reminders (
http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html). I remember
having found a URL where there was a table that listed to which directory
each QStandardPath resolved to, but I don't seem to be able to find it
again. In any case, /usr/share/reminders is still one of the dirs where
we're looking for the main .qml file.

Cheers,
David.

Anyways, code reads fine to me, I'd like to make sure it works before I +1.
> --
>
> https://code.launchpad.net/~mzanetti/reminders-app/qmlfile-param/+merge/210891
> Your team Ubuntu Reminders app developers is requested to review the
> proposed merge of lp:~mzanetti/reminders-app/qmlfile-param into
> lp:reminders-app.
>

Revision history for this message
Michael Zanetti (mzanetti) wrote :

It also looks in /usr/local/share/, ~/.local/share/ and /opt/share if it can't be found in the local dir or /usr/share

Giving the -q argument disables that searching and only tries to open the given file (to avoid confusion if giving a file and the app silently loading another one)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/main.cpp'
2--- src/app/main.cpp 2014-02-25 09:42:51 +0000
3+++ src/app/main.cpp 2014-03-13 19:49:58 +0000
4@@ -46,9 +46,11 @@
5 qDebug() << " -t|--tablet If running on Desktop, start in a tablet sized window.";
6 qDebug() << " -h|--help Print this help.";
7 qDebug() << " -I <path> Give a path for an additional QML import directory. May be used multiple times.";
8+ qDebug() << " -q <qmlfile> Give an alternative location for the main qml file.";
9 return 0;
10 }
11
12+ QString qmlfile;
13 for (int i = 0; i < args.count(); i++) {
14 if (args.at(i) == "-I" && args.count() > i + 1) {
15 QString addedPath = args.at(i+1);
16@@ -57,6 +59,8 @@
17 addedPath.prepend(QDir::currentPath());
18 }
19 importPathList.append(addedPath);
20+ } else if (args.at(i) == "-q" && args.count() > i + 1) {
21+ qmlfile = args.at(i+1);
22 }
23 }
24
25@@ -84,13 +88,20 @@
26 view.engine()->rootContext()->setContextProperty("accountPreference", &preferences);
27
28 // load the qml file
29- QFileInfo fi("qml/reminders.qml");
30- if (fi.exists()) {
31- view.setSource(QUrl::fromLocalFile("qml/reminders.qml"));
32- } else {
33- view.setSource(QUrl::fromLocalFile("/usr/share/reminders/qml/reminders.qml"));
34+ if (qmlfile.isEmpty()) {
35+ QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
36+ paths.prepend(".");
37+
38+ foreach (const QString &path, paths) {
39+ QFileInfo fi(path + "/qml/reminders.qml");
40+ if (fi.exists()) {
41+ qmlfile = path + "/qml/reminders.qml";
42+ break;
43+ }
44+ }
45 }
46-
47+ qDebug() << "using main qml file from:" << qmlfile;
48+ view.setSource(QUrl::fromLocalFile(qmlfile));
49 view.show();
50
51 return a.exec();

Subscribers

People subscribed via source and target branches