/*****************************************************************************
- * ToolbarEdit.cpp : ToolbarEdit and About dialogs
+ * ToolbarEdit.cpp : ToolbarEdit dialog
****************************************************************************
* Copyright (C) 2008-2009 the VideoLAN team
* $Id$
#include <QLabel>
#include <QComboBox>
#include <QListWidget>
+#include <QSpinBox>
#include <QDragEnterEvent>
#include <QDialogButtonBox>
#include <QInputDialog>
+#include <assert.h>
+
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 );
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,
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,
{
hide();
QLayoutItem *child;
- int i =0;
while( (child = controlLayout->takeAt( 0 ) ) != 0 )
{
child->widget()->hide();
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 )
{
foreach( child, children )
{
QWidget *childWidg;
- if( childWidg = qobject_cast<QWidget *>( child ) )
+ if( ( childWidg = qobject_cast<QWidget *>( child ) ) )
{
child->installEventFilter( this );
childWidg->setEnabled( true );
/* 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 );
}
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 */
{
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);
}
if( i == -1 ) return true;
+ i_dragIndex = i;
+
doubleInt *dI = widgetList.at( i );
int i_type = dI->i_type;
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;