From 481676dcedf17a48d996b1f368f72d38869a3e4d Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 15 Nov 2017 14:10:36 +0100 Subject: [PATCH] Do not show "Continue" while on Save format warning It makes no sense, only on Save As makes sense --- part.cpp | 62 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/part.cpp b/part.cpp index c025bf6ce..33102a9be 100644 --- a/part.cpp +++ b/part.cpp @@ -2516,27 +2516,49 @@ bool Part::saveAs( const QUrl & saveUrl, SaveAsFlags flags ) if ( wontSaveAnnotations ) listOfwontSaves << i18n( "User annotations" ); if ( !listOfwontSaves.isEmpty() ) { - const QString warningMessage = m_document->canSwapBackingFile() ? - i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the Okular document archive format to preserve them. Click Continue to save the document and discard these elements." ) : - i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the Okular document archive format to preserve them. Click Continue to save, but you will lose these elements as well as the undo/redo history." ); - const QString continueMessage = m_document->canSwapBackingFile() ? - i18n( "Continue" ) : - i18n( "Continue losing changes" ); - const int result = KMessageBox::warningYesNoCancelList( widget(), - warningMessage, - listOfwontSaves, i18n( "Warning" ), - KGuiItem( i18n( "Save as Okular document archive..." ), "document-save-as" ), // <- KMessageBox::Yes - KGuiItem( continueMessage, "arrow-right" ) ); // <- KMessageBox::NO - - switch (result) + if ( saveUrl == url() ) { - 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; + // Save + const QString warningMessage = i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the Okular document archive format to preserve them." ); + const int result = KMessageBox::warningYesNoList( widget(), + warningMessage, + listOfwontSaves, i18n( "Warning" ), + KGuiItem( i18n( "Save as Okular document archive..." ), "document-save-as" ), // <- KMessageBox::Yes + KStandardGuiItem::cancel() ); + + switch (result) + { + case KMessageBox::Yes: // -> Save as Okular document archive + return slotSaveFileAs( true /* showOkularArchiveAsDefaultFormat */ ); + default: + return false; + } + } + else + { + // Save as + const QString warningMessage = m_document->canSwapBackingFile() ? + i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the Okular document archive format to preserve them. Click Continue to save the document and discard these elements." ) : + i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the Okular document archive format to preserve them. Click Continue to save, but you will lose these elements as well as the undo/redo history." ); + const QString continueMessage = m_document->canSwapBackingFile() ? + i18n( "Continue" ) : + i18n( "Continue losing changes" ); + const int result = KMessageBox::warningYesNoCancelList( widget(), + warningMessage, + listOfwontSaves, i18n( "Warning" ), + KGuiItem( i18n( "Save as Okular document archive..." ), "document-save-as" ), // <- KMessageBox::Yes + KGuiItem( continueMessage, "arrow-right" ) ); // <- KMessageBox::NO + + switch (result) + { + 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; + } } }