summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qaction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qaction.cpp')
-rw-r--r--src/gui/kernel/qaction.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index a7f458f..59b00b8 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -76,7 +76,7 @@ static QString qt_strippedText(QString s)
s.remove(i-1,1);
}
return s.trimmed();
-};
+}
QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
@@ -136,25 +136,31 @@ 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.count(); ++i) {
+ if (const 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.count(); ++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)
+ for(int i = 0; i < alternateShortcutIds.count(); ++i) {
+ const int id = alternateShortcutIds.at(i);
map.setShortcutEnabled(false, id, q);
+ }
}
if (!autorepeat) {
- foreach (int id, alternateShortcutIds)
+ for(int i = 0; i < alternateShortcutIds.count(); ++i) {
+ const int id = alternateShortcutIds.at(i);
map.setShortcutAutoRepeat(false, id, q);
+ }
}
}
@@ -163,9 +169,10 @@ 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.count(); ++i) {
+ if (const int id = alternateShortcutIds.at(i))
map.setShortcutEnabled(enable, id, q);
+ }
}
#endif // QT_NO_SHORTCUT
@@ -615,8 +622,10 @@ QAction::~QAction()
#ifndef QT_NO_SHORTCUT
if (d->shortcutId && qApp) {
qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this);
- foreach (int id, d->alternateShortcutIds)
+ for(int i = 0; i < d->alternateShortcutIds.count(); ++i) {
+ const int id = d->alternateShortcutIds.at(i);
qApp->d_func()->shortcutMap.removeShortcut(id, this);
+ }
}
#endif
}
@@ -1151,6 +1160,8 @@ void QAction::activate(ActionEvent event)
// the checked action of an exclusive group cannot be unchecked
if (d->checked && (d->group && d->group->isExclusive()
&& d->group->checkedAction() == this)) {
+ if (guard)
+ emit triggered(true);
QMetaObject::removeGuard(&guard);
return;
}
@@ -1368,7 +1379,7 @@ QAction::MenuRole QAction::menuRole() const
void QAction::setIconVisibleInMenu(bool visible)
{
Q_D(QAction);
- if (visible != (bool)d->iconVisibleInMenu) {
+ if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) {
int oldValue = d->iconVisibleInMenu;
d->iconVisibleInMenu = visible;
// Only send data changed if we really need to.