Skip to content

Commit

Permalink
Revert refactoring of showNotSavedDialog()
Browse files Browse the repository at this point in the history
  • Loading branch information
houmain committed Jan 15, 2023
1 parent baeda3f commit e1b4c9d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/FileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ bool FileDialog::exec(Options options, QString currentFileName,
return true;
}

bool showNotSavedDialog(QWidget *parent, const QString& fileName)
int showNotSavedDialog(QWidget *parent, const QString &fileName)
{
auto dialog = QMessageBox(parent);
dialog.setIcon(QMessageBox::Question);
Expand All @@ -255,7 +255,7 @@ bool showNotSavedDialog(QWidget *parent, const QString& fileName)
dialog.addButton(parent->tr("&Don't Save"), QMessageBox::RejectRole);
dialog.addButton(QMessageBox::Cancel);
dialog.setDefaultButton(QMessageBox::Save);
return (dialog.exec() == QMessageBox::Save);
return dialog.exec();
}

bool showSavingFailedMessage(QWidget *parent, const QString &fileName)
Expand All @@ -267,7 +267,7 @@ bool showSavingFailedMessage(QWidget *parent, const QString &fileName)
text += parent->tr("Is the path writeable");
if (FileDialog::isTextureFileName(fileName))
text += parent->tr(" and does the file format support the texture format");
text += "?";
text += "?<br>";
dialog.setText(text);
dialog.addButton(QMessageBox::Retry);
dialog.addButton(QMessageBox::Cancel);
Expand All @@ -278,7 +278,8 @@ void showCopyingSessionFailedMessage(QWidget *parent)
{
auto dialog = QMessageBox(parent);
dialog.setIcon(QMessageBox::Warning);
dialog.setText(parent->tr("<h3>Copying session files failed.</h3>"));
dialog.setText(parent->tr("<h3>Copying session files failed.</h3>"
"Not all files in session could be copied.<br>"));
dialog.addButton(QMessageBox::Ok);
dialog.exec();
}
2 changes: 1 addition & 1 deletion src/FileDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FileDialog final : public QObject
bool mAsBinaryFile{ };
};

bool showNotSavedDialog(QWidget *parent, const QString &fileName);
int showNotSavedDialog(QWidget *parent, const QString &fileName);
bool showSavingFailedMessage(QWidget *parent, const QString &fileName);
void showCopyingSessionFailedMessage(QWidget *parent);

Expand Down
5 changes: 4 additions & 1 deletion src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,10 @@ bool MainWindow::closeSession()
return false;

if (mSessionEditor->isModified()) {
if (!showNotSavedDialog(this, mSessionEditor->fileName()) ||
const auto ret = showNotSavedDialog(this, mSessionEditor->fileName());
if (ret == QMessageBox::Cancel)
return false;
if (ret == QMessageBox::Save &&
!saveSession())
return false;
}
Expand Down
5 changes: 4 additions & 1 deletion src/editors/EditorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,10 @@ bool EditorManager::promptSaveDock(QDockWidget *dock)
if (dock->isWindowModified()) {
autoRaise(dock->widget());

if (!showNotSavedDialog(this, editor->fileName()) ||
const auto ret = showNotSavedDialog(this, editor->fileName());
if (ret == QMessageBox::Cancel)
return false;
if (ret == QMessageBox::Save &&
!saveDock(dock))
return false;
}
Expand Down

0 comments on commit e1b4c9d

Please sign in to comment.