1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
/*****************************************************************************
* actions_manager.cpp : Controller for the main interface
****************************************************************************
* Copyright © 2009-2014 VideoLAN and VLC authors
* $Id: b7ca9673447036201cd26e85eb1144b756de5ca0 $
*
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* ( at your option ) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "qt4.hpp"
#include <vlc_vout.h>
#include <vlc_keys.h>
#include "actions_manager.hpp"
#include "dialogs_provider.hpp" /* Opening Dialogs */
#include "input_manager.hpp" /* THEMIM */
#include "main_interface.hpp" /* Show playlist */
#include "components/controller.hpp" /* Toggle FSC controller width */
#include "components/extended_panels.hpp"
ActionsManager::ActionsManager( intf_thread_t * _p_i )
{
p_intf = _p_i;
}
void ActionsManager::doAction( int id_action )
{
switch( id_action )
{
case PLAY_ACTION:
play(); break;
case STOP_ACTION:
THEMIM->stop(); break;
case OPEN_ACTION:
THEDP->openDialog(); break;
case PREVIOUS_ACTION:
THEMIM->prev(); break;
case NEXT_ACTION:
THEMIM->next(); break;
case SLOWER_ACTION:
THEMIM->getIM()->slower(); break;
case FASTER_ACTION:
THEMIM->getIM()->faster(); break;
case FULLSCREEN_ACTION:
fullscreen(); break;
case EXTENDED_ACTION:
THEDP->extendedDialog(); break;
case PLAYLIST_ACTION:
playlist(); break;
case SNAPSHOT_ACTION:
snapshot(); break;
case RECORD_ACTION:
record(); break;
case FRAME_ACTION:
frame(); break;
case ATOB_ACTION:
THEMIM->getIM()->setAtoB(); break;
case REVERSE_ACTION:
THEMIM->getIM()->reverse(); break;
case SKIP_BACK_ACTION:
skipBackward();
break;
case SKIP_FW_ACTION:
skipForward();
break;
case QUIT_ACTION:
THEDP->quit(); break;
case RANDOM_ACTION:
THEMIM->toggleRandom(); break;
case INFO_ACTION:
THEDP->mediaInfoDialog(); break;
case OPEN_SUB_ACTION:
THEDP->loadSubtitlesFile(); break;
case FULLWIDTH_ACTION:
if( p_intf->p_sys->p_mi )
p_intf->p_sys->p_mi->getFullscreenControllerWidget()->toggleFullwidth();
break;
default:
msg_Warn( p_intf, "Action not supported: %i", id_action );
break;
}
}
void ActionsManager::play()
{
if( THEPL->current.i_size == 0 && THEPL->items.i_size == 0 )
{
/* The playlist is empty, open a file requester */
THEDP->openFileDialog();
return;
}
THEMIM->togglePlayPause();
}
/**
* TODO
* This functions toggle the fullscreen mode
* If there is no video, it should first activate Visualisations...
* This has also to be fixed in enableVideo()
*/
void ActionsManager::fullscreen()
{
bool fs = var_ToggleBool( THEPL, "fullscreen" );
vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout)
{
var_SetBool( p_vout, "fullscreen", fs );
vlc_object_release( p_vout );
}
}
void ActionsManager::snapshot()
{
vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout )
{
var_TriggerCallback( p_vout, "video-snapshot" );
vlc_object_release( p_vout );
}
}
void ActionsManager::playlist()
{
if( p_intf->p_sys->p_mi )
p_intf->p_sys->p_mi->togglePlaylist();
}
void ActionsManager::record()
{
input_thread_t *p_input = THEMIM->getInput();
if( p_input )
{
/* This method won't work fine if the stream can't be cut anywhere */
var_ToggleBool( p_input, "record" );
#if 0
else
{
/* 'record' access-filter is not loaded, we open Save dialog */
input_item_t *p_item = input_GetItem( p_input );
if( !p_item )
return;
char *psz = input_item_GetURI( p_item );
if( psz )
THEDP->streamingDialog( NULL, qfu(psz), true );
}
#endif
}
}
void ActionsManager::frame()
{
input_thread_t *p_input = THEMIM->getInput();
if( p_input )
var_TriggerCallback( p_input, "frame-next" );
}
void ActionsManager::toggleMuteAudio()
{
playlist_MuteToggle( THEPL );
}
void ActionsManager::AudioUp()
{
playlist_VolumeUp( THEPL, 1, NULL );
}
void ActionsManager::AudioDown()
{
playlist_VolumeDown( THEPL, 1, NULL );
}
void ActionsManager::skipForward()
{
input_thread_t *p_input = THEMIM->getInput();
if( p_input )
THEMIM->getIM()->jumpFwd();
}
void ActionsManager::skipBackward()
{
input_thread_t *p_input = THEMIM->getInput();
if( p_input )
THEMIM->getIM()->jumpBwd();
}
void ActionsManager::PPaction( QAction *a )
{
int i_q = -1;
if( a != NULL )
i_q = a->data().toInt();
ExtVideo::setPostprocessing( p_intf, i_q );
}
|