]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/preferences_widgets.cpp
qt4 - Mousewheel (2)
[vlc] / modules / gui / qt4 / components / preferences_widgets.cpp
index aea238411db1f92e06f2448ae40fe6e0e65fc1fa..90bc37917b94723d28cb1f8bd8f082045d3bd09d 100644 (file)
@@ -46,6 +46,7 @@
 #include <QPushButton>
 #include <QSlider>
 #include <QFileDialog>
+#include <QFontDialog>
 
 #include <vlc_keys.h>
 
@@ -110,6 +111,10 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
         p_control = new DirectoryConfigControl( p_this, p_item, parent, l,
                                                 line, false );
         break;
+    case CONFIG_ITEM_FONT:
+        p_control = new FontConfigControl( p_this, p_item, parent, l,
+                                           line, false );
+        break;
     case CONFIG_ITEM_KEY:
         p_control = new KeySelectorControl( p_this, p_item, parent, l, line );
         break;
@@ -220,7 +225,7 @@ 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..." ) );
 
     BUTTONACT( browse, updateField() );
 
@@ -273,7 +278,6 @@ void FileConfigControl::finish()
 }
 
 /********* String / Directory **********/
-
 DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
                         module_config_t *_p_item, QWidget *_p_widget,
                         QGridLayout *_p_layout, int& _int, bool _pwd ) :
@@ -286,17 +290,39 @@ DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
      FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button, _pwd)
 {}
 
-
 void DirectoryConfigControl::updateField()
 {
     QString dir = QFileDialog::getExistingDirectory( NULL,
                       qtr( "Select Directory" ),
-                      qfu( p_this->p_libvlc->psz_homedir ),
-                      QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
+                      text->text().isEmpty() ?
+                        qfu( p_this->p_libvlc->psz_homedir ) : text->text(),
+                      QFileDialog::ShowDirsOnly |
+                        QFileDialog::DontResolveSymlinks );
     if( dir.isNull() ) return;
     text->setText( dir );
 }
 
+/********* String / Font **********/
+FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
+                        module_config_t *_p_item, QWidget *_p_widget,
+                        QGridLayout *_p_layout, int& _int, bool _pwd ) :
+     FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int, _pwd)
+{}
+
+FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
+                        module_config_t *_p_item, QLabel *_p_label,
+                        QLineEdit *_p_line, QPushButton *_p_button, bool _pwd ):
+     FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button, _pwd)
+{}
+
+void FontConfigControl::updateField()
+{
+    bool ok;
+    QFont font = QFontDialog::getFont( &ok, QFont( text->text() ), NULL );
+    if( !ok ) return;
+    text->setText( font.family() );
+}
+
 /********* String / choice list **********/
 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
                module_config_t *_p_item, QWidget *_parent, bool bycat,
@@ -960,16 +986,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;
@@ -984,5 +1007,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;
 }