Merge lp:~josharenson/unity8/doc_args into lp:unity8

Proposed by Josh Arenson
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 863
Merged at revision: 887
Proposed branch: lp:~josharenson/unity8/doc_args
Merge into: lp:unity8
Prerequisite: lp:~aacid/unity8/killqt51
Diff against target: 126 lines (+47/-14)
2 files modified
src/ApplicationArguments.h (+4/-8)
src/main.cpp (+43/-6)
To merge this branch: bzr merge lp:~josharenson/unity8/doc_args
Reviewer Review Type Date Requested Status
Michał Sawicz Abstain
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+217840@code.launchpad.net

This proposal supersedes a proposal from 2014-04-25.

Commit message

Implements usage-style documentation for unity8 executable.
Fixes lp:1269282

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
lp:~aacid/unity8/killqt51

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Compiled code, verified new feature works as expected, and ran ctest

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Dependent branch does. This MP does not

 * If you changed the UI, has there been a design review?
na

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Should increase the qt5 version number dependency in debian/control to 5.2 since QCommandLineParser is new for 5.2
Also probably in the find_package of CMakeListst.txt

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

And you're missing https://wiki.ubuntu.com/Process/Merges/Checklists/Unity8 as part of your description of the change

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

And finally, we don't support Qt translation system (we are using gettext) so for now i think we can just pretend we don't need to translate the commandline options and just drop the QCoreApplication::translate() and just pass the English text as second param of QCommandLineOption.

Saviq, what's your opinion?

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Yeah, let's leave the help in English. It's not like they're general-use.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

In case you're confused by all the failings → whitespace issues

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

src/main.cpp: bad whitespace in lines 67, 84

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

you probably want to merge lp:~aacid/unity8/killqt51 into here (you'll have to resubmit the MR setting a prerequisite branch)

Revision history for this message
Josh Arenson (josharenson) wrote : Posted in a previous version of this proposal

> you probably want to merge lp:~aacid/unity8/killqt51 into here (you'll have
> to resubmit the MR setting a prerequisite branch)

So if I clean up my white space, depend on _your_ MP, and resubmit _this_ MP in the proper format, we should be good to go?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

You didn't merge Albert's branch into this one, and you didn't put it in the "prerequisite" field when resubmitting.

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

I've resubmitted this for you, you can merge Albert's branch, but that's not necessary, since the other one will be merged before anyway.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

This breaks the -windowgeometry param, i.e.

./builddir/src/unity8 -windowgeometry 400x400

Doesn't work anymore

review: Needs Fixing
Revision history for this message
Josh Arenson (josharenson) wrote : Posted in a previous version of this proposal

> This breaks the -windowgeometry param, i.e.
>
> ./builddir/src/unity8 -windowgeometry 400x400
>
> Doesn't work anymore
Pushed a small hack to WAR this. Let me know if you have an idea for something more elegant.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

> > This breaks the -windowgeometry param, i.e.
> >
> > ./builddir/src/unity8 -windowgeometry 400x400
> >
> > Doesn't work anymore
> Pushed a small hack to WAR this. Let me know if you have an idea for something
> more elegant.

I think i'd prefer if you move the parsing of the argument to main.cpp and only pass to ApplicationArguments the already parsed size instead of the list of args

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

I'm confused about the auto_ptr use

Wouldn't

std::auto_ptr<ApplicationArguments> appArgs;
if (parser.isSet(windowGeometryOption) &&
  parser.value(windowGeometryOption).split('x').size() == 2) {
  QStringList geom = parser.value(windowGeometryOption).split('x');
  appArgs.reset(new ApplicationArguments(geom.at(0).toInt(), geom.at(1).toInt()));
} else {
  appArgs.reset(new ApplicationArguments());
}
ApplicationArguments& qmlArgs = *appArgs;

make more sense as

ApplicationArguments qmlArgs;
if (parser.isSet(windowGeometryOption) &&
  parser.value(windowGeometryOption).split('x').size() == 2) {
  QStringList geom = parser.value(windowGeometryOption).split('x');
  qmlArgs.setSize(new ApplicationArguments(geom.at(0).toInt(), geom.at(1).toInt()));
}

or if you don't want to expose setSize (which is indeed fine since if you don't make it a q_invokable it won't be available from the qml side)

QSize size;
if (parser.isSet(windowGeometryOption) &&
  parser.value(windowGeometryOption).split('x').size() == 2) {
  QStringList geom = parser.value(windowGeometryOption).split('x');
  size = QSize(new ApplicationArguments(geom.at(0).toInt(), geom.at(1).toInt()));
}
ApplicationArguments qmlArgs(size);

?

Any of those two versions seem easier to read to me

// Note code not warranteed to compile :D

review: Needs Information
lp:~josharenson/unity8/doc_args updated
863. By Josh Arenson

Refactored ApplicationArguments constructor(s)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Please strip tags: http://people.canonical.com/~msawicz/unity8/strip-u8-tags.sh

Do the same on your local checkout(s), too!

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Code looks good to me now, please ping us once the tags are cleared so we can top approve

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes, works

* Did CI run pass?
No, qmluitests failed to even start for some reason, but qmluitests don't cover these changes anyway

review: Approve
Revision history for this message
Josh Arenson (josharenson) wrote :

> Please strip tags:
> http://people.canonical.com/~msawicz/unity8/strip-u8-tags.sh
>
> Do the same on your local checkout(s), too!

Done

Revision history for this message
Michał Sawicz (saviq) :
review: Abstain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ApplicationArguments.h'
2--- src/ApplicationArguments.h 2014-03-19 15:29:35 +0000
3+++ src/ApplicationArguments.h 2014-05-05 22:46:16 +0000
4@@ -28,14 +28,10 @@
5 {
6 Q_OBJECT
7 public:
8- ApplicationArguments(const QStringList& args) {
9- if (args.contains(QLatin1String("-windowgeometry")) && args.size() > args.indexOf(QLatin1String("-windowgeometry")) + 1) {
10- QStringList geometryArg = args.at(args.indexOf(QLatin1String("-windowgeometry")) + 1).split('x');
11- if (geometryArg.size() == 2) {
12- m_size.rwidth() = geometryArg.at(0).toInt();
13- m_size.rheight() = geometryArg.at(1).toInt();
14- }
15- }
16+ // Not exposed to the app as setSize isn't invokable
17+ void setSize(int width, int height) {
18+ m_size.rwidth() = width;
19+ m_size.rheight() = height;
20 }
21
22 Q_INVOKABLE bool hasGeometry() const { return m_size.isValid(); }
23
24=== modified file 'src/main.cpp'
25--- src/main.cpp 2014-04-02 11:19:54 +0000
26+++ src/main.cpp 2014-05-05 22:46:16 +0000
27@@ -18,6 +18,7 @@
28 */
29
30 // Qt
31+#include <QCommandLineParser>
32 #include <QtQuick/QQuickView>
33 #include <QtGui/QGuiApplication>
34 #include <QtQml/QQmlEngine>
35@@ -43,6 +44,32 @@
36
37 QGuiApplication::setApplicationName("Unity 8");
38 QGuiApplication *application;
39+
40+ QCommandLineParser parser;
41+ parser.setApplicationDescription("Description: Unity 8 Shell");
42+ parser.addHelpOption();
43+
44+ QCommandLineOption fullscreenOption("fullscreen",
45+ "Run in fullscreen");
46+ parser.addOption(fullscreenOption);
47+
48+ QCommandLineOption framelessOption("frameless",
49+ "Run without window borders");
50+ parser.addOption(framelessOption);
51+
52+ QCommandLineOption mousetouchOption("mousetouch",
53+ "Allow the mouse to provide touch input");
54+ parser.addOption(mousetouchOption);
55+
56+ QCommandLineOption windowGeometryOption(QStringList() << "windowgeometry",
57+ "Specify the window geometry as [<width>x<height>]", "windowgeometry", "1");
58+ parser.addOption(windowGeometryOption);
59+
60+ QCommandLineOption testabilityOption("testability",
61+ "DISCOURAGED: Please set QT_LOAD_TESTABILITY instead. \n \
62+Load the testability driver");
63+ parser.addOption(testabilityOption);
64+
65 if (isUbuntuMirServer) {
66 QLibrary unityMir("unity-mir", 1);
67 unityMir.load();
68@@ -59,6 +86,11 @@
69 application = new QGuiApplication(argc, (char**)argv);
70 }
71
72+ // Treat args with single dashes the same as arguments with two dashes
73+ // Ex: -fullscreen == --fullscreen
74+ parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
75+ parser.process(*application);
76+
77 QString indicatorProfile = qgetenv("UNITY_INDICATOR_PROFILE");
78 if (indicatorProfile.isEmpty()) {
79 indicatorProfile = "phone";
80@@ -66,12 +98,17 @@
81
82 resolveIconTheme();
83
84- QStringList args = application->arguments();
85- ApplicationArguments qmlArgs(args);
86+ ApplicationArguments qmlArgs;
87+ if (parser.isSet(windowGeometryOption) &&
88+ parser.value(windowGeometryOption).split('x').size() == 2)
89+ {
90+ QStringList geom = parser.value(windowGeometryOption).split('x');
91+ qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
92+ }
93
94 // The testability driver is only loaded by QApplication but not by QGuiApplication.
95 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
96- if (args.contains(QLatin1String("-testability")) || getenv("QT_LOAD_TESTABILITY")) {
97+ if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
98 QLibrary testLib(QLatin1String("qttestability"));
99 if (testLib.load()) {
100 typedef void (*TasInitialize)(void);
101@@ -94,14 +131,14 @@
102 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
103 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
104 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
105- if (args.contains(QLatin1String("-frameless"))) {
106+ if (parser.isSet(framelessOption)) {
107 view->setFlags(Qt::FramelessWindowHint);
108 }
109
110 // You will need this if you want to interact with touch-only components using a mouse
111 // Needed only when manually testing on a desktop.
112 MouseTouchAdaptor *mouseTouchAdaptor = 0;
113- if (args.contains(QLatin1String("-mousetouch"))) {
114+ if (parser.isSet(mousetouchOption)) {
115 mouseTouchAdaptor = new MouseTouchAdaptor;
116 application->installNativeEventFilter(mouseTouchAdaptor);
117 }
118@@ -125,7 +162,7 @@
119 view->setSource(source);
120 view->setColor("transparent");
121
122- if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || args.contains(QLatin1String("-fullscreen"))) {
123+ if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || parser.isSet(fullscreenOption)) {
124 view->showFullScreen();
125 } else {
126 view->show();

Subscribers

People subscribed via source and target branches