| 1223 | } |
| 1224 | |
| 1225 | void MainWindow::closeFile(ScintillaNext *editor) |
| 1226 | { |
| 1227 | // Early out. If we aren't exiting on last tab closed, and it exists, there's no point in continuing |
| 1228 | if (!app->getSettings()->exitOnLastTabClosed() && getInitialEditor() != Q_NULLPTR) { |
| 1229 | return; |
| 1230 | } |
| 1231 | |
| 1232 | if(editor->isSavedToDisk()) { |
| 1233 | editor->close(); |
| 1234 | } |
| 1235 | else { |
| 1236 | // The user needs be asked what to do about this file, so switch to it |
| 1237 | dockedEditor->switchToEditor(editor); |
| 1238 | |
| 1239 | QString message = tr("Save file <b>%1</b>?").arg(editor->getName()); |
| 1240 | auto reply = QMessageBox::question(this, tr("Save File"), message, QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); |
| 1241 | |
| 1242 | if (reply == QMessageBox::Cancel) { |
| 1243 | return; |
| 1244 | } |
| 1245 | |
| 1246 | if (reply == QMessageBox::Save) { |
| 1247 | bool didFileGetSaved = saveFile(editor); |
| 1248 | |
| 1249 | // The user might have canceled the save file dialog so just stop now |
| 1250 | if (didFileGetSaved == false) |
| 1251 | return; |
| 1252 | } |
| 1253 | |
| 1254 | editor->close(); |
| 1255 | } |
| 1256 | |
| 1257 | // If the last document was closed, figure out what to do next |
| 1258 | if (editorCount() == 0) { |
| 1259 | if (app->getSettings()->exitOnLastTabClosed()) { |
| 1260 | close(); |
| 1261 | } |
| 1262 | else { |
| 1263 | newFile(); |
| 1264 | } |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | void MainWindow::closeAllFiles() |
| 1269 | { |
nothing calls this directly
no test coverage detected