Commit 8ab578b1 authored by dt's avatar dt
Browse files

Show a nice checkbox in the save dialog for SaveBeforeBuild

parent 6838223e
......@@ -55,6 +55,8 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
m_ui.buttonBox->button(QDialogButtonBox::Save)->setFocus(Qt::TabFocusReason);
m_ui.buttonBox->button(QDialogButtonBox::Save)->setMinimumWidth(130); // bad magic number to avoid resizing of button
m_ui.saveBeforeBuildCheckBox->setVisible(false);
foreach (IFile *file, items) {
QString visibleName;
QString directory;
......@@ -121,3 +123,14 @@ QList<IFile*> SaveItemsDialog::itemsToSave() const
{
return m_itemsToSave;
}
void SaveItemsDialog::setAlwaysSaveMessage(const QString &msg)
{
m_ui.saveBeforeBuildCheckBox->setText(msg);
m_ui.saveBeforeBuildCheckBox->setVisible(true);
}
bool SaveItemsDialog::alwaysSaveChecked()
{
return m_ui.saveBeforeBuildCheckBox->isChecked();
}
......@@ -57,7 +57,8 @@ public:
QList<Core::IFile *> items);
void setMessage(const QString &msg);
void setAlwaysSaveMessage(const QString &msg);
bool alwaysSaveChecked();
QList<Core::IFile *> itemsToSave() const;
private slots:
......
......@@ -56,6 +56,13 @@
</column>
</widget>
</item>
<item>
<widget class="QCheckBox" name="saveBeforeBuildCheckBox">
<property name="text">
<string>Automatically save all Files before building</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
......
......@@ -292,9 +292,11 @@ QList<IFile *> FileManager::saveModifiedFilesSilently(const QList<IFile *> &file
Asks the user whether to save the files listed in \a files . Returns the files that have not been saved.
*/
QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
bool *cancelled, const QString &message)
bool *cancelled, const QString &message,
const QString &alwaysSaveMessage,
bool *alwaysSave)
{
return saveModifiedFiles(files, cancelled, false, message);
return saveModifiedFiles(files, cancelled, false, message, alwaysSaveMessage, alwaysSave);
}
static QMessageBox::StandardButton skipFailedPrompt(QWidget *parent, const QString &fileName)
......@@ -307,7 +309,11 @@ static QMessageBox::StandardButton skipFailedPrompt(QWidget *parent, const QStri
}
QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
bool *cancelled, bool silently, const QString &message)
bool *cancelled,
bool silently,
const QString &message,
const QString &alwaysSaveMessage,
bool *alwaysSave)
{
if (cancelled)
(*cancelled) = false;
......@@ -338,12 +344,18 @@ QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
SaveItemsDialog dia(m_mainWindow, modifiedFiles);
if (!message.isEmpty())
dia.setMessage(message);
if (!alwaysSaveMessage.isNull())
dia.setAlwaysSaveMessage(alwaysSaveMessage);
if (dia.exec() != QDialog::Accepted) {
if (cancelled)
(*cancelled) = true;
if (alwaysSave)
*alwaysSave = dia.alwaysSaveChecked();
notSaved = modifiedFiles;
return notSaved;
}
if (alwaysSave)
*alwaysSave = dia.alwaysSaveChecked();
filesToSave = dia.itemsToSave();
}
......
......@@ -97,7 +97,9 @@ public:
QList<IFile *> saveModifiedFilesSilently(const QList<IFile *> &files);
QList<IFile *> saveModifiedFiles(const QList<IFile *> &files,
bool *cancelled = 0,
const QString &message = QString());
const QString &message = QString(),
const QString &alwaysSaveMessage = QString::null,
bool *alwaysSave = 0);
signals:
void currentFileChanged(const QString &filePath);
......@@ -116,7 +118,10 @@ private:
void updateFileInfo(IFile *file);
QList<IFile *> saveModifiedFiles(const QList<IFile *> &files,
bool *cancelled, bool silently, const QString &message);
bool *cancelled, bool silently,
const QString &message,
const QString &alwaysSaveMessage = QString::null,
bool *alwaysSave = 0);
QMap<IFile*, FileInfo> m_managedFiles;
......
......@@ -1324,10 +1324,14 @@ bool ProjectExplorerPlugin::saveModifiedFiles(const QList<Project *> & projects)
Core::ICore::instance()->fileManager()->saveModifiedFilesSilently(filesToSave);
} else {
bool cancelled = false;
Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave, &cancelled);
bool alwaysSave = false;
Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave, &cancelled, QString::null, "Always save files before build", &alwaysSave);
if (cancelled) {
return false;
}
if (alwaysSave) {
m_projectExplorerSettings.saveBeforeBuild = true;
}
}
}
return true;
......
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