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