Commit 70019a85 authored by David Schulz's avatar David Schulz

Editor: Added a close all option to the deleted file dialog.

Change-Id: Ibacfc31c4cd6193e85c84f8553bae7495aea08c7
Reviewed-by: default avatarSimon Schäfer <simon.schaefer@koeln.de>
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
parent d5d019a3
...@@ -91,6 +91,7 @@ QTCREATOR_UTILS_EXPORT Utils::FileDeletedPromptAnswer ...@@ -91,6 +91,7 @@ QTCREATOR_UTILS_EXPORT Utils::FileDeletedPromptAnswer
"The file %1 was removed. Do you want to save it under a different name, or close the editor?").arg(QDir::toNativeSeparators(fileName)); "The file %1 was removed. Do you want to save it under a different name, or close the editor?").arg(QDir::toNativeSeparators(fileName));
QMessageBox box(QMessageBox::Question, title, msg, QMessageBox::NoButton, parent); QMessageBox box(QMessageBox::Question, title, msg, QMessageBox::NoButton, parent);
QPushButton *close = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Close"), QMessageBox::RejectRole); QPushButton *close = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Close"), QMessageBox::RejectRole);
QPushButton *closeAll = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "C&lose All"), QMessageBox::RejectRole);
QPushButton *saveas = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "Save &as..."), QMessageBox::ActionRole); QPushButton *saveas = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "Save &as..."), QMessageBox::ActionRole);
QPushButton *save = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Save"), QMessageBox::AcceptRole); QPushButton *save = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Save"), QMessageBox::AcceptRole);
box.setDefaultButton(saveas); box.setDefaultButton(saveas);
...@@ -98,6 +99,8 @@ QTCREATOR_UTILS_EXPORT Utils::FileDeletedPromptAnswer ...@@ -98,6 +99,8 @@ QTCREATOR_UTILS_EXPORT Utils::FileDeletedPromptAnswer
QAbstractButton *clickedbutton = box.clickedButton(); QAbstractButton *clickedbutton = box.clickedButton();
if (clickedbutton == close) if (clickedbutton == close)
return FileDeletedClose; return FileDeletedClose;
else if (clickedbutton == closeAll)
return FileDeletedCloseAll;
else if (clickedbutton == saveas) else if (clickedbutton == saveas)
return FileDeletedSaveAs; return FileDeletedSaveAs;
else if (clickedbutton == save) else if (clickedbutton == save)
......
...@@ -44,7 +44,12 @@ enum ReloadPromptAnswer { ReloadCurrent, ReloadAll, ReloadSkipCurrent, ReloadNon ...@@ -44,7 +44,12 @@ enum ReloadPromptAnswer { ReloadCurrent, ReloadAll, ReloadSkipCurrent, ReloadNon
QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &fileName, bool modified, QWidget *parent); QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &fileName, bool modified, QWidget *parent);
QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &title, const QString &prompt, const QString &details, QWidget *parent); QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &title, const QString &prompt, const QString &details, QWidget *parent);
enum FileDeletedPromptAnswer { FileDeletedClose, FileDeletedSaveAs, FileDeletedSave }; enum FileDeletedPromptAnswer {
FileDeletedClose,
FileDeletedCloseAll,
FileDeletedSaveAs,
FileDeletedSave
};
QTCREATOR_UTILS_EXPORT FileDeletedPromptAnswer fileDeletedPrompt(const QString &fileName, bool triggerExternally, QWidget *parent); QTCREATOR_UTILS_EXPORT FileDeletedPromptAnswer fileDeletedPrompt(const QString &fileName, bool triggerExternally, QWidget *parent);
......
...@@ -824,7 +824,8 @@ void DocumentManager::checkForReload() ...@@ -824,7 +824,8 @@ void DocumentManager::checkForReload()
d->m_blockActivated = true; d->m_blockActivated = true;
IDocument::ReloadSetting defaultBehavior = EditorManager::reloadSetting(); IDocument::ReloadSetting defaultBehavior = EditorManager::reloadSetting();
Utils::ReloadPromptAnswer previousAnswer = Utils::ReloadCurrent; Utils::ReloadPromptAnswer previousReloadAnswer = Utils::ReloadCurrent;
Utils::FileDeletedPromptAnswer previousDeletedAnswer = Utils::FileDeletedSave;
QList<IDocument *> documentsToClose; QList<IDocument *> documentsToClose;
QMap<IDocument*, QString> documentsToSave; QMap<IDocument*, QString> documentsToSave;
...@@ -949,16 +950,16 @@ void DocumentManager::checkForReload() ...@@ -949,16 +950,16 @@ void DocumentManager::checkForReload()
// IDocument wants us to ask // IDocument wants us to ask
} else if (type == IDocument::TypeContents) { } else if (type == IDocument::TypeContents) {
// content change, IDocument wants to ask user // content change, IDocument wants to ask user
if (previousAnswer == Utils::ReloadNone) { if (previousReloadAnswer == Utils::ReloadNone) {
// answer already given, ignore // answer already given, ignore
success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents); success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents);
} else if (previousAnswer == Utils::ReloadAll) { } else if (previousReloadAnswer == Utils::ReloadAll) {
// answer already given, reload // answer already given, reload
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents); success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
} else { } else {
// Ask about content change // Ask about content change
previousAnswer = Utils::reloadPrompt(document->filePath(), document->isModified(), QApplication::activeWindow()); previousReloadAnswer = Utils::reloadPrompt(document->filePath(), document->isModified(), QApplication::activeWindow());
switch (previousAnswer) { switch (previousReloadAnswer) {
case Utils::ReloadAll: case Utils::ReloadAll:
case Utils::ReloadCurrent: case Utils::ReloadCurrent:
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents); success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
...@@ -977,7 +978,13 @@ void DocumentManager::checkForReload() ...@@ -977,7 +978,13 @@ void DocumentManager::checkForReload()
// Ask about removed file // Ask about removed file
bool unhandled = true; bool unhandled = true;
while (unhandled) { while (unhandled) {
switch (Utils::fileDeletedPrompt(document->filePath(), trigger == IDocument::TriggerExternal, QApplication::activeWindow())) { if (previousDeletedAnswer != Utils::FileDeletedCloseAll) {
previousDeletedAnswer =
Utils::fileDeletedPrompt(document->filePath(),
trigger == IDocument::TriggerExternal,
QApplication::activeWindow());
}
switch (previousDeletedAnswer) {
case Utils::FileDeletedSave: case Utils::FileDeletedSave:
documentsToSave.insert(document, document->filePath()); documentsToSave.insert(document, document->filePath());
unhandled = false; unhandled = false;
...@@ -992,6 +999,7 @@ void DocumentManager::checkForReload() ...@@ -992,6 +999,7 @@ void DocumentManager::checkForReload()
break; break;
} }
case Utils::FileDeletedClose: case Utils::FileDeletedClose:
case Utils::FileDeletedCloseAll:
documentsToClose << document; documentsToClose << document;
unhandled = false; unhandled = false;
break; break;
......
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