MCPcopy Create free account
hub / github.com/KDE/kdevelop / askForCloseFeedback

Method askForCloseFeedback

kdevplatform/shell/partdocument.cpp:102–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102bool 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
136bool PartDocument::close(DocumentSaveMode mode)
137{

Callers

nothing calls this directly

Calls 4

urlFunction · 0.85
uiControllerMethod · 0.80
toLocalFileMethod · 0.80
activeMainWindowMethod · 0.45

Tested by

no test coverage detected