mirror of
https://invent.kde.org/graphics/okular
synced 2024-11-05 18:34:53 +00:00
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:
parent
f80b4a085d
commit
169df555d5
3 changed files with 22 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue