Implement diff on close, on revert and on external modification

Task-number: QTCREATORBUG-1531
Change-Id: I8c9a740d66eb7836b3df6850ac243260fd282b32
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Jarek Kobus
2016-10-05 17:37:00 +02:00
committed by Jarek Kobus
parent 72e19c4886
commit 1414826183
11 changed files with 243 additions and 17 deletions

View File

@@ -35,6 +35,7 @@ namespace Utils {
QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const FileName &fileName,
bool modified,
bool enableDiffOption,
QWidget *parent)
{
@@ -50,12 +51,13 @@ QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const FileName &fileName,
"The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it?");
}
msg = msg.arg(fileName.fileName());
return reloadPrompt(title, msg, fileName.toUserOutput(), parent);
return reloadPrompt(title, msg, fileName.toUserOutput(), enableDiffOption, parent);
}
QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &title,
const QString &prompt,
const QString &details,
bool enableDiffOption,
QWidget *parent)
{
QMessageBox msg(parent);
@@ -69,7 +71,19 @@ QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &title,
msg.button(QMessageBox::Close)->setText(QCoreApplication::translate("Utils::reloadPrompt",
"&Close"));
switch (msg.exec()) {
QPushButton *diffButton = nullptr;
if (enableDiffOption) {
diffButton = msg.addButton(QCoreApplication::translate(
"Utils::reloadPrompt", "No to All && &Diff"),
QMessageBox::NoRole);
}
const int result = msg.exec();
if (msg.clickedButton() == diffButton)
return ReloadNoneAndDiff;
switch (result) {
case QMessageBox::Yes:
return ReloadCurrent;
case QMessageBox::YesToAll: