forked from qt-creator/qt-creator
ActionManager API cleanup.
d-pointer instead of inheritance static methods Change-Id: I7b2f0c8b05ad3951e1ff26a7d4e08e195d2dd258 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "actionmanager.h"
|
||||
#include "actionmanager_p.h"
|
||||
#include "mainwindow.h"
|
||||
#include "actioncontainer_p.h"
|
||||
@@ -53,6 +54,9 @@ namespace {
|
||||
enum { warnAboutFindFailures = 0 };
|
||||
}
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
/*!
|
||||
\class Core::ActionManager
|
||||
\mainclass
|
||||
@@ -61,11 +65,8 @@ namespace {
|
||||
menu items and keyboard shortcuts.
|
||||
|
||||
The ActionManager is the central bookkeeper of actions and their shortcuts and layout.
|
||||
You get the only implementation of this class from the core interface
|
||||
ICore::actionManager() method, e.g.
|
||||
\code
|
||||
Core::ICore::actionManager()
|
||||
\endcode
|
||||
It is a singleton containing mostly static methods. If you need access to the instance,
|
||||
e.g. for connecting to signals, is its ActionManager::instance() method.
|
||||
|
||||
The main reasons for the need of this class is to provide a central place where the user
|
||||
can specify all his keyboard shortcuts, and to provide a solution for actions that should
|
||||
@@ -73,7 +74,7 @@ namespace {
|
||||
|
||||
\section1 Contexts
|
||||
|
||||
All actions that are registered with the same string ID (but different context lists)
|
||||
All actions that are registered with the same Id (but different context lists)
|
||||
are considered to be overloads of the same command, represented by an instance
|
||||
of the Command class.
|
||||
Exactly only one of the registered actions with the same ID is active at any time.
|
||||
@@ -99,9 +100,8 @@ namespace {
|
||||
To register a globally active action "My Action"
|
||||
put the following in your plugin's IPlugin::initialize method:
|
||||
\code
|
||||
Core::ActionManager *am = Core::ICore::actionManager();
|
||||
QAction *myAction = new QAction(tr("My Action"), this);
|
||||
Core::Command *cmd = am->registerAction(myAction,
|
||||
Core::Command *cmd = Core::ActionManager::registerAction(myAction,
|
||||
"myplugin.myaction",
|
||||
Core::Context(C_GLOBAL));
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+u")));
|
||||
@@ -125,7 +125,7 @@ namespace {
|
||||
|
||||
Following the example adding "My Action" to the "Tools" menu would be done by
|
||||
\code
|
||||
am->actionContainer(Core::M_TOOLS)->addAction(cmd);
|
||||
Core::ActionManager::actionContainer(Core::M_TOOLS)->addAction(cmd);
|
||||
\endcode
|
||||
|
||||
\section1 Important Guidelines:
|
||||
@@ -146,9 +146,36 @@ namespace {
|
||||
\sa Core::IContext
|
||||
*/
|
||||
|
||||
static ActionManager *m_instance = 0;
|
||||
|
||||
/*!
|
||||
\fn ActionContainer *ActionManager::createMenu(const Id &id)
|
||||
\brief Creates a new menu with the given string \a id.
|
||||
\internal
|
||||
*/
|
||||
ActionManager::ActionManager(QObject *parent)
|
||||
: QObject(parent),
|
||||
d(new ActionManagerPrivate())
|
||||
{
|
||||
m_instance = this;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
ActionManager::~ActionManager()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return Singleton action manager instance
|
||||
*/
|
||||
ActionManager *ActionManager::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Creates a new menu with the given \a id.
|
||||
|
||||
Returns a new ActionContainer that you can use to get the QMenu instance
|
||||
or to add menu items to the menu. The ActionManager owns
|
||||
@@ -156,19 +183,51 @@ namespace {
|
||||
Add your menu to some other menu or a menu bar via the
|
||||
ActionManager::actionContainer and ActionContainer::addMenu methods.
|
||||
*/
|
||||
ActionContainer *ActionManager::createMenu(const Id &id)
|
||||
{
|
||||
const ActionManagerPrivate::IdContainerMap::const_iterator it = m_instance->d->m_idContainerMap.constFind(id);
|
||||
if (it != m_instance->d->m_idContainerMap.constEnd())
|
||||
return it.value();
|
||||
|
||||
QMenu *m = new QMenu(ICore::mainWindow());
|
||||
m->setObjectName(QLatin1String(id.name()));
|
||||
|
||||
MenuActionContainer *mc = new MenuActionContainer(id);
|
||||
mc->setMenu(m);
|
||||
|
||||
m_instance->d->m_idContainerMap.insert(id, mc);
|
||||
connect(mc, SIGNAL(destroyed()), m_instance->d, SLOT(containerDestroyed()));
|
||||
|
||||
return mc;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ActionContainer *ActionManager::createMenuBar(const Id &id)
|
||||
\brief Creates a new menu bar with the given string \a id.
|
||||
\brief Creates a new menu bar with the given \a id.
|
||||
|
||||
Returns a new ActionContainer that you can use to get the QMenuBar instance
|
||||
or to add menus to the menu bar. The ActionManager owns
|
||||
the returned ActionContainer.
|
||||
*/
|
||||
ActionContainer *ActionManager::createMenuBar(const Id &id)
|
||||
{
|
||||
const ActionManagerPrivate::IdContainerMap::const_iterator it = m_instance->d->m_idContainerMap.constFind(id);
|
||||
if (it != m_instance->d->m_idContainerMap.constEnd())
|
||||
return it.value();
|
||||
|
||||
QMenuBar *mb = new QMenuBar; // No parent (System menu bar on Mac OS X)
|
||||
mb->setObjectName(id.toString());
|
||||
|
||||
MenuBarActionContainer *mbc = new MenuBarActionContainer(id);
|
||||
mbc->setMenuBar(mb);
|
||||
|
||||
m_instance->d->m_idContainerMap.insert(id, mbc);
|
||||
connect(mbc, SIGNAL(destroyed()), m_instance->d, SLOT(containerDestroyed()));
|
||||
|
||||
return mbc;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn Command *ActionManager::registerAction(QAction *action, const Id &id, const Context &context, bool scriptable)
|
||||
\brief Makes an \a action known to the system under the specified string \a id.
|
||||
\brief Makes an \a action known to the system under the specified \a id.
|
||||
|
||||
Returns a command object that represents the action in the application and is
|
||||
owned by the ActionManager. You can register several actions with the
|
||||
@@ -178,10 +237,19 @@ namespace {
|
||||
A scriptable action can be called from a script without the need for the user
|
||||
to interact with it.
|
||||
*/
|
||||
Command *ActionManager::registerAction(QAction *action, const Id &id, const Context &context, bool scriptable)
|
||||
{
|
||||
Action *a = m_instance->d->overridableAction(id);
|
||||
if (a) {
|
||||
a->addOverrideAction(action, context, scriptable);
|
||||
emit m_instance->commandListChanged();
|
||||
emit m_instance->commandAdded(id.toString());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn Command *ActionManager::registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable)
|
||||
\brief Makes a \a shortcut known to the system under the specified string \a id.
|
||||
\brief 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
|
||||
@@ -191,47 +259,199 @@ namespace {
|
||||
A scriptable shortcut can be called from a script without the need for the user
|
||||
to interact with it.
|
||||
*/
|
||||
Command *ActionManager::registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable)
|
||||
{
|
||||
Shortcut *sc = 0;
|
||||
if (CommandPrivate *c = m_instance->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);
|
||||
m_instance->d->m_idCmdMap.insert(id, sc);
|
||||
}
|
||||
|
||||
if (sc->shortcut()) {
|
||||
qWarning() << "registerShortcut: action already registered, id" << id.name() << ".";
|
||||
return sc;
|
||||
}
|
||||
|
||||
if (!m_instance->d->hasContext(context))
|
||||
shortcut->setEnabled(false);
|
||||
shortcut->setObjectName(id.toString());
|
||||
shortcut->setParent(ICore::mainWindow());
|
||||
sc->setShortcut(shortcut);
|
||||
sc->setScriptable(scriptable);
|
||||
|
||||
if (context.isEmpty())
|
||||
sc->setContext(Context(0));
|
||||
else
|
||||
sc->setContext(context);
|
||||
|
||||
emit m_instance->commandListChanged();
|
||||
emit m_instance->commandAdded(id.toString());
|
||||
|
||||
if (isPresentationModeEnabled())
|
||||
connect(sc->shortcut(), SIGNAL(activated()), m_instance->d, SLOT(shortcutTriggered()));
|
||||
return sc;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn Command *ActionManager::command(const Id &id) const
|
||||
\brief Returns the Command object that is known to the system
|
||||
under the given string \a id.
|
||||
under the given \a id.
|
||||
|
||||
\sa ActionManager::registerAction()
|
||||
*/
|
||||
Command *ActionManager::command(const Id &id)
|
||||
{
|
||||
const ActionManagerPrivate::IdCmdMap::const_iterator it = m_instance->d->m_idCmdMap.constFind(id);
|
||||
if (it == m_instance->d->m_idCmdMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManagerPrivate::command(): failed to find :"
|
||||
<< id.name();
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ActionContainer *ActionManager::actionContainer(const Id &id) const
|
||||
\brief Returns the IActionContainter object that is know to the system
|
||||
under the given string \a id.
|
||||
under the given \a id.
|
||||
|
||||
\sa ActionManager::createMenu()
|
||||
\sa ActionManager::createMenuBar()
|
||||
*/
|
||||
ActionContainer *ActionManager::actionContainer(const Id &id)
|
||||
{
|
||||
const ActionManagerPrivate::IdContainerMap::const_iterator it = m_instance->d->m_idContainerMap.constFind(id);
|
||||
if (it == m_instance->d->m_idContainerMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :"
|
||||
<< id.name();
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn Command *ActionManager::unregisterAction(QAction *action, const Id &id)
|
||||
\brief Removes the knowledge about an \a action under the specified string \a id.
|
||||
* \brief Returns all commands that have been registered.
|
||||
*/
|
||||
QList<Command *> ActionManager::commands()
|
||||
{
|
||||
// transform list of CommandPrivate into list of Command
|
||||
QList<Command *> result;
|
||||
foreach (Command *cmd, m_instance->d->m_idCmdMap.values())
|
||||
result << cmd;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Removes the knowledge about an \a action under the specified \a id.
|
||||
|
||||
Usually you do not need to unregister actions. The only valid use case for unregistering
|
||||
actions, is for actions that represent user definable actions, like for the custom Locator
|
||||
filters. If the user removes such an action, it also has to be unregistered from the action manager,
|
||||
to make it disappear from shortcut settings etc.
|
||||
*/
|
||||
void ActionManager::unregisterAction(QAction *action, const Id &id)
|
||||
{
|
||||
Action *a = 0;
|
||||
CommandPrivate *c = m_instance->d->m_idCmdMap.value(id, 0);
|
||||
QTC_ASSERT(c, return);
|
||||
a = qobject_cast<Action *>(c);
|
||||
if (!a) {
|
||||
qWarning() << "unregisterAction: id" << id.name()
|
||||
<< "is registered with a different command type.";
|
||||
return;
|
||||
}
|
||||
a->removeOverrideAction(action);
|
||||
if (a->isEmpty()) {
|
||||
// clean up
|
||||
// ActionContainers listen to the commands' destroyed signals
|
||||
ICore::mainWindow()->removeAction(a->action());
|
||||
delete a->action();
|
||||
m_instance->d->m_idCmdMap.remove(id);
|
||||
delete a;
|
||||
}
|
||||
emit m_instance->commandListChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ActionManager::ActionManager(QObject *parent)
|
||||
\internal
|
||||
*/
|
||||
/*!
|
||||
\fn ActionManager::~ActionManager()
|
||||
\internal
|
||||
*/
|
||||
\brief Removes the knowledge about a shortcut under the specified \a id.
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
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(const Core::Id &id)
|
||||
{
|
||||
Shortcut *sc = 0;
|
||||
CommandPrivate *c = m_instance->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();
|
||||
m_instance->d->m_idCmdMap.remove(id);
|
||||
delete sc;
|
||||
emit m_instance->commandListChanged();
|
||||
}
|
||||
|
||||
ActionManagerPrivate* ActionManagerPrivate::m_instance = 0;
|
||||
|
||||
void ActionManager::setPresentationModeEnabled(bool enabled)
|
||||
{
|
||||
if (enabled == isPresentationModeEnabled())
|
||||
return;
|
||||
|
||||
// Signal/slots to commands:
|
||||
foreach (Command *c, commands()) {
|
||||
if (c->action()) {
|
||||
if (enabled)
|
||||
connect(c->action(), SIGNAL(triggered()), m_instance->d, SLOT(actionTriggered()));
|
||||
else
|
||||
disconnect(c->action(), SIGNAL(triggered()), m_instance->d, SLOT(actionTriggered()));
|
||||
}
|
||||
if (c->shortcut()) {
|
||||
if (enabled)
|
||||
connect(c->shortcut(), SIGNAL(activated()), m_instance->d, SLOT(shortcutTriggered()));
|
||||
else
|
||||
disconnect(c->shortcut(), SIGNAL(activated()), m_instance->d, SLOT(shortcutTriggered()));
|
||||
}
|
||||
}
|
||||
|
||||
// The label for the shortcuts:
|
||||
if (!m_instance->d->m_presentationLabel) {
|
||||
m_instance->d->m_presentationLabel = new QLabel(0, Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
QFont font = m_instance->d->m_presentationLabel->font();
|
||||
font.setPixelSize(45);
|
||||
m_instance->d->m_presentationLabel->setFont(font);
|
||||
m_instance->d->m_presentationLabel->setAlignment(Qt::AlignCenter);
|
||||
m_instance->d->m_presentationLabel->setMargin(5);
|
||||
|
||||
connect(&m_instance->d->m_presentationLabelTimer, SIGNAL(timeout()), m_instance->d->m_presentationLabel, SLOT(hide()));
|
||||
} else {
|
||||
m_instance->d->m_presentationLabelTimer.stop();
|
||||
delete m_instance->d->m_presentationLabel;
|
||||
m_instance->d->m_presentationLabel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ActionManager::isPresentationModeEnabled()
|
||||
{
|
||||
return m_instance->d->m_presentationLabel;
|
||||
}
|
||||
|
||||
bool ActionManager::hasContext(int context)
|
||||
{
|
||||
return m_instance->d->m_context.contains(context);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class ActionManagerPrivate
|
||||
@@ -239,13 +459,10 @@ ActionManagerPrivate* ActionManagerPrivate::m_instance = 0;
|
||||
\internal
|
||||
*/
|
||||
|
||||
ActionManagerPrivate::ActionManagerPrivate(MainWindow *mainWnd)
|
||||
: ActionManager(mainWnd),
|
||||
m_mainWnd(mainWnd),
|
||||
m_presentationLabel(0)
|
||||
ActionManagerPrivate::ActionManagerPrivate()
|
||||
: m_presentationLabel(0)
|
||||
{
|
||||
m_presentationLabelTimer.setInterval(1000);
|
||||
m_instance = this;
|
||||
}
|
||||
|
||||
ActionManagerPrivate::~ActionManagerPrivate()
|
||||
@@ -257,25 +474,6 @@ ActionManagerPrivate::~ActionManagerPrivate()
|
||||
qDeleteAll(m_idCmdMap.values());
|
||||
}
|
||||
|
||||
ActionManagerPrivate *ActionManagerPrivate::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
QList<Command *> ActionManagerPrivate::commands() const
|
||||
{
|
||||
// transform list of CommandPrivate into list of Command
|
||||
QList<Command *> result;
|
||||
foreach (Command *cmd, m_idCmdMap.values())
|
||||
result << cmd;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ActionManagerPrivate::hasContext(int context) const
|
||||
{
|
||||
return m_context.contains(context);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug in, const Context &context)
|
||||
{
|
||||
in << "CONTEXT: ";
|
||||
@@ -304,42 +502,6 @@ bool ActionManagerPrivate::hasContext(const Context &context) const
|
||||
return false;
|
||||
}
|
||||
|
||||
ActionContainer *ActionManagerPrivate::createMenu(const Id &id)
|
||||
{
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(id);
|
||||
if (it != m_idContainerMap.constEnd())
|
||||
return it.value();
|
||||
|
||||
QMenu *m = new QMenu(m_mainWnd);
|
||||
m->setObjectName(QLatin1String(id.name()));
|
||||
|
||||
MenuActionContainer *mc = new MenuActionContainer(id);
|
||||
mc->setMenu(m);
|
||||
|
||||
m_idContainerMap.insert(id, mc);
|
||||
connect(mc, SIGNAL(destroyed()), this, SLOT(containerDestroyed()));
|
||||
|
||||
return mc;
|
||||
}
|
||||
|
||||
ActionContainer *ActionManagerPrivate::createMenuBar(const Id &id)
|
||||
{
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(id);
|
||||
if (it != m_idContainerMap.constEnd())
|
||||
return it.value();
|
||||
|
||||
QMenuBar *mb = new QMenuBar; // No parent (System menu bar on Mac OS X)
|
||||
mb->setObjectName(id.toString());
|
||||
|
||||
MenuBarActionContainer *mbc = new MenuBarActionContainer(id);
|
||||
mbc->setMenuBar(mb);
|
||||
|
||||
m_idContainerMap.insert(id, mbc);
|
||||
connect(mbc, SIGNAL(destroyed()), this, SLOT(containerDestroyed()));
|
||||
|
||||
return mbc;
|
||||
}
|
||||
|
||||
void ActionManagerPrivate::containerDestroyed()
|
||||
{
|
||||
ActionContainerPrivate *container = static_cast<ActionContainerPrivate *>(sender());
|
||||
@@ -362,13 +524,13 @@ void ActionManagerPrivate::shortcutTriggered()
|
||||
|
||||
void ActionManagerPrivate::showShortcutPopup(const QString &shortcut)
|
||||
{
|
||||
if (shortcut.isEmpty() || !isPresentationModeEnabled())
|
||||
if (shortcut.isEmpty() || !ActionManager::isPresentationModeEnabled())
|
||||
return;
|
||||
|
||||
m_presentationLabel->setText(shortcut);
|
||||
m_presentationLabel->adjustSize();
|
||||
|
||||
QPoint p = m_mainWnd->mapToGlobal(m_mainWnd->rect().center() - m_presentationLabel->rect().center());
|
||||
QPoint p = ICore::mainWindow()->mapToGlobal(ICore::mainWindow()->rect().center() - m_presentationLabel->rect().center());
|
||||
m_presentationLabel->move(p);
|
||||
|
||||
m_presentationLabel->show();
|
||||
@@ -376,17 +538,6 @@ void ActionManagerPrivate::showShortcutPopup(const QString &shortcut)
|
||||
m_presentationLabelTimer.start();
|
||||
}
|
||||
|
||||
Command *ActionManagerPrivate::registerAction(QAction *action, const Id &id, const Context &context, bool scriptable)
|
||||
{
|
||||
Action *a = overridableAction(id);
|
||||
if (a) {
|
||||
a->addOverrideAction(action, context, scriptable);
|
||||
emit commandListChanged();
|
||||
emit commandAdded(id.toString());
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
Action *ActionManagerPrivate::overridableAction(const Id &id)
|
||||
{
|
||||
Action *a = 0;
|
||||
@@ -400,105 +551,18 @@ Action *ActionManagerPrivate::overridableAction(const Id &id)
|
||||
} else {
|
||||
a = new Action(id);
|
||||
m_idCmdMap.insert(id, a);
|
||||
m_mainWnd->addAction(a->action());
|
||||
ICore::mainWindow()->addAction(a->action());
|
||||
a->action()->setObjectName(id.toString());
|
||||
a->action()->setShortcutContext(Qt::ApplicationShortcut);
|
||||
a->setCurrentContext(m_context);
|
||||
|
||||
if (isPresentationModeEnabled())
|
||||
if (ActionManager::isPresentationModeEnabled())
|
||||
connect(a->action(), SIGNAL(triggered()), this, SLOT(actionTriggered()));
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
void ActionManagerPrivate::unregisterAction(QAction *action, const Id &id)
|
||||
{
|
||||
Action *a = 0;
|
||||
CommandPrivate *c = m_idCmdMap.value(id, 0);
|
||||
QTC_ASSERT(c, return);
|
||||
a = qobject_cast<Action *>(c);
|
||||
if (!a) {
|
||||
qWarning() << "unregisterAction: id" << id.name()
|
||||
<< "is registered with a different command type.";
|
||||
return;
|
||||
}
|
||||
a->removeOverrideAction(action);
|
||||
if (a->isEmpty()) {
|
||||
// clean up
|
||||
// ActionContainers listen to the commands' destroyed signals
|
||||
m_mainWnd->removeAction(a->action());
|
||||
delete a->action();
|
||||
m_idCmdMap.remove(id);
|
||||
delete a;
|
||||
}
|
||||
emit commandListChanged();
|
||||
}
|
||||
|
||||
Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable)
|
||||
{
|
||||
Shortcut *sc = 0;
|
||||
if (CommandPrivate *c = 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);
|
||||
m_idCmdMap.insert(id, sc);
|
||||
}
|
||||
|
||||
if (sc->shortcut()) {
|
||||
qWarning() << "registerShortcut: action already registered, id" << id.name() << ".";
|
||||
return sc;
|
||||
}
|
||||
|
||||
if (!hasContext(context))
|
||||
shortcut->setEnabled(false);
|
||||
shortcut->setObjectName(id.toString());
|
||||
shortcut->setParent(m_mainWnd);
|
||||
sc->setShortcut(shortcut);
|
||||
sc->setScriptable(scriptable);
|
||||
|
||||
if (context.isEmpty())
|
||||
sc->setContext(Context(0));
|
||||
else
|
||||
sc->setContext(context);
|
||||
|
||||
emit commandListChanged();
|
||||
emit commandAdded(id.toString());
|
||||
|
||||
if (isPresentationModeEnabled())
|
||||
connect(sc->shortcut(), SIGNAL(activated()), this, SLOT(shortcutTriggered()));
|
||||
return sc;
|
||||
}
|
||||
|
||||
Command *ActionManagerPrivate::command(const Id &id) const
|
||||
{
|
||||
const IdCmdMap::const_iterator it = m_idCmdMap.constFind(id);
|
||||
if (it == m_idCmdMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManagerPrivate::command(): failed to find :"
|
||||
<< id.name();
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
ActionContainer *ActionManagerPrivate::actionContainer(const Id &id) const
|
||||
{
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(id);
|
||||
if (it == m_idContainerMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :"
|
||||
<< id.name();
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
static const char settingsGroup[] = "KeyBindings";
|
||||
static const char idKey[] = "ID";
|
||||
static const char sequenceKey[] = "Keysequence";
|
||||
@@ -512,7 +576,7 @@ void ActionManagerPrivate::initialize()
|
||||
const QKeySequence key(settings->value(QLatin1String(sequenceKey)).toString());
|
||||
const Id id = Id(settings->value(QLatin1String(idKey)).toString());
|
||||
|
||||
Command *cmd = command(id);
|
||||
Command *cmd = ActionManager::command(id);
|
||||
if (cmd)
|
||||
cmd->setKeySequence(key);
|
||||
}
|
||||
@@ -539,63 +603,3 @@ void ActionManagerPrivate::saveSettings(QSettings *settings)
|
||||
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
void ActionManagerPrivate::unregisterShortcut(const Core::Id &id)
|
||||
{
|
||||
Shortcut *sc = 0;
|
||||
CommandPrivate *c = 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();
|
||||
m_idCmdMap.remove(id);
|
||||
delete sc;
|
||||
emit commandListChanged();
|
||||
}
|
||||
|
||||
void ActionManagerPrivate::setPresentationModeEnabled(bool enabled)
|
||||
{
|
||||
if (enabled == isPresentationModeEnabled())
|
||||
return;
|
||||
|
||||
// Signal/slots to commands:
|
||||
foreach (Command *c, commands()) {
|
||||
if (c->action()) {
|
||||
if (enabled)
|
||||
connect(c->action(), SIGNAL(triggered()), this, SLOT(actionTriggered()));
|
||||
else
|
||||
disconnect(c->action(), SIGNAL(triggered()), this, SLOT(actionTriggered()));
|
||||
}
|
||||
if (c->shortcut()) {
|
||||
if (enabled)
|
||||
connect(c->shortcut(), SIGNAL(activated()), this, SLOT(shortcutTriggered()));
|
||||
else
|
||||
disconnect(c->shortcut(), SIGNAL(activated()), this, SLOT(shortcutTriggered()));
|
||||
}
|
||||
}
|
||||
|
||||
// The label for the shortcuts:
|
||||
if (!m_presentationLabel) {
|
||||
m_presentationLabel = new QLabel(0, Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
QFont font = m_presentationLabel->font();
|
||||
font.setPixelSize(45);
|
||||
m_presentationLabel->setFont(font);
|
||||
m_presentationLabel->setAlignment(Qt::AlignCenter);
|
||||
m_presentationLabel->setMargin(5);
|
||||
|
||||
connect(&m_presentationLabelTimer, SIGNAL(timeout()), m_presentationLabel, SLOT(hide()));
|
||||
} else {
|
||||
m_presentationLabelTimer.stop();
|
||||
delete m_presentationLabel;
|
||||
m_presentationLabel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ActionManagerPrivate::isPresentationModeEnabled()
|
||||
{
|
||||
return m_presentationLabel;
|
||||
}
|
||||
|
||||
@@ -51,30 +51,46 @@ namespace Core {
|
||||
|
||||
class ActionContainer;
|
||||
|
||||
namespace Internal {
|
||||
class ActionManagerPrivate;
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class CORE_EXPORT ActionManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ActionManager(QObject *parent = 0) : QObject(parent) {}
|
||||
virtual ~ActionManager() {}
|
||||
static ActionManager *instance();
|
||||
|
||||
virtual ActionContainer *createMenu(const Id &id) = 0;
|
||||
virtual ActionContainer *createMenuBar(const Id &id) = 0;
|
||||
static ActionContainer *createMenu(const Id &id);
|
||||
static ActionContainer *createMenuBar(const Id &id);
|
||||
|
||||
virtual Command *registerAction(QAction *action, const Id &id, const Context &context, bool scriptable = false) = 0;
|
||||
virtual Command *registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable = false) = 0;
|
||||
static Command *registerAction(QAction *action, const Id &id, const Context &context, bool scriptable = false);
|
||||
static Command *registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable = false);
|
||||
|
||||
virtual Command *command(const Id &id) const = 0;
|
||||
virtual ActionContainer *actionContainer(const Id &id) const = 0;
|
||||
static Command *command(const Id &id);
|
||||
static ActionContainer *actionContainer(const Id &id);
|
||||
|
||||
virtual QList<Command *> commands() const = 0;
|
||||
static QList<Command *> commands();
|
||||
|
||||
virtual void unregisterAction(QAction *action, const Id &id) = 0;
|
||||
virtual void unregisterShortcut(const Id &id) = 0;
|
||||
static void unregisterAction(QAction *action, const Id &id);
|
||||
static void unregisterShortcut(const Id &id);
|
||||
|
||||
static void setPresentationModeEnabled(bool enabled);
|
||||
static bool isPresentationModeEnabled();
|
||||
|
||||
static bool hasContext(int context);
|
||||
|
||||
signals:
|
||||
void commandListChanged();
|
||||
void commandAdded(const QString &id);
|
||||
|
||||
private:
|
||||
ActionManager(QObject *parent = 0);
|
||||
~ActionManager();
|
||||
Internal::ActionManagerPrivate *d;
|
||||
|
||||
friend class Core::Internal::MainWindow;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
#ifndef ACTIONMANAGERPRIVATE_H
|
||||
#define ACTIONMANAGERPRIVATE_H
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command_p.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer_p.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
#include <QMap>
|
||||
@@ -48,21 +48,23 @@ class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class ActionContainerPrivate;
|
||||
class MainWindow;
|
||||
class CommandPrivate;
|
||||
|
||||
class ActionManagerPrivate : public Core::ActionManager
|
||||
class ActionManagerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ActionManagerPrivate(MainWindow *mainWnd);
|
||||
~ActionManagerPrivate();
|
||||
typedef QHash<Core::Id, CommandPrivate *> IdCmdMap;
|
||||
typedef QHash<Core::Id, ActionContainerPrivate *> IdContainerMap;
|
||||
|
||||
static ActionManagerPrivate *instance();
|
||||
explicit ActionManagerPrivate();
|
||||
~ActionManagerPrivate();
|
||||
|
||||
void initialize();
|
||||
|
||||
@@ -71,49 +73,23 @@ public:
|
||||
|
||||
void saveSettings(QSettings *settings);
|
||||
|
||||
QList<Command *> commands() const;
|
||||
|
||||
Command *command(const Id &id) const;
|
||||
ActionContainer *actionContainer(const Id &id) const;
|
||||
ActionContainer *createMenu(const Id &id);
|
||||
ActionContainer *createMenuBar(const Id &id);
|
||||
|
||||
Command *registerAction(QAction *action, const Id &id,
|
||||
const Context &context, bool scriptable = false);
|
||||
Command *registerShortcut(QShortcut *shortcut, const Id &id,
|
||||
const Context &context, bool scriptable = false);
|
||||
|
||||
void unregisterAction(QAction *action, const Id &id);
|
||||
void unregisterShortcut(const Id &id);
|
||||
|
||||
void setPresentationModeEnabled(bool enabled);
|
||||
bool isPresentationModeEnabled();
|
||||
|
||||
private slots:
|
||||
void containerDestroyed();
|
||||
|
||||
void actionTriggered();
|
||||
void shortcutTriggered();
|
||||
private:
|
||||
void showShortcutPopup(const QString &shortcut);
|
||||
bool hasContext(const Context &context) const;
|
||||
Action *overridableAction(const Id &id);
|
||||
|
||||
static ActionManagerPrivate *m_instance;
|
||||
public slots:
|
||||
void containerDestroyed();
|
||||
|
||||
typedef QHash<Core::Id, CommandPrivate *> IdCmdMap;
|
||||
void actionTriggered();
|
||||
void shortcutTriggered();
|
||||
|
||||
public:
|
||||
IdCmdMap m_idCmdMap;
|
||||
|
||||
typedef QHash<Core::Id, ActionContainerPrivate *> IdContainerMap;
|
||||
IdContainerMap m_idContainerMap;
|
||||
|
||||
// typedef QMap<int, int> GlobalGroupMap;
|
||||
// GlobalGroupMap m_globalgroups;
|
||||
//
|
||||
Context m_context;
|
||||
|
||||
MainWindow *m_mainWnd;
|
||||
|
||||
QLabel *m_presentationLabel;
|
||||
QTimer m_presentationLabelTimer;
|
||||
};
|
||||
|
||||
@@ -33,9 +33,6 @@
|
||||
#include "commandmappings.h"
|
||||
#include "shortcutsettings.h"
|
||||
#include "ui_commandmappings.h"
|
||||
#include "actionmanager_p.h"
|
||||
#include "actionmanager/command.h"
|
||||
#include "command_p.h"
|
||||
#include "commandsfile.h"
|
||||
#include "coreconstants.h"
|
||||
#include "documentmanager.h"
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "coreplugin.h"
|
||||
#include "actionmanager.h"
|
||||
#include "designmode.h"
|
||||
#include "editmode.h"
|
||||
#include "editormanager.h"
|
||||
@@ -81,7 +82,7 @@ void CorePlugin::parseArguments(const QStringList &arguments)
|
||||
i++; // skip the argument
|
||||
}
|
||||
if (arguments.at(i) == QLatin1String("-presentationMode"))
|
||||
m_mainWindow->setPresentationModeEnabled(true);
|
||||
ActionManager::setPresentationModeEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "shortcutsettings.h"
|
||||
#include "actionmanager_p.h"
|
||||
#include "actionmanager/actionmanager.h"
|
||||
#include "actionmanager/command.h"
|
||||
#include "command_p.h"
|
||||
#include "commandsfile.h"
|
||||
@@ -61,8 +61,7 @@ using namespace Core::Internal;
|
||||
ShortcutSettings::ShortcutSettings(QObject *parent)
|
||||
: CommandMappings(parent), m_initialized(false)
|
||||
{
|
||||
Core::Internal::ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
||||
connect(am, SIGNAL(commandListChanged()), this, SLOT(initialize()));
|
||||
connect(ActionManager::instance(), SIGNAL(commandListChanged()), this, SLOT(initialize()));
|
||||
|
||||
setId(QLatin1String(Core::Constants::SETTINGS_ID_SHORTCUTS));
|
||||
setDisplayName(tr("Keyboard"));
|
||||
@@ -265,10 +264,9 @@ void ShortcutSettings::initialize()
|
||||
if (!m_initialized)
|
||||
return;
|
||||
clear();
|
||||
Core::Internal::ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
||||
QMap<QString, QTreeWidgetItem *> sections;
|
||||
|
||||
foreach (Command *c, am->commands()) {
|
||||
foreach (Command *c, ActionManager::instance()->commands()) {
|
||||
if (c->hasAttribute(Command::CA_NonConfigurable))
|
||||
continue;
|
||||
if (c->action() && c->action()->isSeparator())
|
||||
|
||||
@@ -274,12 +274,12 @@ static EditorManager *m_instance = 0;
|
||||
|
||||
EditorManager *EditorManager::instance() { return m_instance; }
|
||||
|
||||
static Command *createSeparator(ActionManager *am, QObject *parent,
|
||||
static Command *createSeparator(QObject *parent,
|
||||
const Id &id, const Context &context)
|
||||
{
|
||||
QAction *tmpaction = new QAction(parent);
|
||||
tmpaction->setSeparator(true);
|
||||
Command *cmd = am->registerAction(tmpaction, id, context);
|
||||
Command *cmd = ActionManager::registerAction(tmpaction, id, context);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@@ -296,12 +296,11 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
// combined context for edit & design modes
|
||||
const Context editDesignContext(Constants::C_EDITORMANAGER, Constants::C_DESIGN_MODE);
|
||||
|
||||
ActionManager *am = ICore::actionManager();
|
||||
ActionContainer *mfile = am->actionContainer(Constants::M_FILE);
|
||||
ActionContainer *mfile = ActionManager::actionContainer(Constants::M_FILE);
|
||||
|
||||
// Revert to saved
|
||||
d->m_revertToSavedAction->setIcon(QIcon::fromTheme(QLatin1String("document-revert")));
|
||||
Command *cmd = am->registerAction(d->m_revertToSavedAction,
|
||||
Command *cmd = ActionManager::registerAction(d->m_revertToSavedAction,
|
||||
Constants::REVERTTOSAVED, editManagerContext);
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
cmd->setDescription(tr("Revert File to Saved"));
|
||||
@@ -309,29 +308,29 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
connect(d->m_revertToSavedAction, SIGNAL(triggered()), this, SLOT(revertToSaved()));
|
||||
|
||||
// Save Action
|
||||
am->registerAction(d->m_saveAction, Constants::SAVE, editManagerContext);
|
||||
ActionManager::registerAction(d->m_saveAction, Constants::SAVE, editManagerContext);
|
||||
connect(d->m_saveAction, SIGNAL(triggered()), this, SLOT(saveDocument()));
|
||||
|
||||
// Save As Action
|
||||
am->registerAction(d->m_saveAsAction, Constants::SAVEAS, editManagerContext);
|
||||
ActionManager::registerAction(d->m_saveAsAction, Constants::SAVEAS, editManagerContext);
|
||||
connect(d->m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveDocumentAs()));
|
||||
|
||||
// Window Menu
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
|
||||
|
||||
// Window menu separators
|
||||
QAction *tmpaction = new QAction(this);
|
||||
tmpaction->setSeparator(true);
|
||||
cmd = am->registerAction(tmpaction, "QtCreator.Window.Sep.Split", editManagerContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Window.Sep.Split", editManagerContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
|
||||
tmpaction = new QAction(this);
|
||||
tmpaction->setSeparator(true);
|
||||
cmd = am->registerAction(tmpaction, "QtCreator.Window.Sep.Navigate", editManagerContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Window.Sep.Navigate", editManagerContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
|
||||
|
||||
// Close Action
|
||||
cmd = am->registerAction(d->m_closeCurrentEditorAction, Constants::CLOSE, editManagerContext, true);
|
||||
cmd = ActionManager::registerAction(d->m_closeCurrentEditorAction, Constants::CLOSE, editManagerContext, true);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+W")));
|
||||
cmd->setAttribute(Core::Command::CA_UpdateText);
|
||||
cmd->setDescription(d->m_closeCurrentEditorAction->text());
|
||||
@@ -341,20 +340,20 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
#ifdef Q_WS_WIN
|
||||
// workaround for QTCREATORBUG-72
|
||||
QShortcut *sc = new QShortcut(parent);
|
||||
cmd = am->registerShortcut(sc, Constants::CLOSE_ALTERNATIVE, editManagerContext);
|
||||
cmd = ActionManager::registerShortcut(sc, Constants::CLOSE_ALTERNATIVE, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F4")));
|
||||
cmd->setDescription(EditorManager::tr("Close"));
|
||||
connect(sc, SIGNAL(activated()), this, SLOT(closeEditor()));
|
||||
#endif
|
||||
|
||||
// Close All Action
|
||||
cmd = am->registerAction(d->m_closeAllEditorsAction, Constants::CLOSEALL, editManagerContext, true);
|
||||
cmd = ActionManager::registerAction(d->m_closeAllEditorsAction, Constants::CLOSEALL, editManagerContext, true);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+W")));
|
||||
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
|
||||
connect(d->m_closeAllEditorsAction, SIGNAL(triggered()), this, SLOT(closeAllEditors()));
|
||||
|
||||
// Close All Others Action
|
||||
cmd = am->registerAction(d->m_closeOtherEditorsAction, Constants::CLOSEOTHERS, editManagerContext, true);
|
||||
cmd = ActionManager::registerAction(d->m_closeOtherEditorsAction, Constants::CLOSEOTHERS, editManagerContext, true);
|
||||
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
|
||||
cmd->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(d->m_closeOtherEditorsAction, SIGNAL(triggered()), this, SLOT(closeOtherEditors()));
|
||||
@@ -368,61 +367,61 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
connect(d->m_openTerminalAction, SIGNAL(triggered()), this, SLOT(openTerminal()));
|
||||
|
||||
// Goto Previous In History Action
|
||||
cmd = am->registerAction(d->m_gotoPreviousDocHistoryAction, Constants::GOTOPREVINHISTORY, editDesignContext);
|
||||
cmd = ActionManager::registerAction(d->m_gotoPreviousDocHistoryAction, Constants::GOTOPREVINHISTORY, editDesignContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Alt+Tab") : tr("Ctrl+Tab")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
|
||||
connect(d->m_gotoPreviousDocHistoryAction, SIGNAL(triggered()), this, SLOT(gotoPreviousDocHistory()));
|
||||
|
||||
// Goto Next In History Action
|
||||
cmd = am->registerAction(d->m_gotoNextDocHistoryAction, Constants::GOTONEXTINHISTORY, editDesignContext);
|
||||
cmd = ActionManager::registerAction(d->m_gotoNextDocHistoryAction, Constants::GOTONEXTINHISTORY, editDesignContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Alt+Shift+Tab") : tr("Ctrl+Shift+Tab")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
|
||||
connect(d->m_gotoNextDocHistoryAction, SIGNAL(triggered()), this, SLOT(gotoNextDocHistory()));
|
||||
|
||||
// Go back in navigation history
|
||||
cmd = am->registerAction(d->m_goBackAction, Constants::GO_BACK, editDesignContext);
|
||||
cmd = ActionManager::registerAction(d->m_goBackAction, Constants::GO_BACK, editDesignContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Alt+Left") : tr("Alt+Left")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
|
||||
connect(d->m_goBackAction, SIGNAL(triggered()), this, SLOT(goBackInNavigationHistory()));
|
||||
|
||||
// Go forward in navigation history
|
||||
cmd = am->registerAction(d->m_goForwardAction, Constants::GO_FORWARD, editDesignContext);
|
||||
cmd = ActionManager::registerAction(d->m_goForwardAction, Constants::GO_FORWARD, editDesignContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Alt+Right") : tr("Alt+Right")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
|
||||
connect(d->m_goForwardAction, SIGNAL(triggered()), this, SLOT(goForwardInNavigationHistory()));
|
||||
|
||||
d->m_splitAction = new QAction(tr("Split"), this);
|
||||
cmd = am->registerAction(d->m_splitAction, Constants::SPLIT, editManagerContext);
|
||||
cmd = ActionManager::registerAction(d->m_splitAction, Constants::SPLIT, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,2") : tr("Ctrl+E,2")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(d->m_splitAction, SIGNAL(triggered()), this, SLOT(split()));
|
||||
|
||||
d->m_splitSideBySideAction = new QAction(tr("Split Side by Side"), this);
|
||||
cmd = am->registerAction(d->m_splitSideBySideAction, Constants::SPLIT_SIDE_BY_SIDE, editManagerContext);
|
||||
cmd = ActionManager::registerAction(d->m_splitSideBySideAction, Constants::SPLIT_SIDE_BY_SIDE, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,3") : tr("Ctrl+E,3")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(d->m_splitSideBySideAction, SIGNAL(triggered()), this, SLOT(splitSideBySide()));
|
||||
|
||||
d->m_removeCurrentSplitAction = new QAction(tr("Remove Current Split"), this);
|
||||
cmd = am->registerAction(d->m_removeCurrentSplitAction, Constants::REMOVE_CURRENT_SPLIT, editManagerContext);
|
||||
cmd = ActionManager::registerAction(d->m_removeCurrentSplitAction, Constants::REMOVE_CURRENT_SPLIT, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,0") : tr("Ctrl+E,0")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(d->m_removeCurrentSplitAction, SIGNAL(triggered()), this, SLOT(removeCurrentSplit()));
|
||||
|
||||
d->m_removeAllSplitsAction = new QAction(tr("Remove All Splits"), this);
|
||||
cmd = am->registerAction(d->m_removeAllSplitsAction, Constants::REMOVE_ALL_SPLITS, editManagerContext);
|
||||
cmd = ActionManager::registerAction(d->m_removeAllSplitsAction, Constants::REMOVE_ALL_SPLITS, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,1") : tr("Ctrl+E,1")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(d->m_removeAllSplitsAction, SIGNAL(triggered()), this, SLOT(removeAllSplits()));
|
||||
|
||||
d->m_gotoOtherSplitAction = new QAction(tr("Go to Next Split"), this);
|
||||
cmd = am->registerAction(d->m_gotoOtherSplitAction, Constants::GOTO_OTHER_SPLIT, editManagerContext);
|
||||
cmd = ActionManager::registerAction(d->m_gotoOtherSplitAction, Constants::GOTO_OTHER_SPLIT, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,o") : tr("Ctrl+E,o")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(d->m_gotoOtherSplitAction, SIGNAL(triggered()), this, SLOT(gotoOtherSplit()));
|
||||
|
||||
ActionContainer *medit = am->actionContainer(Constants::M_EDIT);
|
||||
ActionContainer *advancedMenu = am->createMenu(Constants::M_EDIT_ADVANCED);
|
||||
ActionContainer *medit = ActionManager::actionContainer(Constants::M_EDIT);
|
||||
ActionContainer *advancedMenu = ActionManager::createMenu(Constants::M_EDIT_ADVANCED);
|
||||
medit->addMenu(advancedMenu, Constants::G_EDIT_ADVANCED);
|
||||
advancedMenu->menu()->setTitle(tr("Ad&vanced"));
|
||||
advancedMenu->appendGroup(Constants::G_EDIT_FORMAT);
|
||||
@@ -432,13 +431,13 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
advancedMenu->appendGroup(Constants::G_EDIT_EDITOR);
|
||||
|
||||
// Advanced menu separators
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Edit.Sep.Collapsing"), editManagerContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Collapsing"), editManagerContext);
|
||||
advancedMenu->addAction(cmd, Constants::G_EDIT_COLLAPSING);
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Edit.Sep.Blocks"), editManagerContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Blocks"), editManagerContext);
|
||||
advancedMenu->addAction(cmd, Constants::G_EDIT_BLOCKS);
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Edit.Sep.Font"), editManagerContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Font"), editManagerContext);
|
||||
advancedMenu->addAction(cmd, Constants::G_EDIT_FONT);
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Edit.Sep.Editor"), editManagerContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Editor"), editManagerContext);
|
||||
advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR);
|
||||
|
||||
// other setup
|
||||
|
||||
@@ -200,12 +200,11 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
|
||||
this, SIGNAL(closeSplitClicked()), Qt::QueuedConnection);
|
||||
|
||||
|
||||
ActionManager *am = ICore::actionManager();
|
||||
connect(am->command(Constants::CLOSE), SIGNAL(keySequenceChanged()),
|
||||
connect(ActionManager::command(Constants::CLOSE), SIGNAL(keySequenceChanged()),
|
||||
this, SLOT(updateActionShortcuts()));
|
||||
connect(am->command(Constants::GO_BACK), SIGNAL(keySequenceChanged()),
|
||||
connect(ActionManager::command(Constants::GO_BACK), SIGNAL(keySequenceChanged()),
|
||||
this, SLOT(updateActionShortcuts()));
|
||||
connect(am->command(Constants::GO_FORWARD), SIGNAL(keySequenceChanged()),
|
||||
connect(ActionManager::command(Constants::GO_FORWARD), SIGNAL(keySequenceChanged()),
|
||||
this, SLOT(updateActionShortcuts()));
|
||||
|
||||
updateActionShortcuts();
|
||||
@@ -362,11 +361,10 @@ void EditorToolBar::setCanGoForward(bool canGoForward)
|
||||
|
||||
void EditorToolBar::updateActionShortcuts()
|
||||
{
|
||||
ActionManager *am = ICore::actionManager();
|
||||
d->m_closeEditorButton->setToolTip(am->command(Constants::CLOSE)->stringWithAppendedShortcut(EditorManager::tr("Close Document")));
|
||||
d->m_goBackAction->setToolTip(am->command(Constants::GO_BACK)->action()->toolTip());
|
||||
d->m_goForwardAction->setToolTip(am->command(Constants::GO_FORWARD)->action()->toolTip());
|
||||
d->m_closeSplitButton->setToolTip(am->command(Constants::REMOVE_CURRENT_SPLIT)->stringWithAppendedShortcut(tr("Remove Split")));
|
||||
d->m_closeEditorButton->setToolTip(ActionManager::command(Constants::CLOSE)->stringWithAppendedShortcut(EditorManager::tr("Close Document")));
|
||||
d->m_goBackAction->setToolTip(ActionManager::command(Constants::GO_BACK)->action()->toolTip());
|
||||
d->m_goForwardAction->setToolTip(ActionManager::command(Constants::GO_FORWARD)->action()->toolTip());
|
||||
d->m_closeSplitButton->setToolTip(ActionManager::command(Constants::REMOVE_CURRENT_SPLIT)->stringWithAppendedShortcut(tr("Remove Split")));
|
||||
}
|
||||
|
||||
void EditorToolBar::checkEditorStatus()
|
||||
|
||||
@@ -710,10 +710,9 @@ void ExternalToolManager::initialize()
|
||||
connect(m_configureAction, SIGNAL(triggered()), this, SLOT(openPreferences()));
|
||||
|
||||
// add the external tools menu
|
||||
ActionManager *am = ICore::actionManager();
|
||||
ActionContainer *mexternaltools = am->createMenu(Id(Constants::M_TOOLS_EXTERNAL));
|
||||
ActionContainer *mexternaltools = ActionManager::createMenu(Id(Constants::M_TOOLS_EXTERNAL));
|
||||
mexternaltools->menu()->setTitle(tr("&External"));
|
||||
ActionContainer *mtools = am->actionContainer(Constants::M_TOOLS);
|
||||
ActionContainer *mtools = ActionManager::actionContainer(Constants::M_TOOLS);
|
||||
mtools->addMenu(mexternaltools, Constants::G_DEFAULT_THREE);
|
||||
|
||||
QMap<QString, QMultiMap<int, ExternalTool*> > categoryPriorityMap;
|
||||
@@ -799,8 +798,7 @@ QMap<QString, ExternalTool *> ExternalToolManager::toolsById() const
|
||||
void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal::ExternalTool *> > &tools)
|
||||
{
|
||||
// clear menu
|
||||
ActionManager *am = ICore::actionManager();
|
||||
ActionContainer *mexternaltools = am->actionContainer(Id(Constants::M_TOOLS_EXTERNAL));
|
||||
ActionContainer *mexternaltools = ActionManager::actionContainer(Id(Constants::M_TOOLS_EXTERNAL));
|
||||
mexternaltools->clear();
|
||||
|
||||
// delete old tools and create list of new ones
|
||||
@@ -825,7 +823,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
|
||||
const QString externalToolsPrefix = QLatin1String("Tools.External.");
|
||||
while (remainingActions.hasNext()) {
|
||||
remainingActions.next();
|
||||
am->unregisterAction(remainingActions.value(), Id(externalToolsPrefix + remainingActions.key()));
|
||||
ActionManager::unregisterAction(remainingActions.value(), Id(externalToolsPrefix + remainingActions.key()));
|
||||
delete remainingActions.value();
|
||||
}
|
||||
m_actions.clear();
|
||||
@@ -847,7 +845,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
|
||||
if (m_containers.contains(containerName)) {
|
||||
container = m_containers.take(containerName); // remove to avoid deletion below
|
||||
} else {
|
||||
container = am->createMenu(Id(QLatin1String("Tools.External.Category.") + containerName));
|
||||
container = ActionManager::createMenu(Id(QLatin1String("Tools.External.Category.") + containerName));
|
||||
}
|
||||
newContainers.insert(containerName, container);
|
||||
mexternaltools->addMenu(container, Constants::G_DEFAULT_ONE);
|
||||
@@ -860,13 +858,13 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
|
||||
Command *command = 0;
|
||||
if (m_actions.contains(toolId)) {
|
||||
action = m_actions.value(toolId);
|
||||
command = am->command(Id(externalToolsPrefix + toolId));
|
||||
command = ActionManager::command(Id(externalToolsPrefix + toolId));
|
||||
} else {
|
||||
action = new QAction(tool->displayName(), this);
|
||||
action->setData(toolId);
|
||||
m_actions.insert(toolId, action);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(menuActivated()));
|
||||
command = am->registerAction(action, Id(externalToolsPrefix + toolId), Context(Constants::C_GLOBAL));
|
||||
command = ActionManager::registerAction(action, Id(externalToolsPrefix + toolId), Context(Constants::C_GLOBAL));
|
||||
command->setAttribute(Command::CA_UpdateText);
|
||||
}
|
||||
action->setText(tool->displayName());
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
const QString &settingsId = QString(),
|
||||
QWidget *parent = 0);
|
||||
|
||||
static ActionManager *actionManager();
|
||||
static QT_DEPRECATED ActionManager *actionManager(); // Use Actionmanager::... directly.
|
||||
static QT_DEPRECATED DocumentManager *documentManager(); // Use DocumentManager::... directly.
|
||||
static MessageManager *messageManager();
|
||||
static EditorManager *editorManager();
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "actioncontainer.h"
|
||||
#include "command.h"
|
||||
#include "actionmanager.h"
|
||||
#include "actionmanager_p.h"
|
||||
#include "icore.h"
|
||||
#include "coreconstants.h"
|
||||
@@ -138,7 +139,7 @@ MainWindow::MainWindow() :
|
||||
QLatin1String("QtCreator"),
|
||||
this)),
|
||||
m_printer(0),
|
||||
m_actionManager(new ActionManagerPrivate(this)),
|
||||
m_actionManager(new ActionManager(this)),
|
||||
m_editorManager(0),
|
||||
m_externalToolManager(0),
|
||||
m_progressManager(new ProgressManagerPrivate()),
|
||||
@@ -266,16 +267,6 @@ void MainWindow::setOverrideColor(const QColor &color)
|
||||
m_overrideColor = color;
|
||||
}
|
||||
|
||||
bool MainWindow::isPresentationModeEnabled()
|
||||
{
|
||||
return m_actionManager->isPresentationModeEnabled();
|
||||
}
|
||||
|
||||
void MainWindow::setPresentationModeEnabled(bool enabled)
|
||||
{
|
||||
m_actionManager->setPresentationModeEnabled(enabled);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void MainWindow::setIsFullScreen(bool fullScreen)
|
||||
{
|
||||
@@ -384,7 +375,7 @@ void MainWindow::extensionsInitialized()
|
||||
m_navigationWidget->setFactories(ExtensionSystem::PluginManager::instance()->getObjects<INavigationWidgetFactory>());
|
||||
|
||||
// reading the shortcut settings must be done after all shortcuts have been registered
|
||||
m_actionManager->initialize();
|
||||
m_actionManager->d->initialize();
|
||||
|
||||
readSettings();
|
||||
updateContext();
|
||||
@@ -497,9 +488,7 @@ QStatusBar *MainWindow::statusBar() const
|
||||
|
||||
void MainWindow::registerDefaultContainers()
|
||||
{
|
||||
ActionManagerPrivate *am = m_actionManager;
|
||||
|
||||
ActionContainer *menubar = am->createMenuBar(Constants::MENU_BAR);
|
||||
ActionContainer *menubar = ActionManager::createMenuBar(Constants::MENU_BAR);
|
||||
|
||||
#ifndef Q_OS_MAC // System menu bar on Mac
|
||||
setMenuBar(menubar->menuBar());
|
||||
@@ -512,7 +501,7 @@ void MainWindow::registerDefaultContainers()
|
||||
menubar->appendGroup(Constants::G_HELP);
|
||||
|
||||
// File Menu
|
||||
ActionContainer *filemenu = am->createMenu(Constants::M_FILE);
|
||||
ActionContainer *filemenu = ActionManager::createMenu(Constants::M_FILE);
|
||||
menubar->addMenu(filemenu, Constants::G_FILE);
|
||||
filemenu->menu()->setTitle(tr("&File"));
|
||||
filemenu->appendGroup(Constants::G_FILE_NEW);
|
||||
@@ -526,7 +515,7 @@ void MainWindow::registerDefaultContainers()
|
||||
|
||||
|
||||
// Edit Menu
|
||||
ActionContainer *medit = am->createMenu(Constants::M_EDIT);
|
||||
ActionContainer *medit = ActionManager::createMenu(Constants::M_EDIT);
|
||||
menubar->addMenu(medit, Constants::G_EDIT);
|
||||
medit->menu()->setTitle(tr("&Edit"));
|
||||
medit->appendGroup(Constants::G_EDIT_UNDOREDO);
|
||||
@@ -537,12 +526,12 @@ void MainWindow::registerDefaultContainers()
|
||||
medit->appendGroup(Constants::G_EDIT_OTHER);
|
||||
|
||||
// Tools Menu
|
||||
ActionContainer *ac = am->createMenu(Constants::M_TOOLS);
|
||||
ActionContainer *ac = ActionManager::createMenu(Constants::M_TOOLS);
|
||||
menubar->addMenu(ac, Constants::G_TOOLS);
|
||||
ac->menu()->setTitle(tr("&Tools"));
|
||||
|
||||
// Window Menu
|
||||
ActionContainer *mwindow = am->createMenu(Constants::M_WINDOW);
|
||||
ActionContainer *mwindow = ActionManager::createMenu(Constants::M_WINDOW);
|
||||
menubar->addMenu(mwindow, Constants::G_WINDOW);
|
||||
mwindow->menu()->setTitle(tr("&Window"));
|
||||
mwindow->appendGroup(Constants::G_WINDOW_SIZE);
|
||||
@@ -553,71 +542,70 @@ void MainWindow::registerDefaultContainers()
|
||||
mwindow->appendGroup(Constants::G_WINDOW_OTHER);
|
||||
|
||||
// Help Menu
|
||||
ac = am->createMenu(Constants::M_HELP);
|
||||
ac = ActionManager::createMenu(Constants::M_HELP);
|
||||
menubar->addMenu(ac, Constants::G_HELP);
|
||||
ac->menu()->setTitle(tr("&Help"));
|
||||
ac->appendGroup(Constants::G_HELP_HELP);
|
||||
ac->appendGroup(Constants::G_HELP_ABOUT);
|
||||
}
|
||||
|
||||
static Command *createSeparator(ActionManager *am, QObject *parent,
|
||||
static Command *createSeparator(QObject *parent,
|
||||
const Id &id, const Context &context)
|
||||
{
|
||||
QAction *tmpaction = new QAction(parent);
|
||||
tmpaction->setSeparator(true);
|
||||
Command *cmd = am->registerAction(tmpaction, id, context);
|
||||
Command *cmd = ActionManager::registerAction(tmpaction, id, context);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
void MainWindow::registerDefaultActions()
|
||||
{
|
||||
ActionManagerPrivate *am = m_actionManager;
|
||||
ActionContainer *mfile = am->actionContainer(Constants::M_FILE);
|
||||
ActionContainer *medit = am->actionContainer(Constants::M_EDIT);
|
||||
ActionContainer *mtools = am->actionContainer(Constants::M_TOOLS);
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
ActionContainer *mhelp = am->actionContainer(Constants::M_HELP);
|
||||
ActionContainer *mfile = ActionManager::actionContainer(Constants::M_FILE);
|
||||
ActionContainer *medit = ActionManager::actionContainer(Constants::M_EDIT);
|
||||
ActionContainer *mtools = ActionManager::actionContainer(Constants::M_TOOLS);
|
||||
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
|
||||
ActionContainer *mhelp = ActionManager::actionContainer(Constants::M_HELP);
|
||||
|
||||
Context globalContext(Constants::C_GLOBAL);
|
||||
|
||||
// File menu separators
|
||||
Command *cmd = createSeparator(am, this, Id("QtCreator.File.Sep.Save"), globalContext);
|
||||
Command *cmd = createSeparator(this, Id("QtCreator.File.Sep.Save"), globalContext);
|
||||
mfile->addAction(cmd, Constants::G_FILE_SAVE);
|
||||
|
||||
cmd = createSeparator(am, this, Id("QtCreator.File.Sep.Print"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.File.Sep.Print"), globalContext);
|
||||
QIcon icon = QIcon::fromTheme(QLatin1String("edit-cut"), QIcon(QLatin1String(Constants::ICON_CUT)));
|
||||
mfile->addAction(cmd, Constants::G_FILE_PRINT);
|
||||
|
||||
cmd = createSeparator(am, this, Id("QtCreator.File.Sep.Close"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.File.Sep.Close"), globalContext);
|
||||
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
|
||||
|
||||
cmd = createSeparator(am, this, Id("QtCreator.File.Sep.Other"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.File.Sep.Other"), globalContext);
|
||||
mfile->addAction(cmd, Constants::G_FILE_OTHER);
|
||||
|
||||
// Edit menu separators
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Edit.Sep.CopyPaste"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.CopyPaste"), globalContext);
|
||||
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
|
||||
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Edit.Sep.SelectAll"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.SelectAll"), globalContext);
|
||||
medit->addAction(cmd, Constants::G_EDIT_SELECTALL);
|
||||
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Edit.Sep.Find"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Find"), globalContext);
|
||||
medit->addAction(cmd, Constants::G_EDIT_FIND);
|
||||
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Edit.Sep.Advanced"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Advanced"), globalContext);
|
||||
medit->addAction(cmd, Constants::G_EDIT_ADVANCED);
|
||||
|
||||
// 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);
|
||||
cmd = am->registerShortcut(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext);
|
||||
cmd = ActionManager::registerShortcut(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
|
||||
connect(m_focusToEditor, SIGNAL(activated()), this, SLOT(setFocusToEditor()));
|
||||
|
||||
// New File Action
|
||||
icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE)));
|
||||
m_newAction = new QAction(icon, tr("&New File or Project..."), this);
|
||||
cmd = am->registerAction(m_newAction, Constants::NEW, globalContext);
|
||||
cmd = ActionManager::registerAction(m_newAction, Constants::NEW, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::New);
|
||||
mfile->addAction(cmd, Constants::G_FILE_NEW);
|
||||
connect(m_newAction, SIGNAL(triggered()), this, SLOT(newFile()));
|
||||
@@ -625,19 +613,19 @@ void MainWindow::registerDefaultActions()
|
||||
// Open Action
|
||||
icon = QIcon::fromTheme(QLatin1String("document-open"), QIcon(QLatin1String(Constants::ICON_OPENFILE)));
|
||||
m_openAction = new QAction(icon, tr("&Open File or Project..."), this);
|
||||
cmd = am->registerAction(m_openAction, Constants::OPEN, globalContext);
|
||||
cmd = ActionManager::registerAction(m_openAction, Constants::OPEN, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Open);
|
||||
mfile->addAction(cmd, Constants::G_FILE_OPEN);
|
||||
connect(m_openAction, SIGNAL(triggered()), this, SLOT(openFile()));
|
||||
|
||||
// Open With Action
|
||||
m_openWithAction = new QAction(tr("Open File &With..."), this);
|
||||
cmd = am->registerAction(m_openWithAction, Constants::OPEN_WITH, globalContext);
|
||||
cmd = ActionManager::registerAction(m_openWithAction, Constants::OPEN_WITH, globalContext);
|
||||
mfile->addAction(cmd, Constants::G_FILE_OPEN);
|
||||
connect(m_openWithAction, SIGNAL(triggered()), this, SLOT(openFileWith()));
|
||||
|
||||
// File->Recent Files Menu
|
||||
ActionContainer *ac = am->createMenu(Constants::M_FILE_RECENTFILES);
|
||||
ActionContainer *ac = ActionManager::createMenu(Constants::M_FILE_RECENTFILES);
|
||||
mfile->addMenu(ac, Constants::G_FILE_OPEN);
|
||||
ac->menu()->setTitle(tr("Recent &Files"));
|
||||
ac->setOnAllDisabledBehavior(ActionContainer::Show);
|
||||
@@ -646,7 +634,7 @@ void MainWindow::registerDefaultActions()
|
||||
icon = QIcon::fromTheme(QLatin1String("document-save"), QIcon(QLatin1String(Constants::ICON_SAVEFILE)));
|
||||
QAction *tmpaction = new QAction(icon, tr("&Save"), this);
|
||||
tmpaction->setEnabled(false);
|
||||
cmd = am->registerAction(tmpaction, Constants::SAVE, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::SAVE, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Save);
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
cmd->setDescription(tr("Save"));
|
||||
@@ -656,7 +644,7 @@ void MainWindow::registerDefaultActions()
|
||||
icon = QIcon::fromTheme(QLatin1String("document-save-as"));
|
||||
tmpaction = new QAction(icon, tr("Save &As..."), this);
|
||||
tmpaction->setEnabled(false);
|
||||
cmd = am->registerAction(tmpaction, Constants::SAVEAS, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+S") : QString()));
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
cmd->setDescription(tr("Save As..."));
|
||||
@@ -664,7 +652,7 @@ void MainWindow::registerDefaultActions()
|
||||
|
||||
// SaveAll Action
|
||||
m_saveAllAction = new QAction(tr("Save A&ll"), this);
|
||||
cmd = am->registerAction(m_saveAllAction, Constants::SAVEALL, globalContext);
|
||||
cmd = ActionManager::registerAction(m_saveAllAction, Constants::SAVEALL, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("Ctrl+Shift+S")));
|
||||
mfile->addAction(cmd, Constants::G_FILE_SAVE);
|
||||
connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll()));
|
||||
@@ -673,14 +661,14 @@ void MainWindow::registerDefaultActions()
|
||||
icon = QIcon::fromTheme(QLatin1String("document-print"));
|
||||
tmpaction = new QAction(icon, tr("&Print..."), this);
|
||||
tmpaction->setEnabled(false);
|
||||
cmd = am->registerAction(tmpaction, Constants::PRINT, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::PRINT, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Print);
|
||||
mfile->addAction(cmd, Constants::G_FILE_PRINT);
|
||||
|
||||
// Exit Action
|
||||
icon = QIcon::fromTheme(QLatin1String("application-exit"));
|
||||
m_exitAction = new QAction(icon, tr("E&xit"), this);
|
||||
cmd = am->registerAction(m_exitAction, Constants::EXIT, globalContext);
|
||||
cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Q")));
|
||||
mfile->addAction(cmd, Constants::G_FILE_OTHER);
|
||||
connect(m_exitAction, SIGNAL(triggered()), this, SLOT(exit()));
|
||||
@@ -688,7 +676,7 @@ void MainWindow::registerDefaultActions()
|
||||
// Undo Action
|
||||
icon = QIcon::fromTheme(QLatin1String("edit-undo"), QIcon(QLatin1String(Constants::ICON_UNDO)));
|
||||
tmpaction = new QAction(icon, tr("&Undo"), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::UNDO, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::UNDO, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Undo);
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
cmd->setDescription(tr("Undo"));
|
||||
@@ -698,7 +686,7 @@ void MainWindow::registerDefaultActions()
|
||||
// Redo Action
|
||||
icon = QIcon::fromTheme(QLatin1String("edit-redo"), QIcon(QLatin1String(Constants::ICON_REDO)));
|
||||
tmpaction = new QAction(icon, tr("&Redo"), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::REDO, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::REDO, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Redo);
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
cmd->setDescription(tr("Redo"));
|
||||
@@ -708,7 +696,7 @@ void MainWindow::registerDefaultActions()
|
||||
// Cut Action
|
||||
icon = QIcon::fromTheme(QLatin1String("edit-cut"), QIcon(QLatin1String(Constants::ICON_CUT)));
|
||||
tmpaction = new QAction(icon, tr("Cu&t"), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::CUT, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::CUT, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Cut);
|
||||
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
|
||||
tmpaction->setEnabled(false);
|
||||
@@ -716,7 +704,7 @@ void MainWindow::registerDefaultActions()
|
||||
// Copy Action
|
||||
icon = QIcon::fromTheme(QLatin1String("edit-copy"), QIcon(QLatin1String(Constants::ICON_COPY)));
|
||||
tmpaction = new QAction(icon, tr("&Copy"), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::COPY, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::COPY, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Copy);
|
||||
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
|
||||
tmpaction->setEnabled(false);
|
||||
@@ -724,7 +712,7 @@ void MainWindow::registerDefaultActions()
|
||||
// Paste Action
|
||||
icon = QIcon::fromTheme(QLatin1String("edit-paste"), QIcon(QLatin1String(Constants::ICON_PASTE)));
|
||||
tmpaction = new QAction(icon, tr("&Paste"), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::PASTE, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::PASTE, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Paste);
|
||||
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
|
||||
tmpaction->setEnabled(false);
|
||||
@@ -732,7 +720,7 @@ void MainWindow::registerDefaultActions()
|
||||
// Select All
|
||||
icon = QIcon::fromTheme(QLatin1String("edit-select-all"));
|
||||
tmpaction = new QAction(icon, tr("Select &All"), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::SELECTALL, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::SelectAll);
|
||||
medit->addAction(cmd, Constants::G_EDIT_SELECTALL);
|
||||
tmpaction->setEnabled(false);
|
||||
@@ -740,17 +728,17 @@ void MainWindow::registerDefaultActions()
|
||||
// Goto Action
|
||||
icon = QIcon::fromTheme(QLatin1String("go-jump"));
|
||||
tmpaction = new QAction(icon, tr("&Go to Line..."), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::GOTO, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::GOTO, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+L")));
|
||||
medit->addAction(cmd, Constants::G_EDIT_OTHER);
|
||||
tmpaction->setEnabled(false);
|
||||
|
||||
// Options Action
|
||||
mtools->appendGroup(Constants::G_TOOLS_OPTIONS);
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Tools.Sep.Options"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Tools.Sep.Options"), globalContext);
|
||||
mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS);
|
||||
m_optionsAction = new QAction(tr("&Options..."), this);
|
||||
cmd = am->registerAction(m_optionsAction, Constants::OPTIONS, globalContext);
|
||||
cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS, globalContext);
|
||||
if (UseMacShortcuts) {
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+,")));
|
||||
cmd->action()->setMenuRole(QAction::PreferencesRole);
|
||||
@@ -761,19 +749,19 @@ void MainWindow::registerDefaultActions()
|
||||
if (UseMacShortcuts) {
|
||||
// Minimize Action
|
||||
m_minimizeAction = new QAction(tr("Minimize"), this);
|
||||
cmd = am->registerAction(m_minimizeAction, Constants::MINIMIZE_WINDOW, globalContext);
|
||||
cmd = ActionManager::registerAction(m_minimizeAction, Constants::MINIMIZE_WINDOW, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
||||
connect(m_minimizeAction, SIGNAL(triggered()), this, SLOT(showMinimized()));
|
||||
|
||||
// Zoom Action
|
||||
m_zoomAction = new QAction(tr("Zoom"), this);
|
||||
cmd = am->registerAction(m_zoomAction, Constants::ZOOM_WINDOW, globalContext);
|
||||
cmd = ActionManager::registerAction(m_zoomAction, Constants::ZOOM_WINDOW, globalContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
||||
connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
|
||||
|
||||
// Window separator
|
||||
cmd = createSeparator(am, this, Id("QtCreator.Window.Sep.Size"), globalContext);
|
||||
cmd = createSeparator(this, Id("QtCreator.Window.Sep.Size"), globalContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
||||
}
|
||||
|
||||
@@ -781,7 +769,7 @@ void MainWindow::registerDefaultActions()
|
||||
m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Constants::ICON_TOGGLE_SIDEBAR)),
|
||||
tr("Show Sidebar"), this);
|
||||
m_toggleSideBarAction->setCheckable(true);
|
||||
cmd = am->registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR, globalContext);
|
||||
cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR, globalContext);
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0")));
|
||||
connect(m_toggleSideBarAction, SIGNAL(triggered(bool)), this, SLOT(setSidebarVisible(bool)));
|
||||
@@ -802,7 +790,7 @@ void MainWindow::registerDefaultActions()
|
||||
// Full Screen Action
|
||||
m_toggleFullScreenAction = new QAction(fullScreenActionText, this);
|
||||
m_toggleFullScreenAction->setCheckable(fullScreenCheckable);
|
||||
cmd = am->registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext);
|
||||
cmd = ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11")));
|
||||
cmd->setAttribute(Command::CA_UpdateText); /* for Mac */
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
||||
@@ -810,7 +798,7 @@ void MainWindow::registerDefaultActions()
|
||||
}
|
||||
|
||||
// Window->Views
|
||||
ActionContainer *mviews = am->createMenu(Constants::M_WINDOW_VIEWS);
|
||||
ActionContainer *mviews = ActionManager::createMenu(Constants::M_WINDOW_VIEWS);
|
||||
mwindow->addMenu(mviews, Constants::G_WINDOW_VIEWS);
|
||||
mviews->menu()->setTitle(tr("&Views"));
|
||||
|
||||
@@ -821,7 +809,7 @@ void MainWindow::registerDefaultActions()
|
||||
#else
|
||||
tmpaction = new QAction(icon, tr("About &Qt Creator..."), this);
|
||||
#endif
|
||||
cmd = am->registerAction(tmpaction, Constants::ABOUT_QTCREATOR, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR, globalContext);
|
||||
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
||||
tmpaction->setEnabled(true);
|
||||
#ifdef Q_OS_MAC
|
||||
@@ -831,7 +819,7 @@ void MainWindow::registerDefaultActions()
|
||||
|
||||
//About Plugins Action
|
||||
tmpaction = new QAction(tr("About &Plugins..."), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::ABOUT_PLUGINS, globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS, globalContext);
|
||||
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
||||
tmpaction->setEnabled(true);
|
||||
#ifdef Q_OS_MAC
|
||||
@@ -840,7 +828,7 @@ void MainWindow::registerDefaultActions()
|
||||
connect(tmpaction, SIGNAL(triggered()), this, SLOT(aboutPlugins()));
|
||||
// About Qt Action
|
||||
// tmpaction = new QAction(tr("About &Qt..."), this);
|
||||
// cmd = am->registerAction(tmpaction, Constants:: ABOUT_QT, globalContext);
|
||||
// cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT, globalContext);
|
||||
// mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
||||
// tmpaction->setEnabled(true);
|
||||
// connect(tmpaction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||
@@ -848,7 +836,7 @@ void MainWindow::registerDefaultActions()
|
||||
#ifndef Q_OS_MAC // doesn't have the "About" actions in the Help menu
|
||||
tmpaction = new QAction(this);
|
||||
tmpaction->setSeparator(true);
|
||||
cmd = am->registerAction(tmpaction, "QtCreator.Help.Sep.About", globalContext);
|
||||
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About", globalContext);
|
||||
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
||||
#endif
|
||||
}
|
||||
@@ -1256,7 +1244,7 @@ void MainWindow::writeSettings()
|
||||
m_settings->endGroup();
|
||||
|
||||
DocumentManager::saveSettings();
|
||||
m_actionManager->saveSettings(m_settings);
|
||||
m_actionManager->d->saveSettings(m_settings);
|
||||
m_editorManager->saveSettings();
|
||||
m_navigationWidget->saveSettings(m_settings);
|
||||
}
|
||||
@@ -1285,7 +1273,7 @@ void MainWindow::updateAdditionalContexts(const Context &remove, const Context &
|
||||
|
||||
bool MainWindow::hasContext(int context) const
|
||||
{
|
||||
return m_actionManager->hasContext(context);
|
||||
return ActionManager::hasContext(context);
|
||||
}
|
||||
|
||||
void MainWindow::updateContext()
|
||||
@@ -1304,14 +1292,14 @@ void MainWindow::updateContext()
|
||||
uniquecontexts.add(c);
|
||||
}
|
||||
|
||||
m_actionManager->setContext(uniquecontexts);
|
||||
m_actionManager->d->setContext(uniquecontexts);
|
||||
emit m_coreImpl->contextChanged(m_activeContext, m_additionalContexts);
|
||||
}
|
||||
|
||||
void MainWindow::aboutToShowRecentFiles()
|
||||
{
|
||||
ActionContainer *aci =
|
||||
m_actionManager->actionContainer(Constants::M_FILE_RECENTFILES);
|
||||
ActionManager::actionContainer(Constants::M_FILE_RECENTFILES);
|
||||
aci->menu()->clear();
|
||||
|
||||
bool hasRecentFiles = false;
|
||||
|
||||
@@ -124,9 +124,6 @@ public:
|
||||
|
||||
void setOverrideColor(const QColor &color);
|
||||
|
||||
bool isPresentationModeEnabled();
|
||||
void setPresentationModeEnabled(bool);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void setIsFullScreen(bool fullScreen);
|
||||
#endif
|
||||
@@ -189,7 +186,7 @@ private:
|
||||
QSettings *m_globalSettings;
|
||||
SettingsDatabase *m_settingsDatabase;
|
||||
mutable QPrinter *m_printer;
|
||||
ActionManagerPrivate *m_actionManager;
|
||||
ActionManager *m_actionManager;
|
||||
EditorManager *m_editorManager;
|
||||
ExternalToolManager *m_externalToolManager;
|
||||
MessageManager *m_messageManager;
|
||||
|
||||
@@ -197,11 +197,10 @@ void ModeManager::objectAdded(QObject *obj)
|
||||
d->m_modeStack->setTabEnabled(index, mode->isEnabled());
|
||||
|
||||
// Register mode shortcut
|
||||
ActionManager *am = d->m_mainWindow->actionManager();
|
||||
const Id shortcutId(QLatin1String("QtCreator.Mode.") + mode->id().toString());
|
||||
QShortcut *shortcut = new QShortcut(d->m_mainWindow);
|
||||
shortcut->setWhatsThis(tr("Switch to <b>%1</b> mode").arg(mode->displayName()));
|
||||
Command *cmd = am->registerShortcut(shortcut, shortcutId, Context(Constants::C_GLOBAL));
|
||||
Command *cmd = ActionManager::registerShortcut(shortcut, shortcutId, Context(Constants::C_GLOBAL));
|
||||
|
||||
d->m_modeShortcuts.insert(index, cmd);
|
||||
connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updateModeToolTip()));
|
||||
|
||||
@@ -187,7 +187,6 @@ NavigationWidget *NavigationWidget::instance()
|
||||
|
||||
void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> factories)
|
||||
{
|
||||
ActionManager *am = ICore::actionManager();
|
||||
Context navicontext(Core::Constants::C_NAVIGATION_PANE);
|
||||
|
||||
foreach (INavigationWidgetFactory *factory, factories) {
|
||||
@@ -198,7 +197,7 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> fact
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget()));
|
||||
d->m_shortcutMap.insert(shortcut, id);
|
||||
|
||||
Command *cmd = am->registerShortcut(shortcut,
|
||||
Command *cmd = ActionManager::registerShortcut(shortcut,
|
||||
Id(QLatin1String("QtCreator.Sidebar.") + QLatin1String(id.name())), navicontext);
|
||||
cmd->setDefaultKeySequence(factory->activationSequence());
|
||||
d->m_commandMap.insert(id, cmd);
|
||||
|
||||
@@ -208,12 +208,11 @@ static inline int paneShortCut(int number)
|
||||
|
||||
void OutputPaneManager::init()
|
||||
{
|
||||
ActionManager *am = Core::ICore::actionManager();
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
|
||||
const Context globalContext(Constants::C_GLOBAL);
|
||||
|
||||
// Window->Output Panes
|
||||
ActionContainer *mpanes = am->createMenu(Constants::M_WINDOW_PANES);
|
||||
ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES);
|
||||
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
|
||||
mpanes->menu()->setTitle(tr("Output &Panes"));
|
||||
mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
|
||||
@@ -221,21 +220,21 @@ void OutputPaneManager::init()
|
||||
|
||||
Command *cmd;
|
||||
|
||||
cmd = am->registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext);
|
||||
cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext);
|
||||
m_clearButton->setDefaultAction(cmd->action());
|
||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
||||
|
||||
cmd = am->registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext);
|
||||
cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
|
||||
m_prevToolButton->setDefaultAction(cmd->action());
|
||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
||||
|
||||
cmd = am->registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext);
|
||||
cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext);
|
||||
m_nextToolButton->setDefaultAction(cmd->action());
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
|
||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
||||
|
||||
cmd = am->registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext);
|
||||
cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9")));
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
cmd->setAttribute(Command::CA_UpdateIcon);
|
||||
@@ -245,7 +244,7 @@ void OutputPaneManager::init()
|
||||
|
||||
QAction *sep = new QAction(this);
|
||||
sep->setSeparator(true);
|
||||
cmd = am->registerAction(sep, "Coreplugin.OutputPane.Sep", globalContext);
|
||||
cmd = ActionManager::registerAction(sep, "Coreplugin.OutputPane.Sep", globalContext);
|
||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
||||
|
||||
QFontMetrics titleFm = m_titleLabel->fontMetrics();
|
||||
@@ -284,7 +283,7 @@ void OutputPaneManager::init()
|
||||
actionId.remove(QLatin1Char(' '));
|
||||
Id id(actionId);
|
||||
QAction *action = new QAction(outPane->displayName(), this);
|
||||
Command *cmd = am->registerAction(action, id, globalContext);
|
||||
Command *cmd = ActionManager::registerAction(action, id, globalContext);
|
||||
|
||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
|
||||
m_actions.append(cmd->action());
|
||||
|
||||
@@ -75,13 +75,12 @@ OutputWindow::OutputWindow(Core::Context context, QWidget *parent)
|
||||
QAction *pasteAction = new QAction(this);
|
||||
QAction *selectAllAction = new QAction(this);
|
||||
|
||||
Core::ActionManager *am = ICore::actionManager();
|
||||
am->registerAction(undoAction, Core::Constants::UNDO, context);
|
||||
am->registerAction(redoAction, Core::Constants::REDO, context);
|
||||
am->registerAction(cutAction, Core::Constants::CUT, context);
|
||||
am->registerAction(copyAction, Core::Constants::COPY, context);
|
||||
am->registerAction(pasteAction, Core::Constants::PASTE, context);
|
||||
am->registerAction(selectAllAction, Core::Constants::SELECTALL, context);
|
||||
ActionManager::registerAction(undoAction, Core::Constants::UNDO, context);
|
||||
ActionManager::registerAction(redoAction, Core::Constants::REDO, context);
|
||||
ActionManager::registerAction(cutAction, Core::Constants::CUT, context);
|
||||
ActionManager::registerAction(copyAction, Core::Constants::COPY, context);
|
||||
ActionManager::registerAction(pasteAction, Core::Constants::PASTE, context);
|
||||
ActionManager::registerAction(selectAllAction, Core::Constants::SELECTALL, context);
|
||||
|
||||
connect(undoAction, SIGNAL(triggered()), this, SLOT(undo()));
|
||||
connect(redoAction, SIGNAL(triggered()), this, SLOT(redo()));
|
||||
|
||||
Reference in New Issue
Block a user