Hack around the fact that CBR or CBZ documents can ahve the wrong extension.

(And I wonder, if the only way to recognize them is via extension, wtf?)

BUG: 174701

svn path=/trunk/KDE/kdegraphics/okular/; revision=882007
remotes/origin/old/work/tiff-improvements
Pino Toscano 18 years ago
parent 9d8c52b5eb
commit 008fce9421
  1. 10
      generators/comicbook/document.cpp

@ -12,6 +12,7 @@
#include <QtGui/QImage>
#include <klocale.h>
#include <kmimetype.h>
#include <kzip.h>
#include "unrar.h"
@ -32,10 +33,12 @@ bool Document::open( const QString &fileName )
{
close();
const KMimeType::Ptr mime = KMimeType::findByFileContent( fileName );
/**
* We have a zip archive
*/
if ( fileName.toLower().endsWith( ".cbz" ) ) {
if ( mime->is( "application/x-cbz" ) || mime->name() == "application/zip" ) {
mZip = new KZip( fileName );
if ( !mZip->open( QIODevice::ReadOnly ) ) {
@ -66,7 +69,7 @@ bool Document::open( const QString &fileName )
extractImageFiles( entries );
} else {
} if ( mime->is( "application/x-cbr" ) || mime->name() == "application/x-rar" ) {
if ( !Unrar::isAvailable() ) {
mLastErrorString = i18n( "Cannot open document, unrar was not found." );
return false;
@ -90,6 +93,9 @@ bool Document::open( const QString &fileName )
}
extractImageFiles( mUnrar->list() );
} else {
mLastErrorString = i18n( "Unknown ComickBook format." );
return false;
}
return true;

Loading…
Cancel
Save