Commit f011c163 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4: separation between widgets/buttons creation and action

parent 2f7f4a74
......@@ -17,6 +17,7 @@ nodist_SOURCES_qt4 = \
menus.moc.cpp \
dialogs_provider.moc.cpp \
input_manager.moc.cpp \
actions_manager.moc.cpp \
recents.moc.cpp \
dialogs/playlist.moc.cpp \
dialogs/bookmarks.moc.cpp \
......@@ -182,6 +183,7 @@ SOURCES_qt4 = qt4.cpp \
main_interface.cpp \
dialogs_provider.cpp \
input_manager.cpp \
actions_manager.cpp \
recents.cpp \
dialogs/playlist.cpp \
dialogs/bookmarks.cpp \
......@@ -223,6 +225,7 @@ noinst_HEADERS = \
main_interface.hpp \
dialogs_provider.hpp \
input_manager.hpp \
actions_manager.hpp \
recents.hpp \
dialogs/playlist.hpp \
dialogs/bookmarks.hpp \
......
/*****************************************************************************
* Controller.cpp : Controller for the main interface
****************************************************************************
* Copyright (C) 2006-2008 the VideoLAN team
* $Id$
*
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
* Ilkka Ollakka <ileoo@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 <vlc_vout.h>
#include <vlc_keys.h>
#include "actions_manager.hpp"
#include "dialogs_provider.hpp" /* Opening Dialogs */
#include "input_manager.hpp"
#include "main_interface.hpp" /* Show playlist */
ActionsManager * ActionsManager::instance = NULL;
ActionsManager::ActionsManager( intf_thread_t * _p_i, QObject *_parent )
: QObject( _parent )
{
p_intf = _p_i;
}
ActionsManager::~ActionsManager()
{
}
//* Actions */
void ActionsManager::doAction( int id_action )
{
switch( id_action )
{
case PLAY_ACTION:
play(); break;
case PREVIOUS_ACTION:
prev(); break;
case NEXT_ACTION:
next(); break;
case STOP_ACTION:
stop(); break;
case SLOWER_ACTION:
slower(); break;
case FASTER_ACTION:
faster(); break;
case FULLSCREEN_ACTION:
fullscreen(); break;
case EXTENDED_ACTION:
extSettings(); break;
case PLAYLIST_ACTION:
playlist(); break;
case SNAPSHOT_ACTION:
snapshot(); break;
case RECORD_ACTION:
record(); break;
case ATOB_ACTION:
THEMIM->getIM()->setAtoB(); break;
case FRAME_ACTION:
frame(); break;
case REVERSE_ACTION:
reverse(); break;
case SKIP_BACK_ACTION:
var_SetInteger( p_intf->p_libvlc, "key-pressed",
ACTIONID_JUMP_BACKWARD_SHORT );
break;
case SKIP_FW_ACTION:
var_SetInteger( p_intf->p_libvlc, "key-pressed",
ACTIONID_JUMP_FORWARD_SHORT );
break;
default:
msg_Dbg( p_intf, "Action: %i", id_action );
break;
}
}
void ActionsManager::stop()
{
THEMIM->stop();
}
void ActionsManager::play()
{
if( THEPL->current.i_size == 0 )
{
/* The playlist is empty, open a file requester */
THEDP->openFileDialog();
return;
}
THEMIM->togglePlayPause();
}
void ActionsManager::prev()
{
THEMIM->prev();
}
void ActionsManager::next()
{
THEMIM->next();
}
/**
* 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()
{
vout_thread_t *p_vout =
(vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout)
{
var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
vlc_object_release( p_vout );
}
}
void ActionsManager::snapshot()
{
vout_thread_t *p_vout =
(vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout )
{
vout_Control( p_vout, VOUT_SNAPSHOT );
vlc_object_release( p_vout );
}
}
void ActionsManager::extSettings()
{
THEDP->extendedDialog();
}
void ActionsManager::reverse()
{
THEMIM->getIM()->reverse();
}
void ActionsManager::slower()
{
THEMIM->getIM()->slower();
}
void ActionsManager::faster()
{
THEMIM->getIM()->faster();
}
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 */
const bool b_recording = var_GetBool( p_input, "record" );
var_SetBool( p_input, "record", !b_recording );
#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, psz, true );
}
#endif
}
}
void ActionsManager::frame()
{
input_thread_t *p_input = THEMIM->getInput();
if( p_input )
var_SetVoid( p_input, "frame-next" );
}
/*****************************************************************************
* Controller.hpp : Controller for the main interface
****************************************************************************
* Copyright (C) 2006-2008 the VideoLAN team
* $Id$
*
* 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.
*****************************************************************************/
#ifndef _ACTIONS_MANAGER_H_
#define _ACTIONS_MANAGER_H_
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "qt4.hpp"
#include <QObject>
typedef enum actionType_e
{
PLAY_ACTION,
STOP_ACTION,
OPEN_ACTION,
PREVIOUS_ACTION,
NEXT_ACTION,
SLOWER_ACTION,
FASTER_ACTION,
FULLSCREEN_ACTION,
EXTENDED_ACTION,
PLAYLIST_ACTION,
SNAPSHOT_ACTION,
RECORD_ACTION,
FRAME_ACTION,
ATOB_ACTION,
REVERSE_ACTION,
SKIP_BACK_ACTION,
SKIP_FW_ACTION,
} actionType_e;
class ActionsManager : public QObject
{
Q_OBJECT
public:
static ActionsManager *getInstance( intf_thread_t *_p_intf )
{
if( !instance )
instance = new ActionsManager( _p_intf );
return instance;
}
static void killInstance()
{
if( instance ) delete instance;
}
virtual ~ActionsManager();
private:
static ActionsManager *instance;
ActionsManager( intf_thread_t *_p_i, QObject *_parent = 0 );
intf_thread_t *p_intf;
protected slots:
virtual void doAction( int );
protected slots:
void play();
void stop();
void prev();
void next();
void fullscreen();
void extSettings();
void faster();
void slower();
void reverse();
void playlist();
void snapshot();
void record();
void frame();
};
#endif
......@@ -35,6 +35,7 @@
#include "dialogs_provider.hpp" /* Opening Dialogs */
#include "input_manager.hpp"
#include "actions_manager.hpp"
#include "util/input_slider.hpp" /* InputSlider */
#include "util/customwidgets.hpp" /* qEventToKey */
......@@ -62,7 +63,8 @@ AbstractController::AbstractController( intf_thread_t * _p_i, QWidget *_parent )
/* Main action provider */
toolbarActionsMapper = new QSignalMapper( this );
CONNECT( toolbarActionsMapper, mapped( int ), this, doAction( int ) );
CONNECT( toolbarActionsMapper, mapped( int ),
ActionsManager::getInstance( p_intf ), doAction( int ) );
CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
}
......@@ -527,163 +529,6 @@ QFrame *AbstractController::telexFrame()
#undef ENABLE_ON_VIDEO
#undef ENABLE_ON_INPUT
//* Actions */
void AbstractController::doAction( int id_action )
{
switch( id_action )
{
case PLAY_ACTION:
play(); break;
case PREVIOUS_ACTION:
prev(); break;
case NEXT_ACTION:
next(); break;
case STOP_ACTION:
stop(); break;
case SLOWER_ACTION:
slower(); break;
case FASTER_ACTION:
faster(); break;
case FULLSCREEN_ACTION:
fullscreen(); break;
case EXTENDED_ACTION:
extSettings(); break;
case PLAYLIST_ACTION:
playlist(); break;
case SNAPSHOT_ACTION:
snapshot(); break;
case RECORD_ACTION:
record(); break;
case ATOB_ACTION:
THEMIM->getIM()->setAtoB(); break;
case FRAME_ACTION:
frame(); break;
case REVERSE_ACTION:
reverse(); break;
case SKIP_BACK_ACTION:
var_SetInteger( p_intf->p_libvlc, "key-pressed",
ACTIONID_JUMP_BACKWARD_SHORT );
break;
case SKIP_FW_ACTION:
var_SetInteger( p_intf->p_libvlc, "key-pressed",
ACTIONID_JUMP_FORWARD_SHORT );
break;
default:
msg_Dbg( p_intf, "Action: %i", id_action );
break;
}
}
void AbstractController::stop()
{
THEMIM->stop();
}
void AbstractController::play()
{
if( THEPL->current.i_size == 0 )
{
/* The playlist is empty, open a file requester */
THEDP->openFileDialog();
return;
}
THEMIM->togglePlayPause();
}
void AbstractController::prev()
{
THEMIM->prev();
}
void AbstractController::next()
{
THEMIM->next();
}
/**
* 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 AbstractController::fullscreen()
{
vout_thread_t *p_vout =
(vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout)
{
var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
vlc_object_release( p_vout );
}
}
void AbstractController::snapshot()
{
vout_thread_t *p_vout =
(vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout )
{
vout_Control( p_vout, VOUT_SNAPSHOT );
vlc_object_release( p_vout );
}
}
void AbstractController::extSettings()
{
THEDP->extendedDialog();
}
void AbstractController::reverse()
{
THEMIM->getIM()->reverse();
}
void AbstractController::slower()
{
THEMIM->getIM()->slower();
}
void AbstractController::faster()
{
THEMIM->getIM()->faster();
}
void AbstractController::playlist()
{
if( p_intf->p_sys->p_mi ) p_intf->p_sys->p_mi->togglePlaylist();
}
void AbstractController::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 */
const bool b_recording = var_GetBool( p_input, "record" );
var_SetBool( p_input, "record", !b_recording );
#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, psz, true );
}
#endif
}
}
void AbstractController::frame()
{
input_thread_t *p_input = THEMIM->getInput();
if( p_input )
var_SetVoid( p_input, "frame-next" );
}
#include <QHBoxLayout>
/*****************************
* DA Control Widget !
......
......@@ -113,27 +113,6 @@ static const QString iconL[BUTTON_MAX] ={ ":/play_b", ":/stop_b", ":/eject",
":/defullscreen", ":/extended", ":/playlist", ":/snapshot", ":/record",
":/atob_nob", ":/frame", ":/reverse", ":/skip_back", ":/skip_fw" };
typedef enum actionType_e
{
PLAY_ACTION,
STOP_ACTION,
OPEN_ACTION,
PREVIOUS_ACTION,
NEXT_ACTION,
SLOWER_ACTION,
FASTER_ACTION,
FULLSCREEN_ACTION,
EXTENDED_ACTION,
PLAYLIST_ACTION,
SNAPSHOT_ACTION,
RECORD_ACTION,
FRAME_ACTION,
ATOB_ACTION,
REVERSE_ACTION,
SKIP_BACK_ACTION,
SKIP_FW_ACTION,
} actionType_e;
enum
{
WIDGET_NORMAL = 0x0,
......@@ -172,23 +151,6 @@ private:
QFrame *telexFrame();
protected slots:
virtual void doAction( int );
protected slots:
void play();
void stop();
void prev();
void next();
void fullscreen();
void extSettings();
void faster();
void slower();
void reverse();
void playlist();
void snapshot();
void record();
void frame();
virtual void setStatus( int );
signals:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment