diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-04-20 16:30:01 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-04-20 16:30:01 (GMT) |
commit | 4708acb70e1e71bf22e85f7335dcaf1401aba3bb (patch) | |
tree | 36043e3def5d50dde51846dea44e376e902524ac /src/gui/kernel/qaction.cpp | |
parent | 556216129bf5738c6ad92807ece1dac233b8b96f (diff) | |
parent | 07703ade86edcd6565c373f63e34306209d1a90a (diff) | |
download | Qt-4708acb70e1e71bf22e85f7335dcaf1401aba3bb.zip Qt-4708acb70e1e71bf22e85f7335dcaf1401aba3bb.tar.gz Qt-4708acb70e1e71bf22e85f7335dcaf1401aba3bb.tar.bz2 |
Merge branch '4.5'
Conflicts:
tests/auto/qaction/tst_qaction.cpp
Diffstat (limited to 'src/gui/kernel/qaction.cpp')
-rw-r--r-- | src/gui/kernel/qaction.cpp | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index c6addc1..921be22 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -136,25 +136,27 @@ void QActionPrivate::redoGrab(QShortcutMap &map) void QActionPrivate::redoGrabAlternate(QShortcutMap &map) { Q_Q(QAction); - foreach (int id, alternateShortcutIds) - if (id) + for (int i = 0; i < alternateShortcutIds.size(); ++i) + if (int id = alternateShortcutIds.at(i)) map.removeShortcut(id, q); alternateShortcutIds.clear(); if (alternateShortcuts.isEmpty()) return; - foreach (const QKeySequence& alternate, alternateShortcuts) { + for (int i = 0; i < alternateShortcuts.size(); ++i) { + const QKeySequence &alternate = alternateShortcuts.at(i); if (!alternate.isEmpty()) alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext)); else alternateShortcutIds.append(0); } + if (!enabled) { - foreach (int id, alternateShortcutIds) - map.setShortcutEnabled(false, id, q); + for (int i = 0; i < alternateShortcutIds.size(); ++i) + map.setShortcutEnabled(false, alternateShortcutIds.at(i), q); } if (!autorepeat) { - foreach (int id, alternateShortcutIds) - map.setShortcutAutoRepeat(false, id, q); + for (int i = 0; i < alternateShortcutIds.size(); ++i) + map.setShortcutAutoRepeat(false, alternateShortcutIds.at(i), q); } } @@ -163,10 +165,26 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) Q_Q(QAction); if (shortcutId) map.setShortcutEnabled(enable, shortcutId, q); - foreach (int id, alternateShortcutIds) - if (id) + for (int i = 0; i < alternateShortcutIds.size(); ++i) + if (int id = alternateShortcutIds.at(i)) map.setShortcutEnabled(enable, id, q); } + +void QActionPrivate::removeAll(QShortcutMap &map) +{ + Q_Q(QAction); + if (shortcutId) { + map.removeShortcut(shortcutId, q); + shortcutId = 0; + } + + for (int i = 0; i < alternateShortcutIds.size(); ++i) + if (int id = alternateShortcutIds.at(i)) + map.removeShortcut(id, q); + + alternateShortcutIds.clear(); +} + #endif // QT_NO_SHORTCUT @@ -615,8 +633,8 @@ QAction::~QAction() #ifndef QT_NO_SHORTCUT if (d->shortcutId && qApp) { qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); - foreach (int id, d->alternateShortcutIds) - qApp->d_func()->shortcutMap.removeShortcut(id, this); + for (int i = 0; i < d->alternateShortcutIds.size(); ++i) + qApp->d_func()->shortcutMap.removeShortcut(d->alternateShortcutIds.at(i), this); } #endif } @@ -1049,7 +1067,12 @@ void QAction::setVisible(bool b) d->visible = b; d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ; #ifndef QT_NO_SHORTCUT - d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap); + if (b) { + d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrabAlternate(qApp->d_func()->shortcutMap); + } else { + d->removeAll(qApp->d_func()->shortcutMap); + } #endif d->sendDataChanged(); } |