]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/preferences_widgets.cpp
Qt4 - Complete preferences. Make ModuleList Clearer than it is now... Align SpinBox...
[vlc] / modules / gui / qt4 / components / preferences_widgets.cpp
index 382640ecca57408b0917aebdd6a7cc8bab5710df..f169a91a9f1c922fda1d977c3a79e24d76c2960b 100644 (file)
@@ -47,6 +47,7 @@
 #include <QSlider>
 #include <QFileDialog>
 #include <QFontDialog>
+#include <QGroupBox>
 
 #include <vlc_keys.h>
 
@@ -225,7 +226,11 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
 {
     label = new QLabel( qfu(p_item->psz_text) );
     text = new QLineEdit( qfu(p_item->value.psz) );
-    browse = new QPushButton( qtr( "Browse" ) );
+    browse = new QPushButton( qtr( "Browse..." ) );
+    QHBoxLayout *textAndButton = new QHBoxLayout();
+    textAndButton->setMargin( 0 );
+    textAndButton->addWidget( text, 2 );
+    textAndButton->addWidget( browse, 0 );
 
     BUTTONACT( browse, updateField() );
 
@@ -234,14 +239,14 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
     if( !l )
     {
         QHBoxLayout *layout = new QHBoxLayout();
-        layout->addWidget( label, 0 ); layout->addWidget( text, 1 );
-        layout->addWidget( browse, 2 );
+        layout->addWidget( label, 0 );
+        layout->addLayout( textAndButton, 1 );
         widget->setLayout( layout );
     }
     else
     {
-        l->addWidget( label, line, 0 ); l->addWidget( text, line, 1 );
-        l->addWidget( browse, line, 2 );
+        l->addWidget( label, line, 0 );
+        l->addLayout( textAndButton, line, 1 );
     }
 }
 
@@ -464,26 +469,30 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
                QGridLayout *l, int &line) :
                VStringConfigControl( _p_this, _p_item, _parent )
 {
-    label = new QLabel( qfu(p_item->psz_text) );
+    groupBox = new QGroupBox ( qfu(p_item->psz_text) );
     text = new QLineEdit();
+    QGridLayout *layoutGroupBox = new QGridLayout( groupBox );
+
     finish( bycat );
 
-    bool pom = false;
+    int boxline = 0;
+    for( QVector<QCheckBox*>::iterator it = modules.begin();
+         it != modules.end(); it++ )
+    {
+        layoutGroupBox->addWidget( *it, boxline++, 0 );
+    }
+    layoutGroupBox->addWidget( text, boxline, 0 );
+
     if( !l )
     {
-        l = new QGridLayout();
-        line = 0;
-        pom = true;
+        QVBoxLayout *layout = new QVBoxLayout();
+        layout->addWidget( groupBox, line, 0 );
+        widget->setLayout( layout );
     }
-    for( QVector<QCheckBox*>::iterator it = modules.begin();
-         it != modules.end(); it++ )
+    else
     {
-        l->addWidget( *it, line++, 1 );
+        l->addWidget( groupBox, line, 0, 1, -1 );
     }
-    l->addWidget( label, line, 0 );
-    l->addWidget( text, line, 1 );
-    if( pom )
-        widget->setLayout( l );
 }
 #if 0
 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
@@ -503,7 +512,7 @@ ModuleListConfigControl::~ModuleListConfigControl()
     {
         delete *it;
     }
-    delete label;
+    delete groupBox;
     delete text;
 }
 
@@ -546,8 +555,8 @@ void ModuleListConfigControl::finish( bool bycat )
     }
     vlc_list_release( p_list );
     text->setToolTip( qfu(p_item->psz_longtext) );
-    if( label )
-        label->setToolTip( qfu(p_item->psz_longtext) );
+    if( groupBox )
+        groupBox->setToolTip( qfu(p_item->psz_longtext) );
 }
 
 QString ModuleListConfigControl::getValue()
@@ -562,8 +571,7 @@ void ModuleListConfigControl::hide()
     {
         (*it)->hide();
     }
-    text->hide();
-    label->hide();
+    groupBox->hide();
 }
 
 void ModuleListConfigControl::show()
@@ -573,8 +581,7 @@ void ModuleListConfigControl::show()
     {
         (*it)->show();
     }
-    text->show();
-    label->show();
+    groupBox->show();
 }
 
 
@@ -600,6 +607,7 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
 {
     label = new QLabel( qfu(p_item->psz_text) );
     spin = new QSpinBox; spin->setMinimumWidth( 80 );
+    spin->setAlignment( Qt::AlignRight );
     spin->setMaximumWidth( 90 );
     finish();
 
@@ -795,6 +803,7 @@ FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
     label = new QLabel( qfu(p_item->psz_text) );
     spin = new QDoubleSpinBox; spin->setMinimumWidth( 80 );
     spin->setMaximumWidth( 90 );
+    spin->setAlignment( Qt::AlignRight );
     finish();
 
     if( !l )
@@ -986,16 +995,13 @@ KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _values,
     l->addLayout( l2 );
 }
 
-void KeyInputDialog::keyPressEvent( QKeyEvent *e )
+void KeyInputDialog::checkForConflicts( int i_vlckey )
 {
-    if( e->key() == Qt::Key_Tab ) return;
-    int i_vlck = qtEventToVLCKey( e );
-    selected->setText( VLCKeyToString( i_vlck ) );
     conflicts = false;
     module_config_t *p_current = NULL;
     foreach( p_current, values )
     {
-        if( p_current->value.i == i_vlck && strcmp( p_current->psz_text,
+        if( p_current->value.i == i_vlckey && strcmp( p_current->psz_text,
                                                     keyToChange ) )
         {
             p_current->value.i = 0;
@@ -1010,5 +1016,21 @@ void KeyInputDialog::keyPressEvent( QKeyEvent *e )
           QString( p_current->psz_text ) + "\"" );
     }
     else warning->setText( "" );
+}
+
+void KeyInputDialog::keyPressEvent( QKeyEvent *e )
+{
+    if( e->key() == Qt::Key_Tab ) return;
+    int i_vlck = qtEventToVLCKey( e );
+    selected->setText( VLCKeyToString( i_vlck ) );
+    checkForConflicts( i_vlck );
+    keyValue = i_vlck;
+}
+
+void KeyInputDialog::wheelEvent( QWheelEvent *e )
+{
+    int i_vlck = qtWheelEventToVLCKey( e );
+    selected->setText( VLCKeyToString( i_vlck ) );
+    checkForConflicts( i_vlck );
     keyValue = i_vlck;
 }