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

List:       kde-commits
Subject:    KDE/kdevplatform/sublime
From:       Milian Wolff <mail () milianw ! de>
Date:       2009-10-28 23:12:22
Message-ID: 1256771542.100202.22129.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1042008 by mwolff:

fix the Tool View menu, i.e. make it possible to toggle dock views from it, not only enable them.
problem is that QActions in a QActionCollection that is set to exclusive cannot be _unchecked_.
=> Remove the collection and check manually that only one widget is visible per bar at any time.

 M  +13 -5     ideal.cpp  
 M  +0 -1      ideal.h  


--- trunk/KDE/kdevplatform/sublime/ideal.cpp #1042007:1042008
@@ -165,12 +165,8 @@
 IdealButtonBarWidget::IdealButtonBarWidget(Qt::DockWidgetArea area, IdealMainWidget *parent)
     : QWidget(parent)
     , _area(area)
-    , _actions(new QActionGroup(this))
     , _corner(0)
 {
-    // TODO Only for now...
-    _actions->setExclusive(true);
-
     if (area == Qt::BottomDockWidgetArea)
     {
         QBoxLayout *statusLayout = new QBoxLayout(QBoxLayout::RightToLeft, this);
@@ -214,7 +210,6 @@
     connect(action, SIGNAL(toggled(bool)), this, SLOT(showWidget(bool)));
 
     addAction(action);
-    _actions->addAction(action);
 
     return action;
 }
@@ -250,6 +245,19 @@
 
     IdealDockWidget *widget = _widgets.value(action);
     Q_ASSERT(widget);
+    
+    if ( checked ) {
+        // Make sure only one widget is visible at any time.
+        // The alternative to use a QActionCollection and setting that to "exclusive"
+        // has a big drawback: QActions in a collection that is exclusive cannot
+        // be un-checked by the user, e.g. in the View -> Tool Views menu.
+        foreach(QAction *otherAction, actions()) {
+            if ( otherAction != action && otherAction->isChecked() ) {
+                otherAction->setChecked(false);
+                break;
+            }
+        }
+    }
 
     parentWidget()->showDockWidget(widget, checked);
 }
--- trunk/KDE/kdevplatform/sublime/ideal.h #1042007:1042008
@@ -100,7 +100,6 @@
     Qt::DockWidgetArea _area;
     QHash<QAction *, IdealToolButton *> _buttons;
     QHash<QAction *, IdealDockWidget*> _widgets;
-    QActionGroup* _actions;
     QWidget *_corner;
 };
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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