actions_manager.cpp
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:5k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * Controller.cpp : Controller for the main interface
  3.  ****************************************************************************
  4.  * Copyright (C) 2006-2008 the VideoLAN team
  5.  * $Id: ed5cd71cd8eafde3c6e5dd24f520fe871d073aae $
  6.  *
  7.  * Authors: Jean-Baptiste Kempf <jb@videolan.org>
  8.  *          Ilkka Ollakka <ileoo@videolan.org>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * ( at your option ) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23.  *****************************************************************************/
  24. #ifdef HAVE_CONFIG_H
  25. # include "config.h"
  26. #endif
  27. #include <vlc_vout.h>
  28. #include <vlc_aout.h>
  29. #include <vlc_keys.h>
  30. #include "actions_manager.hpp"
  31. #include "dialogs_provider.hpp" /* Opening Dialogs */
  32. #include "input_manager.hpp"
  33. #include "main_interface.hpp" /* Show playlist */
  34. ActionsManager * ActionsManager::instance = NULL;
  35. ActionsManager::ActionsManager( intf_thread_t * _p_i, QObject *_parent )
  36.                : QObject( _parent )
  37. {
  38.     p_intf = _p_i;
  39. }
  40. ActionsManager::~ActionsManager(){}
  41. void ActionsManager::doAction( int id_action )
  42. {
  43.     switch( id_action )
  44.     {
  45.         case PLAY_ACTION:
  46.             play(); break;
  47.         case STOP_ACTION:
  48.             THEMIM->stop(); break;
  49.         case OPEN_ACTION:
  50.             THEDP->openDialog(); break;
  51.         case PREVIOUS_ACTION:
  52.             THEMIM->prev(); break;
  53.         case NEXT_ACTION:
  54.             THEMIM->next(); break;
  55.         case SLOWER_ACTION:
  56.             THEMIM->getIM()->slower(); break;
  57.         case FASTER_ACTION:
  58.             THEMIM->getIM()->faster(); break;
  59.         case FULLSCREEN_ACTION:
  60.             fullscreen(); break;
  61.         case EXTENDED_ACTION:
  62.             THEDP->extendedDialog(); break;
  63.         case PLAYLIST_ACTION:
  64.             playlist(); break;
  65.         case SNAPSHOT_ACTION:
  66.             snapshot(); break;
  67.         case RECORD_ACTION:
  68.             record(); break;
  69.         case FRAME_ACTION:
  70.             frame(); break;
  71.         case ATOB_ACTION:
  72.             THEMIM->getIM()->setAtoB(); break;
  73.         case REVERSE_ACTION:
  74.             THEMIM->getIM()->reverse(); break;
  75.         case SKIP_BACK_ACTION:
  76.             var_SetInteger( p_intf->p_libvlc, "key-action",
  77.                     ACTIONID_JUMP_BACKWARD_SHORT );
  78.             break;
  79.         case SKIP_FW_ACTION:
  80.             var_SetInteger( p_intf->p_libvlc, "key-action",
  81.                     ACTIONID_JUMP_FORWARD_SHORT );
  82.             break;
  83.         case QUIT_ACTION:
  84.             THEDP->quit();  break;
  85.         default:
  86.             msg_Dbg( p_intf, "Action: %i", id_action );
  87.             break;
  88.     }
  89. }
  90. void ActionsManager::play()
  91. {
  92.     if( THEPL->current.i_size == 0 )
  93.     {
  94.         /* The playlist is empty, open a file requester */
  95.         THEDP->openFileDialog();
  96.         return;
  97.     }
  98.     THEMIM->togglePlayPause();
  99. }
  100. /**
  101.   * TODO
  102.  * This functions toggle the fullscreen mode
  103.  * If there is no video, it should first activate Visualisations...
  104.  *  This has also to be fixed in enableVideo()
  105.  */
  106. void ActionsManager::fullscreen()
  107. {
  108.     vout_thread_t *p_vout = THEMIM->getVout();
  109.     if( p_vout)
  110.     {
  111.         var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
  112.         vlc_object_release( p_vout );
  113.     }
  114. }
  115. void ActionsManager::snapshot()
  116. {
  117.     vout_thread_t *p_vout = THEMIM->getVout();
  118.     if( p_vout )
  119.     {
  120.         var_TriggerCallback( p_vout, "video-snapshot" );
  121.         vlc_object_release( p_vout );
  122.     }
  123. }
  124. void ActionsManager::playlist()
  125. {
  126.     if( p_intf->p_sys->p_mi ) p_intf->p_sys->p_mi->togglePlaylist();
  127. }
  128. void ActionsManager::record()
  129. {
  130.     input_thread_t *p_input = THEMIM->getInput();
  131.     if( p_input )
  132.     {
  133.         /* This method won't work fine if the stream can't be cut anywhere */
  134.         const bool b_recording = var_GetBool( p_input, "record" );
  135.         var_SetBool( p_input, "record", !b_recording );
  136. #if 0
  137.         else
  138.         {
  139.             /* 'record' access-filter is not loaded, we open Save dialog */
  140.             input_item_t *p_item = input_GetItem( p_input );
  141.             if( !p_item )
  142.                 return;
  143.             char *psz = input_item_GetURI( p_item );
  144.             if( psz )
  145.                 THEDP->streamingDialog( NULL, psz, true );
  146.         }
  147. #endif
  148.     }
  149. }
  150. void ActionsManager::frame()
  151. {
  152.     input_thread_t *p_input = THEMIM->getInput();
  153.     if( p_input )
  154.         var_SetVoid( p_input, "frame-next" );
  155. }
  156. void ActionsManager::toggleMuteAudio()
  157. {
  158.      aout_VolumeMute( p_intf, NULL );
  159. }
  160. void ActionsManager::AudioUp()
  161. {
  162.     aout_VolumeUp( p_intf, 1, NULL );
  163. }
  164. void ActionsManager::AudioDown()
  165. {
  166.     aout_VolumeDown( p_intf, 1, NULL );
  167. }