forked from qt-creator/qt-creator
ActionManager: Remove QShortcut registration API
Registering QShortcuts doesn't solve any problem that is not already solved by registering QActions, and shortcuts are in fact much more limited (not being able to register multiple shortcuts for different contexts). Change-Id: I9478e601b2cbc3c5e12fb5baee43cacc20d0fb9c Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -258,56 +258,6 @@ Command *ActionManager::registerAction(QAction *action, Id id, const Context &co
|
||||
return a;
|
||||
}
|
||||
|
||||
/*!
|
||||
Makes a \a shortcut known to the system under the specified \a id.
|
||||
|
||||
Returns a command object that represents the shortcut in the application and is
|
||||
owned by the ActionManager. You can registered several shortcuts with the
|
||||
same \a id as long as the \a context is different. In this case
|
||||
a trigger of the actual shortcut is forwarded to the registered QShortcut
|
||||
for the currently active context.
|
||||
A scriptable shortcut can be called from a script without the need for the user
|
||||
to interact with it.
|
||||
*/
|
||||
Command *ActionManager::registerShortcut(QShortcut *shortcut, Id id, const Context &context, bool scriptable)
|
||||
{
|
||||
QTC_CHECK(!context.isEmpty());
|
||||
Shortcut *sc = 0;
|
||||
if (CommandPrivate *c = d->m_idCmdMap.value(id, 0)) {
|
||||
sc = qobject_cast<Shortcut *>(c);
|
||||
if (!sc) {
|
||||
qWarning() << "registerShortcut: id" << id.name()
|
||||
<< "is registered with a different command type.";
|
||||
return c;
|
||||
}
|
||||
} else {
|
||||
sc = new Shortcut(id);
|
||||
d->m_idCmdMap.insert(id, sc);
|
||||
}
|
||||
|
||||
if (sc->shortcut()) {
|
||||
qWarning() << "registerShortcut: action already registered, id" << id.name() << ".";
|
||||
return sc;
|
||||
}
|
||||
|
||||
if (!d->hasContext(context))
|
||||
shortcut->setEnabled(false);
|
||||
shortcut->setObjectName(id.toString());
|
||||
shortcut->setParent(ICore::mainWindow());
|
||||
shortcut->setContext(Qt::ApplicationShortcut);
|
||||
sc->setShortcut(shortcut);
|
||||
sc->setScriptable(scriptable);
|
||||
sc->setContext(context);
|
||||
d->readUserSettings(id, sc);
|
||||
|
||||
emit m_instance->commandListChanged();
|
||||
emit m_instance->commandAdded(id.toString());
|
||||
|
||||
if (isPresentationModeEnabled())
|
||||
connect(sc->shortcut(), SIGNAL(activated()), d, SLOT(shortcutTriggered()));
|
||||
return sc;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the Command object that is known to the system
|
||||
under the given \a id.
|
||||
@@ -350,7 +300,7 @@ ActionContainer *ActionManager::actionContainer(Id id)
|
||||
*/
|
||||
QList<Command *> ActionManager::commands()
|
||||
{
|
||||
// transform list of CommandPrivate into list of Command
|
||||
// transform list of Action into list of Command
|
||||
QList<Command *> result;
|
||||
foreach (Command *cmd, d->m_idCmdMap)
|
||||
result << cmd;
|
||||
@@ -367,10 +317,7 @@ QList<Command *> ActionManager::commands()
|
||||
*/
|
||||
void ActionManager::unregisterAction(QAction *action, Id id)
|
||||
{
|
||||
Action *a = 0;
|
||||
CommandPrivate *c = d->m_idCmdMap.value(id, 0);
|
||||
QTC_ASSERT(c, return);
|
||||
a = qobject_cast<Action *>(c);
|
||||
Action *a = d->m_idCmdMap.value(id, 0);
|
||||
if (!a) {
|
||||
qWarning() << "unregisterAction: id" << id.name()
|
||||
<< "is registered with a different command type.";
|
||||
@@ -388,31 +335,6 @@ void ActionManager::unregisterAction(QAction *action, Id id)
|
||||
emit m_instance->commandListChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes the knowledge about a shortcut under the specified \a id.
|
||||
|
||||
Usually you do not need to unregister shortcuts. The only valid use case for unregistering
|
||||
shortcuts, is for shortcuts that represent user definable actions. If the user removes such an action,
|
||||
a corresponding shortcut also has to be unregistered from the action manager,
|
||||
to make it disappear from shortcut settings etc.
|
||||
*/
|
||||
void ActionManager::unregisterShortcut(Id id)
|
||||
{
|
||||
Shortcut *sc = 0;
|
||||
CommandPrivate *c = d->m_idCmdMap.value(id, 0);
|
||||
QTC_ASSERT(c, return);
|
||||
sc = qobject_cast<Shortcut *>(c);
|
||||
if (!sc) {
|
||||
qWarning() << "unregisterShortcut: id" << id.name()
|
||||
<< "is registered with a different command type.";
|
||||
return;
|
||||
}
|
||||
delete sc->shortcut();
|
||||
d->m_idCmdMap.remove(id);
|
||||
delete sc;
|
||||
emit m_instance->commandListChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
Handles the display of the used shortcuts in the presentation mode. The presentation mode is
|
||||
enabled when starting \QC with the command line argument \c{-presentationMode}. In the
|
||||
@@ -431,12 +353,6 @@ void ActionManager::setPresentationModeEnabled(bool enabled)
|
||||
else
|
||||
disconnect(c->action(), SIGNAL(triggered()), d, SLOT(actionTriggered()));
|
||||
}
|
||||
if (c->shortcut()) {
|
||||
if (enabled)
|
||||
connect(c->shortcut(), SIGNAL(activated()), d, SLOT(shortcutTriggered()));
|
||||
else
|
||||
disconnect(c->shortcut(), SIGNAL(activated()), d, SLOT(shortcutTriggered()));
|
||||
}
|
||||
}
|
||||
|
||||
// The label for the shortcuts:
|
||||
@@ -538,13 +454,6 @@ void ActionManagerPrivate::actionTriggered()
|
||||
showShortcutPopup(action->shortcut().toString());
|
||||
}
|
||||
|
||||
void ActionManagerPrivate::shortcutTriggered()
|
||||
{
|
||||
QShortcut *sc = qobject_cast<QShortcut *>(QObject::sender());
|
||||
if (sc)
|
||||
showShortcutPopup(sc->key().toString());
|
||||
}
|
||||
|
||||
void ActionManagerPrivate::showShortcutPopup(const QString &shortcut)
|
||||
{
|
||||
if (shortcut.isEmpty() || !ActionManager::isPresentationModeEnabled())
|
||||
@@ -563,15 +472,8 @@ void ActionManagerPrivate::showShortcutPopup(const QString &shortcut)
|
||||
|
||||
Action *ActionManagerPrivate::overridableAction(Id id)
|
||||
{
|
||||
Action *a = 0;
|
||||
if (CommandPrivate *c = m_idCmdMap.value(id, 0)) {
|
||||
a = qobject_cast<Action *>(c);
|
||||
Action *a = m_idCmdMap.value(id, 0);
|
||||
if (!a) {
|
||||
qWarning() << "registerAction: id" << id.name()
|
||||
<< "is registered with a different command type.";
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
a = new Action(id);
|
||||
m_idCmdMap.insert(id, a);
|
||||
readUserSettings(id, a);
|
||||
@@ -587,7 +489,7 @@ Action *ActionManagerPrivate::overridableAction(Id id)
|
||||
return a;
|
||||
}
|
||||
|
||||
void ActionManagerPrivate::readUserSettings(Id id, CommandPrivate *cmd)
|
||||
void ActionManagerPrivate::readUserSettings(Id id, Action *cmd)
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(QLatin1String(kKeyboardSettingsKey));
|
||||
@@ -635,7 +537,7 @@ void ActionManagerPrivate::saveSettings(QSettings *settings)
|
||||
const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd();
|
||||
for (IdCmdMap::const_iterator j = m_idCmdMap.constBegin(); j != cmdcend; ++j) {
|
||||
const Id id = j.key();
|
||||
CommandPrivate *cmd = j.value();
|
||||
Action *cmd = j.value();
|
||||
QKeySequence key = cmd->keySequence();
|
||||
if (key != cmd->defaultKeySequence())
|
||||
settings->setValue(id.toString(), key.toString());
|
||||
|
||||
@@ -60,7 +60,6 @@ public:
|
||||
static ActionContainer *createMenuBar(Id id);
|
||||
|
||||
static Command *registerAction(QAction *action, Id id, const Context &context, bool scriptable = false);
|
||||
static Command *registerShortcut(QShortcut *shortcut, Id id, const Context &context, bool scriptable = false);
|
||||
|
||||
static Command *command(Id id);
|
||||
static ActionContainer *actionContainer(Id id);
|
||||
@@ -68,7 +67,6 @@ public:
|
||||
static QList<Command *> commands();
|
||||
|
||||
static void unregisterAction(QAction *action, Id id);
|
||||
static void unregisterShortcut(Id id);
|
||||
|
||||
static void setPresentationModeEnabled(bool enabled);
|
||||
static bool isPresentationModeEnabled();
|
||||
|
||||
@@ -48,16 +48,16 @@ namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class Action;
|
||||
class ActionContainerPrivate;
|
||||
class MainWindow;
|
||||
class CommandPrivate;
|
||||
|
||||
class ActionManagerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef QHash<Core::Id, CommandPrivate *> IdCmdMap;
|
||||
typedef QHash<Core::Id, Action *> IdCmdMap;
|
||||
typedef QHash<Core::Id, ActionContainerPrivate *> IdContainerMap;
|
||||
|
||||
explicit ActionManagerPrivate();
|
||||
@@ -74,13 +74,12 @@ public:
|
||||
bool hasContext(const Context &context) const;
|
||||
Action *overridableAction(Id id);
|
||||
|
||||
void readUserSettings(Id id, CommandPrivate *cmd);
|
||||
void readUserSettings(Id id, Action *cmd);
|
||||
|
||||
public slots:
|
||||
void containerDestroyed();
|
||||
|
||||
void actionTriggered();
|
||||
void shortcutTriggered();
|
||||
|
||||
public:
|
||||
IdCmdMap m_idCmdMap;
|
||||
|
||||
@@ -203,174 +203,14 @@
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
/*!
|
||||
\class CommandPrivate
|
||||
\internal
|
||||
*/
|
||||
|
||||
CommandPrivate::CommandPrivate(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;
|
||||
}
|
||||
|
||||
QKeySequence CommandPrivate::defaultKeySequence() const
|
||||
{
|
||||
return m_defaultKey;
|
||||
}
|
||||
|
||||
void CommandPrivate::setKeySequence(const QKeySequence &key)
|
||||
{
|
||||
Q_UNUSED(key)
|
||||
m_isKeyInitialized = true;
|
||||
}
|
||||
|
||||
void CommandPrivate::setDescription(const QString &text)
|
||||
{
|
||||
m_defaultText = text;
|
||||
}
|
||||
|
||||
QString CommandPrivate::description() const
|
||||
{
|
||||
if (!m_defaultText.isEmpty())
|
||||
return m_defaultText;
|
||||
if (action()) {
|
||||
QString text = action()->text();
|
||||
text.remove(QRegExp(QLatin1String("&(?!&)")));
|
||||
if (!text.isEmpty())
|
||||
return text;
|
||||
} else if (shortcut()) {
|
||||
if (!shortcut()->whatsThis().isEmpty())
|
||||
return shortcut()->whatsThis();
|
||||
}
|
||||
return id().toString();
|
||||
}
|
||||
|
||||
Id CommandPrivate::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
Core::Context CommandPrivate::context() const
|
||||
{
|
||||
return m_context;
|
||||
}
|
||||
|
||||
void CommandPrivate::setAttribute(CommandAttribute attr)
|
||||
{
|
||||
m_attributes |= attr;
|
||||
}
|
||||
|
||||
void CommandPrivate::removeAttribute(CommandAttribute attr)
|
||||
{
|
||||
m_attributes &= ~attr;
|
||||
}
|
||||
|
||||
bool CommandPrivate::hasAttribute(CommandAttribute attr) const
|
||||
{
|
||||
return (m_attributes & attr);
|
||||
}
|
||||
|
||||
QString CommandPrivate::stringWithAppendedShortcut(const QString &str) const
|
||||
{
|
||||
return Utils::ProxyAction::stringWithAppendedShortcut(str, keySequence());
|
||||
}
|
||||
|
||||
// ---------- Shortcut ------------
|
||||
|
||||
/*!
|
||||
\class Shortcut
|
||||
\internal
|
||||
*/
|
||||
|
||||
Shortcut::Shortcut(Id id)
|
||||
: CommandPrivate(id), m_shortcut(0), m_scriptable(false)
|
||||
{}
|
||||
|
||||
void Shortcut::setShortcut(QShortcut *shortcut)
|
||||
{
|
||||
m_shortcut = shortcut;
|
||||
}
|
||||
|
||||
QShortcut *Shortcut::shortcut() const
|
||||
{
|
||||
return m_shortcut;
|
||||
}
|
||||
|
||||
void Shortcut::setContext(const Core::Context &context)
|
||||
{
|
||||
m_context = context;
|
||||
}
|
||||
|
||||
Core::Context Shortcut::context() const
|
||||
{
|
||||
return m_context;
|
||||
}
|
||||
|
||||
void Shortcut::setKeySequence(const QKeySequence &key)
|
||||
{
|
||||
CommandPrivate::setKeySequence(key);
|
||||
m_shortcut->setKey(key);
|
||||
emit keySequenceChanged();
|
||||
}
|
||||
|
||||
QKeySequence Shortcut::keySequence() const
|
||||
{
|
||||
return m_shortcut->key();
|
||||
}
|
||||
|
||||
void Shortcut::setCurrentContext(const Core::Context &context)
|
||||
{
|
||||
foreach (Id id, m_context) {
|
||||
if (context.contains(id)) {
|
||||
if (!m_shortcut->isEnabled()) {
|
||||
m_shortcut->setEnabled(true);
|
||||
emit activeStateChanged();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (m_shortcut->isEnabled()) {
|
||||
m_shortcut->setEnabled(false);
|
||||
emit activeStateChanged();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool Shortcut::isActive() const
|
||||
{
|
||||
return m_shortcut->isEnabled();
|
||||
}
|
||||
|
||||
bool Shortcut::isScriptable() const
|
||||
{
|
||||
return m_scriptable;
|
||||
}
|
||||
|
||||
bool Shortcut::isScriptable(const Core::Context &) const
|
||||
{
|
||||
return m_scriptable;
|
||||
}
|
||||
|
||||
void Shortcut::setScriptable(bool value)
|
||||
{
|
||||
m_scriptable = value;
|
||||
}
|
||||
|
||||
// ---------- Action ------------
|
||||
|
||||
/*!
|
||||
\class Action
|
||||
\internal
|
||||
*/
|
||||
Action::Action(Id id)
|
||||
: CommandPrivate(id),
|
||||
: m_attributes(0),
|
||||
m_id(id),
|
||||
m_isKeyInitialized(false),
|
||||
m_action(new Utils::ProxyAction(this)),
|
||||
m_active(false),
|
||||
m_contextInitialized(false)
|
||||
@@ -379,14 +219,41 @@ Action::Action(Id id)
|
||||
connect(m_action, SIGNAL(changed()), this, SLOT(updateActiveState()));
|
||||
}
|
||||
|
||||
Id Action::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Action::setDefaultKeySequence(const QKeySequence &key)
|
||||
{
|
||||
if (!m_isKeyInitialized)
|
||||
setKeySequence(key);
|
||||
m_defaultKey = key;
|
||||
}
|
||||
|
||||
QKeySequence Action::defaultKeySequence() const
|
||||
{
|
||||
return m_defaultKey;
|
||||
}
|
||||
|
||||
QAction *Action::action() const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
QString Action::stringWithAppendedShortcut(const QString &str) const
|
||||
{
|
||||
return Utils::ProxyAction::stringWithAppendedShortcut(str, keySequence());
|
||||
}
|
||||
|
||||
Context Action::context() const
|
||||
{
|
||||
return m_context;
|
||||
}
|
||||
|
||||
void Action::setKeySequence(const QKeySequence &key)
|
||||
{
|
||||
CommandPrivate::setKeySequence(key);
|
||||
m_isKeyInitialized = true;
|
||||
m_action->setShortcut(key);
|
||||
emit keySequenceChanged();
|
||||
}
|
||||
@@ -396,6 +263,24 @@ QKeySequence Action::keySequence() const
|
||||
return m_action->shortcut();
|
||||
}
|
||||
|
||||
void Action::setDescription(const QString &text)
|
||||
{
|
||||
m_defaultText = text;
|
||||
}
|
||||
|
||||
QString Action::description() const
|
||||
{
|
||||
if (!m_defaultText.isEmpty())
|
||||
return m_defaultText;
|
||||
if (action()) {
|
||||
QString text = action()->text();
|
||||
text.remove(QRegExp(QLatin1String("&(?!&)")));
|
||||
if (!text.isEmpty())
|
||||
return text;
|
||||
}
|
||||
return id().toString();
|
||||
}
|
||||
|
||||
void Action::setCurrentContext(const Core::Context &context)
|
||||
{
|
||||
m_context = context;
|
||||
@@ -502,7 +387,7 @@ bool Action::isScriptable(const Core::Context &context) const
|
||||
|
||||
void Action::setAttribute(CommandAttribute attr)
|
||||
{
|
||||
CommandPrivate::setAttribute(attr);
|
||||
m_attributes |= attr;
|
||||
switch (attr) {
|
||||
case Core::Command::CA_Hide:
|
||||
m_action->setAttribute(Utils::ProxyAction::Hide);
|
||||
@@ -520,7 +405,7 @@ void Action::setAttribute(CommandAttribute attr)
|
||||
|
||||
void Action::removeAttribute(CommandAttribute attr)
|
||||
{
|
||||
CommandPrivate::removeAttribute(attr);
|
||||
m_attributes &= ~attr;
|
||||
switch (attr) {
|
||||
case Core::Command::CA_Hide:
|
||||
m_action->removeAttribute(Utils::ProxyAction::Hide);
|
||||
@@ -535,3 +420,8 @@ void Action::removeAttribute(CommandAttribute attr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool Action::hasAttribute(Command::CommandAttribute attr) const
|
||||
{
|
||||
return (m_attributes & attr);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ public:
|
||||
virtual Id id() const = 0;
|
||||
|
||||
virtual QAction *action() const = 0;
|
||||
virtual QShortcut *shortcut() const = 0;
|
||||
virtual Context context() const = 0;
|
||||
|
||||
virtual void setAttribute(CommandAttribute attr) = 0;
|
||||
|
||||
@@ -46,85 +46,30 @@
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class CommandPrivate : public Core::Command
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CommandPrivate(Id id);
|
||||
virtual ~CommandPrivate() {}
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
QKeySequence defaultKeySequence() const;
|
||||
|
||||
void setKeySequence(const QKeySequence &key);
|
||||
|
||||
void setDescription(const QString &text);
|
||||
QString description() const;
|
||||
|
||||
Id id() const;
|
||||
|
||||
Context context() const;
|
||||
|
||||
|
||||
void setAttribute(CommandAttribute attr);
|
||||
void removeAttribute(CommandAttribute attr);
|
||||
bool hasAttribute(CommandAttribute attr) const;
|
||||
|
||||
virtual void setCurrentContext(const Context &context) = 0;
|
||||
|
||||
QString stringWithAppendedShortcut(const QString &str) const;
|
||||
|
||||
protected:
|
||||
Context m_context;
|
||||
CommandAttributes m_attributes;
|
||||
Id m_id;
|
||||
QKeySequence m_defaultKey;
|
||||
QString m_defaultText;
|
||||
bool m_isKeyInitialized;
|
||||
};
|
||||
|
||||
class Shortcut : public CommandPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Shortcut(Id id);
|
||||
|
||||
void setKeySequence(const QKeySequence &key);
|
||||
QKeySequence keySequence() const;
|
||||
|
||||
void setShortcut(QShortcut *shortcut);
|
||||
QShortcut *shortcut() const;
|
||||
|
||||
QAction *action() const { return 0; }
|
||||
|
||||
void setContext(const Context &context);
|
||||
Context context() const;
|
||||
void setCurrentContext(const Context &context);
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
bool isScriptable() const;
|
||||
bool isScriptable(const Context &) const;
|
||||
void setScriptable(bool value);
|
||||
|
||||
private:
|
||||
QShortcut *m_shortcut;
|
||||
bool m_scriptable;
|
||||
};
|
||||
|
||||
class Action : public CommandPrivate
|
||||
class Action : public Core::Command
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Action(Id id);
|
||||
|
||||
Id id() const;
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
QKeySequence defaultKeySequence() const;
|
||||
|
||||
void setKeySequence(const QKeySequence &key);
|
||||
QKeySequence keySequence() const;
|
||||
|
||||
QAction *action() const;
|
||||
QShortcut *shortcut() const { return 0; }
|
||||
void setDescription(const QString &text);
|
||||
QString description() const;
|
||||
|
||||
QAction *action() const;
|
||||
|
||||
QString stringWithAppendedShortcut(const QString &str) const;
|
||||
|
||||
Context context() const;
|
||||
void setCurrentContext(const Context &context);
|
||||
|
||||
bool isActive() const;
|
||||
void addOverrideAction(QAction *action, const Context &context, bool scriptable);
|
||||
void removeOverrideAction(QAction *action);
|
||||
@@ -135,6 +80,7 @@ public:
|
||||
|
||||
void setAttribute(CommandAttribute attr);
|
||||
void removeAttribute(CommandAttribute attr);
|
||||
bool hasAttribute(CommandAttribute attr) const;
|
||||
|
||||
private slots:
|
||||
void updateActiveState();
|
||||
@@ -142,6 +88,13 @@ private slots:
|
||||
private:
|
||||
void setActive(bool state);
|
||||
|
||||
Context m_context;
|
||||
CommandAttributes m_attributes;
|
||||
Id m_id;
|
||||
QKeySequence m_defaultKey;
|
||||
QString m_defaultText;
|
||||
bool m_isKeyInitialized;
|
||||
|
||||
Utils::ProxyAction *m_action;
|
||||
QString m_toolTip;
|
||||
|
||||
|
||||
@@ -73,7 +73,6 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include <QAction>
|
||||
#include <QShortcut>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QMenu>
|
||||
@@ -307,11 +306,11 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
// workaround for QTCREATORBUG-72
|
||||
QShortcut *sc = new QShortcut(parent);
|
||||
cmd = ActionManager::registerShortcut(sc, Constants::CLOSE_ALTERNATIVE, editManagerContext);
|
||||
QAction *action = new QAction(tr("Alternative Close"), this);
|
||||
cmd = ActionManager::registerAction(action, Constants::CLOSE_ALTERNATIVE, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F4")));
|
||||
cmd->setDescription(EditorManager::tr("Close"));
|
||||
connect(sc, SIGNAL(activated()), this, SLOT(closeEditor()));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(closeEditor()));
|
||||
}
|
||||
|
||||
// Close All Action
|
||||
|
||||
@@ -92,7 +92,6 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QMenu>
|
||||
#include <QPrinter>
|
||||
#include <QShortcut>
|
||||
#include <QStatusBar>
|
||||
#include <QToolButton>
|
||||
#include <QMessageBox>
|
||||
@@ -537,10 +536,10 @@ void MainWindow::registerDefaultActions()
|
||||
|
||||
// Return to editor shortcut: Note this requires Qt to fix up
|
||||
// handling of shortcut overrides in menus, item views, combos....
|
||||
m_focusToEditor = new QShortcut(this);
|
||||
Command *cmd = ActionManager::registerShortcut(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext);
|
||||
m_focusToEditor = new QAction(tr("Return to Editor"), this);
|
||||
Command *cmd = ActionManager::registerAction(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
|
||||
connect(m_focusToEditor, SIGNAL(activated()), this, SLOT(setFocusToEditor()));
|
||||
connect(m_focusToEditor, SIGNAL(triggered()), this, SLOT(setFocusToEditor()));
|
||||
|
||||
// New File Action
|
||||
QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE)));
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
class QShortcut;
|
||||
class QPrinter;
|
||||
class QToolButton;
|
||||
QT_END_NAMESPACE
|
||||
@@ -195,7 +194,7 @@ private:
|
||||
SystemEditor *m_systemEditor;
|
||||
|
||||
// actions
|
||||
QShortcut *m_focusToEditor;
|
||||
QAction *m_focusToEditor;
|
||||
QAction *m_newAction;
|
||||
QAction *m_openAction;
|
||||
QAction *m_openWithAction;
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include <QVector>
|
||||
|
||||
#include <QSignalMapper>
|
||||
#include <QShortcut>
|
||||
#include <QAction>
|
||||
|
||||
namespace Core {
|
||||
@@ -68,7 +67,7 @@ struct ModeManagerPrivate
|
||||
Internal::FancyActionBar *m_actionBar;
|
||||
QMap<QAction*, int> m_actions;
|
||||
QVector<IMode*> m_modes;
|
||||
QVector<Command*> m_modeShortcuts;
|
||||
QVector<Command*> m_modeCommands;
|
||||
QSignalMapper *m_signalMapper;
|
||||
Context m_addedContexts;
|
||||
int m_oldCurrent;
|
||||
@@ -182,15 +181,14 @@ void ModeManager::objectAdded(QObject *obj)
|
||||
d->m_modeStack->setTabEnabled(index, mode->isEnabled());
|
||||
|
||||
// Register mode shortcut
|
||||
const Id shortcutId = mode->id().withPrefix("QtCreator.Mode.");
|
||||
QShortcut *shortcut = new QShortcut(d->m_mainWindow);
|
||||
shortcut->setWhatsThis(tr("Switch to <b>%1</b> mode").arg(mode->displayName()));
|
||||
Command *cmd = ActionManager::registerShortcut(shortcut, shortcutId, Context(Constants::C_GLOBAL));
|
||||
const Id actionId = mode->id().withPrefix("QtCreator.Mode.");
|
||||
QAction *action = new QAction(tr("Switch to <b>%1</b> mode").arg(mode->displayName()), this);
|
||||
Command *cmd = ActionManager::registerAction(action, actionId, Context(Constants::C_GLOBAL));
|
||||
|
||||
d->m_modeShortcuts.insert(index, cmd);
|
||||
d->m_modeCommands.insert(index, cmd);
|
||||
connect(cmd, SIGNAL(keySequenceChanged()), m_instance, SLOT(updateModeToolTip()));
|
||||
for (int i = 0; i < d->m_modeShortcuts.size(); ++i) {
|
||||
Command *currentCmd = d->m_modeShortcuts.at(i);
|
||||
for (int i = 0; i < d->m_modeCommands.size(); ++i) {
|
||||
Command *currentCmd = d->m_modeCommands.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
|
||||
@@ -202,8 +200,8 @@ void ModeManager::objectAdded(QObject *obj)
|
||||
currentCmd->setKeySequence(currentCmd->defaultKeySequence());
|
||||
}
|
||||
|
||||
d->m_signalMapper->setMapping(shortcut, mode->id().uniqueIdentifier());
|
||||
connect(shortcut, SIGNAL(activated()), d->m_signalMapper, SLOT(map()));
|
||||
d->m_signalMapper->setMapping(action, mode->id().uniqueIdentifier());
|
||||
connect(action, SIGNAL(triggered()), d->m_signalMapper, SLOT(map()));
|
||||
connect(mode, SIGNAL(enabledStateChanged(bool)),
|
||||
m_instance, SLOT(enabledStateChanged()));
|
||||
}
|
||||
@@ -212,9 +210,9 @@ void ModeManager::updateModeToolTip()
|
||||
{
|
||||
Command *cmd = qobject_cast<Command *>(sender());
|
||||
if (cmd) {
|
||||
int index = d->m_modeShortcuts.indexOf(cmd);
|
||||
int index = d->m_modeCommands.indexOf(cmd);
|
||||
if (index != -1)
|
||||
d->m_modeStack->setTabToolTip(index, cmd->stringWithAppendedShortcut(cmd->shortcut()->whatsThis()));
|
||||
d->m_modeStack->setTabToolTip(index, cmd->action()->toolTip());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +251,7 @@ void ModeManager::aboutToRemoveObject(QObject *obj)
|
||||
|
||||
const int index = d->m_modes.indexOf(mode);
|
||||
d->m_modes.remove(index);
|
||||
d->m_modeShortcuts.remove(index);
|
||||
d->m_modeCommands.remove(index);
|
||||
d->m_modeStack->removeTab(index);
|
||||
|
||||
d->m_mainWindow->removeContextObject(mode);
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <QAction>
|
||||
#include <QHBoxLayout>
|
||||
#include <QResizeEvent>
|
||||
#include <QShortcut>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *)
|
||||
@@ -137,7 +136,7 @@ struct NavigationWidgetPrivate
|
||||
~NavigationWidgetPrivate() { delete m_factoryModel; }
|
||||
|
||||
QList<Internal::NavigationSubWidget *> m_subWidgets;
|
||||
QHash<QShortcut *, Core::Id> m_shortcutMap;
|
||||
QHash<QAction *, Core::Id> m_actionMap;
|
||||
QHash<Core::Id, Core::Command *> m_commandMap;
|
||||
QStandardItemModel *m_factoryModel;
|
||||
|
||||
@@ -185,12 +184,11 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> &fac
|
||||
foreach (INavigationWidgetFactory *factory, factories) {
|
||||
const Id id = factory->id();
|
||||
|
||||
QShortcut *shortcut = new QShortcut(this);
|
||||
shortcut->setWhatsThis(tr("Activate %1 Pane").arg(factory->displayName()));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget()));
|
||||
d->m_shortcutMap.insert(shortcut, id);
|
||||
QAction *action= new QAction(tr("Activate %1 Pane").arg(factory->displayName()), this);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateSubWidget()));
|
||||
d->m_actionMap.insert(action, id);
|
||||
|
||||
Command *cmd = ActionManager::registerShortcut(shortcut,
|
||||
Command *cmd = ActionManager::registerAction(action,
|
||||
id.withPrefix("QtCreator.Sidebar."), navicontext);
|
||||
cmd->setDefaultKeySequence(factory->activationSequence());
|
||||
d->m_commandMap.insert(id, cmd);
|
||||
@@ -257,8 +255,8 @@ Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position,int
|
||||
|
||||
void NavigationWidget::activateSubWidget()
|
||||
{
|
||||
QShortcut *original = qobject_cast<QShortcut *>(sender());
|
||||
Id id = d->m_shortcutMap[original];
|
||||
QAction *original = qobject_cast<QAction *>(sender());
|
||||
Id id = d->m_actionMap[original];
|
||||
activateSubWidget(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
class QShortcut;
|
||||
class QAbstractItemModel;
|
||||
class QStandardItemModel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
#include <QComboBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QMenu>
|
||||
#include <QShortcut>
|
||||
#include <QStackedLayout>
|
||||
#include <QSplitter>
|
||||
|
||||
@@ -420,11 +419,10 @@ void HelpPlugin::setupUi()
|
||||
m_centralWidget, SLOT(showTopicChooser(QMap<QString,QUrl>,QString)));
|
||||
|
||||
QMap<QString, Command*> shortcutMap;
|
||||
QShortcut *shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Index in Help mode"));
|
||||
Command *cmd = ActionManager::registerShortcut(shortcut, "Help.IndexShortcut", modecontext);
|
||||
QAction *action = new QAction(tr("Activate Index in Help mode"), m_splitter);
|
||||
Command *cmd = ActionManager::registerAction(action, "Help.IndexShortcut", modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+I") : tr("Ctrl+Shift+I")));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateIndex()));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateIndex()));
|
||||
shortcutMap.insert(QLatin1String(SB_INDEX), cmd);
|
||||
|
||||
ContentWindow *contentWindow = new ContentWindow();
|
||||
@@ -433,11 +431,10 @@ void HelpPlugin::setupUi()
|
||||
connect(contentWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
||||
SLOT(setSource(QUrl)));
|
||||
|
||||
shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Contents in Help mode"));
|
||||
cmd = ActionManager::registerShortcut(shortcut, "Help.ContentsShortcut", modecontext);
|
||||
action = new QAction(tr("Activate Contents in Help mode"), m_splitter);
|
||||
cmd = ActionManager::registerAction(action, "Help.ContentsShortcut", modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Shift+C") : tr("Ctrl+Shift+C")));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateContents()));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateContents()));
|
||||
shortcutMap.insert(QLatin1String(SB_CONTENTS), cmd);
|
||||
|
||||
SearchWidget *searchWidget = new SearchWidget();
|
||||
@@ -446,11 +443,10 @@ void HelpPlugin::setupUi()
|
||||
connect(searchWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
||||
SLOT(setSourceFromSearch(QUrl)));
|
||||
|
||||
shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Search in Help mode"));
|
||||
cmd = ActionManager::registerShortcut(shortcut, "Help.SearchShortcut", modecontext);
|
||||
action = new QAction(tr("Activate Search in Help mode"), m_splitter);
|
||||
cmd = ActionManager::registerAction(action, "Help.SearchShortcut", modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+/") : tr("Ctrl+Shift+/")));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateSearch()));
|
||||
shortcutMap.insert(QLatin1String(SB_SEARCH), cmd);
|
||||
|
||||
BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
|
||||
@@ -462,22 +458,20 @@ void HelpPlugin::setupUi()
|
||||
connect(bookmarkWidget, SIGNAL(createPage(QUrl,bool)), &OpenPagesManager::instance(),
|
||||
SLOT(createPage(QUrl,bool)));
|
||||
|
||||
shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Bookmarks in Help mode"));
|
||||
cmd = ActionManager::registerShortcut(shortcut, "Help.BookmarkShortcut", modecontext);
|
||||
action = new QAction(tr("Activate Bookmarks in Help mode"), m_splitter);
|
||||
cmd = ActionManager::registerAction(action, "Help.BookmarkShortcut", modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+B") : tr("Ctrl+Shift+B")));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateBookmarks()));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateBookmarks()));
|
||||
shortcutMap.insert(QLatin1String(SB_BOOKMARKS), cmd);
|
||||
|
||||
QWidget *openPagesWidget = OpenPagesManager::instance().openPagesWidget();
|
||||
openPagesWidget->setWindowTitle(tr("Open Pages"));
|
||||
m_openPagesItem = new SideBarItem(openPagesWidget, QLatin1String(SB_OPENPAGES));
|
||||
|
||||
shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Open Pages in Help mode"));
|
||||
cmd = ActionManager::registerShortcut(shortcut, "Help.PagesShortcut", modecontext);
|
||||
action = new QAction(tr("Activate Open Pages in Help mode"), m_splitter);
|
||||
cmd = ActionManager::registerAction(action, "Help.PagesShortcut", modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+O") : tr("Ctrl+Shift+O")));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateOpenPages()));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateOpenPages()));
|
||||
shortcutMap.insert(QLatin1String(SB_OPENPAGES), cmd);
|
||||
|
||||
QList<SideBarItem*> itemList;
|
||||
|
||||
@@ -113,10 +113,6 @@ void ActionMacroHandler::registerCommand(Id id)
|
||||
m_mapper->setMapping(action, id.toString());
|
||||
return;
|
||||
}
|
||||
if (QShortcut *shortcut = command->shortcut()) {
|
||||
connect(shortcut, SIGNAL(activated()), m_mapper, SLOT(map()));
|
||||
m_mapper->setMapping(shortcut, id.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@@ -57,7 +58,6 @@
|
||||
#include <QSignalMapper>
|
||||
#include <QList>
|
||||
|
||||
#include <QShortcut>
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
@@ -100,6 +100,7 @@ public:
|
||||
|
||||
MacroManager *q;
|
||||
QMap<QString, Macro *> macros;
|
||||
QMap<QString, QAction *> actions;
|
||||
Macro *currentMacro;
|
||||
bool isRecording;
|
||||
|
||||
@@ -163,14 +164,16 @@ void MacroManager::MacroManagerPrivate::addMacro(Macro *macro)
|
||||
{
|
||||
// Add sortcut
|
||||
Core::Context context(TextEditor::Constants::C_TEXTEDITOR);
|
||||
QShortcut *shortcut = new QShortcut(Core::ICore::mainWindow());
|
||||
shortcut->setWhatsThis(macro->description());
|
||||
Core::ActionManager::registerShortcut(shortcut, makeId(macro->displayName()), context);
|
||||
connect(shortcut, SIGNAL(activated()), mapper, SLOT(map()));
|
||||
mapper->setMapping(shortcut, macro->displayName());
|
||||
QAction *action = new QAction(macro->description(), q);
|
||||
Core::Command *command = Core::ActionManager::registerAction(
|
||||
action, makeId(macro->displayName()), context);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
|
||||
mapper->setMapping(action, macro->displayName());
|
||||
|
||||
// Add macro to the map
|
||||
macros[macro->displayName()] = macro;
|
||||
actions[macro->displayName()] = action;
|
||||
}
|
||||
|
||||
void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
|
||||
@@ -178,7 +181,9 @@ void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
|
||||
if (!macros.contains(name))
|
||||
return;
|
||||
// Remove shortcut
|
||||
Core::ActionManager::unregisterShortcut(makeId(name));
|
||||
QAction *action = actions.take(name);
|
||||
Core::ActionManager::unregisterAction(action, makeId(name));
|
||||
delete action;
|
||||
|
||||
// Remove macro from the map
|
||||
Macro *macro = macros.take(name);
|
||||
@@ -192,10 +197,9 @@ void MacroManager::MacroManagerPrivate::changeMacroDescription(Macro *macro, con
|
||||
macro->setDescription(description);
|
||||
macro->save(macro->fileName(), Core::ICore::mainWindow());
|
||||
|
||||
// Change shortcut what's this
|
||||
Core::Command *command = Core::ActionManager::command(makeId(macro->displayName()));
|
||||
if (command && command->shortcut())
|
||||
command->shortcut()->setWhatsThis(description);
|
||||
QAction *action = actions[macro->displayName()];
|
||||
QTC_ASSERT(action, return);
|
||||
action->setText(description);
|
||||
}
|
||||
|
||||
bool MacroManager::MacroManagerPrivate::executeMacro(Macro *macro)
|
||||
|
||||
@@ -112,8 +112,8 @@ void MacroOptionsWidget::createTable()
|
||||
|
||||
Core::Command *command =
|
||||
Core::ActionManager::command(base.withSuffix(it.value()->displayName()));
|
||||
if (command && command->shortcut())
|
||||
macroItem->setText(2, command->shortcut()->key().toString());
|
||||
if (command && command->action())
|
||||
macroItem->setText(2, command->action()->shortcut().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void TextEditorMacroHandler::startRecording(Macro *macro)
|
||||
m_currentEditor->widget()->installEventFilter(this);
|
||||
|
||||
// Block completion
|
||||
Core::ActionManager::command(TextEditor::Constants::COMPLETE_THIS)->shortcut()->blockSignals(true);
|
||||
Core::ActionManager::command(TextEditor::Constants::COMPLETE_THIS)->action()->blockSignals(true);
|
||||
}
|
||||
|
||||
void TextEditorMacroHandler::endRecordingMacro(Macro *macro)
|
||||
@@ -85,7 +85,7 @@ void TextEditorMacroHandler::endRecordingMacro(Macro *macro)
|
||||
IMacroHandler::endRecordingMacro(macro);
|
||||
|
||||
// Unblock completion
|
||||
Core::ActionManager::command(TextEditor::Constants::COMPLETE_THIS)->shortcut()->blockSignals(false);
|
||||
Core::ActionManager::command(TextEditor::Constants::COMPLETE_THIS)->action()->blockSignals(false);
|
||||
}
|
||||
|
||||
bool TextEditorMacroHandler::canExecuteEvent(const MacroEvent ¯oEvent)
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QShortcut>
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
@@ -169,29 +169,21 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
Core::Context context(TextEditor::Constants::C_TEXTEDITOR);
|
||||
|
||||
// Add shortcut for invoking automatic completion
|
||||
QShortcut *completionShortcut = new QShortcut(Core::ICore::mainWindow());
|
||||
completionShortcut->setWhatsThis(tr("Triggers a completion in this scope"));
|
||||
// Make sure the shortcut still works when the completion widget is active
|
||||
completionShortcut->setContext(Qt::ApplicationShortcut);
|
||||
Core::Command *command = Core::ActionManager::registerShortcut(completionShortcut, Constants::COMPLETE_THIS, context);
|
||||
QAction *completionAction = new QAction(tr("Trigger Completion"), this);
|
||||
Core::Command *command = Core::ActionManager::registerAction(completionAction, Constants::COMPLETE_THIS, context);
|
||||
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Space") : tr("Ctrl+Space")));
|
||||
connect(completionShortcut, SIGNAL(activated()), this, SLOT(invokeCompletion()));
|
||||
connect(completionAction, SIGNAL(triggered()), this, SLOT(invokeCompletion()));
|
||||
|
||||
// Add shortcut for invoking quick fix options
|
||||
QShortcut *quickFixShortcut = new QShortcut(Core::ICore::mainWindow());
|
||||
quickFixShortcut->setWhatsThis(tr("Triggers a quick fix in this scope"));
|
||||
// Make sure the shortcut still works when the quick fix widget is active
|
||||
quickFixShortcut->setContext(Qt::ApplicationShortcut);
|
||||
Core::Command *quickFixCommand = Core::ActionManager::registerShortcut(quickFixShortcut, Constants::QUICKFIX_THIS, context);
|
||||
QAction *quickFixAction = new QAction(tr("Trigger Quick Fix"), this);
|
||||
Core::Command *quickFixCommand = Core::ActionManager::registerAction(quickFixAction, Constants::QUICKFIX_THIS, context);
|
||||
quickFixCommand->setDefaultKeySequence(QKeySequence(tr("Alt+Return")));
|
||||
connect(quickFixShortcut, SIGNAL(activated()), this, SLOT(invokeQuickFix()));
|
||||
connect(quickFixAction, SIGNAL(triggered()), this, SLOT(invokeQuickFix()));
|
||||
|
||||
// Add shortcut for create a scratch buffer
|
||||
QShortcut *scratchBufferShortcut = new QShortcut(Core::ICore::mainWindow());
|
||||
scratchBufferShortcut->setWhatsThis(tr("Creates a scratch buffer using a temporary file."));
|
||||
scratchBufferShortcut->setContext(Qt::ApplicationShortcut);
|
||||
Core::ActionManager::registerShortcut(scratchBufferShortcut, Constants::CREATE_SCRATCH_BUFFER, context);
|
||||
connect(scratchBufferShortcut, SIGNAL(activated()), scratchFile, SLOT(createFile()));
|
||||
QAction *scratchBufferAction = new QAction(tr("Create Scratch Buffer Using a Temporary File"), this);
|
||||
Core::ActionManager::registerAction(scratchBufferAction, Constants::CREATE_SCRATCH_BUFFER, context);
|
||||
connect(scratchBufferAction, SIGNAL(triggered()), scratchFile, SLOT(createFile()));
|
||||
|
||||
// Generic highlighter.
|
||||
connect(Core::ICore::instance(), SIGNAL(coreOpened()),
|
||||
|
||||
Reference in New Issue
Block a user