forked from qt-creator/qt-creator
Add a save macro menu item, and remove the 'show save dialog' option in macro plugin
Merge-request: 240 Reviewed-by: con <qtc-committer@nokia.com>
This commit is contained in:
committed by
con
parent
0444335aba
commit
23e024de64
@@ -271,12 +271,6 @@ void MacroManager::MacroManagerPrivate::showSaveDialog()
|
|||||||
QMainWindow *mainWindow = Core::ICore::instance()->mainWindow();
|
QMainWindow *mainWindow = Core::ICore::instance()->mainWindow();
|
||||||
SaveDialog dialog(mainWindow);
|
SaveDialog dialog(mainWindow);
|
||||||
if (dialog.exec()) {
|
if (dialog.exec()) {
|
||||||
bool changed = false;
|
|
||||||
if (settings.showSaveDialog == dialog.hideSaveDialog()) {
|
|
||||||
settings.showSaveDialog = !dialog.hideSaveDialog();
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dialog.name().isEmpty())
|
if (dialog.name().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -293,16 +287,13 @@ void MacroManager::MacroManagerPrivate::showSaveDialog()
|
|||||||
return;
|
return;
|
||||||
settings.directories.append(directory);
|
settings.directories.append(directory);
|
||||||
settings.defaultDirectory= directory;
|
settings.defaultDirectory= directory;
|
||||||
changed = true;
|
q->saveSettings();
|
||||||
}
|
}
|
||||||
QString fileName = directory + '/' + dialog.name()
|
QString fileName = directory + '/' + dialog.name()
|
||||||
+ '.' + Constants::M_EXTENSION;
|
+ '.' + Constants::M_EXTENSION;
|
||||||
currentMacro->setDescription(dialog.description());
|
currentMacro->setDescription(dialog.description());
|
||||||
currentMacro->save(fileName);
|
currentMacro->save(fileName);
|
||||||
addMacro(currentMacro);
|
addMacro(currentMacro);
|
||||||
|
|
||||||
if (changed)
|
|
||||||
q->saveSettings();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,6 +341,7 @@ void MacroManager::startMacro()
|
|||||||
am->command(Constants::START_MACRO)->action()->setEnabled(false);
|
am->command(Constants::START_MACRO)->action()->setEnabled(false);
|
||||||
am->command(Constants::END_MACRO)->action()->setEnabled(true);
|
am->command(Constants::END_MACRO)->action()->setEnabled(true);
|
||||||
am->command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(false);
|
am->command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(false);
|
||||||
|
am->command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(false);
|
||||||
foreach (IMacroHandler *handler, d->handlers)
|
foreach (IMacroHandler *handler, d->handlers)
|
||||||
handler->startRecording(d->currentMacro);
|
handler->startRecording(d->currentMacro);
|
||||||
|
|
||||||
@@ -371,13 +363,11 @@ void MacroManager::endMacro()
|
|||||||
am->command(Constants::START_MACRO)->action()->setEnabled(true);
|
am->command(Constants::START_MACRO)->action()->setEnabled(true);
|
||||||
am->command(Constants::END_MACRO)->action()->setEnabled(false);
|
am->command(Constants::END_MACRO)->action()->setEnabled(false);
|
||||||
am->command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(true);
|
am->command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(true);
|
||||||
|
am->command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
|
||||||
foreach (IMacroHandler *handler, d->handlers)
|
foreach (IMacroHandler *handler, d->handlers)
|
||||||
handler->endRecordingMacro(d->currentMacro);
|
handler->endRecordingMacro(d->currentMacro);
|
||||||
|
|
||||||
d->isRecording = false;
|
d->isRecording = false;
|
||||||
|
|
||||||
if (d->currentMacro->events().count() && d->settings.showSaveDialog)
|
|
||||||
d->showSaveDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroManager::executeLastMacro()
|
void MacroManager::executeLastMacro()
|
||||||
@@ -400,6 +390,10 @@ bool MacroManager::executeMacro(const QString &name)
|
|||||||
if (d->currentMacro && d->currentMacro->displayName().isEmpty())
|
if (d->currentMacro && d->currentMacro->displayName().isEmpty())
|
||||||
delete d->currentMacro;
|
delete d->currentMacro;
|
||||||
d->currentMacro = macro;
|
d->currentMacro = macro;
|
||||||
|
|
||||||
|
Core::ActionManager *am = Core::ICore::instance()->actionManager();
|
||||||
|
am->command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,11 +414,6 @@ void MacroManager::setDefaultDirectory(const QString &directory)
|
|||||||
d->settings.defaultDirectory = directory;
|
d->settings.defaultDirectory = directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroManager::showSaveDialog(bool value)
|
|
||||||
{
|
|
||||||
d->settings.showSaveDialog = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroManager::deleteMacro(const QString &name)
|
void MacroManager::deleteMacro(const QString &name)
|
||||||
{
|
{
|
||||||
Macro *macro = d->macros.value(name);
|
Macro *macro = d->macros.value(name);
|
||||||
@@ -466,3 +455,9 @@ void MacroManager::changeMacro(const QString &name, const QString &description)
|
|||||||
if (macro->description() != description)
|
if (macro->description() != description)
|
||||||
d->changeMacroDescription(macro, description);
|
d->changeMacroDescription(macro, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Macros::MacroManager::saveLastMacro()
|
||||||
|
{
|
||||||
|
if (d->currentMacro->events().count())
|
||||||
|
d->showSaveDialog();
|
||||||
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public slots:
|
|||||||
void startMacro();
|
void startMacro();
|
||||||
void endMacro();
|
void endMacro();
|
||||||
void executeLastMacro();
|
void executeLastMacro();
|
||||||
|
void saveLastMacro();
|
||||||
bool executeMacro(const QString &name);
|
bool executeMacro(const QString &name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -81,7 +82,6 @@ protected:
|
|||||||
void appendDirectory(const QString &directory);
|
void appendDirectory(const QString &directory);
|
||||||
void removeDirectory(const QString &directory);
|
void removeDirectory(const QString &directory);
|
||||||
void setDefaultDirectory(const QString &directory);
|
void setDefaultDirectory(const QString &directory);
|
||||||
void showSaveDialog(bool value);
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -104,8 +104,6 @@ void MacroOptionsWidget::setSettings(const MacroSettings &s)
|
|||||||
m_directories.clear();
|
m_directories.clear();
|
||||||
ui->treeWidget->clear();
|
ui->treeWidget->clear();
|
||||||
|
|
||||||
ui->showSaveDialog->setChecked(s.showSaveDialog);
|
|
||||||
|
|
||||||
// Create the treeview
|
// Create the treeview
|
||||||
foreach (const QString &dir, s.directories)
|
foreach (const QString &dir, s.directories)
|
||||||
appendDirectory(dir, s.defaultDirectory==dir);
|
appendDirectory(dir, s.defaultDirectory==dir);
|
||||||
@@ -231,8 +229,6 @@ void MacroOptionsWidget::apply()
|
|||||||
foreach (const QString &dir, dirToRemove)
|
foreach (const QString &dir, dirToRemove)
|
||||||
MacroManager::instance()->removeDirectory(dir);
|
MacroManager::instance()->removeDirectory(dir);
|
||||||
|
|
||||||
MacroManager::instance()->showSaveDialog(ui->showSaveDialog->checkState()==Qt::Checked);
|
|
||||||
|
|
||||||
MacroManager::instance()->saveSettings();
|
MacroManager::instance()->saveSettings();
|
||||||
|
|
||||||
// Reinitialize the page
|
// Reinitialize the page
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<string>Preferences</string>
|
<string>Preferences</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="Utils::PathChooser" name="directoryPathChooser" native="true">
|
<widget class="Utils::PathChooser" name="directoryPathChooser" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
@@ -43,14 +43,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QPushButton" name="addButton">
|
<widget class="QPushButton" name="addButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
<item row="1" column="0" colspan="3">
|
||||||
<widget class="QTreeWidget" name="treeWidget">
|
<widget class="QTreeWidget" name="treeWidget">
|
||||||
<property name="textElideMode">
|
<property name="textElideMode">
|
||||||
<enum>Qt::ElideLeft</enum>
|
<enum>Qt::ElideLeft</enum>
|
||||||
@@ -87,14 +87,14 @@
|
|||||||
</column>
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QPushButton" name="defaultButton">
|
<widget class="QPushButton" name="defaultButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Default Directory</string>
|
<string>Default Directory</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="2" column="1">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@@ -107,20 +107,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QPushButton" name="removeButton">
|
<widget class="QPushButton" name="removeButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remove</string>
|
<string>Remove</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" colspan="3">
|
|
||||||
<widget class="QCheckBox" name="showSaveDialog">
|
|
||||||
<property name="text">
|
|
||||||
<string>Show the save dialog at the end of the macro</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ const char * const M_TOOLS_MACRO = "Macros.Tools.Menu";
|
|||||||
const char * const START_MACRO = "Macros.StartMacro";
|
const char * const START_MACRO = "Macros.StartMacro";
|
||||||
const char * const END_MACRO = "Macros.EndMacro";
|
const char * const END_MACRO = "Macros.EndMacro";
|
||||||
const char * const EXECUTE_LAST_MACRO = "Macros.ExecuteLastMacro";
|
const char * const EXECUTE_LAST_MACRO = "Macros.ExecuteLastMacro";
|
||||||
|
const char * const SAVE_LAST_MACRO = "Macros.SaveLastMacro";
|
||||||
const char * const PREFIX_MACRO = "Macros.";
|
const char * const PREFIX_MACRO = "Macros.";
|
||||||
|
|
||||||
const char * const M_OPTIONS_PAGE = "Macros";
|
const char * const M_OPTIONS_PAGE = "Macros";
|
||||||
|
|||||||
@@ -39,13 +39,11 @@ using namespace Macros::Internal;
|
|||||||
|
|
||||||
static const char GROUP[] = "Macro";
|
static const char GROUP[] = "Macro";
|
||||||
static const char DEFAULT_DIRECTORY[] = "DefaultDirectory";
|
static const char DEFAULT_DIRECTORY[] = "DefaultDirectory";
|
||||||
static const char SHOW_SAVE_DIALOG[] = "ShowSaveDialog";
|
|
||||||
static const char DIRECTORIES[] = "Directories";
|
static const char DIRECTORIES[] = "Directories";
|
||||||
static const char SHORTCUTS[] = "Shortcuts";
|
static const char SHORTCUTS[] = "Shortcuts";
|
||||||
|
|
||||||
|
|
||||||
MacroSettings::MacroSettings():
|
MacroSettings::MacroSettings()
|
||||||
showSaveDialog(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +51,6 @@ void MacroSettings::toSettings(QSettings *s) const
|
|||||||
{
|
{
|
||||||
s->beginGroup(QLatin1String(GROUP));
|
s->beginGroup(QLatin1String(GROUP));
|
||||||
s->setValue(QLatin1String(DEFAULT_DIRECTORY), defaultDirectory);
|
s->setValue(QLatin1String(DEFAULT_DIRECTORY), defaultDirectory);
|
||||||
s->setValue(QLatin1String(SHOW_SAVE_DIALOG), showSaveDialog);
|
|
||||||
s->setValue(QLatin1String(DIRECTORIES), directories);
|
s->setValue(QLatin1String(DIRECTORIES), directories);
|
||||||
s->setValue(QLatin1String(SHORTCUTS), shortcuts);
|
s->setValue(QLatin1String(SHORTCUTS), shortcuts);
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
@@ -63,7 +60,6 @@ void MacroSettings::fromSettings(QSettings *s)
|
|||||||
{
|
{
|
||||||
s->beginGroup(QLatin1String(GROUP));
|
s->beginGroup(QLatin1String(GROUP));
|
||||||
defaultDirectory = s->value(QLatin1String(DEFAULT_DIRECTORY), QString("")).toString();
|
defaultDirectory = s->value(QLatin1String(DEFAULT_DIRECTORY), QString("")).toString();
|
||||||
showSaveDialog = s->value(QLatin1String(SHOW_SAVE_DIALOG), false).toBool();
|
|
||||||
directories = s->value(QLatin1String(DIRECTORIES)).toStringList();
|
directories = s->value(QLatin1String(DIRECTORIES)).toStringList();
|
||||||
shortcuts = s->value(QLatin1String(SHORTCUTS)).toMap();
|
shortcuts = s->value(QLatin1String(SHORTCUTS)).toMap();
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
@@ -73,6 +69,5 @@ bool MacroSettings::equals(const MacroSettings &ms) const
|
|||||||
{
|
{
|
||||||
return defaultDirectory == ms.defaultDirectory &&
|
return defaultDirectory == ms.defaultDirectory &&
|
||||||
shortcuts == ms.shortcuts &&
|
shortcuts == ms.shortcuts &&
|
||||||
directories == ms.directories &&
|
directories == ms.directories;
|
||||||
showSaveDialog == ms.showSaveDialog;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ public:
|
|||||||
QString defaultDirectory;
|
QString defaultDirectory;
|
||||||
QStringList directories;
|
QStringList directories;
|
||||||
QMap<QString, QVariant> shortcuts;
|
QMap<QString, QVariant> shortcuts;
|
||||||
bool showSaveDialog;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const MacroSettings &m1, const MacroSettings &m2) { return m1.equals(m2); }
|
inline bool operator==(const MacroSettings &m1, const MacroSettings &m2) { return m1.equals(m2); }
|
||||||
|
|||||||
@@ -115,6 +115,12 @@ bool MacrosPlugin::initialize(const QStringList &arguments, QString *error_messa
|
|||||||
mmacrotools->addAction(command);
|
mmacrotools->addAction(command);
|
||||||
connect(executeLastMacro, SIGNAL(triggered()), m_macroManager, SLOT(executeLastMacro()));
|
connect(executeLastMacro, SIGNAL(triggered()), m_macroManager, SLOT(executeLastMacro()));
|
||||||
|
|
||||||
|
QAction *saveLastMacro = new QAction(tr("Save Last Macro"), this);
|
||||||
|
saveLastMacro->setEnabled(false);
|
||||||
|
command = am->registerAction(saveLastMacro, Constants::SAVE_LAST_MACRO, textContext);
|
||||||
|
mmacrotools->addAction(command);
|
||||||
|
connect(saveLastMacro, SIGNAL(triggered()), m_macroManager, SLOT(saveLastMacro()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,3 @@ QString SaveDialog::description() const
|
|||||||
{
|
{
|
||||||
return ui->description->text();
|
return ui->description->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaveDialog::hideSaveDialog() const
|
|
||||||
{
|
|
||||||
return ui->hideSaveDialog->isChecked();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ public:
|
|||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
bool hideSaveDialog() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SaveDialog *ui;
|
Ui::SaveDialog *ui;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>219</width>
|
<width>219</width>
|
||||||
<height>116</height>
|
<height>91</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -42,13 +42,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="hideSaveDialog">
|
|
||||||
<property name="text">
|
|
||||||
<string>Don't show this dialog again</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0" colspan="2">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||||
@@ -60,7 +53,6 @@
|
|||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>name</tabstop>
|
<tabstop>name</tabstop>
|
||||||
<tabstop>description</tabstop>
|
<tabstop>description</tabstop>
|
||||||
<tabstop>hideSaveDialog</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|||||||
Reference in New Issue
Block a user