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:
5 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) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4343#include "mediaplayer.h"
    4444
     45const qreal DefaultVolume = -1.0;
     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 (smallScreen)
    8387        player.showMaximized();
    8488    else
  • trunk/demos/qmediaplayer/mediaplayer.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#include "ui_settings.h"
    4848
     49#ifdef Q_OS_SYMBIAN
     50#include <cdbcols.h>
     51#include <cdblen.h>
     52#include <commdb.h>
     53#endif
    4954
    5055MediaVideoWidget::MediaVideoWidget(MediaPlayer *player, QWidget *parent) :
     
    153158
    154159
    155 MediaPlayer::MediaPlayer(const QString &filePath,
    156                          const bool hasSmallScreen) :
     160MediaPlayer::MediaPlayer() :
    157161        playButton(0), nextEffect(0), settingsDialog(0), ui(0),
    158162            m_AudioOutput(Phonon::VideoCategory),
    159             m_videoWidget(new MediaVideoWidget(this)),
    160             m_hasSmallScreen(hasSmallScreen)
     163            m_videoWidget(new MediaVideoWidget(this))
    161164{
    162165    setWindowTitle(tr("Media Player"));
     
    272275    QAction *openFileAction = fileMenu->addAction(tr("Open &File..."));
    273276    QAction *openUrlAction = fileMenu->addAction(tr("Open &Location..."));
     277#ifdef Q_OS_SYMBIAN
     278    QAction *selectIAPAction = fileMenu->addAction(tr("Select &IAP..."));
     279    connect(selectIAPAction, SIGNAL(triggered(bool)), this, SLOT(selectIAP()));
     280#endif
    274281    QAction *const openLinkAction = fileMenu->addAction(tr("Open &RAM File..."));
    275282
     
    347354    Phonon::createPath(&m_MediaObject, m_videoWidget);
    348355
    349     if (!filePath.isEmpty())
    350         setFile(filePath);
    351356    resize(minimumSizeHint());
    352357}
     
    359364        QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint());
    360365        QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect);
    361         if (!m_hasSmallScreen) {
     366        if (!m_smallScreen) {
    362367            if (m_MediaObject.hasVideo()) {
    363368                // Flush event que so that sizeHint takes the
     
    467472}
    468473
     474void MediaPlayer::setVolume(qreal volume)
     475{
     476    m_AudioOutput.setVolume(volume);
     477}
     478
     479void MediaPlayer::setSmallScreen(bool smallScreen)
     480{
     481    m_smallScreen = smallScreen;
     482}
     483
    469484void MediaPlayer::effectChanged()
    470485{
     
    590605
    591606        if (effectDialog.result() != QDialog::Accepted) {
    592             //we need to restore the paramaters values
     607            //we need to restore the parameters values
    593608            int currentIndex = 0;
    594609            foreach(Phonon::EffectParameter param, nextEffect->parameters()) {
     
    686701    // popping up dialogs. We neither want to tamper with the state if the
    687702    // user has paused.
    688     if (m_hasSmallScreen && m_MediaObject.hasVideo()) {
     703    if (m_smallScreen && m_MediaObject.hasVideo()) {
    689704        if (Phonon::PlayingState == m_MediaObject.state()) {
    690705            m_MediaObject.pause();
     
    717732void MediaPlayer::bufferStatus(int percent)
    718733{
    719     if (percent == 0 || percent == 100)
     734    if (percent == 100)
    720735        progressLabel->setText(QString());
    721736    else {
     
    944959    m_fullScreenAction->setEnabled(bHasVideo);
    945960}
     961
     962#ifdef Q_OS_SYMBIAN
     963void MediaPlayer::selectIAP()
     964{
     965    TRAPD(err, selectIAPL());
     966    if (KErrNone != err)
     967        QMessageBox::warning(this, "Phonon Mediaplayer", "Error selecting IAP", QMessageBox::Close);
     968}
     969
     970void MediaPlayer::selectIAPL()
     971{
     972    QVariant currentIAPValue = m_MediaObject.property("InternetAccessPointName");
     973    QString currentIAPString = currentIAPValue.toString();
     974    bool ok = false;
     975    CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
     976    CleanupStack::PushL(commsDb);
     977    commsDb->ShowHiddenRecords();
     978    CCommsDbTableView* view = commsDb->OpenTableLC(TPtrC(IAP));
     979    QStringList items;
     980    TInt currentIAP = 0;
     981    for (TInt l = view->GotoFirstRecord(), i = 0; l != KErrNotFound; l = view->GotoNextRecord(), i++) {
     982       TBuf<KCommsDbSvrMaxColumnNameLength> iapName;
     983       view->ReadTextL(TPtrC(COMMDB_NAME), iapName);
     984       QString iapString = QString::fromUtf16(iapName.Ptr(), iapName.Length());
     985       items << iapString;
     986       if (iapString == currentIAPString)
     987           currentIAP = i;
     988    }
     989    currentIAPString = QInputDialog::getItem(this, tr("Select Access Point"), tr("Select Access Point"), items, currentIAP, false, &ok);
     990    if (ok)
     991        m_MediaObject.setProperty("InternetAccessPointName", currentIAPString);
     992    CleanupStack::PopAndDestroy(2); //commsDB, view
     993}
     994#endif
  • trunk/demos/qmediaplayer/mediaplayer.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    105105    Q_OBJECT
    106106public:
    107     MediaPlayer(const QString &,
    108                 const bool hasSmallScreen);
     107    MediaPlayer();
    109108
    110109    void dragEnterEvent(QDragEnterEvent *e);
     
    116115    void initVideoWindow();
    117116    void initSettingsDialog();
     117    void setVolume(qreal volume);
     118    void setSmallScreen(bool smallScreen);
    118119
    119120public slots:
     
    141142    void bufferStatus(int percent);
    142143    void openUrl();
     144#ifdef Q_OS_SYMBIAN
     145    void selectIAP();
     146#endif
    143147    void openRamFile();
    144148    void configureEffect();
     
    147151private:
    148152    bool playPauseForDialog();
     153#ifdef Q_OS_SYMBIAN
     154    void selectIAPL();
     155#endif
    149156
    150157    QIcon playIcon;
     
    172179    MediaVideoWidget *m_videoWidget;
    173180    Phonon::Path m_audioOutputPath;
    174     const bool m_hasSmallScreen;
     181    bool m_smallScreen;
    175182};
    176183
  • trunk/demos/qmediaplayer/qmediaplayer.pro

    r561 r846  
    3434    include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
    3535
     36        LIBS += -lCommDb
     37
    3638    TARGET.CAPABILITY="NetworkServices"
    3739}
Note: See TracChangeset for help on using the changeset viewer.