[vlc-commits] Qt: SimplePreferences: Don't use QButtonGroup (fix #8609)

Francois Cartegnie git at videolan.org
Sat May 18 14:42:36 CEST 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat May 18 14:40:52 2013 +0200| [514a59441ff442372efab7d1123d93982ba22ceb] | committer: Francois Cartegnie

Qt: SimplePreferences: Don't use QButtonGroup (fix #8609)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=514a59441ff442372efab7d1123d93982ba22ceb
---

 modules/gui/qt4/components/simple_preferences.cpp |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp
index 0467cc0..47170c8 100644
--- a/modules/gui/qt4/components/simple_preferences.cpp
+++ b/modules/gui/qt4/components/simple_preferences.cpp
@@ -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"),



More information about the vlc-commits mailing list