From 4ec4b249c927694be69084582fa32333f21546d6 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 2 Oct 2009 16:10:52 +0200 Subject: Ensure we can handle file names on the cmdline too. --- demos/mediaplayer/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/demos/mediaplayer/main.cpp b/demos/mediaplayer/main.cpp index a5bcee2..66aa445 100644 --- a/demos/mediaplayer/main.cpp +++ b/demos/mediaplayer/main.cpp @@ -50,8 +50,6 @@ int main (int argc, char *argv[]) app.setOrganizationName("Qt"); app.setQuitOnLastWindowClosed(true); - QString fileString = app.arguments().value(1); - bool hasSmallScreen = #ifdef Q_OS_SYMBIAN /* On Symbian, we always want fullscreen. One reason is that it's not @@ -63,10 +61,20 @@ int main (int argc, char *argv[]) #endif ; + QString fileString; const QStringList args(app.arguments()); + /* We have a minor problem here, we accept two arguments, both are + * optional: + * - A file name + * - the option "-small-screen", so let's try to cope with that. + */ for (int i = 0; i < args.count(); ++i) { - if (args.at(i) == QLatin1String("-small-screen")) + const QString &at = args.at(i); + + if (at == QLatin1String("-small-screen")) hasSmallScreen = true; + else if (i > 0) // We don't want the app name. + fileString = at; } MediaPlayer player(fileString, hasSmallScreen); -- cgit v0.12