videocollection/tsrc/simplevideoplayback/src/svpbplugin.cpp
changeset 52 e3cecb93e76a
equal deleted inserted replaced
47:45e72b57a2fd 52:e3cecb93e76a
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Simple Video Playback MXP view plugin
       
    15 *
       
    16 */
       
    17 
       
    18 #include <xqplugin.h>
       
    19 
       
    20 #include "svpbdocumentloader.h"
       
    21 #include "svpbengine.h"
       
    22 #include "svpbplugin.h"
       
    23 #include "svpbview.h"
       
    24 #include "mpxhbvideocommondefs.h"
       
    25 #include "trace.h"
       
    26 
       
    27 static const QString NAME_DOCML = ":/resources/simplevideoplayback.docml";
       
    28 static const QString NAME_VIEW = "view";
       
    29 
       
    30 SvpbPlugin::SvpbPlugin() : mView(0), mEngine(0)
       
    31 {
       
    32     FUNC_LOG;
       
    33 }
       
    34 
       
    35 SvpbPlugin::~SvpbPlugin()
       
    36 {
       
    37     FUNC_LOG;
       
    38     destroyView();
       
    39 }
       
    40 
       
    41 void SvpbPlugin::createView()
       
    42 {
       
    43     FUNC_LOG;
       
    44 
       
    45     if (!mView) {
       
    46         SvpbDocumentLoader loader;
       
    47         bool ok;
       
    48         loader.load(NAME_DOCML, &ok);
       
    49 
       
    50         if (ok) {
       
    51             mView = qobject_cast<SvpbView *>(loader.findWidget(NAME_VIEW));
       
    52             HANDLE_ERROR_NULL(mView);
       
    53             connect(mView, SIGNAL(finished()), SLOT(back()), Qt::QueuedConnection);
       
    54 
       
    55             mEngine = new SvpbEngine;
       
    56             HANDLE_ERROR_NULL(mEngine);
       
    57             connect(mEngine, SIGNAL(finished()), SLOT(back()), Qt::QueuedConnection);
       
    58 
       
    59             connect(mView, SIGNAL(tapped()), mEngine, SLOT(togglePause()));
       
    60             connect(mView, SIGNAL(longTapped()), mEngine, SLOT(stop()));
       
    61         }
       
    62         else {
       
    63             ERROR(QString("Unable to read ").append(NAME_DOCML));
       
    64         }
       
    65     }
       
    66 }
       
    67 
       
    68 void SvpbPlugin::destroyView()
       
    69 {
       
    70     FUNC_LOG;
       
    71 
       
    72     deactivateView();
       
    73 
       
    74     delete mEngine; // disconnects any signals
       
    75     mEngine = 0;
       
    76 
       
    77     delete mView; // disconnects any signals
       
    78     mView = 0;
       
    79 }
       
    80 
       
    81 void SvpbPlugin::activateView()
       
    82 {
       
    83     FUNC_LOG;
       
    84 
       
    85     if (mEngine && mView) {
       
    86         mEngine->connectMPX();
       
    87         mView->activate();
       
    88         mEngine->setSurfaceContainer(mView->surfaceContainer());
       
    89     }
       
    90 }
       
    91 
       
    92 void SvpbPlugin::deactivateView()
       
    93 {
       
    94     FUNC_LOG;
       
    95 
       
    96     if (mEngine && mView) {
       
    97         mView->deactivate();
       
    98         mEngine->disconnectMPX();
       
    99     }
       
   100 }
       
   101 
       
   102 QGraphicsWidget* SvpbPlugin::getView()
       
   103 {
       
   104     FUNC_LOG;
       
   105 
       
   106     return mView;
       
   107 }
       
   108 
       
   109 void SvpbPlugin::orientationChange(Qt::Orientation orientation)
       
   110 {
       
   111     FUNC_LOG;
       
   112     Q_UNUSED( orientation );
       
   113 }
       
   114 
       
   115 void SvpbPlugin::back()
       
   116 {
       
   117     FUNC_LOG;
       
   118 
       
   119     emit command(MpxHbVideoCommon::CollectionView);
       
   120 }
       
   121 
       
   122 XQ_EXPORT_PLUGIN2(simplevideoplayback, SvpbPlugin);