dlnasrv_exampleapp/src/exampleappui.cpp
branchIOP_Improvements
changeset 41 b4d83ea1d6e2
parent 40 08b5eae9f9ff
child 43 9b689d9d3a1c
equal deleted inserted replaced
40:08b5eae9f9ff 41:b4d83ea1d6e2
    29 #include "trace.h"
    29 #include "trace.h"
    30 
    30 
    31 /*!
    31 /*!
    32     \class ExampleAppUi
    32     \class ExampleAppUi
    33     \brief Implements the application UI for Dlnasrv example application.
    33     \brief Implements the application UI for Dlnasrv example application.
       
    34 
       
    35     The application provides a simple UI for selecting a renderer device
       
    36     (from a connected WLAN AP, if none is connected that needs to be done
       
    37     outside the application UI) and selecting a file to be rendered and
       
    38     control buttons for controlling the playback on the renderer device.
       
    39 
       
    40     So the first step is to have a WLAN connection active. Only then the
       
    41     renderer search and selection can be done.
       
    42 
       
    43     The next step is to select a rendering device. When rendering device
       
    44     search is initiated, the underlying UPnP AV control server is queried
       
    45     for existing renderers. Also all new renderers appearing in the AP
       
    46     get signalled with renderingDeviceFound()
       
    47 
       
    48     When a renderer is selected, the next step is to select a file to be
       
    49     pushed to the renderer. When selecting a file, it gets published in
       
    50     the push server as a DLNA item. When that is done, the controls for
       
    51     playback are enabled and the renderer can be controlled with those.
    34 */
    52 */
    35 
    53 
    36 /*!
    54 /*!
    37     ExampleAppUi constructor.
    55     ExampleAppUi constructor.
    38  */
    56  */
    62 
    80 
    63     delete mEngine;
    81     delete mEngine;
    64 }
    82 }
    65 
    83 
    66 /*!
    84 /*!
    67     description
    85     Creates application engine and the UI. Also the state of the WLAN AP
    68  
    86     connection gets queried and updated on the UI.
    69     /a
       
    70     /return
       
    71  */
    87  */
    72 void ExampleAppUi::construct()
    88 void ExampleAppUi::construct()
    73 {
    89 {
    74     FUNC_LOG
    90     FUNC_LOG
    75 
    91 
    76     createEngine();
    92     createEngine();
    77     createUi();
    93     createUi();
    78 }
    94 }
    79 
    95 
    80 /*!
    96 /*!
    81     description
    97     Creates the UI components.
    82  
       
    83     /a
       
    84     /return
       
    85  */
    98  */
    86 void ExampleAppUi::createUi()
    99 void ExampleAppUi::createUi()
    87 {
   100 {
    88     FUNC_LOG
   101     FUNC_LOG
    89 
   102 
   115     mainLayout->addLayout(layout);
   128     mainLayout->addLayout(layout);
   116     mainLayout->addSpacing(40);
   129     mainLayout->addSpacing(40);
   117 }
   130 }
   118 
   131 
   119 /*!
   132 /*!
   120     description
   133     Creates the UI for showing and selecting WLAN AP connection status.
   121  
       
   122     /a
       
   123     /return
       
   124  */
   134  */
   125 QLayout *ExampleAppUi::createApSelectionUi()
   135 QLayout *ExampleAppUi::createApSelectionUi()
   126 {
   136 {
   127     FUNC_LOG
   137     FUNC_LOG
   128 
   138 
   150     
   160     
   151     return layout;
   161     return layout;
   152 }
   162 }
   153 
   163 
   154 /*!
   164 /*!
   155     description
   165     Creates the UI for showing and selecting renderer device.
   156  
       
   157     /a
       
   158     /return
       
   159  */
   166  */
   160 QLayout *ExampleAppUi::createRendererSelectionUi()
   167 QLayout *ExampleAppUi::createRendererSelectionUi()
   161 {
   168 {
   162     FUNC_LOG
   169     FUNC_LOG
   163 
   170 
   199     
   206     
   200     return layout;
   207     return layout;
   201 }
   208 }
   202 
   209 
   203 /*!
   210 /*!
   204     description
   211     Creates the UI for showing and selecting media file to be rendered.
   205  
       
   206     /a
       
   207     /return
       
   208  */
   212  */
   209 QLayout *ExampleAppUi::createFileSelectionUi()
   213 QLayout *ExampleAppUi::createFileSelectionUi()
   210 {
   214 {
   211     FUNC_LOG
   215     FUNC_LOG
   212 
   216 
   240 
   244 
   241     return layout;
   245     return layout;
   242 }
   246 }
   243 
   247 
   244 /*!
   248 /*!
   245     description
   249     Creates the push buttons for controlling the playback.
   246  
       
   247     /a
       
   248     /return
       
   249  */
   250  */
   250 QLayout *ExampleAppUi::createPlaybackUi()
   251 QLayout *ExampleAppUi::createPlaybackUi()
   251 {
   252 {
   252     FUNC_LOG
   253     FUNC_LOG
   253 
   254 
   297 
   298 
   298     return layout;
   299     return layout;
   299 }
   300 }
   300 
   301 
   301 /*!
   302 /*!
   302     description
   303     Creates the application engine and resolves the current connection status.
   303  
       
   304     /a
       
   305     /return
       
   306  */
   304  */
   307 void ExampleAppUi::createEngine()
   305 void ExampleAppUi::createEngine()
   308 {
   306 {
   309     FUNC_LOG
   307     FUNC_LOG
   310 
   308 
   318     connect(mEngine, SIGNAL(renderingDeviceDisappeared(const QString &, const QString &)), this, SLOT(removeRenderingDevice(const QString &, const QString &)));
   316     connect(mEngine, SIGNAL(renderingDeviceDisappeared(const QString &, const QString &)), this, SLOT(removeRenderingDevice(const QString &, const QString &)));
   319     connect(mEngine, SIGNAL(initComplete(int)), this, SLOT(enablePlayback(int)));
   317     connect(mEngine, SIGNAL(initComplete(int)), this, SLOT(enablePlayback(int)));
   320 }
   318 }
   321 
   319 
   322 /*!
   320 /*!
   323     description
   321     This function gets called by the engine, when the renderer changes its state.
   324  
       
   325     /a
       
   326     /return
       
   327  */
   322  */
   328 void ExampleAppUi::updateState(int newState)
   323 void ExampleAppUi::updateState(int newState)
   329 {
   324 {
   330     FUNC_LOG
   325     FUNC_LOG
   331 
   326 
   358     // update playback controls
   353     // update playback controls
   359     enablePlayback();
   354     enablePlayback();
   360 }
   355 }
   361 
   356 
   362 /*!
   357 /*!
   363     description
   358     Launches QFile dialog for selecting a media file from the local
   364  
   359     file system. Then the file is sent to the engine for sharing, i.e.
   365     /a
   360     it will get resolved as an URI on the UPnP push server.
   366     /return
       
   367  */
   361  */
   368 void ExampleAppUi::selectFile()
   362 void ExampleAppUi::selectFile()
   369 {
   363 {
   370     FUNC_LOG
   364     FUNC_LOG
   371     
   365     
   405         disablePlayback();
   399         disablePlayback();
   406     }
   400     }
   407 }
   401 }
   408 
   402 
   409 /*!
   403 /*!
   410     description
   404     Shows searching string on UI during search if no renderers are found yet.
   411     
       
   412     /a
       
   413     /return
       
   414 */
   405 */
   415 void ExampleAppUi::deviceSearchStarted()
   406 void ExampleAppUi::deviceSearchStarted()
   416 {
   407 {
   417     FUNC_LOG
   408     FUNC_LOG
   418     
   409     
   421         mSelectedRenderer->setText(tr("Searching"));
   412         mSelectedRenderer->setText(tr("Searching"));
   422     }
   413     }
   423 }
   414 }
   424 
   415 
   425 /*!
   416 /*!
   426     description
   417     Adds a renderer to the UI's model.
   427  
       
   428     /a
       
   429     /return
       
   430  */
   418  */
   431 void ExampleAppUi::addRenderingDevice(const QString &name, const QString &uuid)
   419 void ExampleAppUi::addRenderingDevice(const QString &name, const QString &uuid)
   432 {
   420 {
   433     FUNC_LOG
   421     FUNC_LOG
   434     
   422     
   435     mRenderingDevices->addItem(name, QVariant(uuid));
   423     mRenderingDevices->addItem(name, QVariant(uuid));
   436 }
   424 }
   437 
   425 
   438 /*!
   426 /*!
   439     description
   427     Removes a renderer from the UI's model.
   440  
       
   441     /a
       
   442     /return
       
   443  */
   428  */
   444 void ExampleAppUi::removeRenderingDevice(const QString &/*name*/, const QString &uuid)
   429 void ExampleAppUi::removeRenderingDevice(const QString &/*name*/, const QString &uuid)
   445 {
   430 {
   446     FUNC_LOG
   431     FUNC_LOG
   447 
   432 
   456         }
   441         }
   457     }
   442     }
   458 }
   443 }
   459 
   444 
   460 /*!
   445 /*!
   461     description
   446     Set the renderer selected from the UI as the current renderer on the engine side.
   462     
       
   463     /a
       
   464     /return
       
   465 */
   447 */
   466 void ExampleAppUi::selectRenderingDevice(int index)
   448 void ExampleAppUi::selectRenderingDevice(int index)
   467 {
   449 {
   468     FUNC_LOG
   450     FUNC_LOG
   469     
   451     
   476     enablePlayback();
   458     enablePlayback();
   477     enableFileSelection();
   459     enableFileSelection();
   478 }
   460 }
   479 
   461 
   480 /*!
   462 /*!
   481     description
   463     Enables/disables the pushbuttons for renderer control according to the
   482     
   464     current state.
   483     /a
       
   484     /return
       
   485 */
   465 */
   486 void ExampleAppUi::enablePlayback(int result)
   466 void ExampleAppUi::enablePlayback(int result)
   487 {
   467 {
   488     FUNC_LOG
   468     FUNC_LOG
   489     
   469     
   534         }
   514         }
   535     }
   515     }
   536 }
   516 }
   537 
   517 
   538 /*!
   518 /*!
   539     description
   519     Disables all renderer control pushbuttons.
   540     
       
   541     /a
       
   542     /return
       
   543 */
   520 */
   544 void ExampleAppUi::disablePlayback()
   521 void ExampleAppUi::disablePlayback()
   545 {
   522 {
   546     FUNC_LOG
   523     FUNC_LOG
   547 
   524 
   551     mRewButton->setDisabled(true);
   528     mRewButton->setDisabled(true);
   552     mFfButton->setDisabled(true);
   529     mFfButton->setDisabled(true);
   553 }
   530 }
   554 
   531 
   555 /*!
   532 /*!
   556     description
   533     Enables file selection button. Called when a renderer is selected.
   557     
       
   558     /a
       
   559     /return
       
   560 */
   534 */
   561 void ExampleAppUi::enableFileSelection()
   535 void ExampleAppUi::enableFileSelection()
   562 {
   536 {
   563     FUNC_LOG
   537     FUNC_LOG
   564     
   538     
   565     mSelectFileButton->setEnabled(true);
   539     mSelectFileButton->setEnabled(true);
   566 }
   540 }
   567 
   541 
   568 /*!
   542 /*!
   569     description
   543     Disables file selection.
   570     
       
   571     /a
       
   572     /return
       
   573 */
   544 */
   574 void ExampleAppUi::disableFileSelection()
   545 void ExampleAppUi::disableFileSelection()
   575 {
   546 {
   576     FUNC_LOG
   547     FUNC_LOG
   577 
   548 
   578     mSelectFileButton->setDisabled(true);
   549     mSelectFileButton->setDisabled(true);
   579 }
   550 }
   580 
   551 
   581 /*!
   552 /*!
   582     description
   553     Enables the rendering device selection pushbutton. Called when a WLAN AP is in use.
   583     
       
   584     /a
       
   585     /return
       
   586 */
   554 */
   587 void ExampleAppUi::enableRenderingDeviceSelection(int iap)
   555 void ExampleAppUi::enableRenderingDeviceSelection(int iap)
   588 {
   556 {
   589     FUNC_LOG
   557     FUNC_LOG
   590     
   558     
   594         mRenderingDevices->setEnabled(true);
   562         mRenderingDevices->setEnabled(true);
   595     }
   563     }
   596 }
   564 }
   597 
   565 
   598 /*!
   566 /*!
   599     description
   567     Disables the rendering device selection pushbutton.
   600     
       
   601     /a
       
   602     /return
       
   603 */
   568 */
   604 void ExampleAppUi::disableRenderingDeviceSelection()
   569 void ExampleAppUi::disableRenderingDeviceSelection()
   605 {
   570 {
   606     FUNC_LOG
   571     FUNC_LOG
   607     
   572