| 100 | } |
| 101 | |
| 102 | bool PartDocument::askForCloseFeedback() |
| 103 | { |
| 104 | auto saveMode = Default; |
| 105 | int code = -1; |
| 106 | if (state() == IDocument::Modified) { |
| 107 | code = KMessageBox::warningTwoActionsCancel( |
| 108 | Core::self()->uiController()->activeMainWindow(), |
| 109 | i18n("The document \"%1\" has unsaved changes. Would you like to save them?", url().toLocalFile()), |
| 110 | i18nc("@title:window", "Close Document"), KStandardGuiItem::save(), KStandardGuiItem::discard()); |
| 111 | } else if (state() == IDocument::DirtyAndModified) { |
| 112 | code = KMessageBox::warningTwoActionsCancel( |
| 113 | Core::self()->uiController()->activeMainWindow(), |
| 114 | i18n("The document \"%1\" has unsaved changes and was modified by an external process.\n" |
| 115 | "Do you want to overwrite the external changes?", |
| 116 | url().toLocalFile()), |
| 117 | i18nc("@title:window", "Close Document"), |
| 118 | KGuiItem(i18nc("@action:button", "Overwrite External Changes"), QStringLiteral("document-save")), |
| 119 | KStandardGuiItem::discard()); |
| 120 | saveMode = Silent; // already asked about the external changes, do not ask again |
| 121 | } |
| 122 | |
| 123 | if (code >= 0) { |
| 124 | if (code == KMessageBox::PrimaryAction) { |
| 125 | if (!save(saveMode)) |
| 126 | return false; |
| 127 | |
| 128 | } else if (code == KMessageBox::Cancel) { |
| 129 | return false; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | return true; |
| 134 | } |
| 135 | |
| 136 | bool PartDocument::close(DocumentSaveMode mode) |
| 137 | { |
nothing calls this directly
no test coverage detected