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

Proposed by Josh Arenson
Status: Superseded
Proposed branch: lp:~josharenson/unity8/doc_args
Merge into: lp:unity8
Prerequisite: lp:~aacid/unity8/killqt51
Diff against target: 132 lines (+53/-14)
2 files modified
src/ApplicationArguments.h (+7/-8)
src/main.cpp (+46/-6)
To merge this branch: bzr merge lp:~josharenson/unity8/doc_args
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Albert Astals Cid (community) Needs Fixing
Review via email: mp+217282@code.launchpad.net

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

This proposal has been superseded by a proposal from 2014-04-30.

Commit message

Adds usage style help to 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 :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

This breaks the -windowgeometry param, i.e.

./builddir/src/unity8 -windowgeometry 400x400

Doesn't work anymore

review: Needs Fixing
lp:~josharenson/unity8/doc_args updated
861. By Josh Arenson

Added windowgeometry to argument list

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

> 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 :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

> > 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

lp:~josharenson/unity8/doc_args updated
862. By Josh Arenson

Handle windowgeometry argument with new argument parsing scheme.

This should retain backwards compatibility.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~josharenson/unity8/doc_args updated
863. By Josh Arenson

Refactored ApplicationArguments constructor(s)

Unmerged revisions

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

Subscribers

People subscribed via source and target branches