MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / checkEditorsBeforeClose

Method checkEditorsBeforeClose

src/dialogs/MainWindow.cpp:1140–1169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1138}
1139
1140bool 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
1171void MainWindow::openFileDialog()
1172{

Callers

nothing calls this directly

Calls 3

isSavedToDiskMethod · 0.80
switchToEditorMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected