[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    KDE/kdelibs/kdeui
From:       Friedrich W. H. Kossebau <kossebau () kde ! org>
Date:       2009-01-10 2:15:57
Message-ID: 1231553757.707405.19109.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 908643 by kossebau:

fixed: if KSelectAction gets disabled, its KComboBox isn't (workaround for QWidgetAction flaw)

KSelectAction has the problem that it does not disable its KComboBox, if is disabled itself.
It works if it is in MenuMode, because there KSelectAction creates a QToolButton and sets itself
as the default action. As a QToolButton reacts to changes of its default action it also syncs with
the enabled state. One would expect that the base class QWidgetAction does this itself also for all
other widgets, but obviously it doesn't (Qt 4.4.3). Reported to the Trolls.

Is there a smarter solution?
Okay to backport to 4.2?

CCMAIL:kde-core-devel@kde.org


 M  +3 -0      actions/kselectaction.cpp  
 M  +10 -1     widgets/kcombobox.cpp  


--- trunk/KDE/kdelibs/kdeui/actions/kselectaction.cpp #908642:908643
@@ -533,6 +533,9 @@
     case ComboBoxMode: {
         KComboBox* comboBox = new KComboBox(parent);
       comboBox->installEventFilter (this);
+      // hack for the fact that QWidgetAction does not sync all its created widgets
+      // to its enabled state, just QToolButtons (Qt 4.4.3)
+      installEventFilter( comboBox );
 
       if ( d->m_maxComboViewCount != -1 )
         comboBox->setMaxVisibleItems( d->m_maxComboViewCount );
--- trunk/KDE/kdelibs/kdeui/widgets/kcombobox.cpp #908642:908643
@@ -28,6 +28,7 @@
 #include <QtGui/QApplication>
 #include <QtGui/QActionEvent>
 
+#include <kselectaction.h>
 #include <kcompletionbox.h>
 #include <kcursor.h>
 #include <kiconloader.h>
@@ -174,9 +175,17 @@
         d->klineEdit->rotateText( type );
 }
 
-// not needed anymore
 bool KComboBox::eventFilter( QObject* o, QEvent* ev )
 {
+    // hack for the fact that QWidgetAction does not sync all its created widgets
+    // to its enabled state, just QToolButtons (Qt 4.4.3)
+    if( ev->type() == QEvent::ActionChanged )
+    {
+        KSelectAction* selectAction = qobject_cast<KSelectAction*>( o );
+        if ( selectAction )
+            setEnabled( selectAction->isEnabled() );
+    }
+
     return QComboBox::eventFilter( o, ev );
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic