report a message when there is no unrar, or the unrar is not suitable

svn path=/trunk/KDE/kdegraphics/okular/; revision=809958
This commit is contained in:
Pino Toscano 2008-05-19 19:43:48 +00:00
parent f80b4a085d
commit 169df555d5
3 changed files with 22 additions and 1 deletions

View file

@ -11,6 +11,7 @@
#include <QtGui/QImage>
#include <klocale.h>
#include <kzip.h>
#include "unrar.h"
@ -67,7 +68,12 @@ bool Document::open( const QString &fileName )
} else {
if ( !Unrar::isAvailable() ) {
// TODO emit a visible error
mLastErrorString = i18n( "Cannot open document, unrar was not found." );
return false;
}
if ( !Unrar::isSuitableVersionAvailable() ) {
mLastErrorString = i18n( "The version of unrar on your system is not suitable for opening comicbooks." );
return false;
}
@ -91,6 +97,8 @@ bool Document::open( const QString &fileName )
void Document::close()
{
mLastErrorString.clear();
if ( !( mZip || mUnrar ) )
return;
@ -141,3 +149,8 @@ QImage Document::pageImage( int page ) const
return QImage();
}
QString Document::lastErrorString() const
{
return mLastErrorString;
}

View file

@ -33,6 +33,8 @@ class Document
QImage pageImage( int page ) const;
QString lastErrorString() const;
private:
void extractImageFiles( const QStringList& );
@ -40,6 +42,7 @@ class Document
Unrar *mUnrar;
KZip *mZip;
KArchiveDirectory *mZipDir;
QString mLastErrorString;
};
}

View file

@ -52,7 +52,12 @@ ComicBookGenerator::~ComicBookGenerator()
bool ComicBookGenerator::loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector )
{
if ( !mDocument.open( fileName ) )
{
const QString errString = mDocument.lastErrorString();
if ( !errString.isEmpty() )
emit error( errString, -1 );
return false;
}
int pages = mDocument.pages();
pagesVector.resize( pages );