]> git.sesse.net Git - vlc/blob - modules/gui/qt4/actions_manager.cpp
Qt: Create a getVout() in MIM to remove some vlc_object_find( p_intf, VLC_OBJECT_VOUT...
[vlc] / modules / gui / qt4 / actions_manager.cpp
1 /*****************************************************************************
2  * Controller.cpp : Controller for the main interface
3  ****************************************************************************
4  * Copyright (C) 2006-2008 the VideoLAN team
5  * $Id$
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
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <vlc_vout.h>
30 #include <vlc_keys.h>
31
32 #include "actions_manager.hpp"
33 #include "dialogs_provider.hpp" /* Opening Dialogs */
34 #include "input_manager.hpp"
35 #include "main_interface.hpp" /* Show playlist */
36
37 ActionsManager * ActionsManager::instance = NULL;
38
39 ActionsManager::ActionsManager( intf_thread_t * _p_i, QObject *_parent )
40                : QObject( _parent )
41 {
42     p_intf = _p_i;
43 }
44
45 ActionsManager::~ActionsManager(){}
46
47 void ActionsManager::doAction( int id_action )
48 {
49     switch( id_action )
50     {
51         case PLAY_ACTION:
52             play(); break;
53         case STOP_ACTION:
54             THEMIM->stop(); break;
55         case OPEN_ACTION:
56             break;
57         case PREVIOUS_ACTION:
58             THEMIM->prev(); break;
59         case NEXT_ACTION:
60             THEMIM->next(); break;
61         case SLOWER_ACTION:
62             THEMIM->getIM()->slower(); break;
63         case FASTER_ACTION:
64             THEMIM->getIM()->faster(); break;
65         case FULLSCREEN_ACTION:
66             fullscreen(); break;
67         case EXTENDED_ACTION:
68             THEDP->extendedDialog(); break;
69         case PLAYLIST_ACTION:
70             playlist(); break;
71         case SNAPSHOT_ACTION:
72             snapshot(); break;
73         case RECORD_ACTION:
74             record(); break;
75         case FRAME_ACTION:
76             frame(); break;
77         case ATOB_ACTION:
78             THEMIM->getIM()->setAtoB(); break;
79         case REVERSE_ACTION:
80             THEMIM->getIM()->reverse(); break;
81         case SKIP_BACK_ACTION:
82             var_SetInteger( p_intf->p_libvlc, "key-pressed",
83                     ACTIONID_JUMP_BACKWARD_SHORT );
84             break;
85         case SKIP_FW_ACTION:
86             var_SetInteger( p_intf->p_libvlc, "key-pressed",
87                     ACTIONID_JUMP_FORWARD_SHORT );
88             break;
89         default:
90             msg_Dbg( p_intf, "Action: %i", id_action );
91             break;
92     }
93 }
94
95 void ActionsManager::play()
96 {
97     if( THEPL->current.i_size == 0 )
98     {
99         /* The playlist is empty, open a file requester */
100         THEDP->openFileDialog();
101         return;
102     }
103     THEMIM->togglePlayPause();
104 }
105
106 /**
107   * TODO
108  * This functions toggle the fullscreen mode
109  * If there is no video, it should first activate Visualisations...
110  *  This has also to be fixed in enableVideo()
111  */
112 void ActionsManager::fullscreen()
113 {
114     vout_thread_t *p_vout = THEMIM->getVout();
115     if( p_vout)
116     {
117         var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
118         vlc_object_release( p_vout );
119     }
120 }
121
122 void ActionsManager::snapshot()
123 {
124     vout_thread_t *p_vout = THEMIM->getVout();
125     if( p_vout )
126     {
127         vout_Control( p_vout, VOUT_SNAPSHOT );
128         vlc_object_release( p_vout );
129     }
130 }
131
132 void ActionsManager::playlist()
133 {
134     if( p_intf->p_sys->p_mi ) p_intf->p_sys->p_mi->togglePlaylist();
135 }
136
137 void ActionsManager::record()
138 {
139     input_thread_t *p_input = THEMIM->getInput();
140     if( p_input )
141     {
142         /* This method won't work fine if the stream can't be cut anywhere */
143         const bool b_recording = var_GetBool( p_input, "record" );
144         var_SetBool( p_input, "record", !b_recording );
145 #if 0
146         else
147         {
148             /* 'record' access-filter is not loaded, we open Save dialog */
149             input_item_t *p_item = input_GetItem( p_input );
150             if( !p_item )
151                 return;
152
153             char *psz = input_item_GetURI( p_item );
154             if( psz )
155                 THEDP->streamingDialog( NULL, psz, true );
156         }
157 #endif
158     }
159 }
160
161 void ActionsManager::frame()
162 {
163     input_thread_t *p_input = THEMIM->getInput();
164     if( p_input )
165         var_SetVoid( p_input, "frame-next" );
166 }
167
168