1 /*****************************************************************************
2 * toolbar.cpp : ToolbarEdit dialog
3 ****************************************************************************
4 * Copyright (C) 2008-2009 the VideoLAN team
7 * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
28 #include "dialogs/toolbar.hpp"
31 #include "util/input_slider.hpp"
32 #include "util/customwidgets.hpp"
33 #include "components/interface_widgets.hpp"
34 #include "util/buttons/DeckButtonsLayout.hpp"
35 #include "util/buttons/BrowseButton.hpp"
36 #include "util/buttons/RoundButton.hpp"
39 #include "input_manager.hpp"
40 #include <vlc_vout.h> /* vout_thread_t for aspect ratio combobox */
42 #include <QScrollArea>
46 #include <QListWidget>
48 #include <QRubberBand>
50 #include <QDragEnterEvent>
51 #include <QDialogButtonBox>
52 #include <QInputDialog>
56 ToolbarEditDialog::ToolbarEditDialog( QWidget *_w, intf_thread_t *_p_intf)
57 : QVLCDialog( _w, _p_intf )
59 setWindowTitle( qtr( "Toolbars Editor" ) );
60 setWindowRole( "vlc-toolbars-editor" );
61 QGridLayout *mainLayout = new QGridLayout( this );
62 setMinimumWidth( 600 );
63 setAttribute( Qt::WA_DeleteOnClose );
66 QGroupBox *widgetBox = new QGroupBox( qtr( "Toolbar Elements") , this );
67 widgetBox->setSizePolicy( QSizePolicy::Preferred,
68 QSizePolicy::MinimumExpanding );
69 QGridLayout *boxLayout = new QGridLayout( widgetBox );
71 QLabel *styleLabel = new QLabel( qtr( "Next widget style:" ) );
72 flatBox = new QCheckBox( qtr( "Flat Button" ) );
73 bigBox = new QCheckBox( qtr( "Big Button" ) );
74 shinyBox = new QCheckBox( qtr( "Native Slider" ) );
76 boxLayout->addWidget( new WidgetListing( p_intf, this ), 0, 0, 1, -1);
77 boxLayout->addWidget( styleLabel, 1, 0 );
78 boxLayout->addWidget( flatBox, 1, 1 );
79 boxLayout->addWidget( bigBox, 1, 2 );
80 boxLayout->addWidget( shinyBox, 2, 1 );
81 mainLayout->addWidget( widgetBox, 0, 0, 5, 1 );
85 QGroupBox *mainToolbarBox = new QGroupBox( qtr( "Main Toolbar" ), this );
86 QGridLayout *mainTboxLayout = new QGridLayout( mainToolbarBox );
88 QLabel *label = new QLabel( qtr( "Toolbar position:" ) );
89 mainTboxLayout->addWidget(label, 0, 0, 1, 2);
91 positionCombo = new QComboBox;
92 positionCombo->addItem( qtr( "Under the Video" ), QVariant( 0 ) );
93 positionCombo->addItem( qtr( "Above the Video" ), QVariant( 1 ) );
94 positionCombo->setCurrentIndex( positionCombo->findData(
95 getSettings()->value( "MainWindow/ToolbarPos", 0 ).toInt() ) );
96 mainTboxLayout->addWidget( positionCombo, 0, 2, 1, 1 );
98 QLabel *line1Label = new QLabel( qtr("Line 1:") );
99 QString line1 = getSettings()->value( "MainWindow/MainToolbar1",
100 MAIN_TB1_DEFAULT ).toString();
101 controller1 = new DroppingController( p_intf, line1,
103 mainTboxLayout->addWidget( line1Label, 1, 0, 1, 1 );
104 mainTboxLayout->addWidget( controller1, 1, 1, 1, 2 );
106 QLabel *line2Label = new QLabel( qtr("Line 2:") );
107 QString line2 = getSettings()->value( "MainWindow/MainToolbar2",
108 MAIN_TB2_DEFAULT ).toString();
109 controller2 = new DroppingController( p_intf, line2,
111 mainTboxLayout->addWidget( line2Label, 2, 0, 1, 1 );
112 mainTboxLayout->addWidget( controller2, 2, 1, 1, 2);
114 /* Advanced ToolBar */
115 QLabel *advLabel = new QLabel( qtr( "Advanced Widget toolbar:" ) );
116 QString lineA = getSettings()->value( "MainWindow/AdvToolbar",
117 ADV_TB_DEFAULT ).toString();
118 controllerA = new DroppingController( p_intf, lineA,
120 mainTboxLayout->addWidget( advLabel, 3, 0, 1, 2 );
121 mainTboxLayout->addWidget( controllerA, 3, 2, 1, 1 );
123 mainLayout->addWidget( mainToolbarBox, 0, 1, 1, -1 );
126 QGroupBox *timeToolbarBox = new QGroupBox( qtr( "Time Toolbar" ) , this );
127 QGridLayout *timeTboxLayout = new QGridLayout( timeToolbarBox );
129 QString line = getSettings()->value( "MainWindow/InputToolbar",
130 INPT_TB_DEFAULT ).toString();
131 controller = new DroppingController( p_intf, line,
133 timeTboxLayout->addWidget( controller, 0, 0, 1, -1 );
135 mainLayout->addWidget( timeToolbarBox, 1, 1, 1, -1 );
138 QGroupBox *FSCToolbarBox = new QGroupBox( qtr( "Fullscreen Controller" ),
140 QGridLayout *FSCTboxLayout = new QGridLayout( FSCToolbarBox );
142 QString lineFSC = getSettings()->value( "MainWindow/FSCtoolbar",
143 FSC_TB_DEFAULT ).toString();
144 controllerFSC = new DroppingController( p_intf,
146 FSCTboxLayout->addWidget( controllerFSC, 0, 0, 1, -1 );
148 mainLayout->addWidget( FSCToolbarBox, 2, 1, 1, -1 );
151 QGroupBox *profileBox = new QGroupBox( qtr( "Profile" ), this );
152 QGridLayout *profileBoxLayout = new QGridLayout( profileBox );
154 profileCombo = new QComboBox;
155 QLabel *profileLabel = new QLabel( qtr( "Select profile:" ), this );
157 QToolButton *newButton = new QToolButton;
158 newButton->setIcon( QIcon( ":/new" ) );
159 newButton->setToolTip( qtr("New profile") );
160 QToolButton *deleteButton = new QToolButton;
161 deleteButton->setIcon( QIcon( ":/toolbar/clear" ) );
162 deleteButton->setToolTip( qtr( "Delete the current profile" ) );
164 profileBoxLayout->addWidget( profileLabel, 0, 0 );
165 profileBoxLayout->addWidget( profileCombo, 0, 1 );
166 profileBoxLayout->addWidget( newButton, 0, 2 );
167 profileBoxLayout->addWidget( deleteButton, 0, 3 );
169 mainLayout->addWidget( profileBox, 3, 1, 1, -1 );
172 int i_size = getSettings()->beginReadArray( "ToolbarProfiles" );
173 for( int i = 0; i < i_size; i++ )
175 getSettings()->setArrayIndex(i);
176 profileCombo->addItem( getSettings()->value( "ProfileName" ).toString(),
177 getSettings()->value( "Value" ).toString() );
179 getSettings()->endArray();
181 /* Load defaults ones if we have no combos */
182 /* We could decide that we load defaults on first launch of the dialog
183 or when the combo is back to 0. I choose the second solution, because some clueless
184 user might hit on delete a bit too much, but discussion is opened. -- jb */
187 profileCombo->addItem( PROFILE_NAME_1, QString( VALUE_1 ) );
188 profileCombo->addItem( PROFILE_NAME_2, QString( VALUE_2 ) );
189 profileCombo->addItem( PROFILE_NAME_3, QString( VALUE_3 ) );
190 profileCombo->addItem( PROFILE_NAME_4, QString( VALUE_4 ) );
191 profileCombo->addItem( PROFILE_NAME_5, QString( VALUE_5 ) );
193 profileCombo->setCurrentIndex( -1 );
196 QDialogButtonBox *okCancel = new QDialogButtonBox;
197 QPushButton *okButton = new QPushButton( qtr( "Cl&ose" ), this );
198 okButton->setDefault( true );
199 QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ), this );
200 okCancel->addButton( okButton, QDialogButtonBox::AcceptRole );
201 okCancel->addButton( cancelButton, QDialogButtonBox::RejectRole );
203 BUTTONACT( deleteButton, deleteProfile() );
204 BUTTONACT( newButton, newProfile() );
205 CONNECT( profileCombo, currentIndexChanged( int ), this, changeProfile( int ) );
206 BUTTONACT( okButton, close() );
207 BUTTONACT( cancelButton, cancel() );
208 mainLayout->addWidget( okCancel, 5, 2 );
212 ToolbarEditDialog::~ToolbarEditDialog()
214 getSettings()->beginWriteArray( "ToolbarProfiles" );
215 for( int i = 0; i < profileCombo->count(); i++ )
217 getSettings()->setArrayIndex(i);
218 getSettings()->setValue( "ProfileName", profileCombo->itemText( i ) );
219 getSettings()->setValue( "Value", profileCombo->itemData( i ) );
221 getSettings()->endArray();
224 void ToolbarEditDialog::newProfile()
227 QString name = QInputDialog::getText( this, qtr( "Profile Name" ),
228 qtr( "Please enter the new profile name." ), QLineEdit::Normal, 0, &ok );
231 QString temp = QString::number( positionCombo->currentIndex() );
232 temp += "|" + controller1->getValue();
233 temp += "|" + controller2->getValue();
234 temp += "|" + controllerA->getValue();
235 temp += "|" + controller->getValue();
236 temp += "|" + controllerFSC->getValue();
238 profileCombo->addItem( name, temp );
239 profileCombo->setCurrentIndex( profileCombo->count() - 1 );
242 void ToolbarEditDialog::deleteProfile()
244 profileCombo->removeItem( profileCombo->currentIndex() );
247 void ToolbarEditDialog::changeProfile( int i )
249 QStringList qs_list = profileCombo->itemData( i ).toString().split( "|" );
250 if( qs_list.count() < 6 )
253 positionCombo->setCurrentIndex( positionCombo->findData( qs_list[0].toInt() ) );
254 controller1->resetLine( qs_list[1] );
255 controller2->resetLine( qs_list[2] );
256 controllerA->resetLine( qs_list[3] );
257 controller->resetLine( qs_list[4] );
258 controllerFSC->resetLine( qs_list[5] );
261 void ToolbarEditDialog::close()
263 msg_Dbg( p_intf, "Close and save" );
264 getSettings()->setValue( "MainWindow/ToolbarPos",
265 positionCombo->itemData( positionCombo->currentIndex() ).toInt() );
266 getSettings()->setValue( "MainWindow/MainToolbar1", controller1->getValue() );
267 getSettings()->setValue( "MainWindow/MainToolbar2", controller2->getValue() );
268 getSettings()->setValue( "MainWindow/AdvToolbar", controllerA->getValue() );
269 getSettings()->setValue( "MainWindow/InputToolbar", controller->getValue() );
270 getSettings()->setValue( "MainWindow/FSCtoolbar", controllerFSC->getValue() );
271 getSettings()->sync();
275 void ToolbarEditDialog::cancel()
280 /************************************************
282 * Creation of the list of drawed lovely buttons
283 ************************************************/
284 WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
285 : QListWidget( _parent )
287 /* We need the parent to know the options checked */
288 parent = qobject_cast<ToolbarEditDialog *>(_parent);
292 setViewMode( QListView::IconMode );
294 setGridSize( QSize(90, 50) );
297 setTextElideMode( Qt::ElideNone );
298 setDragEnabled( true );
300 /* All the buttons do not need a special rendering */
301 for( int i = 0; i < BUTTON_MAX; i++ )
303 QListWidgetItem *widgetItem = new QListWidgetItem( this );
304 widgetItem->setText( qtr( nameL[i] ) );
305 QPixmap pix( iconL[i] );
306 widgetItem->setIcon( pix.scaled( 16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
307 widgetItem->setData( Qt::UserRole, QVariant( i ) );
308 addItem( widgetItem );
311 /* Spacers are yet again a different thing */
312 QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ),
313 qtr( "Spacer" ), this );
314 widgetItem->setData( Qt::UserRole, WIDGET_SPACER );
315 addItem( widgetItem );
317 widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ),
318 qtr( "Expanding Spacer" ), this );
319 widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND );
320 addItem( widgetItem );
323 * For all other widgets, we create then, do a pseudo rendering in
324 * a pixmaps for the view, and delete the object
326 * A lot of code is retaken from the Abstract, but not exactly...
328 * They are better ways to deal with this, but I doubt that this is
329 * necessary. If you feel like you have the time, be my guest.
333 for( int i = SPLITTER; i < SPECIAL_MAX; i++ )
335 QWidget *widget = NULL;
336 QListWidgetItem *widgetItem = new QListWidgetItem( this );
341 QFrame *line = new QFrame( this );
342 line->setFrameShape( QFrame::VLine );
343 line->setFrameShadow( QFrame::Raised );
344 line->setLineWidth( 0 ); line->setMidLineWidth( 1 );
347 widgetItem->setText( qtr("Splitter") );
351 SeekSlider *slider = new SeekSlider( Qt::Horizontal, this );
354 widgetItem->setText( qtr("Time Slider") );
358 SoundWidget *snd = new SoundWidget( this, p_intf,
359 parent->getOptions() & WIDGET_SHINY );
362 widgetItem->setText( qtr("Volume") );
366 QListWidgetItem *widgetItem = new QListWidgetItem( this );
367 widgetItem->setText( qtr("Small Volume") );
368 widgetItem->setIcon( QIcon( ":/toolbar/volume-medium" ) );
369 widgetItem->setData( Qt::UserRole, QVariant( i ) );
370 addItem( widgetItem );
375 QLabel *timeLabel = new QLabel( "12:42/2:12:42", this );
378 widgetItem->setText( qtr("Time") );
382 QWidget *discFrame = new QWidget( this );
383 //discFrame->setLineWidth( 1 );
384 QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
385 discLayout->setSpacing( 0 ); discLayout->setMargin( 0 );
387 QToolButton *prevSectionButton = new QToolButton( discFrame );
388 prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev" ) );
389 prevSectionButton->setToolTip( qtr("Previous chapter") );
390 discLayout->addWidget( prevSectionButton );
392 QToolButton *menuButton = new QToolButton( discFrame );
393 menuButton->setIcon( QIcon( ":/toolbar/dvd_menu" ) );
394 menuButton->setToolTip( qtr("Go to the DVD menu") );
395 discLayout->addWidget( menuButton );
397 QToolButton *nextButton = new QToolButton( discFrame );
398 nextButton->setIcon( QIcon( ":/toolbar/dvd_next" ) );
399 nextButton->setToolTip( qtr("Next chapter") );
400 discLayout->addWidget( nextButton );
404 widgetItem->setText( qtr("DVD menus") );
406 case TELETEXT_BUTTONS:
408 QWidget *telexFrame = new QWidget( this );
409 QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
410 telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 );
412 QToolButton *telexOn = new QToolButton( telexFrame );
413 telexOn->setIcon( QIcon( ":/toolbar/tv" ) );
414 telexLayout->addWidget( telexOn );
416 QToolButton *telexTransparent = new QToolButton;
417 telexTransparent->setIcon( QIcon( ":/toolbar/tvtelx" ) );
418 telexTransparent->setToolTip( qtr("Teletext transparency") );
419 telexLayout->addWidget( telexTransparent );
421 QSpinBox *telexPage = new QSpinBox;
422 telexLayout->addWidget( telexPage );
426 widgetItem->setText( qtr("Teletext") );
428 case ADVANCED_CONTROLLER:
430 AdvControlsWidget *advControls = new AdvControlsWidget( p_intf, this );
431 widget = advControls;
433 widgetItem->setText( qtr("Advanced Buttons") );
435 case PLAYBACK_BUTTONS:
437 widget = new QWidget;
438 DeckButtonsLayout *layout = new DeckButtonsLayout( widget );
439 BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward );
440 BrowseButton *next = new BrowseButton( widget );
441 RoundButton *play = new RoundButton( widget );
442 layout->setBackwardButton( prev );
443 layout->setForwardButton( next );
444 layout->setRoundButton( play );
446 widgetItem->setText( qtr("Playback Buttons") );
448 case ASPECT_RATIO_COMBOBOX:
449 widget = new AspectRatioComboBox( p_intf );
450 widgetItem->setText( qtr("Aspect ratio selector") );
453 msg_Warn( p_intf, "This should not happen %i", i );
457 if( widget == NULL ) continue;
460 widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) );
462 widgetItem->setData( Qt::UserRole, QVariant( i ) );
464 addItem( widgetItem );
469 void WidgetListing::startDrag( Qt::DropActions /*supportedActions*/ )
471 QListWidgetItem *item = currentItem();
474 QDataStream dataStream( &itemData, QIODevice::WriteOnly );
476 int i_type = item->data( Qt::UserRole ).toInt();
477 int i_option = parent->getOptions();
478 dataStream << i_type << i_option;
480 /* Create a new dragging event */
481 QDrag *drag = new QDrag( this );
483 /* With correct mimedata */
484 QMimeData *mimeData = new QMimeData;
485 mimeData->setData( "vlc/button-bar", itemData );
486 drag->setMimeData( mimeData );
488 /* And correct pixmap */
489 QPixmap aPixmap = item->icon().pixmap( QSize( 22, 22 ) );
490 drag->setPixmap( aPixmap );
491 drag->setHotSpot( QPoint( 20, 20 ) );
493 /* We want to keep a copy */
494 drag->exec( Qt::CopyAction | Qt::MoveAction );
498 * The special controller with drag'n drop abilities.
499 * We don't do this in the main controller, since we don't want the OverHead
500 * to propagate there too
502 DroppingController::DroppingController( intf_thread_t *_p_intf,
505 : AbstractController( _p_intf, _parent )
507 RTL_UNAFFECTED_WIDGET
510 setAcceptDrops( true );
511 controlLayout = new QHBoxLayout( this );
512 controlLayout->setSpacing( 5 );
513 controlLayout->setMargin( 0 );
514 setFrameShape( QFrame::StyledPanel );
515 setFrameShadow( QFrame::Raised );
517 parseAndCreate( line, controlLayout );
520 void DroppingController::resetLine( const QString& line )
524 while( (child = controlLayout->takeAt( 0 ) ) != 0 )
526 child->widget()->hide();
530 parseAndCreate( line, controlLayout );
534 /* Overloading the AbstractController one, because we don't manage the
535 Spacing items in the same ways */
536 void DroppingController::createAndAddWidget( QBoxLayout *controlLayout,
541 doubleInt *value = new doubleInt;
542 value->i_type = i_type;
543 value->i_option = i_option;
545 /* Special case for SPACERS, who aren't QWidgets */
546 if( i_type == WIDGET_SPACER || i_type == WIDGET_SPACER_EXTEND )
548 QLabel *label = new QLabel( this );
549 label->setPixmap( QPixmap( ":/toolbar/space" ) );
550 if( i_type == WIDGET_SPACER_EXTEND )
552 label->setSizePolicy( QSizePolicy::MinimumExpanding,
553 QSizePolicy::Preferred );
555 /* Create a box around it */
556 label->setFrameStyle( QFrame::Panel | QFrame::Sunken );
557 label->setLineWidth ( 1 );
558 label->setAlignment( Qt::AlignCenter );
561 label->setSizePolicy( QSizePolicy::Fixed,
562 QSizePolicy::Preferred );
564 /* Install event Filter for drag'n drop */
565 label->installEventFilter( this );
566 controlLayout->insertWidget( i_index, label );
572 QWidget *widg = createWidget( i_type, i_option );
575 /* Install the Event Filter in order to catch the drag */
576 widg->setParent( this );
577 widg->installEventFilter( this );
579 /* We are in a complex widget, we need to stop events on children too */
580 if( i_type >= VOLUME && i_type < SPECIAL_MAX )
582 QList<QObject *>children = widg->children();
585 foreach( child, children )
588 if( ( childWidg = qobject_cast<QWidget *>( child ) ) )
590 child->installEventFilter( this );
591 childWidg->setEnabled( true );
595 /* Decorating the frames when possible */
597 if( i_type >= MENU_BUTTONS /* Don't bother to check for volume */
598 && ( frame = qobject_cast<QFrame *>( widg ) ) != NULL )
600 frame->setFrameStyle( QFrame::Panel | QFrame::Raised );
601 frame->setLineWidth ( 1 );
605 /* Some Widgets are deactivated at creation */
606 widg->setEnabled( true );
608 controlLayout->insertWidget( i_index, widg );
611 /* QList and QBoxLayout don't act the same with insert() */
612 if( i_index < 0 ) i_index = controlLayout->count() - 1;
614 widgetList.insert( i_index, value );
617 DroppingController::~DroppingController()
619 qDeleteAll( widgetList );
623 QString DroppingController::getValue()
627 for( int i = 0; i < controlLayout->count(); i++ )
629 doubleInt *dI = widgetList.at( i );
632 qs.append( QString::number( dI->i_type ) );
633 if( dI->i_option ) qs.append( "-" + QString::number( dI->i_option ) );
639 void DroppingController::dragEnterEvent( QDragEnterEvent * event )
641 if( event->mimeData()->hasFormat( "vlc/button-bar" ) )
647 void DroppingController::dragMoveEvent( QDragMoveEvent *event )
649 QPoint origin = event->pos();
651 int i_pos = getParentPosInLayout( origin );
654 /* Both sides of the frame */
657 if( rubberband ) rubberband->hide();
661 /* Last item is special because of underlying items */
662 if( i_pos >= controlLayout->count() )
668 /* Query the underlying item for size && middles */
669 QLayoutItem *tempItem = controlLayout->itemAt( i_pos ); assert( tempItem );
670 QWidget *temp = tempItem->widget(); assert( temp );
672 /* Position assignment */
674 origin.rx() = temp->x() - 2;
676 if( b_end ) origin.rx() += temp->width();
679 rubberband = new QRubberBand( QRubberBand::Line, this );
680 rubberband->setGeometry( origin.x(), origin.y(), 4, height() );
684 inline int DroppingController::getParentPosInLayout( QPoint point )
686 point.ry() = height() / 2 ;
687 QPoint origin = mapToGlobal ( point );
689 QWidget *tempWidg = QApplication::widgetAt( origin );
690 if( tempWidg == NULL )
693 int i = controlLayout->indexOf( tempWidg );
696 i = controlLayout->indexOf( tempWidg->parentWidget() );
697 tempWidg = tempWidg->parentWidget();
700 /* Return the nearest position */
701 if( ( point.x() - tempWidg->x() > tempWidg->width() / 2 ) && i != -1 )
704 // msg_Dbg( p_intf, "%i", i);
708 void DroppingController::dropEvent( QDropEvent *event )
710 int i = getParentPosInLayout( event->pos() );
712 /* Workaround: do not let the item move to its current
713 position + 1 as it breaks the widgetList */
714 if ( i - 1 == i_dragIndex )
717 QByteArray data = event->mimeData()->data( "vlc/button-bar" );
718 QDataStream dataStream(&data, QIODevice::ReadOnly);
720 int i_option = 0, i_type = 0;
721 dataStream >> i_type >> i_option;
723 createAndAddWidget( controlLayout, i, (buttonType_e)i_type, i_option );
725 /* Hide by precaution, you don't exactly know what could have happened in
727 if( rubberband ) rubberband->hide();
730 void DroppingController::dragLeaveEvent ( QDragLeaveEvent * event )
732 if( rubberband ) rubberband->hide();
737 * Overloading doAction to block any action
739 void DroppingController::doAction( int i )
744 bool DroppingController::eventFilter( QObject *obj, QEvent *event )
746 switch( event->type() )
748 case QEvent::MouseButtonPress:
751 case QEvent::MouseButtonRelease:
754 case QEvent::MouseMove:
756 if( !b_draging ) return true;
757 QWidget *widg = static_cast<QWidget*>(obj);
760 QDataStream dataStream( &itemData, QIODevice::WriteOnly );
763 i = controlLayout->indexOf( widg );
766 i = controlLayout->indexOf( widg->parentWidget() );
767 widg = widg->parentWidget();
768 /* NOTE: be extra-careful Now with widg access */
771 if( i == -1 ) return true;
774 doubleInt *dI = widgetList.at( i );
776 int i_type = dI->i_type;
777 int i_option = dI->i_option;
778 dataStream << i_type << i_option;
780 /* With correct mimedata */
781 QMimeData *mimeData = new QMimeData;
782 mimeData->setData( "vlc/button-bar", itemData );
784 QDrag *drag = new QDrag( widg );
785 drag->setMimeData( mimeData );
787 /* Remove before the drag to not mess DropEvent,
788 that will createAndAddWidget */
789 widgetList.removeAt( i );
791 /* Start the effective drag */
792 drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction);
794 controlLayout->removeWidget( widg );
799 case QEvent::MouseButtonDblClick:
800 case QEvent::EnabledChange:
802 case QEvent::HideToParent:
804 case QEvent::ZOrderChange: