]> git.sesse.net Git - vlc/commitdiff
Qt: SimplePreferences: Don't use QButtonGroup (fix #8609)
authorFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 18 May 2013 12:40:52 +0000 (14:40 +0200)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 18 May 2013 12:42:11 +0000 (14:42 +0200)
modules/gui/qt4/components/simple_preferences.cpp

index 0467cc090b0b4189d02913eac930af3f8e611d18..47170c857d757182584d69bd88d3d612f7cd1cf0 100644 (file)
@@ -37,7 +37,7 @@
 #include <QString>
 #include <QFont>
 #include <QToolButton>
-#include <QButtonGroup>
+#include <QSignalMapper>
 #include <QVBoxLayout>
 #include <QScrollArea>
 
@@ -61,10 +61,11 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool sma
 {
     QVBoxLayout *layout = new QVBoxLayout();
 
-    QButtonGroup *buttonGroup = new QButtonGroup( this );
-    buttonGroup->setExclusive ( true );
-    CONNECT( buttonGroup, buttonClicked ( int ),
-            this, switchPanel( int ) );
+    /* Use autoExclusive buttons and a mapper as QButtonGroup can't
+       set focus (keys) when it manages the buttons's exclusivity.
+       See QT bugs 131 & 816 and QAbstractButton's source code. */
+    QSignalMapper *mapper = new QSignalMapper( layout );
+    CONNECT( mapper, mapped(int), this, switchPanel(int) );
 
     short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
 
@@ -79,7 +80,9 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool sma
     button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ;  \
     button->setAutoRaise( true );                                           \
     button->setCheckable( true );                                           \
-    buttonGroup->addButton( button, numb );                                 \
+    button->setAutoExclusive( true );                                       \
+    CONNECT( button, clicked(), mapper, map() );                            \
+    mapper->setMapping( button, numb );                                     \
     layout->addWidget( button );
 
     ADD_CATEGORY( SPrefsInterface, qtr("Interface"), qtr("Interface Settings"),