on xenial help sign in
Handle windowgeometry argument with new argument parsing scheme.

This should retain backwards compatibility.

commit0cb120674a1e04613c597eb1f7a33ee35f50f579 authorJosh Arenson <joshua.arenson@canonical.com> dateTue 29 Apr 2014, 10:47 (12 years ago) parent9d4075b
2 files changed+19−12
src/ApplicationArguments.h+7−8 src/main.cpp+12−4
src/ApplicationArguments.h+7−8
@@ -28,14 +28,13 @@ class ApplicationArguments : public QObject
2828{
2929 Q_OBJECT
3030public:
31− ApplicationArguments(const QStringList& args) {
32− if (args.contains(QLatin1String("-windowgeometry")) && args.size() > args.indexOf(QLatin1String("-windowgeometry")) + 1) {
33− QStringList geometryArg = args.at(args.indexOf(QLatin1String("-windowgeometry")) + 1).split('x');
34− if (geometryArg.size() == 2) {
35− m_size.rwidth() = geometryArg.at(0).toInt();
36− m_size.rheight() = geometryArg.at(1).toInt();
37− }
38− }
31+ ApplicationArguments()
32+ {
33+ }
34+
35+ ApplicationArguments(int width, int height) {
36+ m_size.rwidth() = width;
37+ m_size.rheight() = height;
3938 }
4039
4140 Q_INVOKABLE bool hasGeometry() const { return m_size.isValid(); }
src/main.cpp+12−4
@@ -61,8 +61,8 @@ int startShell(int argc, const char** argv, void* server)
6161 "Allow the mouse to provide touch input");
6262 parser.addOption(mousetouchOption);
6363
64− QCommandLineOption windowGeometryOption("windowgeometry",
65− "Specify the window geometry as [<width>x<height>]");
64+ QCommandLineOption windowGeometryOption(QStringList() << "windowgeometry",
65+ "Specify the window geometry as [<width>x<height>]", "windowgeometry", "1");
6666 parser.addOption(windowGeometryOption);
6767
6868 QCommandLineOption testabilityOption("testability",
@@ -98,8 +98,16 @@ Load the testability driver");
9898
9999 resolveIconTheme();
100100
101− QStringList args = application->arguments();
102− ApplicationArguments qmlArgs(args);
101+ std::auto_ptr<ApplicationArguments> appArgs;
102+ if (parser.isSet(windowGeometryOption) &&
103+ parser.value(windowGeometryOption).split('x').size() == 2) {
104+ QStringList geom =
105+ parser.value(windowGeometryOption).split('x');
106+ appArgs.reset(new ApplicationArguments(geom.at(0).toInt(), geom.at(1).toInt()));
107+ } else {
108+ appArgs.reset(new ApplicationArguments());
109+ }
110+ ApplicationArguments& qmlArgs = *appArgs;
103111
104112 // The testability driver is only loaded by QApplication but not by QGuiApplication.
105113 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.