| 1138 | } |
| 1139 | |
| 1140 | bool MainWindow::checkEditorsBeforeClose(const QVector<ScintillaNext *> &editors) |
| 1141 | { |
| 1142 | for (ScintillaNext *editor : editors) { |
| 1143 | if (!editor->isSavedToDisk()) { |
| 1144 | // Switch to it |
| 1145 | dockedEditor->switchToEditor(editor); |
| 1146 | |
| 1147 | // Ask the user what to do |
| 1148 | QString message = tr("Save file <b>%1</b>?").arg(editor->getName()); |
| 1149 | auto reply = QMessageBox::question(this, tr("Save File"), message, QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); |
| 1150 | |
| 1151 | if (reply == QMessageBox::Cancel) { |
| 1152 | // Stop checking and let the caller know |
| 1153 | return false; |
| 1154 | } |
| 1155 | else if (reply == QMessageBox::Save) { |
| 1156 | bool didFileGetSaved = saveFile(editor); |
| 1157 | |
| 1158 | // The user might have canceled the save file dialog so just stop now |
| 1159 | if (didFileGetSaved == false) { |
| 1160 | // Stop checking and let the caller know |
| 1161 | return false; |
| 1162 | } |
| 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | |
| 1167 | // Everything is fine |
| 1168 | return true; |
| 1169 | } |
| 1170 | |
| 1171 | void MainWindow::openFileDialog() |
| 1172 | { |
nothing calls this directly
no test coverage detected