Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/demos/qmediaplayer/main.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    4343#include "mediaplayer.h"
    4444
     45
     46
    4547int main (int argc, char *argv[])
    4648{
     
    5153    app.setQuitOnLastWindowClosed(true);
    5254
    53     bool hasSmallScreen =
     55    QString fileName;
     56    qreal volume = DefaultVolume;
     57    bool smallScreen = false;
    5458#ifdef Q_OS_SYMBIAN
    55         /* On Symbian, we always want fullscreen. One reason is that it's not
    56          * possible to launch any demos from the fluidlauncher due to a
    57          * limitation in the emulator. */
    58         true
    59 #else
    60         false
     59    smallScreen = true;
    6160#endif
    62     ;
    6361
    64     QString fileString;
    65     const QStringList args(app.arguments());
    66     /* We have a minor problem here, we accept two arguments, both are
    67      * optional:
    68      * - A file name
    69      * - the option "-small-screen", so let's try to cope with that.
    70      */
    71     for (int i = 0; i < args.count(); ++i) {
    72         const QString &at = args.at(i);
    73 
    74         if (at == QLatin1String("-small-screen"))
    75             hasSmallScreen = true;
    76         else if (i > 0) // We don't want the app name.
    77             fileString = at;
     62    QStringList args(app.arguments());
     63    args.removeFirst(); // remove name of executable
     64    while (!args.empty()) {
     65        const QString &arg = args.first();
     66        if (QLatin1String("-small-screen") == arg || QLatin1String("--small-screen") == arg) {
     67            smallScreen = true;
     68        } else if (QLatin1String("-volume") == arg || QLatin1String("--volume") == arg) {
     69            if (!args.empty()) {
     70                args.removeFirst();
     71                volume = qMax(qMin(args.first().toFloat(), float(1.0)), float(0.0));
     72            }
     73        } else if (fileName.isNull()) {
     74            fileName = arg;
     75        }
     76        args.removeFirst();
    7877    }
    7978
    80     MediaPlayer player(fileString, hasSmallScreen);
     79    MediaPlayer player;
     80    player.setSmallScreen(smallScreen);
     81    if (DefaultVolume != volume)
     82        player.setVolume(volume);
     83    if (!fileName.isNull())
     84        player.setFile(fileName);
    8185
    82     if (hasSmallScreen)
     86    if (mallScreen)
    8387        player.showMaximized();
    8488    else
Note: See TracChangeset for help on using the changeset viewer.