summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2009-04-23 12:26:19 (GMT)
committerjasplin <qt-info@nokia.com>2009-04-23 12:36:09 (GMT)
commitb51dd5a7b328291c5dbda540ce228e7d867662cb (patch)
tree2ba45f66aec3d27d9881d6ec1d655d31deaf0de2 /src/gui
parentaa234610048a741cddc991be25b84d235f40e345 (diff)
downloadQt-b51dd5a7b328291c5dbda540ce228e7d867662cb.zip
Qt-b51dd5a7b328291c5dbda540ce228e7d867662cb.tar.gz
Qt-b51dd5a7b328291c5dbda540ce228e7d867662cb.tar.bz2
Revert "Fixed key sequence eating behavior for QShortcut and QAction."
This reverts commit 031adeaf42ddaef8d01338f6c59ba97170be5d53. The patch had some unforeseen side-effects for Creator. It may also affect other existing applications in a similar way. For now, this behavior (eating key sequences for disabled shortcuts) should be achieved using a local workaround in creator. Reviewed-by: mariusSO Task-number: 251246
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qaction.cpp47
-rw-r--r--src/gui/kernel/qaction_p.h1
-rw-r--r--src/gui/kernel/qshortcut.cpp20
-rw-r--r--src/gui/kernel/qshortcutmap.cpp9
4 files changed, 27 insertions, 50 deletions
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index 4edc1ca..abb17d7 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -136,27 +136,25 @@ void QActionPrivate::redoGrab(QShortcutMap &map)
void QActionPrivate::redoGrabAlternate(QShortcutMap &map)
{
Q_Q(QAction);
- for (int i = 0; i < alternateShortcutIds.size(); ++i)
- if (int id = alternateShortcutIds.at(i))
+ foreach (int id, alternateShortcutIds)
+ if (id)
map.removeShortcut(id, q);
alternateShortcutIds.clear();
if (alternateShortcuts.isEmpty())
return;
- for (int i = 0; i < alternateShortcuts.size(); ++i) {
- const QKeySequence &alternate = alternateShortcuts.at(i);
+ foreach (const QKeySequence& alternate, alternateShortcuts) {
if (!alternate.isEmpty())
alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext));
else
alternateShortcutIds.append(0);
}
-
if (!enabled) {
- for (int i = 0; i < alternateShortcutIds.size(); ++i)
- map.setShortcutEnabled(false, alternateShortcutIds.at(i), q);
+ foreach (int id, alternateShortcutIds)
+ map.setShortcutEnabled(false, id, q);
}
if (!autorepeat) {
- for (int i = 0; i < alternateShortcutIds.size(); ++i)
- map.setShortcutAutoRepeat(false, alternateShortcutIds.at(i), q);
+ foreach (int id, alternateShortcutIds)
+ map.setShortcutAutoRepeat(false, id, q);
}
}
@@ -165,26 +163,10 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
Q_Q(QAction);
if (shortcutId)
map.setShortcutEnabled(enable, shortcutId, q);
- for (int i = 0; i < alternateShortcutIds.size(); ++i)
- if (int id = alternateShortcutIds.at(i))
+ foreach (int id, alternateShortcutIds)
+ if (id)
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
@@ -633,8 +615,8 @@ QAction::~QAction()
#ifndef QT_NO_SHORTCUT
if (d->shortcutId && qApp) {
qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this);
- for (int i = 0; i < d->alternateShortcutIds.size(); ++i)
- qApp->d_func()->shortcutMap.removeShortcut(d->alternateShortcutIds.at(i), this);
+ foreach (int id, d->alternateShortcutIds)
+ qApp->d_func()->shortcutMap.removeShortcut(id, this);
}
#endif
}
@@ -1067,12 +1049,7 @@ void QAction::setVisible(bool b)
d->visible = b;
d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ;
#ifndef QT_NO_SHORTCUT
- if (b) {
- d->redoGrab(qApp->d_func()->shortcutMap);
- d->redoGrabAlternate(qApp->d_func()->shortcutMap);
- } else {
- d->removeAll(qApp->d_func()->shortcutMap);
- }
+ d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap);
#endif
d->sendDataChanged();
}
diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h
index a5b3731..0617ef5 100644
--- a/src/gui/kernel/qaction_p.h
+++ b/src/gui/kernel/qaction_p.h
@@ -111,7 +111,6 @@ public:
void redoGrab(QShortcutMap &map);
void redoGrabAlternate(QShortcutMap &map);
void setShortcutEnabled(bool enable, QShortcutMap &map);
- void removeAll(QShortcutMap &map);
static QShortcutMap *globalMap;
#endif // QT_NO_SHORTCUT
diff --git a/src/gui/kernel/qshortcut.cpp b/src/gui/kernel/qshortcut.cpp
index f3c93c6..50b6e59 100644
--- a/src/gui/kernel/qshortcut.cpp
+++ b/src/gui/kernel/qshortcut.cpp
@@ -385,21 +385,19 @@ bool QShortcut::event(QEvent *e)
{
Q_D(QShortcut);
bool handled = false;
- if (e->type() == QEvent::Shortcut) {
+ if (d->sc_enabled && e->type() == QEvent::Shortcut) {
QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){
- if (d->sc_enabled) {
#ifndef QT_NO_WHATSTHIS
- if (QWhatsThis::inWhatsThisMode()) {
- QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis);
- handled = true;
- } else
+ if (QWhatsThis::inWhatsThisMode()) {
+ QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis);
+ handled = true;
+ } else
#endif
- if (se->isAmbiguous())
- emit activatedAmbiguously();
- else
- emit activated();
- }
+ if (se->isAmbiguous())
+ emit activatedAmbiguously();
+ else
+ emit activated();
handled = true;
}
}
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index 415d71e..1babeb6 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -368,8 +368,9 @@ bool QShortcutMap::tryShortcutEvent(QObject *o, QKeyEvent *e)
default:
break;
}
-
- return true;
+ // If nextState is QKeySequence::ExactMatch && identicals.count == 0
+ // we've only found disabled shortcuts
+ return identicalMatches > 0 || result == QKeySequence::PartialMatch;
}
/*! \internal
@@ -491,7 +492,9 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e)
// We don't need partials, if we have identicals
if (d->identicals.size())
break;
- partialFound = true;
+ // We only care about enabled partials, so we don't consume
+ // key events when all partials are disabled!
+ partialFound |= (*it).enabled;
}
}
++it;