Commit a6922a44 authored by Fabio D'Urso's avatar Fabio D'Urso

Don't produce unusable file if user presses "Save As" on a .okular archive

Make "Save As" behave like "Export as Document Archive" if we are
saving a .okular file.
BUG: 258475
parent 7087f20f
......@@ -1175,12 +1175,18 @@ bool Part::openFile()
mime = KMimeType::findByPath( fileNameToOpen );
}
bool ok = false;
isDocumentArchive = false;
if ( uncompressOk )
{
if ( mime->is( "application/vnd.kde.okular-archive" ) )
{
ok = m_document->openDocumentArchive( fileNameToOpen, url() );
isDocumentArchive = true;
}
else
{
ok = m_document->openDocument( fileNameToOpen, url(), mime );
}
}
bool canSearch = m_document->supportsSearching();
......@@ -1188,7 +1194,7 @@ bool Part::openFile()
m_find->setEnabled( ok && canSearch );
m_findNext->setEnabled( ok && canSearch );
m_findPrev->setEnabled( ok && canSearch );
if( m_saveAs ) m_saveAs->setEnabled( ok && m_document->canSaveChanges() );
if( m_saveAs ) m_saveAs->setEnabled( ok && (m_document->canSaveChanges() || isDocumentArchive) );
if( m_saveCopyAs ) m_saveCopyAs->setEnabled( ok );
emit enablePrintAction( ok && m_document->printingSupport() != Okular::Document::NoPrinting );
m_printPreview->setEnabled( ok && m_document->printingSupport() != Okular::Document::NoPrinting );
......@@ -1959,7 +1965,14 @@ bool Part::saveAs( const KUrl & saveUrl )
tf.close();
QString errorText;
if ( !m_document->saveChanges( fileName, &errorText ) )
bool saved;
if ( isDocumentArchive )
saved = m_document->saveDocumentArchive( fileName );
else
saved = m_document->saveChanges( fileName, &errorText );
if ( !saved )
{
if (errorText.isEmpty())
{
......
......@@ -236,6 +236,7 @@ class Part : public KParts::ReadWritePart, public Okular::DocumentObserver, publ
// the document
Okular::Document * m_document;
QString m_temporaryLocalFile;
bool isDocumentArchive;
// main widgets
Sidebar *m_sidebar;
......
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