summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <[email protected]>2017-10-26 19:11:44 +0200
committerAlbert Astals Cid <[email protected]>2017-10-26 19:16:48 +0200
commit147735fc5a85a5d33d44368af7c6b0be227d3b04 (patch)
tree07bead083c251dd925655102632795803a6c6aed
parentb2673a58b10c1399722978f5a2e914cc9faa2162 (diff)
set the modified flag when saving a file that doesn't support saving all of the things (e.g. annotations) but supports file swapping
Example, png files. If you add an annotation and save and choose to lose changes, the annotation will still be around "in okular" but not on the file, so we need to mark the file as modified so that when the user tries to close he will get again the warning of "you're trying to save and will lose data" because otherwise the user may think the annotation actually was saved since he can see it
-rw-r--r--part.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/part.cpp b/part.cpp
index 559f556..f7bf554 100644
--- a/part.cpp
+++ b/part.cpp
@@ -2460,6 +2460,8 @@ bool Part::saveAs( const QUrl & saveUrl, SaveAsFlags flags )
}
}
+ bool setModifiedAfterSave = false;
+
QTemporaryFile tf;
QString fileName;
if ( !tf.open() )
@@ -2528,6 +2530,7 @@ bool Part::saveAs( const QUrl & saveUrl, SaveAsFlags flags )
case KMessageBox::Yes: // -> Save as Okular document archive
return slotSaveFileAs( true /* showOkularArchiveAsDefaultFormat */ );
case KMessageBox::No: // -> Continue
+ setModifiedAfterSave = m_document->canSwapBackingFile();
break;
case KMessageBox::Cancel:
return false;
@@ -2643,8 +2646,18 @@ bool Part::saveAs( const QUrl & saveUrl, SaveAsFlags flags )
{
// this calls openFile internally, which in turn actually calls
// m_document->swapBackingFile() instead of the regular loadDocument
- if ( !openUrl( saveUrl, true /* swapInsteadOfOpening */ ) )
+ if ( openUrl( saveUrl, true /* swapInsteadOfOpening */ ) )
+ {
+ if ( setModifiedAfterSave )
+ {
+ setModified();
+ setWindowTitleFromDocument();
+ }
+ }
+ else
+ {
reloadedCorrectly = false;
+ }
}
else
{