Commit 23e024de authored by Nicolas Arnaud-Cormos's avatar Nicolas Arnaud-Cormos Committed by con
Browse files

Add a save macro menu item, and remove the 'show save dialog' option in macro plugin



Merge-request: 240
Reviewed-by: default avatarcon <qtc-committer@nokia.com>
parent 0444335a
......@@ -271,12 +271,6 @@ void MacroManager::MacroManagerPrivate::showSaveDialog()
QMainWindow *mainWindow = Core::ICore::instance()->mainWindow();
SaveDialog dialog(mainWindow);
if (dialog.exec()) {
bool changed = false;
if (settings.showSaveDialog == dialog.hideSaveDialog()) {
settings.showSaveDialog = !dialog.hideSaveDialog();
changed = true;
}
if (dialog.name().isEmpty())
return;
......@@ -293,16 +287,13 @@ void MacroManager::MacroManagerPrivate::showSaveDialog()
return;
settings.directories.append(directory);
settings.defaultDirectory= directory;
changed = true;
q->saveSettings();
}
QString fileName = directory + '/' + dialog.name()
+ '.' + Constants::M_EXTENSION;
currentMacro->setDescription(dialog.description());
currentMacro->save(fileName);
addMacro(currentMacro);
if (changed)
q->saveSettings();
}
}
......@@ -350,6 +341,7 @@ void MacroManager::startMacro()
am->command(Constants::START_MACRO)->action()->setEnabled(false);
am->command(Constants::END_MACRO)->action()->setEnabled(true);
am->command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(false);
am->command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(false);
foreach (IMacroHandler *handler, d->handlers)
handler->startRecording(d->currentMacro);
......@@ -371,13 +363,11 @@ void MacroManager::endMacro()
am->command(Constants::START_MACRO)->action()->setEnabled(true);
am->command(Constants::END_MACRO)->action()->setEnabled(false);
am->command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(true);
am->command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
foreach (IMacroHandler *handler, d->handlers)
handler->endRecordingMacro(d->currentMacro);
d->isRecording = false;
if (d->currentMacro->events().count() && d->settings.showSaveDialog)
d->showSaveDialog();
}
void MacroManager::executeLastMacro()
......@@ -400,6 +390,10 @@ bool MacroManager::executeMacro(const QString &name)
if (d->currentMacro && d->currentMacro->displayName().isEmpty())
delete d->currentMacro;
d->currentMacro = macro;
Core::ActionManager *am = Core::ICore::instance()->actionManager();
am->command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
return true;
}
......@@ -420,11 +414,6 @@ void MacroManager::setDefaultDirectory(const QString &directory)
d->settings.defaultDirectory = directory;
}
void MacroManager::showSaveDialog(bool value)
{
d->settings.showSaveDialog = value;
}
void MacroManager::deleteMacro(const QString &name)
{
Macro *macro = d->macros.value(name);
......@@ -466,3 +455,9 @@ void MacroManager::changeMacro(const QString &name, const QString &description)
if (macro->description() != 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 endMacro();
void executeLastMacro();
void saveLastMacro();
bool executeMacro(const QString &name);
protected:
......@@ -81,7 +82,6 @@ protected:
void appendDirectory(const QString &directory);
void removeDirectory(const QString &directory);
void setDefaultDirectory(const QString &directory);
void showSaveDialog(bool value);
void saveSettings();
private:
......
......@@ -104,8 +104,6 @@ void MacroOptionsWidget::setSettings(const MacroSettings &s)
m_directories.clear();
ui->treeWidget->clear();
ui->showSaveDialog->setChecked(s.showSaveDialog);
// Create the treeview
foreach (const QString &dir, s.directories)
appendDirectory(dir, s.defaultDirectory==dir);
......@@ -231,8 +229,6 @@ void MacroOptionsWidget::apply()
foreach (const QString &dir, dirToRemove)
MacroManager::instance()->removeDirectory(dir);
MacroManager::instance()->showSaveDialog(ui->showSaveDialog->checkState()==Qt::Checked);
MacroManager::instance()->saveSettings();
// Reinitialize the page
......
......@@ -20,7 +20,7 @@
<string>Preferences</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
......@@ -33,7 +33,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="Utils::PathChooser" name="directoryPathChooser" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
......@@ -43,14 +43,14 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="0" column="2">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<item row="1" column="0" colspan="3">
<widget class="QTreeWidget" name="treeWidget">
<property name="textElideMode">
<enum>Qt::ElideLeft</enum>
......@@ -87,14 +87,14 @@
</column>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QPushButton" name="defaultButton">
<property name="text">
<string>Default Directory</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -107,20 +107,13 @@
</property>
</spacer>
</item>
<item row="3" column="2">
<item row="2" column="2">
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</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>
</widget>
</item>
......
......@@ -42,6 +42,7 @@ const char * const M_TOOLS_MACRO = "Macros.Tools.Menu";
const char * const START_MACRO = "Macros.StartMacro";
const char * const END_MACRO = "Macros.EndMacro";
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 M_OPTIONS_PAGE = "Macros";
......
......@@ -39,13 +39,11 @@ using namespace Macros::Internal;
static const char GROUP[] = "Macro";
static const char DEFAULT_DIRECTORY[] = "DefaultDirectory";
static const char SHOW_SAVE_DIALOG[] = "ShowSaveDialog";
static const char DIRECTORIES[] = "Directories";
static const char SHORTCUTS[] = "Shortcuts";
MacroSettings::MacroSettings():
showSaveDialog(false)
MacroSettings::MacroSettings()
{
}
......@@ -53,7 +51,6 @@ void MacroSettings::toSettings(QSettings *s) const
{
s->beginGroup(QLatin1String(GROUP));
s->setValue(QLatin1String(DEFAULT_DIRECTORY), defaultDirectory);
s->setValue(QLatin1String(SHOW_SAVE_DIALOG), showSaveDialog);
s->setValue(QLatin1String(DIRECTORIES), directories);
s->setValue(QLatin1String(SHORTCUTS), shortcuts);
s->endGroup();
......@@ -63,7 +60,6 @@ void MacroSettings::fromSettings(QSettings *s)
{
s->beginGroup(QLatin1String(GROUP));
defaultDirectory = s->value(QLatin1String(DEFAULT_DIRECTORY), QString("")).toString();
showSaveDialog = s->value(QLatin1String(SHOW_SAVE_DIALOG), false).toBool();
directories = s->value(QLatin1String(DIRECTORIES)).toStringList();
shortcuts = s->value(QLatin1String(SHORTCUTS)).toMap();
s->endGroup();
......@@ -73,6 +69,5 @@ bool MacroSettings::equals(const MacroSettings &ms) const
{
return defaultDirectory == ms.defaultDirectory &&
shortcuts == ms.shortcuts &&
directories == ms.directories &&
showSaveDialog == ms.showSaveDialog;
directories == ms.directories;
}
......@@ -58,7 +58,6 @@ public:
QString defaultDirectory;
QStringList directories;
QMap<QString, QVariant> shortcuts;
bool showSaveDialog;
};
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);
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;
}
......
......@@ -62,8 +62,3 @@ QString SaveDialog::description() const
{
return ui->description->text();
}
bool SaveDialog::hideSaveDialog() const
{
return ui->hideSaveDialog->isChecked();
}
......@@ -53,7 +53,6 @@ public:
QString name() const;
QString description() const;
bool hideSaveDialog() const;
private:
Ui::SaveDialog *ui;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>219</width>
<height>116</height>
<height>91</height>
</rect>
</property>
<property name="windowTitle">
......@@ -42,13 +42,6 @@
</widget>
</item>
<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">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
......@@ -60,7 +53,6 @@
<tabstops>
<tabstop>name</tabstop>
<tabstop>description</tabstop>
<tabstop>hideSaveDialog</tabstop>
</tabstops>
<resources/>
<connections>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment