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

Subscribers

People subscribed via source and target branches