on xenial help sign in
Handle windowgeometry argument with new argument parsing scheme.
0cb1206Josh Arenson
src/ApplicationArguments.h+7−8
@@ -28,14 +28,13 @@ class ApplicationArguments : public QObject
28{
28{
29 Q_OBJECT
29 Q_OBJECT
30public:
30public:
31− ApplicationArguments(const QStringList& args) {
31+ ApplicationArguments()
32− if (args.contains(QLatin1String("-windowgeometry")) && args.size() > args.indexOf(QLatin1String("-windowgeometry")) + 1) {
32+ {
33− QStringList geometryArg = args.at(args.indexOf(QLatin1String("-windowgeometry")) + 1).split('x');
33+ }
34− if (geometryArg.size() == 2) {
34+
35+ ApplicationArguments(int width, int height) {
35− m_size.rwidth() = geometryArg.at(0).toInt();
36+ m_size.rwidth() = width;
36− m_size.rheight() = geometryArg.at(1).toInt();
37+ m_size.rheight() = height;
37− }
38− }
39 }
38 }
40
39
41 Q_INVOKABLE bool hasGeometry() const { return m_size.isValid(); }
40 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)
61 "Allow the mouse to provide touch input");
61 "Allow the mouse to provide touch input");
62 parser.addOption(mousetouchOption);
62 parser.addOption(mousetouchOption);
63
63
64− QCommandLineOption windowGeometryOption("windowgeometry",
64+ QCommandLineOption windowGeometryOption(QStringList() << "windowgeometry",
65− "Specify the window geometry as [<width>x<height>]");
65+ "Specify the window geometry as [<width>x<height>]", "windowgeometry", "1");
66 parser.addOption(windowGeometryOption);
66 parser.addOption(windowGeometryOption);
67
67
68 QCommandLineOption testabilityOption("testability",
68 QCommandLineOption testabilityOption("testability",
@@ -98,8 +98,16 @@ Load the testability driver");
98
98
99 resolveIconTheme();
99 resolveIconTheme();
100
100
101+ std::auto_ptr<ApplicationArguments> appArgs;
102+ if (parser.isSet(windowGeometryOption) &&
103+ parser.value(windowGeometryOption).split('x').size() == 2) {
101− QStringList args = application->arguments();
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+ }
102− ApplicationArguments qmlArgs(args);
110+ ApplicationArguments& qmlArgs = *appArgs;
103
111
104 // The testability driver is only loaded by QApplication but not by QGuiApplication.
112 // The testability driver is only loaded by QApplication but not by QGuiApplication.
105 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
113 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.