2010-12-20 10:35:30 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (c) 2013 Nicolas Arnaud-Cormos
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-12-20 10:35:30 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-12-20 10:35:30 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-12-20 10:35:30 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, 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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-20 11:10:30 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
#include "macromanager.h"
|
|
|
|
|
|
|
|
|
|
#include "macrosconstants.h"
|
2011-01-24 12:29:48 +01:00
|
|
|
#include "macroevent.h"
|
2010-12-20 10:35:30 +01:00
|
|
|
#include "macro.h"
|
|
|
|
|
#include "imacrohandler.h"
|
|
|
|
|
#include "savedialog.h"
|
|
|
|
|
#include "actionmacrohandler.h"
|
|
|
|
|
#include "texteditormacrohandler.h"
|
|
|
|
|
#include "findmacrohandler.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>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QSignalMapper>
|
|
|
|
|
#include <QList>
|
2011-01-20 14:03:07 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QShortcut>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QMessageBox>
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
using namespace Macros;
|
|
|
|
|
using namespace Macros::Internal;
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\namespace Macros
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The Macros namespace contains support for macros in \QC.
|
2010-12-20 10:35:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
|
|
\class Macro::MacroManager
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The MacroManager class implements a manager for macros.
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
The MacroManager manage all macros, it loads them on startup, keep track of the
|
|
|
|
|
current macro and create new macros.
|
|
|
|
|
|
|
|
|
|
There are two important methods in this class that can be used outside the Macros plugin:
|
|
|
|
|
\list
|
2013-02-06 08:50:23 +01:00
|
|
|
\li registerEventHandler: add a new event handler
|
|
|
|
|
\li registerAction: add a macro event when this action is triggered
|
2010-12-20 10:35:30 +01:00
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
This class is a singleton and can be accessed using the instance method.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void registerAction(QAction *action, const QString &id)
|
|
|
|
|
|
|
|
|
|
Append this action to the list of actions registered in a macro. The id is
|
|
|
|
|
the action id passed to the ActionManager.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class Macros::MacroManager::MacroManagerPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
MacroManagerPrivate(MacroManager *qq);
|
|
|
|
|
|
|
|
|
|
MacroManager *q;
|
|
|
|
|
QMap<QString, Macro *> macros;
|
|
|
|
|
Macro *currentMacro;
|
|
|
|
|
bool isRecording;
|
|
|
|
|
|
|
|
|
|
QList<IMacroHandler*> handlers;
|
|
|
|
|
|
|
|
|
|
QSignalMapper *mapper;
|
|
|
|
|
|
|
|
|
|
ActionMacroHandler *actionHandler;
|
|
|
|
|
TextEditorMacroHandler *textEditorHandler;
|
|
|
|
|
FindMacroHandler *findHandler;
|
|
|
|
|
|
2011-02-07 11:34:02 +01:00
|
|
|
void initialize();
|
|
|
|
|
void addMacro(Macro *macro);
|
2010-12-20 10:35:30 +01:00
|
|
|
void removeMacro(const QString &name);
|
|
|
|
|
void changeMacroDescription(Macro *macro, const QString &description);
|
|
|
|
|
|
|
|
|
|
bool executeMacro(Macro *macro);
|
|
|
|
|
void showSaveDialog();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MacroManager::MacroManagerPrivate::MacroManagerPrivate(MacroManager *qq):
|
|
|
|
|
q(qq),
|
|
|
|
|
currentMacro(0),
|
|
|
|
|
isRecording(false),
|
2011-01-24 11:39:42 +01:00
|
|
|
mapper(new QSignalMapper(qq))
|
2010-12-20 10:35:30 +01:00
|
|
|
{
|
|
|
|
|
connect(mapper, SIGNAL(mapped(QString)), q, SLOT(executeMacro(QString)));
|
|
|
|
|
|
2011-02-07 11:34:02 +01:00
|
|
|
// Load existing macros
|
|
|
|
|
initialize();
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
actionHandler = new ActionMacroHandler;
|
|
|
|
|
textEditorHandler = new TextEditorMacroHandler;
|
|
|
|
|
findHandler = new FindMacroHandler;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-07 11:34:02 +01:00
|
|
|
void MacroManager::MacroManagerPrivate::initialize()
|
2010-12-20 10:35:30 +01:00
|
|
|
{
|
|
|
|
|
macros.clear();
|
2011-02-07 11:34:02 +01:00
|
|
|
QDir dir(q->macrosDirectory());
|
2010-12-20 10:35:30 +01:00
|
|
|
QStringList filter;
|
2012-11-26 20:55:11 +02:00
|
|
|
filter << QLatin1String("*.") + QLatin1String(Constants::M_EXTENSION);
|
2010-12-20 10:35:30 +01:00
|
|
|
QStringList files = dir.entryList(filter, QDir::Files);
|
|
|
|
|
|
|
|
|
|
foreach (const QString &name, files) {
|
2012-11-26 20:55:11 +02:00
|
|
|
QString fileName = dir.absolutePath() + QLatin1Char('/') + name;
|
2010-12-20 10:35:30 +01:00
|
|
|
Macro *macro = new Macro;
|
2011-03-30 15:15:15 +02:00
|
|
|
if (macro->loadHeader(fileName))
|
|
|
|
|
addMacro(macro);
|
|
|
|
|
else
|
|
|
|
|
delete macro;
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-16 14:18:35 +01:00
|
|
|
static Core::Id makeId(const QString &name)
|
|
|
|
|
{
|
2013-03-19 13:51:25 +01:00
|
|
|
return Core::Id(Constants::PREFIX_MACRO).withSuffix(name);
|
2013-01-16 14:18:35 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-07 11:34:02 +01:00
|
|
|
void MacroManager::MacroManagerPrivate::addMacro(Macro *macro)
|
2010-12-20 10:35:30 +01:00
|
|
|
{
|
2011-01-24 11:39:42 +01:00
|
|
|
// Add sortcut
|
|
|
|
|
Core::Context context(TextEditor::Constants::C_TEXTEDITOR);
|
2012-01-24 15:36:40 +01:00
|
|
|
QShortcut *shortcut = new QShortcut(Core::ICore::mainWindow());
|
2011-01-24 11:39:42 +01:00
|
|
|
shortcut->setWhatsThis(macro->description());
|
2013-01-16 14:18:35 +01:00
|
|
|
Core::ActionManager::registerShortcut(shortcut, makeId(macro->displayName()), context);
|
2011-01-24 11:39:42 +01:00
|
|
|
connect(shortcut, SIGNAL(activated()), mapper, SLOT(map()));
|
|
|
|
|
mapper->setMapping(shortcut, macro->displayName());
|
|
|
|
|
|
|
|
|
|
// Add macro to the map
|
2010-12-20 10:35:30 +01:00
|
|
|
macros[macro->displayName()] = macro;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
if (!macros.contains(name))
|
|
|
|
|
return;
|
2011-01-24 11:39:42 +01:00
|
|
|
// Remove shortcut
|
2013-01-16 14:18:35 +01:00
|
|
|
Core::ActionManager::unregisterShortcut(makeId(name));
|
2011-01-24 11:39:42 +01:00
|
|
|
|
|
|
|
|
// Remove macro from the map
|
2010-12-20 10:35:30 +01:00
|
|
|
Macro *macro = macros.take(name);
|
|
|
|
|
delete macro;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacroManager::MacroManagerPrivate::changeMacroDescription(Macro *macro, const QString &description)
|
|
|
|
|
{
|
2011-03-30 15:15:15 +02:00
|
|
|
if (!macro->load())
|
|
|
|
|
return;
|
2010-12-20 10:35:30 +01:00
|
|
|
macro->setDescription(description);
|
2012-01-24 15:36:40 +01:00
|
|
|
macro->save(macro->fileName(), Core::ICore::mainWindow());
|
2010-12-20 10:35:30 +01:00
|
|
|
|
2011-01-24 11:39:42 +01:00
|
|
|
// Change shortcut what's this
|
2013-01-16 14:18:35 +01:00
|
|
|
Core::Command *command = Core::ActionManager::command(makeId(macro->displayName()));
|
2011-01-24 11:39:42 +01:00
|
|
|
if (command && command->shortcut())
|
|
|
|
|
command->shortcut()->setWhatsThis(description);
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MacroManager::MacroManagerPrivate::executeMacro(Macro *macro)
|
|
|
|
|
{
|
2011-03-30 15:15:15 +02:00
|
|
|
bool error = !macro->load();
|
2010-12-20 10:35:30 +01:00
|
|
|
foreach (const MacroEvent ¯oEvent, macro->events()) {
|
2011-03-30 15:15:15 +02:00
|
|
|
if (error)
|
|
|
|
|
break;
|
2010-12-20 10:35:30 +01:00
|
|
|
foreach (IMacroHandler *handler, handlers) {
|
|
|
|
|
if (handler->canExecuteEvent(macroEvent)) {
|
|
|
|
|
if (!handler->executeEvent(macroEvent))
|
|
|
|
|
error = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error) {
|
2012-01-24 15:36:40 +01:00
|
|
|
QMessageBox::warning(Core::ICore::mainWindow(),
|
2011-02-07 11:34:00 +01:00
|
|
|
tr("Playing Macro"),
|
2011-04-19 15:42:14 +02:00
|
|
|
tr("An error occurred while replaying the macro, execution stopped."));
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the focus back to the editor
|
|
|
|
|
// TODO: is it really needed??
|
2012-05-08 09:43:14 +02:00
|
|
|
if (Core::IEditor *current = Core::EditorManager::currentEditor())
|
|
|
|
|
current->widget()->setFocus(Qt::OtherFocusReason);
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
return !error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacroManager::MacroManagerPrivate::showSaveDialog()
|
|
|
|
|
{
|
2012-07-19 15:31:22 +04:00
|
|
|
QWidget *mainWindow = Core::ICore::mainWindow();
|
2010-12-20 10:35:30 +01:00
|
|
|
SaveDialog dialog(mainWindow);
|
|
|
|
|
if (dialog.exec()) {
|
|
|
|
|
if (dialog.name().isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2011-02-07 11:34:02 +01:00
|
|
|
// Save in the resource path
|
2012-11-26 20:55:11 +02:00
|
|
|
QString fileName = q->macrosDirectory() + QLatin1Char('/') + dialog.name()
|
|
|
|
|
+ QLatin1Char('.') + QLatin1String(Constants::M_EXTENSION);
|
2010-12-20 10:35:30 +01:00
|
|
|
currentMacro->setDescription(dialog.description());
|
2011-03-30 15:15:15 +02:00
|
|
|
currentMacro->save(fileName, mainWindow);
|
2010-12-20 10:35:30 +01:00
|
|
|
addMacro(currentMacro);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------- MacroManager ------------
|
|
|
|
|
MacroManager *MacroManager::m_instance = 0;
|
|
|
|
|
|
|
|
|
|
MacroManager::MacroManager(QObject *parent) :
|
|
|
|
|
QObject(parent),
|
|
|
|
|
d(new MacroManagerPrivate(this))
|
|
|
|
|
{
|
|
|
|
|
registerMacroHandler(d->actionHandler);
|
|
|
|
|
registerMacroHandler(d->findHandler);
|
|
|
|
|
registerMacroHandler(d->textEditorHandler);
|
|
|
|
|
m_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MacroManager::~MacroManager()
|
|
|
|
|
{
|
|
|
|
|
// Cleanup macro
|
|
|
|
|
QStringList macroList = d->macros.keys();
|
|
|
|
|
foreach (const QString &name, macroList)
|
|
|
|
|
d->removeMacro(name);
|
|
|
|
|
|
|
|
|
|
// Cleanup handlers
|
|
|
|
|
qDeleteAll(d->handlers);
|
|
|
|
|
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacroManager::startMacro()
|
|
|
|
|
{
|
|
|
|
|
d->isRecording = true;
|
|
|
|
|
// Delete anonymous macro
|
|
|
|
|
if (d->currentMacro && d->currentMacro->displayName().isEmpty())
|
|
|
|
|
delete d->currentMacro;
|
|
|
|
|
d->currentMacro = new Macro;
|
|
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::command(Constants::START_MACRO)->action()->setEnabled(false);
|
|
|
|
|
Core::ActionManager::command(Constants::END_MACRO)->action()->setEnabled(true);
|
|
|
|
|
Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(false);
|
|
|
|
|
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(false);
|
2010-12-20 10:35:30 +01:00
|
|
|
foreach (IMacroHandler *handler, d->handlers)
|
|
|
|
|
handler->startRecording(d->currentMacro);
|
|
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
QString endShortcut = Core::ActionManager::command(Constants::END_MACRO)->defaultKeySequence().toString();
|
|
|
|
|
QString executeShortcut = Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->defaultKeySequence().toString();
|
2011-02-07 11:34:00 +01:00
|
|
|
QString help = tr("Macro mode. Type \"%1\" to stop recording and \"%2\" to play it")
|
2010-12-20 10:35:30 +01:00
|
|
|
.arg(endShortcut).arg(executeShortcut);
|
|
|
|
|
Core::EditorManager::instance()->showEditorStatusBar(
|
|
|
|
|
QLatin1String(Constants::M_STATUS_BUFFER),
|
|
|
|
|
help,
|
2011-02-07 11:34:00 +01:00
|
|
|
tr("Stop Recording Macro"), this, SLOT(endMacro()));
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacroManager::endMacro()
|
|
|
|
|
{
|
|
|
|
|
Core::EditorManager::instance()->hideEditorStatusBar(QLatin1String(Constants::M_STATUS_BUFFER));
|
|
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::command(Constants::START_MACRO)->action()->setEnabled(true);
|
|
|
|
|
Core::ActionManager::command(Constants::END_MACRO)->action()->setEnabled(false);
|
|
|
|
|
Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(true);
|
|
|
|
|
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
|
2010-12-20 10:35:30 +01:00
|
|
|
foreach (IMacroHandler *handler, d->handlers)
|
|
|
|
|
handler->endRecordingMacro(d->currentMacro);
|
|
|
|
|
|
|
|
|
|
d->isRecording = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacroManager::executeLastMacro()
|
|
|
|
|
{
|
2011-07-26 13:42:34 +02:00
|
|
|
if (!d->currentMacro)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// make sure the macro doesn't accidentally invoke a macro action
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::command(Constants::START_MACRO)->action()->setEnabled(false);
|
|
|
|
|
Core::ActionManager::command(Constants::END_MACRO)->action()->setEnabled(false);
|
|
|
|
|
Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(false);
|
|
|
|
|
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(false);
|
2011-07-26 13:42:34 +02:00
|
|
|
|
|
|
|
|
d->executeMacro(d->currentMacro);
|
|
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::command(Constants::START_MACRO)->action()->setEnabled(true);
|
|
|
|
|
Core::ActionManager::command(Constants::END_MACRO)->action()->setEnabled(false);
|
|
|
|
|
Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(true);
|
|
|
|
|
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MacroManager::executeMacro(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
// Don't execute macro while recording
|
|
|
|
|
if (d->isRecording || !d->macros.contains(name))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
Macro *macro = d->macros.value(name);
|
|
|
|
|
if (!d->executeMacro(macro))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Delete anonymous macro
|
|
|
|
|
if (d->currentMacro && d->currentMacro->displayName().isEmpty())
|
|
|
|
|
delete d->currentMacro;
|
|
|
|
|
d->currentMacro = macro;
|
2011-02-07 11:34:01 +01:00
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
|
2011-02-07 11:34:01 +01:00
|
|
|
|
2010-12-20 10:35:30 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacroManager::deleteMacro(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
Macro *macro = d->macros.value(name);
|
|
|
|
|
if (macro) {
|
|
|
|
|
QString fileName = macro->fileName();
|
|
|
|
|
d->removeMacro(name);
|
|
|
|
|
QFile::remove(fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QMap<QString,Macro*> &MacroManager::macros() const
|
|
|
|
|
{
|
|
|
|
|
return d->macros;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MacroManager::registerMacroHandler(IMacroHandler *handler)
|
|
|
|
|
{
|
|
|
|
|
d->handlers.prepend(handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MacroManager *MacroManager::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-24 11:39:42 +01:00
|
|
|
void MacroManager::changeMacro(const QString &name, const QString &description)
|
2010-12-20 10:35:30 +01:00
|
|
|
{
|
|
|
|
|
if (!d->macros.contains(name))
|
|
|
|
|
return;
|
|
|
|
|
Macro *macro = d->macros.value(name);
|
|
|
|
|
|
|
|
|
|
// Change description
|
|
|
|
|
if (macro->description() != description)
|
|
|
|
|
d->changeMacroDescription(macro, description);
|
|
|
|
|
}
|
2011-02-07 11:34:01 +01:00
|
|
|
|
|
|
|
|
void Macros::MacroManager::saveLastMacro()
|
|
|
|
|
{
|
|
|
|
|
if (d->currentMacro->events().count())
|
|
|
|
|
d->showSaveDialog();
|
|
|
|
|
}
|
2011-02-07 11:34:02 +01:00
|
|
|
|
|
|
|
|
QString Macros::MacroManager::macrosDirectory() const
|
|
|
|
|
{
|
|
|
|
|
const QString &path =
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ICore::userResourcePath() + QLatin1String("/macros");
|
2011-02-07 11:34:02 +01:00
|
|
|
if (QFile::exists(path) || QDir().mkpath(path))
|
|
|
|
|
return path;
|
|
|
|
|
return QString();
|
|
|
|
|
}
|