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
"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);
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 *save = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Save"), QMessageBox::AcceptRole);
box.setDefaultButton(saveas);
......@@ -98,6 +99,8 @@ QTCREATOR_UTILS_EXPORT Utils::FileDeletedPromptAnswer
QAbstractButton *clickedbutton = box.clickedButton();
if (clickedbutton == close)
return FileDeletedClose;
else if (clickedbutton == closeAll)
return FileDeletedCloseAll;
else if (clickedbutton == saveas)
return FileDeletedSaveAs;
else if (clickedbutton == save)
......
......@@ -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 &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);
......
......@@ -824,7 +824,8 @@ void DocumentManager::checkForReload()
d->m_blockActivated = true;
IDocument::ReloadSetting defaultBehavior = EditorManager::reloadSetting();
Utils::ReloadPromptAnswer previousAnswer = Utils::ReloadCurrent;
Utils::ReloadPromptAnswer previousReloadAnswer = Utils::ReloadCurrent;
Utils::FileDeletedPromptAnswer previousDeletedAnswer = Utils::FileDeletedSave;
QList<IDocument *> documentsToClose;
QMap<IDocument*, QString> documentsToSave;
......@@ -949,16 +950,16 @@ void DocumentManager::checkForReload()
// IDocument wants us to ask
} else if (type == IDocument::TypeContents) {
// content change, IDocument wants to ask user
if (previousAnswer == Utils::ReloadNone) {
if (previousReloadAnswer == Utils::ReloadNone) {
// answer already given, ignore
success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents);
} else if (previousAnswer == Utils::ReloadAll) {
} else if (previousReloadAnswer == Utils::ReloadAll) {
// answer already given, reload
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
} else {
// Ask about content change
previousAnswer = Utils::reloadPrompt(document->filePath(), document->isModified(), QApplication::activeWindow());
switch (previousAnswer) {
previousReloadAnswer = Utils::reloadPrompt(document->filePath(), document->isModified(), QApplication::activeWindow());
switch (previousReloadAnswer) {
case Utils::ReloadAll:
case Utils::ReloadCurrent:
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
......@@ -977,7 +978,13 @@ void DocumentManager::checkForReload()
// Ask about removed file
bool unhandled = true;
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:
documentsToSave.insert(document, document->filePath());
unhandled = false;
......@@ -992,6 +999,7 @@ void DocumentManager::checkForReload()
break;
}
case Utils::FileDeletedClose:
case Utils::FileDeletedCloseAll:
documentsToClose << document;
unhandled = false;
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