Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 147735fc authored by Albert Astals Cid's avatar Albert Astals Cid Committed by Albert Astals Cid

set the modified flag when saving a file that doesn't support saving all of...

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
parent b2673a58
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment