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 008fce94 authored by Pino Toscano's avatar Pino Toscano

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
parent 9d8c52b5
......@@ -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;
......
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