diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp index 993555d20dde9dc214a344d60b6cecd7ec956177..96888ad819efaabe0d0c1daf10cf0795b6c02244 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp +++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp @@ -377,8 +377,6 @@ Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const #endif a->setAction(baseAction); m_mainWnd->addAction(baseAction); - a->setKeySequence(a->keySequence()); - a->setDefaultKeySequence(QKeySequence()); } else if (checkUnique) { qWarning() << "registerOverridableAction: id" << id << "is already registered."; } @@ -417,9 +415,6 @@ Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const Id &i else sc->setContext(context); - sc->setKeySequence(shortcut->key()); - sc->setDefaultKeySequence(QKeySequence()); - return sc; } diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp index 2c37d312492a2470ff3aaec5ef63b7565872a954..ccf4ccd56eed754491c7ae56d4b4de6bb8c76cb1 100644 --- a/src/plugins/coreplugin/actionmanager/command.cpp +++ b/src/plugins/coreplugin/actionmanager/command.cpp @@ -200,12 +200,14 @@ using namespace Core::Internal; */ CommandPrivate::CommandPrivate(int id) - : m_attributes(0), m_id(id) + : m_attributes(0), m_id(id), m_isKeyInitialized(false) { } void CommandPrivate::setDefaultKeySequence(const QKeySequence &key) { + if (!m_isKeyInitialized) + setKeySequence(key); m_defaultKey = key; } @@ -214,6 +216,12 @@ QKeySequence CommandPrivate::defaultKeySequence() const return m_defaultKey; } +void CommandPrivate::setKeySequence(const QKeySequence &key) +{ + Q_UNUSED(key) + m_isKeyInitialized = true; +} + void CommandPrivate::setDefaultText(const QString &text) { m_defaultText = text; @@ -306,15 +314,9 @@ Core::Context Shortcut::context() const return m_context; } -void Shortcut::setDefaultKeySequence(const QKeySequence &key) -{ - if (m_shortcut->key().isEmpty()) - setKeySequence(key); - CommandPrivate::setDefaultKeySequence(key); -} - void Shortcut::setKeySequence(const QKeySequence &key) { + CommandPrivate::setKeySequence(key); m_shortcut->setKey(key); emit keySequenceChanged(); } @@ -405,15 +407,9 @@ QList<CommandLocation> Action::locations() const return m_locations; } -void Action::setDefaultKeySequence(const QKeySequence &key) -{ - if (m_action->shortcut().isEmpty()) - setKeySequence(key); - CommandPrivate::setDefaultKeySequence(key); -} - void Action::setKeySequence(const QKeySequence &key) { + CommandPrivate::setKeySequence(key); m_action->setShortcut(key); updateToolTipWithKeySequence(); emit keySequenceChanged(); @@ -538,3 +534,4 @@ void Action::setActive(bool state) emit activeStateChanged(); } } + diff --git a/src/plugins/coreplugin/actionmanager/command_p.h b/src/plugins/coreplugin/actionmanager/command_p.h index 12ed105afdc5634de5da124f7fd18018a88ed6b9..a7bac35da14fb23030d240be47e57029486df6e2 100644 --- a/src/plugins/coreplugin/actionmanager/command_p.h +++ b/src/plugins/coreplugin/actionmanager/command_p.h @@ -53,6 +53,8 @@ public: void setDefaultKeySequence(const QKeySequence &key); QKeySequence defaultKeySequence() const; + void setKeySequence(const QKeySequence &key); + void setDefaultText(const QString &text); QString defaultText() const; @@ -78,6 +80,7 @@ protected: int m_id; QKeySequence m_defaultKey; QString m_defaultText; + bool m_isKeyInitialized; }; class Shortcut : public CommandPrivate @@ -88,7 +91,6 @@ public: QString name() const; - void setDefaultKeySequence(const QKeySequence &key); void setKeySequence(const QKeySequence &key); QKeySequence keySequence() const; @@ -116,7 +118,6 @@ public: QString name() const; - void setDefaultKeySequence(const QKeySequence &key); void setKeySequence(const QKeySequence &key); QKeySequence keySequence() const; diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index 1b0a14e329821869c5fb2d6ea8a5c71e4afc2264..8d086473f42e1c78581c807834a9625e4666b640 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -198,6 +198,9 @@ void ModeManager::objectAdded(QObject *obj) connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updateModeToolTip())); for (int i = 0; i < d->m_modeShortcuts.size(); ++i) { Command *currentCmd = d->m_modeShortcuts.at(i); + // we need this hack with currentlyHasDefaultSequence + // because we call setDefaultShortcut multiple times on the same cmd + // and still expect the current shortcut to change with it bool currentlyHasDefaultSequence = (currentCmd->keySequence() == currentCmd->defaultKeySequence()); #ifdef Q_WS_MAC