[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/actions
From: Andreas Pakulat <apaku () gmx ! de>
Date: 2009-05-06 11:29:06
Message-ID: 1241609346.425602.17278.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 964242 by apaku:
Disable the action when there are no subactions as it doesn't make sense to
have the menu open in that case.
M +21 -3 kselectaction.cpp
--- trunk/KDE/kdelibs/kdeui/actions/kselectaction.cpp #964241:964242
@@ -106,6 +106,7 @@
QObject::connect(q_ptr->selectableActionGroup(), SIGNAL(triggered(QAction*)), \
q_ptr, SLOT(actionTriggered(QAction*))); QObject::connect(q_ptr, \
SIGNAL(toggled(bool)), q_ptr, SLOT(slotToggled(bool))); q_ptr->setMenu(new KMenu());
+ q_ptr->setEnabled( false );
}
QActionGroup * KSelectAction::selectableActionGroup( ) const
@@ -240,13 +241,20 @@
//kDebug (129) << "KSelectAction::addAction(" << action << ")";
action->setActionGroup(selectableActionGroup());
+
+ // Re-Enable when an action is added
+ setEnabled(true);
// Keep in sync with createToolBarWidget()
- foreach (QToolButton* button, d->m_buttons)
+ foreach (QToolButton* button, d->m_buttons) {
+ button->setEnabled(true);
button->addAction(action);
+ }
- foreach (KComboBox* comboBox, d->m_comboBoxes)
+ foreach (KComboBox* comboBox, d->m_comboBoxes) {
+ comboBox->setEnabled(true);
comboBox->addAction(action);
+ }
menu()->addAction(action);
}
@@ -285,14 +293,24 @@
// Removes the action from the group and sets its parent to null.
d->m_actionGroup->removeAction(action);
- foreach (QToolButton* button, d->m_buttons)
+ // Disable when no action is in the group
+ bool hasActions = selectableActionGroup()->actions().isEmpty();
+ setEnabled( !hasActions );
+
+ foreach (QToolButton* button, d->m_buttons) {
+ button->setEnabled( !hasActions );
button->removeAction(action);
+ }
foreach (KComboBox* comboBox, d->m_comboBoxes)
+ {
+ comboBox->setEnabled( !hasActions );
comboBox->removeAction(action);
+ }
menu()->removeAction(action);
+
return action;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic