[vlc-devel] [PATCH 3/3] Add a simple "download"-button to the Qt-interface

Rémi Denis-Courmont remi at remlab.net
Sun Jan 6 12:41:51 CET 2013


Le samedi 5 janvier 2013 23:12:48, Mario Speiß a écrit :
> This sets the input_item_t->i_download flag and feeds the playlist fetcher
> with the item to download the content to hdd. This completes the previous
> patches.
> 
> Regards,
> Mario
> ---
>  modules/gui/qt4/actions_manager.cpp       |   32
> +++++++++++++++++++++++++++++ modules/gui/qt4/actions_manager.hpp       | 
>   2 +
>  modules/gui/qt4/components/controller.cpp |    5 ++++
>  modules/gui/qt4/components/controller.hpp |    8 ++++--
>  4 files changed, 44 insertions(+), 3 deletions(-)
>  mode change 100644 => 100755 modules/gui/qt4/actions_manager.cpp
>  mode change 100644 => 100755 modules/gui/qt4/actions_manager.hpp
>  mode change 100644 => 100755 modules/gui/qt4/components/controller.cpp
>  mode change 100644 => 100755 modules/gui/qt4/components/controller.hpp
> 
> diff --git a/modules/gui/qt4/actions_manager.cpp
> b/modules/gui/qt4/actions_manager.cpp index fa3703b..8e73928
> --- a/modules/gui/qt4/actions_manager.cpp
> +++ b/modules/gui/qt4/actions_manager.cpp
> @@ -97,6 +97,9 @@ void ActionsManager::doAction( int id_action )
>              if( p_intf->p_sys->p_mi )
>                 
> p_intf->p_sys->p_mi->getFullscreenControllerWidget()->toggleFullwidth();
> break;
> +        case DOWNLOAD_ACTION:
> +            download();
> +            break;
>          default:
>              msg_Dbg( p_intf, "Action: %i", id_action );
>              break;
> @@ -146,6 +149,35 @@ void ActionsManager::playlist()
>      if( p_intf->p_sys->p_mi ) p_intf->p_sys->p_mi->togglePlaylist();
>  }
> 
> +void ActionsManager::download()
> +{
> +    playlist_t *p_playlist = pl_Get( p_intf );

There is no point in doing this inside the Qt4 plugin.

> +    if( p_playlist )

This is always true.

> +    {
> +        playlist_item_t * p_playlist_item =
> playlist_CurrentPlayingItem(p_playlist); +        if(
> p_playlist_item->p_input )
> +        {
> +            input_item_t* p_item =
> p_playlist_item->p_input;//p_playlist->current.p_elems[p_playlist->i_curre
> nt_index]->p_input; +            if( p_item->i_download <= 0 )
> +            {
> +                if( strncmp( p_item->psz_uri , "http://", 7 ) && strncmp(
> p_item->psz_uri , "https://", 8 ) && strncmp( p_item->psz_uri , "ftp://",
> 5 ) ) +                {
> +                    /* no http, https or ftp => no download! */
> +                    p_item->i_download = 1;
> +                    return;
> +                }
> +                /* set download flag */
> +                p_item->i_download =- 1;
> +                playlist_AskForArtEnqueue( pl_Get(p_intf), p_item );
> +                /* stop the playback to not interfere with the download
> +                 * (this is not neccessary but nevertheless...
> +                 */
> +                THEMIM->stop();
> +            }
> +        }
> +    }
> +}
> +
>  void ActionsManager::record()
>  {
>      input_thread_t *p_input = THEMIM->getInput();
> diff --git a/modules/gui/qt4/actions_manager.hpp
> b/modules/gui/qt4/actions_manager.hpp index a694579..7a4825d
> --- a/modules/gui/qt4/actions_manager.hpp
> +++ b/modules/gui/qt4/actions_manager.hpp
> @@ -56,6 +56,7 @@ typedef enum actionType_e
>      LOOP_ACTION,
>      INFO_ACTION,
>      OPEN_SUB_ACTION,
> +    DOWNLOAD_ACTION,
>  } actionType_e;
> 
>  class ActionsManager : public QObject
> @@ -90,6 +91,7 @@ public slots:
>      void record();
>      void skipForward();
>      void skipBackward();
> +    void download();
>  protected slots:
>      void fullscreen();
>      void snapshot();
> diff --git a/modules/gui/qt4/components/controller.cpp
> b/modules/gui/qt4/components/controller.cpp index 44de18a..6323d2e
> --- a/modules/gui/qt4/components/controller.cpp
> +++ b/modules/gui/qt4/components/controller.cpp
> @@ -308,6 +308,11 @@ QWidget *AbstractController::createWidget(
> buttonType_e button, int options ) NORMAL_BUTTON( FULLWIDTH );
>          }
>          break;
> +    case DOWNLOAD_BUTTON: {
> +        NORMAL_BUTTON( DOWNLOAD );
> +        ENABLE_ON_INPUT( DOWNLOADButton );
> +        }
> +        break;
>      case EXTENDED_BUTTON:{
>          NORMAL_BUTTON( EXTENDED );
>          }
> diff --git a/modules/gui/qt4/components/controller.hpp
> b/modules/gui/qt4/components/controller.hpp index 1df8703..c0e174b
> --- a/modules/gui/qt4/components/controller.hpp
> +++ b/modules/gui/qt4/components/controller.hpp
> @@ -89,6 +89,7 @@ typedef enum buttonType_e
>      NEXT_BUTTON,
>      OPEN_SUB_BUTTON,
>      FULLWIDTH_BUTTON,
> +    DOWNLOAD_BUTTON,
>      BUTTON_MAX,
> 
>      SPLITTER = 0x20,
> @@ -118,7 +119,7 @@ static const char* const nameL[BUTTON_MAX] = {
> N_("Play"), N_("Stop"), N_("Open" N_("Record"), N_("A->B Loop"), N_("Frame
> By Frame"), N_("Trickplay Reverse"), N_("Step backward" ), N_("Step
> forward"), N_("Quit"), N_("Random"), N_("Loop / Repeat"),
> N_("Information"), N_("Previous"), N_("Next"), -    N_("Open subtitles"),
> N_("Dock fullscreen controller")
> +    N_("Open subtitles"), N_("Dock fullscreen controller"), N_("Download")
>  };
>  static const char* const tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
>      N_("Stop playback"), N_("Open a medium"),
> @@ -132,7 +133,8 @@ static const char* const tooltipL[BUTTON_MAX] = {
> I_PLAY_TOOLTIP, N_("Random"), N_("Change the loop and repeat modes"),
> N_("Information"), N_("Previous media in the playlist"), N_("Next media in
> the playlist"), N_("Open subtitles file"),
> -    N_("Dock/undock fullscreen controller to/from bottom of screen")
> +    N_("Dock/undock fullscreen controller to/from bottom of screen"),
> +    N_("Download this file")
>  };
>  static const QString iconL[BUTTON_MAX] ={ ":/toolbar/play_b",
> ":/toolbar/stop_b", ":/toolbar/eject", ":/toolbar/previous_b",
> ":/toolbar/next_b", @@ -142,7 +144,7 @@ static const QString
> iconL[BUTTON_MAX] ={ ":/toolbar/play_b", ":/toolbar/stop_b"
> ":/toolbar/frame", ":/toolbar/reverse", ":/toolbar/skip_back",
> ":/toolbar/skip_fw", ":/toolbar/clear", ":/buttons/playlist/shuffle_on",
> ":/buttons/playlist/repeat_all", ":/menu/info",
> -    ":/toolbar/previous_b", ":/toolbar/next_b", ":/toolbar/eject",
> ":/toolbar/space" +    ":/toolbar/previous_b", ":/toolbar/next_b",
> ":/toolbar/eject", ":/toolbar/space", ":/dropzone" };
> 
>  enum

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list