#include <QSignalMapper>
#include <QTimer>
-#define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a media")
-
/**********************************************************************
* TEH controls
**********************************************************************/
/******
- * This is an abstract Toolbar/Controller
- * This has helper to create any toolbar, any buttons and to manage the actions
- *
- *****/
+ * This is an abstract Toolbar/Controller
+ * This has helper to create any toolbar, any buttons and to manage the actions
+ *
+ *****/
AbstractController::AbstractController( intf_thread_t * _p_i ) : QFrame( NULL )
{
p_intf = _p_i;
-
- /* We need one layout. An controller without layout is stupid with
- current architecture */
- controlLayout = new QGridLayout( this );
+ advControls = NULL;
/* Main action provider */
toolbarActionsMapper = new QSignalMapper( this );
- CONNECT( toolbarActionsMapper, mapped( int ),
- this, doAction( int ) );
+ CONNECT( toolbarActionsMapper, mapped( int ), this, doAction( int ) );
CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
}
/* Open the generic config line for the toolbar, parse it
* and create the widgets accordingly */
-void AbstractController::parseAndCreateLine( QString config, int i_line )
+void AbstractController::parseAndCreate( QString config,
+ QBoxLayout *controlLayout )
{
- int i_column = 0;
QStringList list = config.split( ";" ) ;
for( int i = 0; i < list.size(); i++ )
{
- QStringList list2 = list.at( i ).split( "-" );
- if( list2.size() < 1 )
- {
- msg_Warn( p_intf, "Parsing error. Report this" );
- continue;
- }
-
- bool ok;
- int i_option = WIDGET_NORMAL;
- buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok );
- if( !ok )
- {
- msg_Warn( p_intf, "Parsing error 0. Please report this" );
- continue;
- }
- /* Special case for SPACERS, who aren't QWidgets */
- if( i_type == WIDGET_SPACER || i_type == WIDGET_SPACER_EXTEND )
- {
- controlLayout->setColumnMinimumWidth( i, 10 );
- i_column++;
- controlLayout->setColumnStretch( i,
- ( i_type == WIDGET_SPACER ) ? 0 : 10 );
- continue;
- }
+ QStringList list2 = list.at( i ).split( "-" );
+ if( list2.size() < 1 )
+ {
+ msg_Warn( p_intf, "Parsing error. Report this" );
+ continue;
+ }
- if( list2.size() > 1 )
- {
- i_option = list2.at( 1 ).toInt( &ok );
- if( !ok )
- {
- msg_Warn( p_intf, "Parsing error 1. Please report this" );
- continue;
- }
- }
+ bool ok;
+ int i_option = WIDGET_NORMAL;
+ buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok );
+ if( !ok )
+ {
+ msg_Warn( p_intf, "Parsing error 0. Please report this" );
+ continue;
+ }
- int i_size;
- QWidget *widg = createWidget( i_type, &i_size, i_option );
- if( !widg ) continue;
+ if( list2.size() > 1 )
+ {
+ i_option = list2.at( 1 ).toInt( &ok );
+ if( !ok )
+ {
+ msg_Warn( p_intf, "Parsing error 1. Please report this" );
+ continue;
+ }
+ }
- if( list2.size() > 2 )
- {
- i_size = list.at( 2 ).toInt( &ok );
+ createAndAddWidget( controlLayout, -1, i_type, i_option );
+ }
+}
- if( !ok )
- {
- msg_Warn( p_intf, "Parsing error 2. Please report this" );
- continue;
- }
- }
+void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
+ int i_index,
+ buttonType_e i_type,
+ int i_option )
+{
+ /* Special case for SPACERS, who aren't QWidgets */
+ if( i_type == WIDGET_SPACER )
+ {
+ controlLayout->insertSpacing( i_index, 16 );
+ return;
+ }
- controlLayout->addWidget( widg, i_line, i_column, 1, i_size );
- i_column += i_size;
+ if( i_type == WIDGET_SPACER_EXTEND )
+ {
+ controlLayout->insertSpacing( i_index, 10 );
+ return;
}
+
+ QWidget *widg = createWidget( i_type, i_option );
+ if( !widg ) return;
+
+ controlLayout->insertWidget( i_index, widg );
}
+
#define CONNECT_MAP( a ) CONNECT( a, clicked(), toolbarActionsMapper, map() )
#define SET_MAPPING( a, b ) toolbarActionsMapper->setMapping( a , b )
#define CONNECT_MAP_SET( a, b ) \
CONNECT_MAP( a ); \
SET_MAPPING( a, b );
-#define BUTTON_SET_BAR( button, image, tooltip ) \
+#define BUTTON_SET_BAR( a_button ) \
+ a_button->setToolTip( tooltipL[button] ); \
+ a_button->setIcon( QIcon( iconL[button] ) );
+#define BUTTON_SET_BAR2( button, image, tooltip ) \
button->setToolTip( tooltip ); \
button->setIcon( QIcon( ":/"#image ) );
+
#define ENABLE_ON_VIDEO( a ) \
CONNECT( THEMIM->getIM(), voutChanged( bool ), a, setEnabled( bool ) ); \
a->setEnabled( THEMIM->getIM()->hasVideo() ); /* TODO: is this necessary? when input is started before the interface? */
CONNECT( this, inputExists( bool ), a, setEnabled( bool ) ); \
a->setEnabled( THEMIM->getIM()->hasInput() ); /* TODO: is this necessary? when input is started before the interface? */
-QWidget *AbstractController::createWidget( buttonType_e button, int* i_size,
- int options )
+QWidget *AbstractController::createWidget( buttonType_e button, int options )
{
- assert( i_size );
bool b_flat = options & WIDGET_FLAT;
bool b_big = options & WIDGET_BIG;
bool b_shiny = options & WIDGET_SHINY;
- *i_size = 1;
QWidget *widget = NULL;
switch( button )
case PLAY_BUTTON: {
PlayButton *playButton = new PlayButton;
setupButton( playButton );
- BUTTON_SET_BAR( playButton, play_b, qtr( I_PLAY_TOOLTIP ) );
+ BUTTON_SET_BAR( playButton );
CONNECT_MAP_SET( playButton, PLAY_ACTION );
CONNECT( this, inputPlaying( bool ),
playButton, updateButton( bool ));
QToolButton *stopButton = new QToolButton;
setupButton( stopButton );
CONNECT_MAP_SET( stopButton, STOP_ACTION );
- BUTTON_SET_BAR( stopButton, stop_b, qtr( "Stop playback" ) );
+ BUTTON_SET_BAR( stopButton );
widget = stopButton;
}
break;
QToolButton *prevButton = new QToolButton;
setupButton( prevButton );
CONNECT_MAP_SET( prevButton, PREVIOUS_ACTION );
- BUTTON_SET_BAR( prevButton, previous_b,
- qtr( "Previous media in the playlist" ) );
+ BUTTON_SET_BAR( prevButton );
widget = prevButton;
}
break;
QToolButton *nextButton = new QToolButton;
setupButton( nextButton );
CONNECT_MAP_SET( nextButton, NEXT_ACTION );
- BUTTON_SET_BAR( nextButton, next_b,
- qtr( "Next media in the playlist" ) );
+ BUTTON_SET_BAR( nextButton );
widget = nextButton;
}
break;
QToolButton *slowerButton = new QToolButton;
setupButton( slowerButton );
CONNECT_MAP_SET( slowerButton, SLOWER_ACTION );
- BUTTON_SET_BAR( slowerButton, slower, qtr( "Slower" ) );
+ BUTTON_SET_BAR( slowerButton );
ENABLE_ON_INPUT( slowerButton );
widget = slowerButton;
}
QToolButton *fasterButton = new QToolButton;
setupButton( fasterButton );
CONNECT_MAP_SET( fasterButton, FASTER_ACTION );
- BUTTON_SET_BAR( fasterButton, faster, qtr( "Faster" ) );
+ BUTTON_SET_BAR( fasterButton );
ENABLE_ON_INPUT( fasterButton );
widget = fasterButton;
}
QToolButton *frameButton = new QToolButton;
setupButton( frameButton );
CONNECT_MAP_SET( frameButton, FRAME_ACTION );
- BUTTON_SET_BAR( frameButton, frame, qtr( "Frame by frame" ) );
+ BUTTON_SET_BAR( frameButton );
ENABLE_ON_VIDEO( frameButton );
widget = frameButton;
}
QToolButton *fullscreenButton = new QToolButton;
setupButton( fullscreenButton );
CONNECT_MAP_SET( fullscreenButton, FULLSCREEN_ACTION );
- BUTTON_SET_BAR( fullscreenButton, fullscreen,
- qtr( "Toggle the video in fullscreen" ) );
+ BUTTON_SET_BAR( fullscreenButton );
ENABLE_ON_VIDEO( fullscreenButton );
widget = fullscreenButton;
}
QToolButton *fullscreenButton = new QToolButton;
setupButton( fullscreenButton );
CONNECT_MAP_SET( fullscreenButton, FULLSCREEN_ACTION );
- BUTTON_SET_BAR( fullscreenButton, defullscreen,
- qtr( "Toggle the video in fullscreen" ) );
+ BUTTON_SET_BAR( fullscreenButton )
ENABLE_ON_VIDEO( fullscreenButton );
widget = fullscreenButton;
}
QToolButton *extSettingsButton = new QToolButton;
setupButton( extSettingsButton );
CONNECT_MAP_SET( extSettingsButton, EXTENDED_ACTION );
- BUTTON_SET_BAR( extSettingsButton, extended,
- qtr( "Show extended settings" ) );
+ BUTTON_SET_BAR( extSettingsButton )
widget = extSettingsButton;
}
break;
QToolButton *playlistButton = new QToolButton;
setupButton( playlistButton );
CONNECT_MAP_SET( playlistButton, PLAYLIST_ACTION );
- BUTTON_SET_BAR( playlistButton, playlist,
- qtr( "Show playlist" ) );
+ BUTTON_SET_BAR( playlistButton );
widget = playlistButton;
}
break;
QToolButton *snapshotButton = new QToolButton;
setupButton( snapshotButton );
CONNECT_MAP_SET( snapshotButton, SNAPSHOT_ACTION );
- BUTTON_SET_BAR( snapshotButton, snapshot, qtr( "Take a snapshot" ) );
+ BUTTON_SET_BAR( snapshotButton );
ENABLE_ON_VIDEO( snapshotButton );
widget = snapshotButton;
}
QToolButton *recordButton = new QToolButton;
setupButton( recordButton );
CONNECT_MAP_SET( recordButton, RECORD_ACTION );
- BUTTON_SET_BAR( recordButton, record, qtr( "Record" ) );
+ BUTTON_SET_BAR( recordButton );
ENABLE_ON_INPUT( recordButton );
widget = recordButton;
}
case ATOB_BUTTON: {
AtoB_Button *ABButton = new AtoB_Button;
setupButton( ABButton );
- BUTTON_SET_BAR( ABButton, atob_nob, qtr( "Loop from point A to point "
- "B continuously.\nClick to set point A" ) );
+ BUTTON_SET_BAR( ABButton );
ENABLE_ON_INPUT( ABButton );
CONNECT_MAP_SET( ABButton, ATOB_ACTION );
CONNECT( THEMIM->getIM(), AtoBchanged( bool, bool),
break;
case INPUT_SLIDER: {
InputSlider *slider = new InputSlider( Qt::Horizontal, NULL );
+
/* Update the position when the IM has changed */
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
slider, setPosition( float, int, int ) );
/* And update the IM, when the position has changed */
CONNECT( slider, sliderDragged( float ),
- THEMIM->getIM(), sliderUpdate( float ) );
- /* *i_size = -1; */
+ THEMIM->getIM(), sliderUpdate( float ) );
widget = slider;
}
break;
case MENU_BUTTONS:
widget = discFrame();
- widget->hide();
- *i_size = 3;
+// widget->hide();
break;
case TELETEXT_BUTTONS:
widget = telexFrame();
- widget->hide();
- *i_size = 4;
+// widget->hide();
break;
case VOLUME:
{
- SoundWidget *snd = new SoundWidget( p_intf, b_shiny );
+ SoundWidget *snd = new SoundWidget( this, p_intf, b_shiny );
widget = snd;
- *i_size = 4;
}
break;
case TIME_LABEL:
{
advControls = new AdvControlsWidget( p_intf );
widget = advControls;
- *i_size = advControls->getWidth();
}
break;
case REVERSE_BUTTON:{
QToolButton *reverseButton = new QToolButton;
setupButton( reverseButton );
CONNECT_MAP_SET( reverseButton, REVERSE_ACTION );
- BUTTON_SET_BAR( reverseButton, reverse, qtr( "Reverse" ) );
+ BUTTON_SET_BAR( reverseButton );
ENABLE_ON_INPUT( reverseButton );
widget = reverseButton;
}
{
tmpButton->setFixedSize( QSize( 32, 32 ) );
tmpButton->setIconSize( QSize( 26, 26 ) );
- *i_size = 2;
}
}
}
QToolButton *prevSectionButton = new QToolButton( discFrame );
setupButton( prevSectionButton );
- BUTTON_SET_BAR( prevSectionButton, dvd_prev,
+ BUTTON_SET_BAR2( prevSectionButton, dvd_prev,
qtr("Previous Chapter/Title" ) );
discLayout->addWidget( prevSectionButton );
QToolButton *menuButton = new QToolButton( discFrame );
setupButton( menuButton );
discLayout->addWidget( menuButton );
- BUTTON_SET_BAR( menuButton, dvd_menu, qtr( "Menu" ) );
+ BUTTON_SET_BAR2( menuButton, dvd_menu, qtr( "Menu" ) );
QToolButton *nextSectionButton = new QToolButton( discFrame );
setupButton( nextSectionButton );
discLayout->addWidget( nextSectionButton );
- BUTTON_SET_BAR( nextSectionButton, dvd_next,
+ BUTTON_SET_BAR2( nextSectionButton, dvd_next,
qtr("Next Chapter/Title" ) );
-
/* Change the navigation button display when the IM
navigation changes */
CONNECT( THEMIM->getIM(), titleChanged( bool ),
QToolButton *telexOn = new QToolButton;
telexFrame->telexOn = telexOn;
setupButton( telexOn );
- BUTTON_SET_BAR( telexOn, tv, qtr( "Teletext Activation" ) );
+ BUTTON_SET_BAR2( telexOn, tv, qtr( "Teletext Activation" ) );
telexLayout->addWidget( telexOn );
/* Teletext Activation and set */
QToolButton *telexTransparent = new QToolButton;
telexFrame->telexTransparent = telexTransparent;
setupButton( telexTransparent );
- BUTTON_SET_BAR( telexTransparent, tvtelx,
- qtr( "Toggle Transparency " ) );
+ BUTTON_SET_BAR2( telexTransparent, tvtelx,
+ qtr( "Toggle Transparency " ) );
telexTransparent->setEnabled( false );
telexLayout->addWidget( telexTransparent );
#undef ENABLE_ON_VIDEO
#undef ENABLE_ON_INPUT
-SoundWidget::SoundWidget( intf_thread_t * _p_intf, bool b_shiny )
- : b_my_volume( false )
+SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
+ bool b_shiny )
+ : b_my_volume( false ), QWidget( _parent )
{
p_intf = _p_intf;
QHBoxLayout *layout = new QHBoxLayout( this );
if( p_input )
var_SetVoid( p_input, "frame-next" );
}
-
+#include <QHBoxLayout>
/*****************************
* DA Control Widget !
*****************************/
/* advanced Controls handling */
b_advancedVisible = b_advControls;
- advControls = NULL;
- controlLayout->setSpacing( 0 );
+ QVBoxLayout *controlLayout = new QVBoxLayout( this );
controlLayout->setLayoutMargins( 6, 4, 6, 2, 5 );
+ controlLayout->setSpacing( 0 );
+ QHBoxLayout *controlLayout1 = new QHBoxLayout;
+ controlLayout1->setSpacing( 0 );
- QString line1 = getSettings()->value( "MainWindow/Controls2",
+ QString line1 = getSettings()->value( "MainWindow/Controls1",
"18;19;25" ).toString();
- parseAndCreateLine( line1, 0 );
+ parseAndCreate( line1, controlLayout1 );
/* QString line2 = QString( "%1-2;%2;%3;%4;%5;%6;%6;%7;%8;%9;%6;%10;%11-4")
.arg( PLAY_BUTTON ) .arg( WIDGET_SPACER )
.arg( EXTENDED_BUTTON ) .arg( WIDGET_SPACER_EXTEND )
.arg( VOLUME ); */
+ QHBoxLayout *controlLayout2 = new QHBoxLayout;
+ controlLayout2->setSpacing( 0 );
QString line2 = getSettings()->value( "MainWindow/Controls2",
- "0-2;21;21;4;2;5;21;21;8;11;10;21;22;20-4" ).toString();
- parseAndCreateLine( line2, 1 );
+ "0-2;21;4;2;5;21;8;11;10;21;22;20-4" ).toString();
+ parseAndCreate( line2, controlLayout2 );
if( !b_advancedVisible && advControls ) advControls->hide();
+
+ controlLayout->addLayout( controlLayout1 );
+ controlLayout->addLayout( controlLayout2 );
}
ControlsWidget::~ControlsWidget()
AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
AbstractController( _p_i )
{
+ controlLayout = new QHBoxLayout( this );
controlLayout->setMargin( 0 );
controlLayout->setSpacing( 0 );
QString line = getSettings()->value( "MainWindow/AdvControl",
"12;13;14;15" ).toString();
- parseAndCreateLine( line, 0 );
+ parseAndCreate( line, controlLayout );
}
InputControlsWidget::InputControlsWidget( intf_thread_t *_p_i ) :
AbstractController( _p_i )
{
+ controlLayout = new QHBoxLayout( this );
controlLayout->setMargin( 0 );
controlLayout->setSpacing( 0 );
.arg( FASTER_BUTTON ); */
QString line = getSettings()->value( "MainWindow/InputControl",
"6-1;16;7-1" ).toString();
- parseAndCreateLine( line, 0 );
+ parseAndCreate( line, controlLayout );
}
/**********************************************************************
* Fullscrenn control widget
setFrameStyle( QFrame::Sunken );
setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+ controlLayout = new QHBoxLayout( this );
controlLayout->setLayoutMargins( 5, 2, 5, 2, 5 );
/* First line */
InputControlsWidget *inputC = new InputControlsWidget( p_intf );
- controlLayout->addWidget( inputC, 0, 0, 1, -1 );
+// controlLayout->addWidget( inputC, 0, 0, 1, -1 );
/* Second line */
/* QString line2 = QString( "%1-2;%2;%3;%4;%5;%2;%6;%2;%7;%2;%8;%9;%10-4")
QString line = getSettings()->value( "MainWindow/FSCline",
"0-2;21;4;2;5;21;18;21;19;21;9;22;23-4" ).toString();
- parseAndCreateLine( line, 1 );
+ parseAndCreate( line, controlLayout );
/* hiding timer */
p_hideTimer = new QTimer( this );
--- /dev/null
+/*****************************************************************************
+ * ToolbarEdit.cpp : ToolbarEdit and About dialogs
+ ****************************************************************************
+ * Copyright (C) 2008 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Jean-Baptiste Kempf <jb (at) 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 "dialogs/toolbar.hpp"
+
+#include "util/input_slider.hpp"
+#include "util/customwidgets.hpp"
+#include "components/interface_widgets.hpp"
+
+#include <QScrollArea>
+#include <QGroupBox>
+#include <QLabel>
+#include <QComboBox>
+#include <QListWidget>
+
+#include <QDragEnterEvent>
+
+ToolbarEditDialog *ToolbarEditDialog::instance = NULL;
+
+ToolbarEditDialog::ToolbarEditDialog( intf_thread_t *_p_intf)
+ : QVLCFrame( _p_intf )
+{
+ setWindowTitle( qtr( "Toolbars Edition" ) );
+ QGridLayout *mainLayout = new QGridLayout( this );
+ setMinimumWidth( 600 );
+
+ /* main GroupBox */
+ QGroupBox *widgetBox = new QGroupBox( "Toolbar Elements", this );
+ widgetBox->setSizePolicy( QSizePolicy::Preferred,
+ QSizePolicy::MinimumExpanding );
+ QGridLayout *boxLayout = new QGridLayout( widgetBox );
+
+ boxLayout->addWidget( new WidgetListing( p_intf, this ), 0, 0, 1, -1);
+ flatBox = new QCheckBox( qtr( "Flat Button" ) );
+ bigBox = new QCheckBox( qtr( "Big Button" ) );
+ shinyBox = new QCheckBox( qtr( "Native Slider" ) );
+ shinyBox->setChecked( true );
+ boxLayout->addWidget( flatBox, 1, 0 );
+ boxLayout->addWidget( bigBox, 1, 1 );
+ boxLayout->addWidget( bigBox, 1, 2 );
+ mainLayout->addWidget( widgetBox, 0, 0, 1, -1 );
+
+
+ /* Main ToolBar */
+ QGroupBox *mainToolbarBox = new QGroupBox( "Main Toolbar", this );
+ QGridLayout *mainTboxLayout = new QGridLayout( mainToolbarBox );
+
+ QLabel *label = new QLabel( "Toolbar position:" );
+ mainTboxLayout->addWidget(label, 0, 0, 1, 1);
+
+ QComboBox *positionCombo = new QComboBox;
+ positionCombo->addItems( QStringList() << "Over the Video"
+ << "Under the Video" );
+ mainTboxLayout->addWidget( positionCombo, 0, 1, 1, 1 );
+
+ QFrame *mainToolFrame = new QFrame;
+ mainToolFrame->setMinimumSize( QSize( 0, 25 ) );
+ mainToolFrame->setFrameShape( QFrame::StyledPanel );
+ mainToolFrame->setFrameShadow( QFrame::Raised );
+ mainTboxLayout->addWidget( mainToolFrame, 1, 0, 1, 2 );
+ mainToolFrame->setAcceptDrops( true );
+ QHBoxLayout *mtlayout = new QHBoxLayout( mainToolFrame );
+
+ DroppingController *controller = new DroppingController( p_intf );
+ mtlayout->addWidget( controller );
+
+
+ QFrame *mainTool2Frame = new QFrame;
+ mainTool2Frame->setMinimumSize( QSize( 0, 25 ) );
+ mainTool2Frame->setFrameShape( QFrame::StyledPanel );
+ mainTool2Frame->setFrameShadow( QFrame::Raised );
+ mainTboxLayout->addWidget( mainTool2Frame, 2, 0, 1, 2 );
+ mainTool2Frame->setAcceptDrops( true );
+
+ mainLayout->addWidget( mainToolbarBox, 1, 0, 1, -1 );
+}
+
+
+ToolbarEditDialog::~ToolbarEditDialog()
+{
+}
+
+WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
+ : QListWidget( _parent )
+{
+ /* We need the parent to know the options checked */
+ parent = qobject_cast<ToolbarEditDialog *>(_parent);
+ assert( parent );
+
+ /* Normal options */
+ setViewMode( QListView::IconMode );
+ setSpacing( 20 );
+ setDragEnabled( true );
+ setMinimumHeight( 250 );
+
+ /* All the buttons do not need a special rendering */
+ for( int i = 0; i < BUTTON_MAX; i++ )
+ {
+ QListWidgetItem *widgetItem = new QListWidgetItem( this );
+ widgetItem->setText( nameL[i] );
+ widgetItem->setIcon( QIcon( iconL[i] ) );
+ widgetItem->setData( Qt::UserRole, QVariant( i ) );
+ addItem( widgetItem );
+ }
+
+ /* Spacers are yet again a different thing */
+ QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/space" ),
+ qtr( "Spacer" ), this );
+ widgetItem->setData( Qt::UserRole, WIDGET_SPACER );
+ addItem( widgetItem );
+
+ widgetItem = new QListWidgetItem( QIcon( ":/space" ),
+ qtr( "Expanding Spacer" ), this );
+ widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND );
+ addItem( widgetItem );
+
+ /**
+ * For all other widgets, we create then, do a pseudo rendering in
+ * a pixmaps for the view, and delete the object
+ *
+ * A lot of code is retaken from the Abstract, but not exactly...
+ * So, rewrite.
+ * They are better ways to deal with this, but I doubt that this is
+ * necessary. If you feel like you have the time, be my guest.
+ * --
+ * jb
+ **/
+ for( int i = SPLITTER; i < SPECIAL_MAX; i++ )
+ {
+ QWidget *widget = NULL;
+ QListWidgetItem *widgetItem = new QListWidgetItem( this );
+ switch( i )
+ {
+ case SPLITTER:
+ {
+ QFrame *line = new QFrame( this );
+ line->setFrameShape( QFrame::VLine );
+ line->setFrameShadow( QFrame::Raised );
+ line->setLineWidth( 0 ); line->setMidLineWidth( 1 );
+ widget = line;
+ }
+ widgetItem->setText( qtr("Splitter") );
+ break;
+ case INPUT_SLIDER:
+ {
+ InputSlider *slider = new InputSlider( Qt::Horizontal, this );
+ widget = slider;
+ }
+ widgetItem->setText( qtr("Time Slider") );
+ break;
+ case VOLUME:
+ {
+ bool b_shiny = false;
+ SoundWidget *snd = new SoundWidget( this, p_intf, b_shiny );
+ widget = snd;
+ }
+ widgetItem->setText( qtr("Volume") );
+ break;
+ case TIME_LABEL:
+ {
+ QLabel *timeLabel = new QLabel( "12:42/2:12:42", this );
+ widget = timeLabel;
+ }
+ widgetItem->setText( qtr("Time") );
+ break;
+ case MENU_BUTTONS:
+ {
+ QWidget *discFrame = new QWidget( this );
+ QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
+ discLayout->setSpacing( 0 ); discLayout->setMargin( 0 );
+
+ QToolButton *prevSectionButton = new QToolButton( discFrame );
+ prevSectionButton->setIcon( QIcon( ":/dvd_prev" ) );
+ discLayout->addWidget( prevSectionButton );
+
+ QToolButton *menuButton = new QToolButton( discFrame );
+ menuButton->setIcon( QIcon( ":/dvd_menu" ) );
+ discLayout->addWidget( menuButton );
+
+ QToolButton *nextButton = new QToolButton( discFrame );
+ nextButton->setIcon( QIcon( ":/dvd_next" ) );
+ discLayout->addWidget( nextButton );
+
+ widget = discFrame;
+ }
+ widgetItem->setText( qtr("DVD menus") );
+ break;
+ case TELETEXT_BUTTONS:
+ {
+ QWidget *telexFrame = new QWidget( this );
+ QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
+ telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 );
+
+ QToolButton *telexOn = new QToolButton( telexFrame );
+ telexOn->setIcon( QIcon( ":/tv" ) );
+ telexLayout->addWidget( telexOn );
+
+ QToolButton *telexTransparent = new QToolButton;
+ telexOn->setIcon( QIcon( ":/tvtelx-trans" ) );
+ telexLayout->addWidget( telexTransparent );
+
+ QSpinBox *telexPage = new QSpinBox;
+ telexLayout->addWidget( telexPage );
+
+ widget = telexFrame;
+ }
+ widgetItem->setText( qtr("Teletext") );
+ break;
+ case ADVANCED_CONTROLLER:
+ {
+ AdvControlsWidget *advControls = new AdvControlsWidget( p_intf );
+ widget = advControls;
+ }
+ widgetItem->setText( qtr("Advanced Buttons") );
+ break;
+ default:
+ msg_Warn( p_intf, "This should not happen %i", i );
+ break;
+ }
+
+ if( widget == NULL ) continue;
+
+
+ widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) );
+ widget->hide();
+ widgetItem->setData( Qt::UserRole, QVariant( i ) );
+
+ addItem( widgetItem );
+ delete widget;
+ }
+}
+
+void WidgetListing::startDrag( Qt::DropActions /*supportedActions*/ )
+{
+ QListWidgetItem *item =currentItem();
+
+ QByteArray itemData;
+ QDataStream dataStream( &itemData, QIODevice::WriteOnly );
+
+ int i_type = item->data( Qt::UserRole ).toInt();
+ int i_option = parent->getOptions();
+ dataStream << i_type << i_option;
+
+ QMimeData *mimeData = new QMimeData;
+ mimeData->setData( "vlc/button-bar", itemData );
+
+ QDrag *drag = new QDrag( this );
+ drag->setMimeData( mimeData );
+// drag->setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2));
+
+ drag->exec(Qt::CopyAction | Qt::MoveAction );
+}
+
+
+DroppingController::DroppingController( intf_thread_t *_p_intf )
+ : AbstractController( _p_intf )
+{
+ rubberband = NULL;
+ setAcceptDrops( true );
+ controlLayout = new QHBoxLayout( this );
+ controlLayout->setSpacing( 0 );
+ controlLayout->setMargin( 0 );
+ setFrameShape( QFrame::StyledPanel );
+ setFrameShadow( QFrame::Raised );
+
+ QString line2 = getSettings()->value( "MainWindow/Controls2",
+ "0-2;21;4;2;5;21;8;11;10;21;22;20-4" ).toString();
+
+ parseAndCreate( line2, controlLayout );
+
+ //QString line1 = getSettings()->value( "MainWindow/Controls2",
+ // "18;19;25;0" ).toString();
+ // parseAndCreate( line1, 1 );
+
+}
+
+/* Overloading the AbstractController one, because we don't manage the
+ Spacing in the same ways */
+void DroppingController::createAndAddWidget( QBoxLayout *controlLayout,
+ int i_index,
+ buttonType_e i_type,
+ int i_option )
+{
+ /* Special case for SPACERS, who aren't QWidgets */
+ if( i_type == WIDGET_SPACER || i_type == WIDGET_SPACER_EXTEND )
+ {
+ QLabel *label = new QLabel;
+ label->setPixmap( QPixmap( ":/space" ) );
+ if( i_type == WIDGET_SPACER_EXTEND )
+ {
+ label->setScaledContents( true );
+ label->setSizePolicy( QSizePolicy::MinimumExpanding,
+ QSizePolicy::Preferred );
+ }
+ else
+ label->setSizePolicy( QSizePolicy::Fixed,
+ QSizePolicy::Preferred );
+
+ controlLayout->insertWidget( i_index, label );
+ }
+ else
+ {
+ QWidget *widg = createWidget( i_type, i_option );
+ if( !widg ) return;
+
+ /* Some Widgets are deactivated at creation */
+ widg->setEnabled( true );
+ controlLayout->insertWidget( i_index, widg );
+ }
+}
+
+void DroppingController::dragEnterEvent( QDragEnterEvent * event )
+{
+ if( event->mimeData()->hasFormat( "vlc/button-bar" ) )
+ event->accept();
+ else
+ event->ignore();
+}
+
+void DroppingController::dragMoveEvent( QDragMoveEvent *event )
+{
+ QPoint origin = event->pos();
+
+ int i_pos = getParentPosInLayout( origin );
+ bool b_end = false;
+
+ /* Both sides of the frame */
+ if( i_pos == -1 )
+ {
+ if( rubberband ) rubberband->hide();
+ return;
+ }
+
+ /* Last item is special because of underlying items */
+ if( i_pos >= controlLayout->count() )
+ {
+ i_pos--;
+ b_end = true;
+ }
+
+ /* Query the underlying item for size && middles */
+ QLayoutItem *tempItem = controlLayout->itemAt( i_pos ); assert( tempItem );
+ QWidget *temp = tempItem->widget(); assert( temp );
+
+ /* Position assignment */
+ origin.ry() = 0;
+ origin.rx() = temp->x() - 2;
+
+ if( b_end ) origin.rx() += temp->width();
+
+ if( !rubberband )
+ rubberband = new QRubberBand( QRubberBand::Line, this );
+ rubberband->setGeometry( origin.x(), origin.y(), 4, height() );
+ rubberband->show();
+}
+
+inline int DroppingController::getParentPosInLayout( QPoint point)
+{
+ point.ry() = height() / 2 ;
+ QPoint origin = mapToGlobal ( point );
+
+ QWidget *tempWidg = QApplication::widgetAt( origin );
+
+ int i = -1;
+ if( tempWidg != NULL)
+ {
+ i = controlLayout->indexOf( tempWidg );
+ if( i == -1 )
+ {
+ i = controlLayout->indexOf( tempWidg->parentWidget() );
+ tempWidg = tempWidg->parentWidget();
+ }
+ }
+
+ /* Return the nearest position */
+ if( ( point.x() - tempWidg->x() > tempWidg->width() / 2 ) && i != -1 )
+ i++;
+
+ // msg_Dbg( p_intf, "%i", i);
+ return i;
+}
+
+void DroppingController::dropEvent( QDropEvent *event )
+{
+ int i = getParentPosInLayout( event->pos() );
+
+ QByteArray data = event->mimeData()->data( "vlc/button-bar" );
+ QDataStream dataStream(&data, QIODevice::ReadOnly);
+
+ int i_option = 0, i_type = 0;
+ dataStream >> i_type >> i_option;
+
+ createAndAddWidget( controlLayout, i, (buttonType_e)i_type, i_option );
+
+ /* Hide by precaution, you don't exactly know what could have happened in
+ between */
+ if( rubberband ) rubberband->hide();
+}
+
+void DroppingController::dragLeaveEvent ( QDragLeaveEvent * event )
+{
+ if( rubberband ) rubberband->hide();
+}
+
+/**
+ * Overloading doAction to block any action
+ **/
+void DroppingController::doAction( int i ){}
+