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

List:       kde-commits
Subject:    KDE/kdelibs/kdeui/actions
From:       Albert Astals Cid <tsdgeos () terra ! es>
Date:       2010-01-23 21:14:10
Message-ID: 1264281250.820581.14570.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1079215 by aacid:

Center widget actions to follow what non widget actions do
This should be fixed in Qt but they refused shielding in "it has been broken forever"
so we are fixing it in KDE
As it is a somewhat dangerous change i'm only doing it for KDE 4.5 so we have time to
evaluate if it breaks something
BUGS: 165274


 M  +18 -0     kaction.cpp  
 M  +7 -0      kaction.h  
 M  +1 -1      kactionmenu.cpp  
 M  +1 -1      kselectaction.cpp  
 M  +1 -1      ktoolbarpopupaction.cpp  


--- trunk/KDE/kdelibs/kdeui/actions/kaction.cpp #1079214:1079215
@@ -33,7 +33,9 @@
 #include "kauthactionwatcher.h"
 
 #include <QtGui/QApplication>
+#include <QtGui/QHBoxLayout>
 #include <QtGui/QShortcutEvent>
+#include <QtGui/QToolBar>
 
 #include <kdebug.h>
 
@@ -415,6 +417,22 @@
     }
 }
 
+QWidget *KAction::proxyWidget(QWidget *w) const
+{
+    QToolBar *tb = dynamic_cast<QToolBar *>(w->parentWidget());
+    if (tb)
+    {
+        QWidget *holder = new QWidget(tb);
+        QHBoxLayout *l = new QHBoxLayout(holder);
+        l->addWidget(w, 0, Qt::AlignCenter);
+        return holder;
+    }
+    else
+    {
+        return w;
+    }
+}
+
 /* vim: et sw=2 ts=2
  */
 
--- trunk/KDE/kdelibs/kdeui/actions/kaction.h #1079214:1079215
@@ -534,6 +534,13 @@
      */
     void globalShortcutChanged(const QKeySequence&);
 
+protected:
+    /**
+     * Call this from your createWidget function to make sure
+     * your action widget is properly centered in vertical toolbars
+     */
+    QWidget *proxyWidget(QWidget *w) const;
+    
 private:
     friend class KGlobalAccelPrivate; // Needs access to the component
     friend class KActionCollectionPrivate; // Needs access to the component
--- trunk/KDE/kdelibs/kdeui/actions/kactionmenu.cpp #1079214:1079215
@@ -101,7 +101,7 @@
   else
     button->setPopupMode(QToolButton::MenuButtonPopup);
 
-  return button;
+  return proxyWidget(button);
 }
 
 void KActionMenu::remove( KAction* cmd )
--- trunk/KDE/kdelibs/kdeui/actions/kselectaction.cpp #1079214:1079215
@@ -546,7 +546,7 @@
       button->addActions(selectableActionGroup()->actions());
 
       d->m_buttons.append(button);
-      return button;
+      return proxyWidget(button);
     }
 
     case ComboBoxMode: {
--- trunk/KDE/kdelibs/kdeui/actions/ktoolbarpopupaction.cpp #1079214:1079215
@@ -92,7 +92,7 @@
   else
     button->setPopupMode( QToolButton::InstantPopup );
 
-  return button;
+  return proxyWidget( button );
 }
 
 bool KToolBarPopupAction::delayed() const
[prev in list] [next in list] [prev in thread] [next in thread] 

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