X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Ftoolbar.cpp;h=72cf40776d95eb5474e25412a1159e55be9aacc1;hb=5b86425b762dab1f6b5bc3e0d6776188c8d927af;hp=2ca4f79f1bb077ee9468a6ce3638719955ed86bb;hpb=eededf1e16d0d3608a1ab2be68add52086105550;p=vlc diff --git a/modules/gui/qt4/dialogs/toolbar.cpp b/modules/gui/qt4/dialogs/toolbar.cpp index 2ca4f79f1b..72cf40776d 100644 --- a/modules/gui/qt4/dialogs/toolbar.cpp +++ b/modules/gui/qt4/dialogs/toolbar.cpp @@ -1,7 +1,7 @@ /***************************************************************************** - * ToolbarEdit.cpp : ToolbarEdit and About dialogs + * ToolbarEdit.cpp : ToolbarEdit dialog **************************************************************************** - * Copyright (C) 2008 the VideoLAN team + * Copyright (C) 2008-2009 the VideoLAN team * $Id$ * * Authors: Jean-Baptiste Kempf @@ -36,15 +36,19 @@ #include #include #include +#include #include #include #include +#include + ToolbarEditDialog::ToolbarEditDialog( QWidget *_w, intf_thread_t *_p_intf) : QVLCDialog( _w, _p_intf ) { setWindowTitle( qtr( "Toolbars Editor" ) ); + setWindowRole( "vlc-toolbars-editor" ); QGridLayout *mainLayout = new QGridLayout( this ); setMinimumWidth( 600 ); setAttribute( Qt::WA_DeleteOnClose ); @@ -82,7 +86,7 @@ ToolbarEditDialog::ToolbarEditDialog( QWidget *_w, intf_thread_t *_p_intf) getSettings()->value( "MainWindow/ToolbarPos", 0 ).toInt() ) ); mainTboxLayout->addWidget( positionCombo, 0, 2, 1, 1 ); - QLabel *line1Label = new QLabel( "Line 1:" ); + QLabel *line1Label = new QLabel( qtr("Line 1:") ); QString line1 = getSettings()->value( "MainWindow/MainToolbar1", MAIN_TB1_DEFAULT ).toString(); controller1 = new DroppingController( p_intf, line1, @@ -90,7 +94,7 @@ ToolbarEditDialog::ToolbarEditDialog( QWidget *_w, intf_thread_t *_p_intf) mainTboxLayout->addWidget( line1Label, 1, 0, 1, 1 ); mainTboxLayout->addWidget( controller1, 1, 1, 1, 2 ); - QLabel *line2Label = new QLabel( "Line 2:" ); + QLabel *line2Label = new QLabel( qtr("Line 2:") ); QString line2 = getSettings()->value( "MainWindow/MainToolbar2", MAIN_TB2_DEFAULT ).toString(); controller2 = new DroppingController( p_intf, line2, @@ -144,7 +148,7 @@ ToolbarEditDialog::ToolbarEditDialog( QWidget *_w, intf_thread_t *_p_intf) QToolButton *newButton = new QToolButton; newButton->setIcon( QIcon( ":/new" ) ); QToolButton *deleteButton = new QToolButton; - deleteButton->setIcon( QIcon( ":/clear" ) ); + deleteButton->setIcon( QIcon( ":/toolbar/clear" ) ); deleteButton->setToolTip( qtr( "Delete the current profile" ) ); profileBoxLayout->addWidget( profileLabel, 0, 0 ); @@ -290,12 +294,12 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) } /* Spacers are yet again a different thing */ - QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/space" ), + QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER ); addItem( widgetItem ); - widgetItem = new QListWidgetItem( QIcon( ":/space" ), + widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Expanding Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND ); addItem( widgetItem ); @@ -346,7 +350,7 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr("Small Volume") ); - widgetItem->setIcon( QIcon( ":/volume-medium" ) ); + widgetItem->setIcon( QIcon( ":/toolbar/volume-medium" ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } @@ -366,15 +370,15 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) discLayout->setSpacing( 0 ); discLayout->setMargin( 0 ); QToolButton *prevSectionButton = new QToolButton( discFrame ); - prevSectionButton->setIcon( QIcon( ":/dvd_prev" ) ); + prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev" ) ); discLayout->addWidget( prevSectionButton ); QToolButton *menuButton = new QToolButton( discFrame ); - menuButton->setIcon( QIcon( ":/dvd_menu" ) ); + menuButton->setIcon( QIcon( ":/toolbar/dvd_menu" ) ); discLayout->addWidget( menuButton ); QToolButton *nextButton = new QToolButton( discFrame ); - nextButton->setIcon( QIcon( ":/dvd_next" ) ); + nextButton->setIcon( QIcon( ":/toolbar/dvd_next" ) ); discLayout->addWidget( nextButton ); widget = discFrame; @@ -388,11 +392,11 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 ); QToolButton *telexOn = new QToolButton( telexFrame ); - telexOn->setIcon( QIcon( ":/tv" ) ); + telexOn->setIcon( QIcon( ":/toolbar/tv" ) ); telexLayout->addWidget( telexOn ); QToolButton *telexTransparent = new QToolButton; - telexOn->setIcon( QIcon( ":/tvtelx" ) ); + telexOn->setIcon( QIcon( ":/toolbar/tvtelx" ) ); telexLayout->addWidget( telexTransparent ); QSpinBox *telexPage = new QSpinBox; @@ -480,7 +484,6 @@ void DroppingController::resetLine( const QString& line ) { hide(); QLayoutItem *child; - int i =0; while( (child = controlLayout->takeAt( 0 ) ) != 0 ) { child->widget()->hide(); @@ -498,11 +501,15 @@ void DroppingController::createAndAddWidget( QBoxLayout *controlLayout, buttonType_e i_type, int i_option ) { + doubleInt *value = new doubleInt; + value->i_type = i_type; + value->i_option = i_option; + /* Special case for SPACERS, who aren't QWidgets */ if( i_type == WIDGET_SPACER || i_type == WIDGET_SPACER_EXTEND ) { QLabel *label = new QLabel( this ); - label->setPixmap( QPixmap( ":/space" ) ); + label->setPixmap( QPixmap( ":/toolbar/space" ) ); if( i_type == WIDGET_SPACER_EXTEND ) { label->setSizePolicy( QSizePolicy::MinimumExpanding, @@ -541,7 +548,7 @@ void DroppingController::createAndAddWidget( QBoxLayout *controlLayout, foreach( child, children ) { QWidget *childWidg; - if( childWidg = qobject_cast( child ) ) + if( ( childWidg = qobject_cast( child ) ) ) { child->installEventFilter( this ); childWidg->setEnabled( true ); @@ -567,10 +574,6 @@ void DroppingController::createAndAddWidget( QBoxLayout *controlLayout, /* QList and QBoxLayout don't act the same with insert() */ if( i_index < 0 ) i_index = controlLayout->count() - 1; - /* Insert in the value listing */ - doubleInt *value = new doubleInt; - value->i_type = i_type; - value->i_option = i_option; widgetList.insert( i_index, value ); } @@ -647,16 +650,14 @@ inline int DroppingController::getParentPosInLayout( QPoint point ) QPoint origin = mapToGlobal ( point ); QWidget *tempWidg = QApplication::widgetAt( origin ); + if( tempWidg == NULL ) + return -1; - int i = -1; - if( tempWidg != NULL) + int i = controlLayout->indexOf( tempWidg ); + if( i == -1 ) { - i = controlLayout->indexOf( tempWidg ); - if( i == -1 ) - { - i = controlLayout->indexOf( tempWidg->parentWidget() ); - tempWidg = tempWidg->parentWidget(); - } + i = controlLayout->indexOf( tempWidg->parentWidget() ); + tempWidg = tempWidg->parentWidget(); } /* Return the nearest position */ @@ -671,6 +672,11 @@ void DroppingController::dropEvent( QDropEvent *event ) { int i = getParentPosInLayout( event->pos() ); + /* Workaround: do not let the item move to its current + position + 1 as it breaks the widgetList */ + if ( i - 1 == i_dragIndex ) + --i; + QByteArray data = event->mimeData()->data( "vlc/button-bar" ); QDataStream dataStream(&data, QIODevice::ReadOnly); @@ -726,6 +732,8 @@ bool DroppingController::eventFilter( QObject *obj, QEvent *event ) } if( i == -1 ) return true; + i_dragIndex = i; + doubleInt *dI = widgetList.at( i ); int i_type = dI->i_type; @@ -739,12 +747,14 @@ bool DroppingController::eventFilter( QObject *obj, QEvent *event ) QDrag *drag = new QDrag( widg ); drag->setMimeData( mimeData ); + /* Remove before the drag to not mess DropEvent, + that will createAndAddWidget */ + widgetList.removeAt( i ); + /* Start the effective drag */ drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction); - - widgetList.removeAt( i ); - controlLayout->removeWidget( widg ); widg->hide(); + controlLayout->removeWidget( widg ); b_draging = false; } return true;