2010-12-20 10:35:30 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2010 Nicolas Arnaud-Cormos.
|
|
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-12-20 10:35:30 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2010-12-20 10:35:30 +01:00
|
|
|
**
|
2010-12-20 11:10:30 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-20 11:10:30 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-20 11:10:30 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-12-20 10:35:30 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "macrosplugin.h"
|
|
|
|
|
|
|
|
|
|
#include "macrosconstants.h"
|
|
|
|
|
#include "macromanager.h"
|
|
|
|
|
#include "macrooptionspage.h"
|
|
|
|
|
#include "macrolocatorfilter.h"
|
|
|
|
|
|
|
|
|
|
#include <texteditor/texteditorconstants.h>
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2011-09-05 16:10:37 +02:00
|
|
|
#include <coreplugin/id.h>
|
2010-12-20 10:35:30 +01:00
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QKeySequence>
|
|
|
|
|
#include <QMenu>
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
using namespace Macros;
|
|
|
|
|
using namespace Macros::Internal;
|
|
|
|
|
|
|
|
|
|
MacrosPlugin::MacrosPlugin()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MacrosPlugin::~MacrosPlugin()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-21 13:05:15 +02:00
|
|
|
bool MacrosPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2010-12-20 10:35:30 +01:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(arguments);
|
2011-09-21 13:05:15 +02:00
|
|
|
Q_UNUSED(errorMessage);
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
addAutoReleasedObject(new MacroOptionsPage);
|
|
|
|
|
addAutoReleasedObject(new MacroLocatorFilter);
|
|
|
|
|
|
|
|
|
|
Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
|
|
|
|
Core::Context textContext(TextEditor::Constants::C_TEXTEDITOR);
|
|
|
|
|
m_macroManager = new MacroManager(this);
|
|
|
|
|
|
|
|
|
|
// Menus
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
Core::ActionContainer *mmacrotools = Core::ActionManager::createMenu(Constants::M_TOOLS_MACRO);
|
2010-12-20 10:35:30 +01:00
|
|
|
QMenu *menu = mmacrotools->menu();
|
|
|
|
|
menu->setTitle(tr("&Macros"));
|
|
|
|
|
menu->setEnabled(true);
|
|
|
|
|
mtools->addMenu(mmacrotools);
|
|
|
|
|
|
2011-02-07 11:34:00 +01:00
|
|
|
QAction *startMacro = new QAction(tr("Record Macro"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::Command *command = Core::ActionManager::registerAction(startMacro, Constants::START_MACRO, textContext);
|
2012-05-23 13:25:51 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Ctrl+(") : tr("Alt+(")));
|
2010-12-20 10:35:30 +01:00
|
|
|
mmacrotools->addAction(command);
|
|
|
|
|
connect(startMacro, SIGNAL(triggered()), m_macroManager, SLOT(startMacro()));
|
|
|
|
|
|
2011-02-07 11:34:00 +01:00
|
|
|
QAction *endMacro = new QAction(tr("Stop Recording Macro"), this);
|
2010-12-20 10:35:30 +01:00
|
|
|
endMacro->setEnabled(false);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(endMacro, Constants::END_MACRO, globalcontext);
|
2012-05-23 13:25:51 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Ctrl+)") : tr("Alt+)")));
|
2010-12-20 10:35:30 +01:00
|
|
|
mmacrotools->addAction(command);
|
|
|
|
|
connect(endMacro, SIGNAL(triggered()), m_macroManager, SLOT(endMacro()));
|
|
|
|
|
|
2011-02-07 11:34:00 +01:00
|
|
|
QAction *executeLastMacro = new QAction(tr("Play Last Macro"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(executeLastMacro, Constants::EXECUTE_LAST_MACRO, textContext);
|
2012-05-23 14:02:36 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+R") : tr("Alt+R")));
|
2010-12-20 10:35:30 +01:00
|
|
|
mmacrotools->addAction(command);
|
|
|
|
|
connect(executeLastMacro, SIGNAL(triggered()), m_macroManager, SLOT(executeLastMacro()));
|
|
|
|
|
|
2011-02-07 11:34:01 +01:00
|
|
|
QAction *saveLastMacro = new QAction(tr("Save Last Macro"), this);
|
|
|
|
|
saveLastMacro->setEnabled(false);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(saveLastMacro, Constants::SAVE_LAST_MACRO, textContext);
|
2011-02-07 11:34:01 +01:00
|
|
|
mmacrotools->addAction(command);
|
|
|
|
|
connect(saveLastMacro, SIGNAL(triggered()), m_macroManager, SLOT(saveLastMacro()));
|
|
|
|
|
|
2010-12-20 10:35:30 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacrosPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(MacrosPlugin)
|