37
37
using namespace Utils;
39
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer
40
Utils::reloadPrompt(const QString &fileName, bool modified, QWidget *parent)
39
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer Utils::reloadPrompt(const QString &fileName,
43
44
const QString title = QCoreApplication::translate("Utils::reloadPrompt", "File Changed");
47
msg = QCoreApplication::translate("Utils::reloadPrompt",
48
"The unsaved file <i>%1</i> has been changed outside Qt Creator. Do you want to reload it and discard your changes?");
50
msg = QCoreApplication::translate("Utils::reloadPrompt",
51
"The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it?");
48
msg = QCoreApplication::translate("Utils::reloadPrompt",
49
"The unsaved file <i>%1</i> has changed outside Qt Creator. "
50
"Do you want to reload it and discard your changes?");
52
msg = QCoreApplication::translate("Utils::reloadPrompt",
53
"The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it?");
52
55
msg = msg.arg(QFileInfo(fileName).fileName());
53
56
return reloadPrompt(title, msg, QDir::toNativeSeparators(fileName), parent);
56
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer
57
Utils::reloadPrompt(const QString &title, const QString &prompt, const QString &details, QWidget *parent)
59
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer Utils::reloadPrompt(const QString &title,
60
const QString &prompt,
61
const QString &details,
59
64
QMessageBox msg(parent);
60
msg.setStandardButtons(QMessageBox::Yes|QMessageBox::YesToAll|QMessageBox::Close|QMessageBox::No|QMessageBox::NoToAll);
65
msg.setStandardButtons(QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::Close
66
| QMessageBox::No | QMessageBox::NoToAll);
61
67
msg.setDefaultButton(QMessageBox::YesToAll);
62
68
msg.setWindowTitle(title);
63
69
msg.setText(prompt);
81
87
QTCREATOR_UTILS_EXPORT Utils::FileDeletedPromptAnswer
82
88
Utils::fileDeletedPrompt(const QString &fileName, bool triggerExternally, QWidget *parent)
84
const QString title = QCoreApplication::translate("Utils::fileDeletedPrompt", "File has been removed");
90
const QString title = QCoreApplication::translate("Utils::fileDeletedPrompt",
91
"File has been removed");
86
if (triggerExternally)
87
msg = QCoreApplication::translate("Utils::fileDeletedPrompt",
88
"The file %1 has been removed outside Qt Creator. Do you want to save it under a different name, or close the editor?").arg(QDir::toNativeSeparators(fileName));
90
msg = QCoreApplication::translate("Utils::fileDeletedPrompt",
91
"The file %1 was removed. Do you want to save it under a different name, or close the editor?").arg(QDir::toNativeSeparators(fileName));
93
if (triggerExternally) {
94
msg = QCoreApplication::translate("Utils::fileDeletedPrompt",
95
"The file %1 has been removed outside Qt Creator. "
96
"Do you want to save it under a different name, or close "
97
"the editor?").arg(QDir::toNativeSeparators(fileName));
99
msg = QCoreApplication::translate("Utils::fileDeletedPrompt",
100
"The file %1 was removed. "
101
"Do you want to save it under a different name, or close "
102
"the editor?").arg(QDir::toNativeSeparators(fileName));
92
104
QMessageBox box(QMessageBox::Question, title, msg, QMessageBox::NoButton, parent);
93
QPushButton *close = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Close"), QMessageBox::RejectRole);
94
QPushButton *saveas = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "Save &as..."), QMessageBox::ActionRole);
95
QPushButton *save = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Save"), QMessageBox::AcceptRole);
106
box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Close"),
107
QMessageBox::RejectRole);
108
QPushButton *closeAll =
109
box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "C&lose All"),
110
QMessageBox::RejectRole);
111
QPushButton *saveas =
112
box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "Save &as..."),
113
QMessageBox::ActionRole);
115
box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Save"),
116
QMessageBox::AcceptRole);
96
117
box.setDefaultButton(saveas);
98
119
QAbstractButton *clickedbutton = box.clickedButton();
99
120
if (clickedbutton == close)
100
121
return FileDeletedClose;
122
else if (clickedbutton == closeAll)
123
return FileDeletedCloseAll;
101
124
else if (clickedbutton == saveas)
102
125
return FileDeletedSaveAs;
103
126
else if (clickedbutton == save)