Merge branch 'master' into dont-use-docdata-for-annots-and-forms

Conflicts:
	core/document.cpp
	core/document_p.h
	part.cpp
	part.h
This commit is contained in:
Fabio D'Urso 2014-09-08 14:58:55 +02:00
commit 288f87f1a5
87 changed files with 1889 additions and 785 deletions

View file

@ -139,7 +139,7 @@ if(LibKScreen_FOUND)
target_link_libraries(okularcore ${LibKScreen_LIBRARY})
endif(LibKScreen_FOUND)
set_target_properties(okularcore PROPERTIES VERSION 4.0.0 SOVERSION 4 )
set_target_properties(okularcore PROPERTIES VERSION 5.0.0 SOVERSION 5 )
install(TARGETS okularcore ${INSTALL_TARGETS_DEFAULT_ARGS} )

View file

@ -1 +1 @@
okular v0.19.60
okular v0.20.60

View file

@ -1,5 +1,6 @@
[Desktop Entry]
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -8,6 +9,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -45,6 +47,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -53,6 +56,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -89,6 +93,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -97,6 +102,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma

View file

@ -1,5 +1,6 @@
[Desktop Entry]
Name=Document viewer
Name[ar]=عارض المستندات
Name[bg]=Преглед на документи
Name[bs]=Prikazivač dokumenata
Name[ca]=Visualitzador de documents
@ -8,6 +9,7 @@ Name[cs]=Prohlížeč dokumentů
Name[da]=Dokumentfremviser
Name[de]=Dokumentenbetrachter
Name[el]=Προβολέας εγγράφων
Name[en_GB]=Document viewer
Name[es]=Visor de documentos
Name[et]=Dokumendinäitaja
Name[fi]=Asiakirjakatselin

View file

@ -4,6 +4,7 @@ File=okular.kcfg
Inherits=SettingsCore
Mutators=true
Singleton=true
IncludeFiles=settings_core.h
Visibility=OKULAR_PART_EXPORT
IncludeFiles=settings_core.h,okular_part_export.h
SourceIncludeFiles=kstandarddirs.h,qdom.h
MemberVariables=dpointer

View file

@ -937,7 +937,9 @@ Document::OpenResult DocumentPrivate::openDocumentInternal( const KService::Ptr&
QApplication::setOverrideCursor( Qt::WaitCursor );
m_generator->setDPI(Utils::realDpi(m_widget));
const QSizeF dpi = Utils::realDpi(m_widget);
kDebug() << "Output DPI:" << dpi;
m_generator->setDPI(dpi);
Document::OpenResult openResult = Document::OpenError;
if ( !isstdin )
@ -2079,6 +2081,26 @@ private:
const KMimeType::Ptr &_mime;
};
QString DocumentPrivate::docDataFileName(const KUrl &url, qint64 document_size)
{
QString fn = url.fileName();
fn = QString::number( document_size ) + '.' + fn + ".xml";
QString newokular = "okular/docdata/" + fn;
QString newokularfile = KStandardDirs::locateLocal( "data", newokular );
if ( !QFile::exists( newokularfile ) )
{
QString oldkpdf = "kpdf/" + fn;
QString oldkpdffile = KStandardDirs::locateLocal( "data", oldkpdf );
if ( QFile::exists( oldkpdffile ) )
{
// ### copy or move?
if ( !QFile::copy( oldkpdffile, newokularfile ) )
return QString();
}
}
return newokularfile;
}
Document::OpenResult Document::openDocument( const QString & docFile, const KUrl& url, const KMimeType::Ptr &_mime, const QString & password )
{
KMimeType::Ptr mime = _mime;
@ -2278,23 +2300,9 @@ bool DocumentPrivate::updateMetadataXmlNameAndDocSize()
// determine the related "xml document-info" filename
if ( m_url.isLocalFile() )
{
const QString fn = QString::number( m_docSize ) + '.' + m_url.fileName() + ".xml";
const QString newokular = "okular/docdata/" + fn;
const QString newokularfile = KStandardDirs::locateLocal( "data", newokular );
if ( !QFile::exists( newokularfile ) )
{
const QString oldkpdf = "kpdf/" + fn;
const QString oldkpdffile = KStandardDirs::locateLocal( "data", oldkpdf );
if ( QFile::exists( oldkpdffile ) )
{
// ### copy or move?
if ( !QFile::copy( oldkpdffile, newokularfile ) )
return false;
}
}
kDebug(OkularDebug) << "Metadata file is now:" << newokularfile;
m_xmlFileName = newokularfile;
const QString filePath = docDataFileName( m_url, m_docSize );
kDebug(OkularDebug) << "Metadata file is now:" << filePath;
m_xmlFileName = filePath;
}
else
{
@ -2446,8 +2454,8 @@ void Document::closeDocument()
d->m_pageSize = PageSize();
d->m_pageSizes.clear();
delete d->m_documentInfo;
d->m_documentInfo = 0;
d->m_documentInfo = DocumentInfo();
d->m_documentInfoAskedKeys.clear();
AudioPlayer::instance()->d->m_currentDocument = KUrl();
@ -2547,42 +2555,59 @@ bool Document::canConfigurePrinter( ) const
return 0;
}
const DocumentInfo * Document::documentInfo() const
DocumentInfo Document::documentInfo() const
{
if ( d->m_documentInfo )
return d->m_documentInfo;
if ( d->m_generator )
QSet<DocumentInfo::Key> keys;
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
ks < Okular::DocumentInfo::Invalid;
ks = Okular::DocumentInfo::Key( ks+1 ) )
{
DocumentInfo *info = new DocumentInfo();
const DocumentInfo *tmp = d->m_generator->generateDocumentInfo();
if ( tmp )
*info = *tmp;
keys << ks;
}
info->set( DocumentInfo::FilePath, currentDocument().prettyUrl() );
const QString pagesSize = d->pagesSizeString();
if ( d->m_docSize != -1 )
return documentInfo( keys );
}
DocumentInfo Document::documentInfo( const QSet<DocumentInfo::Key> &keys ) const
{
DocumentInfo result = d->m_documentInfo;
const QSet<DocumentInfo::Key> missingKeys = keys - d->m_documentInfoAskedKeys;
if ( d->m_generator && !missingKeys.isEmpty() )
{
DocumentInfo info = d->m_generator->generateDocumentInfo( missingKeys );
if ( missingKeys.contains( DocumentInfo::FilePath ) )
{
info.set( DocumentInfo::FilePath, currentDocument().prettyUrl() );
}
if ( d->m_docSize != -1 && missingKeys.contains( DocumentInfo::DocumentSize ) )
{
const QString sizeString = KGlobal::locale()->formatByteSize( d->m_docSize );
info->set( DocumentInfo::DocumentSize, sizeString );
info.set( DocumentInfo::DocumentSize, sizeString );
}
if (!pagesSize.isEmpty())
if ( missingKeys.contains( DocumentInfo::PagesSize ) )
{
info->set( DocumentInfo::PagesSize, pagesSize );
const QString pagesSize = d->pagesSizeString();
if ( !pagesSize.isEmpty() )
{
info.set( DocumentInfo::PagesSize, pagesSize );
}
}
const DocumentInfo::Key keyPages = DocumentInfo::Pages;
const QString keyString = DocumentInfo::getKeyString( keyPages );
if ( info->get( keyString ).isEmpty() ) {
info->set( keyString, QString::number( this->pages() ),
DocumentInfo::getKeyTitle( keyPages ) );
if ( missingKeys.contains( DocumentInfo::Pages ) && info.get( DocumentInfo::Pages ).isEmpty() ) {
info.set( DocumentInfo::Pages, QString::number( this->pages() ) );
}
d->m_documentInfo = info;
return info;
d->m_documentInfo.d->values.unite(info.d->values);
d->m_documentInfo.d->titles.unite(info.d->titles);
result.d->values.unite(info.d->values);
result.d->titles.unite(info.d->titles);
}
else return NULL;
d->m_documentInfoAskedKeys += keys;
return result;
}
const DocumentSynopsis * Document::documentSynopsis() const
@ -2814,7 +2839,7 @@ void Document::requestPixmaps( const QLinkedList< PixmapRequest * > & requests,
if ( requests.isEmpty() )
return;
if ( !d->m_generator || d->m_closingLoop )
if ( !d->m_pageController )
{
// delete requests..
QLinkedList< PixmapRequest * >::const_iterator rIt = requests.constBegin(), rEnd = requests.constEnd();
@ -4523,7 +4548,7 @@ void DocumentPrivate::calculateMaxTextPages()
void DocumentPrivate::textGenerationDone( Page *page )
{
if ( !m_generator || m_closingLoop ) return;
if ( !m_pageController ) return;
// 1. If we reached the cache limit, delete the first text page from the fifo
if (m_allocatedTextPagesFifo.size() == m_maxAllocatedTextPages)
@ -4734,52 +4759,51 @@ bool DocumentViewport::operator<( const DocumentViewport & vp ) const
/** DocumentInfo **/
DocumentInfo::DocumentInfo()
: QDomDocument( "DocumentInformation" )
DocumentInfo::DocumentInfo() : d(new DocumentInfoPrivate())
{
QDomElement docElement = createElement( "DocumentInfo" );
appendChild( docElement );
}
void DocumentInfo::set( const QString &key, const QString &value,
const QString &title )
DocumentInfo::DocumentInfo(const DocumentInfo &info) : d(new DocumentInfoPrivate())
{
QDomElement docElement = documentElement();
QDomElement element;
*this = info;
}
// check whether key already exists
QDomNodeList list = docElement.elementsByTagName( key );
if ( list.count() > 0 )
element = list.item( 0 ).toElement();
else
element = createElement( key );
DocumentInfo& DocumentInfo::operator=(const DocumentInfo &info)
{
d->values = info.d->values;
d->titles = info.d->titles;
return *this;
}
element.setAttribute( "value", value );
element.setAttribute( "title", title );
DocumentInfo::~DocumentInfo()
{
delete d;
}
if ( list.count() == 0 )
docElement.appendChild( element );
void DocumentInfo::set( const QString &key, const QString &value, const QString &title )
{
d->values[ key ] = value;
d->titles[ key ] = title;
}
void DocumentInfo::set( Key key, const QString &value )
{
const QString keyString = getKeyString( key );
if ( !keyString.isEmpty() )
set( keyString, value, getKeyTitle( key ) );
else
kWarning(OkularDebug) << "Invalid key passed";
d->values[ getKeyString( key ) ] = value;
}
QStringList DocumentInfo::keys() const
{
return d->values.keys();
}
QString DocumentInfo::get( Key key ) const
{
return get( getKeyString( key ) );
}
QString DocumentInfo::get( const QString &key ) const
{
const QDomElement docElement = documentElement();
// check whether key already exists
const QDomNodeList list = docElement.elementsByTagName( key );
if ( list.count() > 0 )
return list.item( 0 ).toElement().attribute( "value" );
else
return QString();
return d->values[ key ];
}
QString DocumentInfo::getKeyString( Key key ) //const
@ -4834,11 +4858,33 @@ QString DocumentInfo::getKeyString( Key key ) //const
return "pageSize";
break;
default:
kWarning() << "Unknown" << key;
return QString();
break;
}
}
DocumentInfo::Key DocumentInfo::getKeyFromString( const QString &key ) //const
{
if (key == "title") return Title;
else if (key == "subject") return Subject;
else if (key == "description") return Description;
else if (key == "author") return Author;
else if (key == "creator") return Creator;
else if (key == "producer") return Producer;
else if (key == "copyright") return Copyright;
else if (key == "pages") return Pages;
else if (key == "creationDate") return CreationDate;
else if (key == "modificationDate") return ModificationDate;
else if (key == "mimeType") return MimeType;
else if (key == "category") return Category;
else if (key == "keywords") return Keywords;
else if (key == "filePath") return FilePath;
else if (key == "documentSize") return DocumentSize;
else if (key == "pageSize") return PagesSize;
else return Invalid;
}
QString DocumentInfo::getKeyTitle( Key key ) //const
{
switch ( key ) {
@ -4896,6 +4942,15 @@ QString DocumentInfo::getKeyTitle( Key key ) //const
}
}
QString DocumentInfo::getKeyTitle( const QString &key ) const
{
QString title = getKeyTitle ( getKeyFromString( key ) );
if ( title.isEmpty() )
title = d->titles[ key ];
return title;
}
/** DocumentSynopsis **/

View file

@ -36,7 +36,7 @@ namespace Okular {
class Annotation;
class BookmarkManager;
class DocumentInfo;
class DocumentInfoPrivate;
class DocumentObserver;
class DocumentPrivate;
class DocumentSynopsis;
@ -63,6 +63,110 @@ class VisiblePageRect;
#define SW_SEARCH_ID 3
#define PRESENTATION_SEARCH_ID 4
/**
* The DocumentInfo structure can be filled in by generators to display
* metadata about the currently opened file.
*/
class OKULAR_EXPORT DocumentInfo
{
friend class Document;
public:
/**
* The list of predefined keys.
*/
enum Key {
Title, ///< The title of the document
Subject, ///< The subject of the document
Description, ///< The description of the document
Author, ///< The author of the document
Creator, ///< The creator of the document (this can be different from the author)
Producer, ///< The producer of the document (e.g. some software)
Copyright, ///< The copyright of the document
Pages, ///< The number of pages of the document
CreationDate, ///< The date of creation of the document
ModificationDate, ///< The date of last modification of the document
MimeType, ///< The mime type of the document
Category, ///< The category of the document
Keywords, ///< The keywords which describe the content of the document
FilePath, ///< The path of the file @since 0.10 (KDE 4.4)
DocumentSize, ///< The size of the document @since 0.10 (KDE 4.4)
PagesSize, ///< The size of the pages (if all pages have the same size) @since 0.10 (KDE 4.4)
CustomKeys, ///< All the custom keys the generator supports @since 0.21
Invalid ///< An invalid key @since 0.21. It will always be the last element in the enum
};
/**
* Creates a new document info.
*/
DocumentInfo();
DocumentInfo(const DocumentInfo &info);
DocumentInfo& operator=( const DocumentInfo& );
~DocumentInfo();
/**
* Returns all the keys present in this DocumentInfo
*
* @since 0.21
*/
QStringList keys() const;
/**
* Returns the value for a given key or an null string when the
* key doesn't exist.
*/
QString get( Key key ) const;
/**
* Returns the value for a given key or an null string when the
* key doesn't exist.
*/
QString get( const QString &key ) const;
/**
* Sets a value for a custom key. The title should be an i18n'ed
* string, since it's used in the document information dialog.
*/
void set( const QString &key, const QString &value,
const QString &title = QString() );
/**
* Sets a value for a special key. The title should be an i18n'ed
* string, since it's used in the document information dialog.
*/
void set( Key key, const QString &value );
/**
* Returns the user visible string for the given key
* Takes into account keys added by the set() that takes a QString
*
* @since 0.21
*/
QString getKeyTitle( const QString &key ) const;
/**
* Returns the internal string for the given key
* @since 0.10 (KDE 4.4)
*/
static QString getKeyString( Key key );
/**
* Returns the user visible string for the given key
* @since 0.10 (KDE 4.4)
*/
static QString getKeyTitle( Key key );
/**
* Returns the Key from a string key
* @since 0.21
*/
static Key getKeyFromString( const QString &key );
private:
DocumentInfoPrivate *d;
};
/**
* @short The Document. Heart of everything. Actions take place here.
@ -139,10 +243,15 @@ class OKULAR_EXPORT Document : public QObject
bool isOpened() const;
/**
* Returns the meta data of the document or 0 if no meta data
* are available.
* Returns the meta data of the document.
*/
const DocumentInfo * documentInfo() const;
DocumentInfo documentInfo() const;
/**
* Returns the asked set of meta data of the document. The result may contain more
* metadata than the one asked for.
*/
DocumentInfo documentInfo( const QSet<DocumentInfo::Key> &keys ) const;
/**
* Returns the table of content of the document or 0 if no
@ -1121,75 +1230,6 @@ class OKULAR_EXPORT DocumentViewport
} autoFit;
};
/**
* @short A DOM tree containing information about the document.
*
* The DocumentInfo structure can be filled in by generators to display
* metadata about the currently opened file.
*/
class OKULAR_EXPORT DocumentInfo : public QDomDocument
{
public:
/**
* The list of predefined keys.
*/
enum Key {
Title, ///< The title of the document
Subject, ///< The subject of the document
Description, ///< The description of the document
Author, ///< The author of the document
Creator, ///< The creator of the document (this can be different from the author)
Producer, ///< The producer of the document (e.g. some software)
Copyright, ///< The copyright of the document
Pages, ///< The number of pages of the document
CreationDate, ///< The date of creation of the document
ModificationDate, ///< The date of last modification of the document
MimeType, ///< The mime type of the document
Category, ///< The category of the document
Keywords, ///< The keywords which describe the content of the document
FilePath, ///< The path of the file @since 0.10 (KDE 4.4)
DocumentSize, ///< The size of the document @since 0.10 (KDE 4.4)
PagesSize ///< The size of the pages (if all pages have the same size) @since 0.10 (KDE 4.4)
};
/**
* Creates a new document info.
*/
DocumentInfo();
/**
* Sets a value for a special key. The title should be an i18n'ed
* string, since it's used in the document information dialog.
*/
void set( const QString &key, const QString &value,
const QString &title = QString() );
/**
* Sets the value for a predefined key. You should use this method
* whenever a predefined key exists for your value.
*/
void set( Key key, const QString &value );
/**
* Returns the value for a given key or an empty string when the
* key doesn't exist.
*/
QString get( const QString &key ) const;
/**
* Returns the internal string for the given key
* @since 0.10 (KDE 4.4)
*/
static QString getKeyString( Key key );
/**
* Returns the user visible string for the given key
* @since 0.10 (KDE 4.4)
*/
static QString getKeyTitle( Key key );
};
/**
* @short A DOM tree that describes the Table of Contents.
*

View file

@ -105,7 +105,6 @@ class DocumentPrivate
m_scripter( 0 ),
m_archiveData( 0 ),
m_fontsCached( false ),
m_documentInfo( 0 ),
m_annotationEditingEnabled ( true ),
m_annotationBeingMoved( false )
{
@ -147,6 +146,7 @@ class DocumentPrivate
bool canAddAnnotationsNatively() const;
bool canModifyExternalAnnotations() const;
bool canRemoveExternalAnnotations() const;
OKULAR_EXPORT static QString docDataFileName(const KUrl &url, qint64 document_size);
// Methods that implement functionality needed by undo commands
void performAddPageAnnotation( int page, Annotation *annotation );
@ -268,7 +268,8 @@ class DocumentPrivate
QPointer< FontExtractionThread > m_fontThread;
bool m_fontsCached;
DocumentInfo *m_documentInfo;
QSet<DocumentInfo::Key> m_documentInfoAskedKeys;
DocumentInfo m_documentInfo;
FontInfo::List m_fontsCache;
QSet< View * > m_views;
@ -281,6 +282,13 @@ class DocumentPrivate
QDomNode m_prevPropsOfAnnotBeingModified;
};
class DocumentInfoPrivate
{
public:
QMap<QString, QString> values; // key -> value
QMap<QString, QString> titles; // key -> title For the custom keys
};
}
#endif

View file

@ -295,9 +295,9 @@ TextPage* Generator::textPage( Page* )
return 0;
}
const DocumentInfo * Generator::generateDocumentInfo()
DocumentInfo Generator::generateDocumentInfo(const QSet<DocumentInfo::Key> &keys) const
{
return 0;
return DocumentInfo();
}
const DocumentSynopsis * Generator::generateDocumentSynopsis()

View file

@ -320,10 +320,9 @@ class OKULAR_EXPORT Generator : public QObject
virtual void generateTextPage( Page * page );
/**
* Returns the general information object of the document or 0 if
* no information are available.
* Returns the general information object of the document.
*/
virtual const DocumentInfo * generateDocumentInfo();
virtual DocumentInfo generateDocumentInfo( const QSet<DocumentInfo::Key> &keys ) const;
/**
* Returns the 'table of content' object of the document or 0 if

View file

@ -135,12 +135,17 @@ static KJSObject docGetInfo( KJSContext *ctx, void *object )
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
KJSObject obj;
const DocumentInfo *docinfo = doc->m_generator->generateDocumentInfo();
if ( docinfo )
{
QSet<DocumentInfo::Key> keys;
keys << DocumentInfo::Title
<< DocumentInfo::Author
<< DocumentInfo::Subject
<< DocumentInfo::Keywords
<< DocumentInfo::Creator
<< DocumentInfo::Producer;
const DocumentInfo docinfo = doc->m_parent->documentInfo( keys );
#define KEY_GET( key, property ) \
do { \
const QString data = docinfo->get( key ); \
const QString data = docinfo.get( key ); \
if ( !data.isEmpty() ) \
{ \
const KJSString newval( data ); \
@ -148,14 +153,13 @@ do { \
obj.setProperty( ctx, QString( property ).toLower(), newval ); \
} \
} while ( 0 );
KEY_GET( "title", "Title" );
KEY_GET( "author", "Author" );
KEY_GET( "subject", "Subject" );
KEY_GET( "keywords", "Keywords" );
KEY_GET( "creator", "Creator" );
KEY_GET( "producer", "Producer" );
KEY_GET( DocumentInfo::Title, "Title" );
KEY_GET( DocumentInfo::Author, "Author" );
KEY_GET( DocumentInfo::Subject, "Subject" );
KEY_GET( DocumentInfo::Keywords, "Keywords" );
KEY_GET( DocumentInfo::Creator, "Creator" );
KEY_GET( DocumentInfo::Producer, "Producer" );
#undef KEY_GET
}
return obj;
}
@ -163,16 +167,16 @@ do { \
static KJSObject docGet ## name( KJSContext *, void *object ) \
{ \
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object ); \
const DocumentInfo *docinfo = doc->m_generator->generateDocumentInfo(); \
return KJSString( docinfo->get( key ) ); \
const DocumentInfo docinfo = doc->m_parent->documentInfo(QSet<DocumentInfo::Key>() << key ); \
return KJSString( docinfo.get( key ) ); \
}
DOCINFO_GET_METHOD( "author", Author )
DOCINFO_GET_METHOD( "creator", Creator )
DOCINFO_GET_METHOD( "keywords", Keywords )
DOCINFO_GET_METHOD( "producer", Producer )
DOCINFO_GET_METHOD( "title", Title )
DOCINFO_GET_METHOD( "subject", Subject )
DOCINFO_GET_METHOD( DocumentInfo::Author, Author )
DOCINFO_GET_METHOD( DocumentInfo::Creator, Creator )
DOCINFO_GET_METHOD( DocumentInfo::Keywords, Keywords )
DOCINFO_GET_METHOD( DocumentInfo::Producer, Producer )
DOCINFO_GET_METHOD( DocumentInfo::Title, Title )
DOCINFO_GET_METHOD( DocumentInfo::Subject, Subject )
#undef DOCINFO_GET_METHOD

View file

@ -453,10 +453,10 @@ bool TextDocumentGenerator::print( QPrinter& printer )
return true;
}
const Okular::DocumentInfo* TextDocumentGenerator::generateDocumentInfo()
Okular::DocumentInfo TextDocumentGenerator::generateDocumentInfo( const QSet<DocumentInfo::Key> & /*keys*/ ) const
{
Q_D( TextDocumentGenerator );
return &d->mDocumentInfo;
Q_D( const TextDocumentGenerator );
return d->mDocumentInfo;
}
const Okular::DocumentSynopsis* TextDocumentGenerator::generateDocumentSynopsis()
@ -473,7 +473,7 @@ QVariant TextDocumentGeneratorPrivate::metaData( const QString &key, const QVari
Q_UNUSED( option )
if ( key == "DocumentTitle" )
{
return mDocumentInfo.get( "title" );
return mDocumentInfo.get( DocumentInfo::Title );
}
return QVariant();
}

View file

@ -211,7 +211,7 @@ class OKULAR_EXPORT TextDocumentGenerator : public Generator, public Okular::Con
*/
TextDocumentSettings* generalSettings();
const Okular::DocumentInfo* generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<DocumentInfo::Key> &keys ) const;
const Okular::DocumentSynopsis* generateDocumentSynopsis();
protected:

View file

@ -16,7 +16,6 @@
#include <QDesktopWidget>
#include <QImage>
#include <QIODevice>
#include <cmath>
#ifdef Q_WS_X11
#include "config-okular.h"
@ -79,6 +78,7 @@ double Utils::realDpiX()
{
const QDesktopWidget* w = QApplication::desktop();
if (w->width() > 0 && w->widthMM() > 0) {
kDebug() << "Pix:" << w->width() << "MM:" << w->widthMM();
return (double(w->width()) * 25.4) / double(w->widthMM());
} else {
return dpiX();
@ -89,6 +89,7 @@ double Utils::realDpiY()
{
const QDesktopWidget* w = QApplication::desktop();
if (w->height() > 0 && w->heightMM() > 0) {
kDebug() << "Pix:" << w->height() << "MM:" << w->heightMM();
return (double(w->height()) * 25.4) / double(w->heightMM());
} else {
return dpiY();
@ -131,14 +132,15 @@ QSizeF Utils::realDpi(QWidget* widgetOnScreen)
kDebug() << "Found widget at output #" << selectedOutput->id();
QRect outputRect(selectedOutput->pos(),selectedOutput->currentMode()->size());
QSize szMM = selectedOutput->sizeMm();
kDebug() << "Output size is " << szMM;
kDebug() << "Output size is (mm) " << szMM;
kDebug() << "Output rect is " << outputRect;
if (selectedOutput->edid()) {
kDebug() << "EDID WxH: " << selectedOutput->edid()->width() << 'x' << selectedOutput->edid()->height();
kDebug() << "EDID WxH (cm): " << selectedOutput->edid()->width() << 'x' << selectedOutput->edid()->height();
}
if (szMM.width() > 0 && szMM.height() > 0 && outputRect.width() > 0 && outputRect.height() > 0
&& selectedOutput->edid()
&& std::abs(static_cast<int>(selectedOutput->edid()->width()*10) - szMM.width()) < 10
&& std::abs(static_cast<int>(selectedOutput->edid()->height()*10) - szMM.height()) < 10)
&& qAbs(static_cast<int>(selectedOutput->edid()->width()*10) - szMM.width()) < 10
&& qAbs(static_cast<int>(selectedOutput->edid()->height()*10) - szMM.height()) < 10)
{
// sizes in EDID seem to be consistent
QSizeF res(static_cast<qreal>(outputRect.width())*25.4/szMM.width(),
@ -148,16 +150,42 @@ QSizeF Utils::realDpi(QWidget* widgetOnScreen)
kDebug() << "Output is vertical, transposing DPI rect";
res.transpose();
}
kDebug() << "Output DPI is " << res;
return res;
if (qAbs(res.width() - res.height()) / qMin(res.height(), res.width()) < 0.05) {
return res;
} else {
kDebug() << "KScreen calculation returned a non square dpi." << res << ". Falling back";
}
}
}
else
{
kDebug() << "Didn't find a KScreen selectedOutput to calculate DPI. Falling back";
}
}
else
{
kDebug() << "Didn't find a KScreen config to calculate DPI. Falling back";
}
#endif
}
// this is also fallback for LibKScreen branch if KScreen::Output
// for particular widget was not found
return QSizeF(realDpiX(), realDpiY());
QSizeF res = QSizeF(realDpiX(), realDpiY());
if (qAbs(res.width() - res.height()) / qMin(res.height(), res.width()) < 0.05) {
return res;
} else {
kDebug() << "QDesktopWidget calculation returned a non square dpi." << res << ". Falling back";
}
res = QSizeF(dpiX(), dpiY());
if (qAbs(res.width() - res.height()) / qMin(res.height(), res.width()) < 0.05) {
return res;
} else {
kDebug() << "QX11Info returned a non square dpi." << res << ". Falling back";
}
res = QSizeF(72, 72);
return res;
}
#elif defined(Q_WS_MAC)

View file

@ -10,9 +10,9 @@
#ifndef _OKULAR_VERSION_H_
#define _OKULAR_VERSION_H_
#define OKULAR_VERSION_STRING "0.19.60"
#define OKULAR_VERSION_STRING "0.20.60"
#define OKULAR_VERSION_MAJOR 0
#define OKULAR_VERSION_MINOR 19
#define OKULAR_VERSION_MINOR 20
#define OKULAR_VERSION_RELEASE 60
#define OKULAR_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c))

View file

@ -1,5 +1,6 @@
[Desktop Entry]
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -8,6 +9,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -45,6 +47,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -53,6 +56,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -89,6 +93,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -97,6 +102,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=chm
X-KDE-Keywords[da]=chm
X-KDE-Keywords[de]=chm
X-KDE-Keywords[el]=chm
X-KDE-Keywords[en_GB]=chm
X-KDE-Keywords[es]=chm
X-KDE-Keywords[et]=chm
X-KDE-Keywords[fi]=chm

View file

@ -71,7 +71,6 @@ CHMGenerator::CHMGenerator( QObject *parent, const QVariantList &args )
m_syncGen=0;
m_file=0;
m_docInfo=0;
m_pixmapRequestZoom=1;
m_request = 0;
}
@ -163,8 +162,6 @@ bool CHMGenerator::loadDocument( const QString & fileName, QVector< Okular::Page
bool CHMGenerator::doCloseDocument()
{
// delete the document information of the old document
delete m_docInfo;
m_docInfo=0;
delete m_file;
m_file=0;
m_textpageAddedList.clear();
@ -234,16 +231,14 @@ void CHMGenerator::slotCompleted()
signalPixmapRequestDone( req );
}
const Okular::DocumentInfo * CHMGenerator::generateDocumentInfo()
Okular::DocumentInfo CHMGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
if (!m_docInfo)
{
m_docInfo=new Okular::DocumentInfo();
m_docInfo->set( Okular::DocumentInfo::MimeType, "application/x-chm" );
m_docInfo->set( Okular::DocumentInfo::Title, m_file->title() );
}
return m_docInfo;
Okular::DocumentInfo docInfo;
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
docInfo.set( Okular::DocumentInfo::MimeType, "application/x-chm" );
if ( keys.contains( Okular::DocumentInfo::Title ) )
docInfo.set( Okular::DocumentInfo::Title, m_file->title() );
return docInfo;
}
const Okular::DocumentSynopsis * CHMGenerator::generateDocumentSynopsis()

View file

@ -36,7 +36,7 @@ class CHMGenerator : public Okular::Generator
~CHMGenerator();
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
const Okular::DocumentSynopsis * generateDocumentSynopsis();
bool canGeneratePixmap() const;
@ -64,7 +64,6 @@ class CHMGenerator : public Okular::Generator
QString m_chmUrl;
Okular::PixmapRequest* m_request;
int m_pixmapRequestZoom;
Okular::DocumentInfo* m_docInfo;
QBitArray m_textpageAddedList;
QBitArray m_rectsGenerated;
};

View file

@ -140,6 +140,7 @@ X-KDE-Keywords[cs]=chm
X-KDE-Keywords[da]=chm
X-KDE-Keywords[de]=chm
X-KDE-Keywords[el]=chm
X-KDE-Keywords[en_GB]=chm
X-KDE-Keywords[es]=chm
X-KDE-Keywords[et]=chm
X-KDE-Keywords[fi]=chm

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/x-chm;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=cbr, cbz, cbt, Comic Book
X-KDE-Keywords[da]=cbr,cbz,cbt,Comic Book
X-KDE-Keywords[de]=cbr, cbz, cbt, Comic-Book
X-KDE-Keywords[el]=cbr, cbz, cbt, Comic Book
X-KDE-Keywords[en_GB]=cbr, cbz, cbt, Comic Book
X-KDE-Keywords[es]=cbr, cbz, cbt, libro de cómic
X-KDE-Keywords[et]=cbr, cbz, cbt, Comic Book, koomiks
X-KDE-Keywords[fi]=cbr, cbz, cbt, Comic Book

View file

@ -140,6 +140,7 @@ X-KDE-Keywords[cs]=cbr, cbz, cbt, Comic Book
X-KDE-Keywords[da]=cbr,cbz,cbt,Comic Book
X-KDE-Keywords[de]=cbr, cbz, cbt, Comic-Book
X-KDE-Keywords[el]=cbr, cbz, cbt, Comic Book
X-KDE-Keywords[en_GB]=cbr, cbz, cbt, Comic Book
X-KDE-Keywords[es]=cbr, cbz, cbt, libro de cómic
X-KDE-Keywords[et]=cbr, cbz, cbt, Comic Book, koomiks
X-KDE-Keywords[fi]=cbr, cbz, cbt, Comic Book

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=image/vnd.djvu;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=djvu
X-KDE-Keywords[da]=djvu
X-KDE-Keywords[de]=djvu
X-KDE-Keywords[el]=djvu
X-KDE-Keywords[en_GB]=djvu
X-KDE-Keywords[es]=djvu
X-KDE-Keywords[et]=djvu
X-KDE-Keywords[fi]=djvu

View file

@ -84,7 +84,7 @@ static KAboutData createAboutData()
OKULAR_EXPORT_PLUGIN( DjVuGenerator, createAboutData() )
DjVuGenerator::DjVuGenerator( QObject *parent, const QVariantList &args )
: Okular::Generator( parent, args ), m_docInfo( 0 ), m_docSyn( 0 )
: Okular::Generator( parent, args ), m_docSyn( 0 )
{
setFeature( TextExtraction );
setFeature( Threaded );
@ -120,8 +120,6 @@ bool DjVuGenerator::doCloseDocument()
m_djvu->closeFile();
userMutex()->unlock();
delete m_docInfo;
m_docInfo = 0;
delete m_docSyn;
m_docSyn = 0;
@ -136,48 +134,34 @@ QImage DjVuGenerator::image( Okular::PixmapRequest *request )
return img;
}
const Okular::DocumentInfo * DjVuGenerator::generateDocumentInfo()
Okular::DocumentInfo DjVuGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
if ( m_docInfo )
return m_docInfo;
Okular::DocumentInfo docInfo;
m_docInfo = new Okular::DocumentInfo();
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/vnd.djvu" );
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
docInfo.set( Okular::DocumentInfo::MimeType, "image/vnd.djvu" );
if ( m_djvu )
{
// compile internal structure reading properties from KDjVu
QString title = m_djvu->metaData( "title" ).toString();
m_docInfo->set( Okular::DocumentInfo::Title, title.isEmpty() ? i18nc( "Unknown title", "Unknown" ) : title );
QString author = m_djvu->metaData( "author" ).toString();
m_docInfo->set( Okular::DocumentInfo::Author, author.isEmpty() ? i18nc( "Unknown author", "Unknown" ) : author );
QString editor = m_djvu->metaData( "editor" ).toString();
m_docInfo->set( "editor", editor.isEmpty() ? i18nc( "Unknown editor", "Unknown" ) : editor, i18n( "Editor" ) );
QString publisher = m_djvu->metaData( "publisher" ).toString();
m_docInfo->set( "publisher", publisher.isEmpty() ? i18nc( "Unknown publisher", "Unknown" ) : publisher, i18n( "Publisher" ) );
QString year = m_djvu->metaData( "year" ).toString();
m_docInfo->set( Okular::DocumentInfo::CreationDate, year.isEmpty() ? i18nc( "Unknown creation date", "Unknown" ) : year );
QString volume = m_djvu->metaData( "volume" ).toString();
m_docInfo->set( "volume", volume.isEmpty() ? i18nc( "Unknown volume information", "Unknown" ) : volume, i18n( "Volume" ) );
QString doctype = m_djvu->metaData( "documentType" ).toString();
m_docInfo->set( "documentType", doctype.isEmpty() ? i18nc( "Unknown type of document", "Unknown" ) : doctype, i18n( "Type of document" ) );
QVariant numcomponents = m_djvu->metaData( "componentFile" );
m_docInfo->set( "componentFile", numcomponents.type() != QVariant::Int ? i18nc( "Unknown number of component files", "Unknown" ) : numcomponents.toString(), i18n( "Component Files" ) );
}
else
{
m_docInfo->set( Okular::DocumentInfo::Title, i18nc( "Unknown title", "Unknown" ) );
m_docInfo->set( Okular::DocumentInfo::Author, i18nc( "Unknown author", "Unknown" ) );
m_docInfo->set( "editor", i18nc( "Unknown editor", "Unknown" ), i18n( "Editor" ) );
m_docInfo->set( "publisher", i18nc( "Unknown publisher", "Unknown" ), i18n( "Publisher" ) );
m_docInfo->set( Okular::DocumentInfo::CreationDate, i18nc( "Unknown creation date", "Unknown" ) );
m_docInfo->set( "volume", i18nc( "Unknown volume information", "Unknown" ), i18n( "Volume" ) );
m_docInfo->set( "documentType", i18nc( "Unknown type of document", "Unknown" ), i18n( "Type of document" ) );
m_docInfo->set( "componentFile", i18nc( "Unknown number of component files", "Unknown" ), i18n( "Component Files" ) );
if ( keys.contains( Okular::DocumentInfo::Author ) )
docInfo.set( Okular::DocumentInfo::Title, m_djvu->metaData( "title" ).toString() );
if ( keys.contains( Okular::DocumentInfo::Author ) )
docInfo.set( Okular::DocumentInfo::Author, m_djvu->metaData( "author" ).toString() );
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
docInfo.set( Okular::DocumentInfo::CreationDate, m_djvu->metaData( "year" ).toString() );
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
{
docInfo.set( "editor", m_djvu->metaData( "editor" ).toString(), i18n( "Editor" ) );
docInfo.set( "publisher", m_djvu->metaData( "publisher" ).toString(), i18n( "Publisher" ) );
docInfo.set( "volume", m_djvu->metaData( "volume" ).toString(), i18n( "Volume" ) );
docInfo.set( "documentType", m_djvu->metaData( "documentType" ).toString(), i18n( "Type of document" ) );
QVariant numcomponents = m_djvu->metaData( "componentFile" );
docInfo.set( "componentFile", numcomponents.type() != QVariant::Int ? i18nc( "Unknown number of component files", "Unknown" ) : numcomponents.toString(), i18n( "Component Files" ) );
}
}
return m_docInfo;
return docInfo;
}
const Okular::DocumentSynopsis * DjVuGenerator::generateDocumentSynopsis()

View file

@ -30,7 +30,7 @@ class DjVuGenerator : public Okular::Generator
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
// document information
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
const Okular::DocumentSynopsis * generateDocumentSynopsis();
// printing
@ -51,7 +51,6 @@ class DjVuGenerator : public Okular::Generator
KDjVu *m_djvu;
Okular::DocumentInfo *m_docInfo;
Okular::DocumentSynopsis *m_docSyn;
};

View file

@ -140,6 +140,7 @@ X-KDE-Keywords[cs]=djvu
X-KDE-Keywords[da]=djvu
X-KDE-Keywords[de]=djvu
X-KDE-Keywords[el]=djvu
X-KDE-Keywords[en_GB]=djvu
X-KDE-Keywords[es]=djvu
X-KDE-Keywords[et]=djvu
X-KDE-Keywords[fi]=djvu

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/x-dvi;application/x-gzdvi;application/x-bzdvi;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=dvi
X-KDE-Keywords[da]=dvi
X-KDE-Keywords[de]=dvi
X-KDE-Keywords[el]=dvi
X-KDE-Keywords[en_GB]=dvi
X-KDE-Keywords[es]=dvi
X-KDE-Keywords[et]=dvi
X-KDE-Keywords[fi]=dvi

View file

@ -52,7 +52,7 @@ static KAboutData createAboutData()
"okular_dvi",
"okular_dvi",
ki18n( "DVI Backend" ),
"0.3.6",
"0.3.7",
ki18n( "A DVI file renderer" ),
KAboutData::License_GPL,
ki18n( "© 2006 Luigi Toscano" )
@ -63,7 +63,7 @@ static KAboutData createAboutData()
OKULAR_EXPORT_PLUGIN( DviGenerator, createAboutData() )
DviGenerator::DviGenerator( QObject *parent, const QVariantList &args ) : Okular::Generator( parent, args ),
m_fontExtracted( false ), m_docInfo( 0 ), m_docSynopsis( 0 ), m_dviRenderer( 0 )
m_fontExtracted( false ), m_docSynopsis( 0 ), m_dviRenderer( 0 )
{
setFeature( Threaded );
setFeature( TextExtraction );
@ -130,8 +130,6 @@ bool DviGenerator::loadDocument( const QString & fileName, QVector< Okular::Page
bool DviGenerator::doCloseDocument()
{
delete m_docInfo;
m_docInfo = 0;
delete m_docSynopsis;
m_docSynopsis = 0;
delete m_dviRenderer;
@ -335,14 +333,12 @@ Okular::TextPage *DviGenerator::extractTextFromPage( dviPageInfo *pageInfo )
return ktp;
}
const Okular::DocumentInfo *DviGenerator::generateDocumentInfo()
Okular::DocumentInfo DviGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
if ( m_docInfo )
return m_docInfo;
Okular::DocumentInfo docInfo;
m_docInfo = new Okular::DocumentInfo();
m_docInfo->set( Okular::DocumentInfo::MimeType, "application/x-dvi" );
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
docInfo.set( Okular::DocumentInfo::MimeType, "application/x-dvi" );
QMutexLocker lock( userMutex() );
@ -351,12 +347,13 @@ const Okular::DocumentInfo *DviGenerator::generateDocumentInfo()
dvifile *dvif = m_dviRenderer->dviFile;
// read properties from dvif
//m_docInfo->set( "filename", dvif->filename, i18n("Filename") );
m_docInfo->set( "generatorDate", dvif->generatorString,
i18n("Generator/Date") );
m_docInfo->set( Okular::DocumentInfo::Pages, QString::number( dvif->total_pages ) );
//docInfo.set( "filename", dvif->filename, i18n("Filename") );
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
docInfo.set( "generatorDate", dvif->generatorString, i18n("Generator/Date") );
if ( keys.contains( Okular::DocumentInfo::Pages ) )
docInfo.set( Okular::DocumentInfo::Pages, QString::number( dvif->total_pages ) );
}
return m_docInfo;
return docInfo;
}
const Okular::DocumentSynopsis *DviGenerator::generateDocumentSynopsis()

View file

@ -31,7 +31,7 @@ class DviGenerator : public Okular::Generator
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
// document information
const Okular::DocumentInfo *generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
// table of contents
const Okular::DocumentSynopsis *generateDocumentSynopsis();
@ -52,7 +52,6 @@ class DviGenerator : public Okular::Generator
double m_resolution;
bool m_fontExtracted;
Okular::DocumentInfo *m_docInfo;
Okular::DocumentSynopsis *m_docSynopsis;
dviRenderer *m_dviRenderer;

View file

@ -140,6 +140,7 @@ X-KDE-Keywords[cs]=dvi
X-KDE-Keywords[da]=dvi
X-KDE-Keywords[de]=dvi
X-KDE-Keywords[el]=dvi
X-KDE-Keywords[en_GB]=dvi
X-KDE-Keywords[es]=dvi
X-KDE-Keywords[et]=dvi
X-KDE-Keywords[fi]=dvi

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/epub+zip;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=epub, e-book
X-KDE-Keywords[da]=epub,e-book
X-KDE-Keywords[de]=epub, e-book
X-KDE-Keywords[el]=epub, e-book
X-KDE-Keywords[en_GB]=epub, e-book
X-KDE-Keywords[es]=epub, e-book
X-KDE-Keywords[et]=epub, e-book, e-raamat
X-KDE-Keywords[fi]=epub, e-book, e-kirja, sähkökirja

View file

@ -140,6 +140,7 @@ X-KDE-Keywords[cs]=epub, e-book
X-KDE-Keywords[da]=epub,e-book
X-KDE-Keywords[de]=epub, e-book
X-KDE-Keywords[el]=epub, e-book
X-KDE-Keywords[en_GB]=epub, e-book
X-KDE-Keywords[es]=epub, e-book
X-KDE-Keywords[et]=epub, e-book, e-raamat
X-KDE-Keywords[fi]=epub, e-book, e-kirja, sähkökirja

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=image/fax-g3;image/g3fax;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma

View file

@ -9,8 +9,6 @@
#include "generator_fax.h"
#include "faxdocument.h"
#include <QtGui/QPainter>
#include <QtGui/QPrinter>
@ -52,13 +50,12 @@ FaxGenerator::~FaxGenerator()
bool FaxGenerator::loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector )
{
FaxDocument::DocumentType type;
if ( fileName.toLower().endsWith( ".g3" ) )
type = FaxDocument::G3;
m_type = FaxDocument::G3;
else
type = FaxDocument::G4;
m_type = FaxDocument::G4;
FaxDocument faxDocument( fileName, type );
FaxDocument faxDocument( fileName, m_type );
if ( !faxDocument.load() )
{
@ -73,20 +70,12 @@ bool FaxGenerator::loadDocument( const QString & fileName, QVector<Okular::Page*
Okular::Page * page = new Okular::Page( 0, m_img.width(), m_img.height(), Okular::Rotation0 );
pagesVector[0] = page;
m_docInfo = new Okular::DocumentInfo();
if ( type == FaxDocument::G3 )
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/fax-g3" );
else
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/fax-g4" );
return true;
}
bool FaxGenerator::doCloseDocument()
{
m_img = QImage();
delete m_docInfo;
m_docInfo = 0;
return true;
}
@ -102,9 +91,17 @@ QImage FaxGenerator::image( Okular::PixmapRequest * request )
return m_img.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
}
const Okular::DocumentInfo * FaxGenerator::generateDocumentInfo()
Okular::DocumentInfo FaxGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
return m_docInfo;
Okular::DocumentInfo docInfo;
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
{
if ( m_type == FaxDocument::G3 )
docInfo.set( Okular::DocumentInfo::MimeType, "image/fax-g3" );
else
docInfo.set( Okular::DocumentInfo::MimeType, "image/fax-g4" );
}
return docInfo;
}
bool FaxGenerator::print( QPrinter& printer )

View file

@ -14,6 +14,8 @@
#include <QtGui/QImage>
#include "faxdocument.h"
class FaxGenerator : public Okular::Generator
{
Q_OBJECT
@ -24,7 +26,7 @@ class FaxGenerator : public Okular::Generator
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
bool print( QPrinter& printer );
@ -34,7 +36,7 @@ class FaxGenerator : public Okular::Generator
private:
QImage m_img;
Okular::DocumentInfo *m_docInfo;
FaxDocument::DocumentType m_type;
};
#endif

View file

@ -24,3 +24,5 @@ install(TARGETS okularGenerator_fb DESTINATION ${PLUGIN_INSTALL_DIR})
install( FILES libokularGenerator_fb.desktop okularFb.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( PROGRAMS okularApplication_fb.desktop active-documentviewer_fb.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
kde4_install_icons(${DATA_INSTALL_DIR}/okular/icons)

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/x-fictionbook+xml;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=FictionBook, e-book, fb2
X-KDE-Keywords[da]=FictionBook,e-book,fb2
X-KDE-Keywords[de]=FictionBook, e-book, fb2
X-KDE-Keywords[el]=FictionBook, e-book, fb2
X-KDE-Keywords[en_GB]=FictionBook, e-book, fb2
X-KDE-Keywords[es]=FictionBook, e-book, fb2
X-KDE-Keywords[et]=FictionBook, e-book, e-raamat, fb2
X-KDE-Keywords[fi]=FictionBook, e-book, e-kirja, sähkökirja, fb2

View file

@ -42,5 +42,5 @@ void FictionBookGenerator::addPages( KConfigDialog* dlg )
{
Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget();
dlg->addPage( widget, generalSettings(), i18n("FictionBook"), "application-x-fictionbook+xml", i18n("FictionBook Backend Configuration") );
dlg->addPage( widget, generalSettings(), i18n("FictionBook"), "okular-fb2", i18n("FictionBook Backend Configuration") );
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -0,0 +1,200 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg4171"
version="1.1"
inkscape:version="0.48+devel r13309"
width="32"
height="32"
viewBox="0 0 32 32"
sodipodi:docname="hi32-app-okular-fb2.svg"
inkscape:export-filename="/home/yurchor/Install/Ukrainization/kde4doc/kdegraphics/okular/generators/fictionbook/test.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<metadata
id="metadata4177">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs4175">
<filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter4229"
x="-0.093600001"
width="1.1872"
y="-0.022285714"
height="1.0445714">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.195"
id="feGaussianBlur4231" />
</filter>
<filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter4461"
x="-0.135"
width="1.27"
y="-0.020769231"
height="1.0415385">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.1125"
id="feGaussianBlur4463" />
</filter>
<mask
maskUnits="userSpaceOnUse"
id="mask4479">
<path
inkscape:connector-curvature="0"
id="path4481"
d="m 10.009212,23.901584 0,-12.909277 1.879574,0 0,12.909277 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</mask>
<filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter4495"
x="-0.065250003"
width="1.1305"
y="-0.024857142"
height="1.0497143">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.2175"
id="feGaussianBlur4497" />
</filter>
<filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter4533"
x="-0.041373824"
width="1.0827476"
y="-0.03186166"
height="1.0637233">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.11070099"
id="feGaussianBlur4535" />
</filter>
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1060"
id="namedview4173"
showgrid="true"
inkscape:zoom="21.140625"
inkscape:cx="2.4646776"
inkscape:cy="10.647411"
inkscape:window-x="-2"
inkscape:window-y="-3"
inkscape:window-maximized="1"
inkscape:current-layer="svg4171">
<inkscape:grid
type="xygrid"
id="grid4181" />
</sodipodi:namedview>
<path
style="fill:#7f7f7f;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
d="m 0,30 0,-28 25,0 0,5 -9,9 9,9 0,5 z"
id="path4451"
inkscape:connector-curvature="0" />
<path
style="fill:#3c3c3c;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter4495)"
d="m 7.4712644,26.572414 0,-21.0000002 2.9999996,0 0,4 4,0 c 0,0 -1,0 0,0 1,0 1,1.0000002 1,1.0000002 l 0,15 c 0,0 0,-1 0,0 0,1 -1,1 -1,1 z"
id="path4193-4"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
d="m 7,26 0,-21 3,0 0,4 4,0 c 0,0 -1,0 0,0 1,0 1,1 1,1 l 0,15 c 0,0 0,-1 0,0 0,1 -1,1 -1,1 z"
id="path4193"
inkscape:connector-curvature="0" />
<rect
style="opacity:1;fill:#ff9900;fill-opacity:1;stroke:none;stroke-width:2.20000005;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4185"
width="11"
height="11"
x="23.475122"
y="-11.911101"
transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,0,0)" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.5px;line-height:125%;font-family:Liberation Sans;-inkscape-font-specification:Liberation Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="1.6183908"
y="5.4068966"
id="text4187"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4189"
x="1.6183908"
y="5.4068966"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Microsoft Sans Serif;-inkscape-font-specification:Microsoft Sans Serif" /></text>
<path
style="fill:#3c3c3c;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter4229)"
d="m 2.5827586,26.372414 0,-15 -1,0 0,-2.0000002 1,0 0,-3 c 0,0 0,1 0,0 0,-1 1,-1 1,-1 l 3,0 0,2 -1,0 0,2 1,0 0,2.0000002 -1,0 0,15 z"
id="path4191-1"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
d="M 2,26 2,11 1,11 1,9 2,9 2,6 C 2,6 2,7 2,6 2,5 3,5 3,5 l 3,0 0,2 -1,0 0,2 1,0 0,2 -1,0 0,15 z"
id="path4191"
inkscape:connector-curvature="0" />
<path
style="fill:#7f7f7f;fill-opacity:1;fill-rule:evenodd;stroke:#3c3c3c;stroke-width:0.51683007;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter4461);stroke-miterlimit:4;stroke-dasharray:none"
d="m 10.30115,24.248277 0,-13 2,0 0,13 z"
id="path4195-1"
inkscape:connector-curvature="0"
inkscape:transform-center-x="0.66534982"
inkscape:transform-center-y="-0.48152163"
mask="url(#mask4479)"
transform="matrix(1.064071,0,0,1.0070277,-0.65051241,-0.06955745)" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:22.5px;line-height:125%;font-family:UkrainianSchoolBook;-inkscape-font-specification:UkrainianSchoolBook Bold;letter-spacing:0px;word-spacing:0px;fill:#3c3c3c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter4533)"
x="21.146496"
y="20.33403"
id="text4233-4"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4235-1"
x="21.146496"
y="20.33403"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:11.25px;font-family:Verdana;-inkscape-font-specification:Verdana Bold;fill:#3c3c3c;fill-opacity:1">2</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:22.5px;line-height:125%;font-family:UkrainianSchoolBook;-inkscape-font-specification:UkrainianSchoolBook Bold;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="20.912128"
y="19.897528"
id="text4233"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4235"
x="20.912128"
y="19.897528"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:11.25px;font-family:Verdana;-inkscape-font-specification:Verdana Bold">2</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -140,6 +140,7 @@ X-KDE-Keywords[cs]=FictionBook, e-book, fb2
X-KDE-Keywords[da]=FictionBook,e-book,fb2
X-KDE-Keywords[de]=FictionBook, e-book, fb2
X-KDE-Keywords[el]=FictionBook, e-book, fb2
X-KDE-Keywords[en_GB]=FictionBook, e-book, fb2
X-KDE-Keywords[es]=FictionBook, e-book, fb2
X-KDE-Keywords[et]=FictionBook, e-book, e-raamat, fb2
X-KDE-Keywords[fi]=FictionBook, e-book, e-kirja, sähkökirja, fb2

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=image/bmp;image/x-dds;image/x-eps;image/x-exr;image/gif;image/x-hdr;image/x-ico;image/jp2;image/jpeg;video/x-mng;image/x-portable-bitmap;image/x-pcx;image/x-portable-graymap;image/png;image/x-portable-pixmap;image/x-psd;image/x-rgb;image/x-tga;image/tiff;image/x-xbitmap;image/x-xcf;image/x-xpixmap;image/x-gzeps;image/x-bzeps;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma

View file

@ -194,9 +194,9 @@ void KIMGIOGenerator::slotTest()
kDebug() << "Test";
}
const Okular::DocumentInfo * KIMGIOGenerator::generateDocumentInfo()
Okular::DocumentInfo KIMGIOGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
return &docInfo;
return docInfo;
}
#include "generator_kimgio.moc"

View file

@ -31,7 +31,7 @@ class KIMGIOGenerator : public Okular::Generator
bool print( QPrinter& printer );
// [INHERITED] document information
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
protected:
bool doCloseDocument();

View file

@ -140,7 +140,9 @@ X-KDE-Keywords[cs]=mobipocket
X-KDE-Keywords[da]=mobipocket
X-KDE-Keywords[de]=Mobipocket
X-KDE-Keywords[el]=mobipocket
X-KDE-Keywords[en_GB]=mobipocket
X-KDE-Keywords[es]=mobipocket
X-KDE-Keywords[et]=mobipocket
X-KDE-Keywords[fi]=mobipocket
X-KDE-Keywords[fr]=mobipocket
X-KDE-Keywords[gl]=mobipocket
@ -169,4 +171,5 @@ X-KDE-Keywords[sv]=mobipocket
X-KDE-Keywords[tr]=mobipocket
X-KDE-Keywords[uk]=mobipocket
X-KDE-Keywords[x-test]=xxmobipocketxx
X-KDE-Keywords[zh_CN]=mobipocket
X-KDE-Keywords[zh_TW]=mobipocket

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/vnd.oasis.opendocument.text;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma

View file

@ -22,7 +22,7 @@ static KAboutData createAboutData()
"okular_ooo",
"okular_ooo",
ki18n( "OpenDocument Text Backend" ),
"0.2.3",
"0.2.4",
ki18n( "A renderer for OpenDocument Text documents" ),
KAboutData::License_GPL,
ki18n( "© 2006-2008 Tobias Koenig" )

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/prs.plucker;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=plucker
X-KDE-Keywords[da]=plucker
X-KDE-Keywords[de]=plucker
X-KDE-Keywords[el]=plucker
X-KDE-Keywords[en_GB]=plucker
X-KDE-Keywords[es]=plucker
X-KDE-Keywords[et]=plucker
X-KDE-Keywords[fi]=plucker

View file

@ -126,9 +126,9 @@ bool PluckerGenerator::doCloseDocument()
return true;
}
const Okular::DocumentInfo* PluckerGenerator::generateDocumentInfo()
Okular::DocumentInfo PluckerGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> & /*keys*/ ) const
{
return &mDocumentInfo;
return mDocumentInfo;
}
QImage PluckerGenerator::image( Okular::PixmapRequest *request )

View file

@ -31,7 +31,7 @@ class PluckerGenerator : public Okular::Generator
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
// [INHERITED] document information
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
// [INHERITED] perform actions on document / pages
QImage image( Okular::PixmapRequest *request );

View file

@ -140,6 +140,7 @@ X-KDE-Keywords[cs]=plucker
X-KDE-Keywords[da]=plucker
X-KDE-Keywords[de]=plucker
X-KDE-Keywords[el]=plucker
X-KDE-Keywords[en_GB]=plucker
X-KDE-Keywords[es]=plucker
X-KDE-Keywords[et]=plucker
X-KDE-Keywords[fi]=plucker

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/pdf;application/x-gzpdf;application/x-bzpdf;application/x-wwf;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=PDF, Portable Document Format
X-KDE-Keywords[da]=PDF,Portable Document Format
X-KDE-Keywords[de]=PDF, Portable Document Format
X-KDE-Keywords[el]=PDF, Portable Document Format
X-KDE-Keywords[en_GB]=PDF, Portable Document Format
X-KDE-Keywords[es]=PDF, Formato de Documento Portable
X-KDE-Keywords[et]=PDF, Portable Document Format
X-KDE-Keywords[fi]=PDF, Portable Document Format

View file

@ -400,7 +400,7 @@ static KAboutData createAboutData()
"okular_poppler",
"okular_poppler",
ki18n( "PDF Backend" ),
"0.6.4",
"0.6.5",
ki18n( "A PDF file renderer" ),
KAboutData::License_GPL,
ki18n( "© 2005-2008 Albert Astals Cid" )
@ -421,7 +421,7 @@ static void PDFGeneratorPopplerDebugFunction(const QString &message, const QVari
PDFGenerator::PDFGenerator( QObject *parent, const QVariantList &args )
: Generator( parent, args ), pdfdoc( 0 ),
docInfoDirty( true ), docSynopsisDirty( true ),
docSynopsisDirty( true ),
docEmbeddedFilesDirty( true ), nextFontPage( 0 ),
annotProxy( 0 ), synctex_scanner( 0 )
{
@ -539,7 +539,6 @@ bool PDFGenerator::doCloseDocument()
delete pdfdoc;
pdfdoc = 0;
userMutex()->unlock();
docInfoDirty = true;
docSynopsisDirty = true;
docSyn.clear();
docEmbeddedFilesDirty = true;
@ -619,64 +618,47 @@ void PDFGenerator::loadPages(QVector<Okular::Page*> &pagesVector, int rotation,
}
}
const Okular::DocumentInfo * PDFGenerator::generateDocumentInfo()
Okular::DocumentInfo PDFGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
if ( docInfoDirty )
Okular::DocumentInfo docInfo;
docInfo.set( Okular::DocumentInfo::MimeType, "application/pdf" );
userMutex()->lock();
if ( pdfdoc )
{
userMutex()->lock();
docInfo.set( Okular::DocumentInfo::MimeType, "application/pdf" );
if ( pdfdoc )
{
// compile internal structure reading properties from PDFDoc
// compile internal structure reading properties from PDFDoc
if ( keys.contains( Okular::DocumentInfo::Title ) )
docInfo.set( Okular::DocumentInfo::Title, pdfdoc->info("Title") );
if ( keys.contains( Okular::DocumentInfo::Subject ) )
docInfo.set( Okular::DocumentInfo::Subject, pdfdoc->info("Subject") );
if ( keys.contains( Okular::DocumentInfo::Author ) )
docInfo.set( Okular::DocumentInfo::Author, pdfdoc->info("Author") );
if ( keys.contains( Okular::DocumentInfo::Keywords ) )
docInfo.set( Okular::DocumentInfo::Keywords, pdfdoc->info("Keywords") );
if ( keys.contains( Okular::DocumentInfo::Creator ) )
docInfo.set( Okular::DocumentInfo::Creator, pdfdoc->info("Creator") );
if ( keys.contains( Okular::DocumentInfo::Producer ) )
docInfo.set( Okular::DocumentInfo::Producer, pdfdoc->info("Producer") );
docInfo.set( Okular::DocumentInfo::CreationDate,
KGlobal::locale()->formatDateTime( pdfdoc->date("CreationDate"), KLocale::LongDate, true ) );
docInfo.set( Okular::DocumentInfo::ModificationDate,
KGlobal::locale()->formatDateTime( pdfdoc->date("ModDate"), KLocale::LongDate, true ) );
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
docInfo.set( Okular::DocumentInfo::CreationDate, KGlobal::locale()->formatDateTime( pdfdoc->date("CreationDate"), KLocale::LongDate, true ) );
if ( keys.contains( Okular::DocumentInfo::ModificationDate ) )
docInfo.set( Okular::DocumentInfo::ModificationDate, KGlobal::locale()->formatDateTime( pdfdoc->date("ModDate"), KLocale::LongDate, true ) );
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
{
int major, minor;
pdfdoc->getPdfVersion(&major, &minor);
docInfo.set( "format", i18nc( "PDF v. <version>", "PDF v. %1.%2",
major, minor ), i18n( "Format" ) );
docInfo.set( "encryption", pdfdoc->isEncrypted() ? i18n( "Encrypted" ) : i18n( "Unencrypted" ),
i18n("Security") );
docInfo.set( "optimization", pdfdoc->isLinearized() ? i18n( "Yes" ) : i18n( "No" ),
i18n("Optimized") );
docInfo.set( Okular::DocumentInfo::Pages, QString::number( pdfdoc->numPages() ) );
docInfo.set( "format", i18nc( "PDF v. <version>", "PDF v. %1.%2", major, minor ), i18n( "Format" ) );
docInfo.set( "encryption", pdfdoc->isEncrypted() ? i18n( "Encrypted" ) : i18n( "Unencrypted" ), i18n("Security") );
docInfo.set( "optimization", pdfdoc->isLinearized() ? i18n( "Yes" ) : i18n( "No" ), i18n("Optimized") );
}
else
{
// TODO not sure one can reach here, check and if it is not possible, remove the code
docInfo.set( Okular::DocumentInfo::Title, i18n("Unknown") );
docInfo.set( Okular::DocumentInfo::Subject, i18n("Unknown") );
docInfo.set( Okular::DocumentInfo::Author, i18n("Unknown") );
docInfo.set( Okular::DocumentInfo::Keywords, i18n("Unknown") );
docInfo.set( Okular::DocumentInfo::Creator, i18n("Unknown") );
docInfo.set( Okular::DocumentInfo::Producer, i18n("Unknown") );
docInfo.set( Okular::DocumentInfo::CreationDate, i18n("Unknown Date") );
docInfo.set( Okular::DocumentInfo::ModificationDate, i18n("Unknown Date") );
docInfo.set( "format", "PDF", i18n( "Format" ) );
docInfo.set( "encryption", i18n( "Unknown Encryption" ), i18n( "Security" ) );
docInfo.set( "optimization", i18n( "Unknown Optimization" ), i18n( "Optimized" ) );
docInfo.set( Okular::DocumentInfo::Pages, i18n("Unknown") );
}
userMutex()->unlock();
// if pdfdoc is valid then we cached good info -> don't cache them again
if ( pdfdoc )
docInfoDirty = false;
docInfo.set( Okular::DocumentInfo::Pages, QString::number( pdfdoc->numPages() ) );
}
return &docInfo;
userMutex()->unlock();
return docInfo;
}
const Okular::DocumentSynopsis * PDFGenerator::generateDocumentSynopsis()

View file

@ -64,7 +64,7 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p
Okular::Document::OpenResult loadDocumentFromDataWithPassword( const QByteArray & fileData, QVector<Okular::Page*> & pagesVector, const QString & password );
void loadPages(QVector<Okular::Page*> &pagesVector, int rotation=-1, bool clear=false);
// [INHERITED] document information
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
const Okular::DocumentSynopsis * generateDocumentSynopsis();
Okular::FontInfo::List fontsForPage( int page );
const QList<Okular::EmbeddedFile*> * embeddedFiles() const;
@ -137,8 +137,6 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p
// misc variables for document info and synopsis caching
bool docInfoDirty;
Okular::DocumentInfo docInfo;
bool docSynopsisDirty;
Okular::DocumentSynopsis docSyn;
mutable bool docEmbeddedFilesDirty;

View file

@ -139,6 +139,7 @@ X-KDE-Keywords[cs]=PDF, Portable Document Format
X-KDE-Keywords[da]=PDF,Portable Document Format
X-KDE-Keywords[de]=PDF, Portable Document Format
X-KDE-Keywords[el]=PDF, Portable Document Format
X-KDE-Keywords[en_GB]=PDF, Portable Document Format
X-KDE-Keywords[es]=PDF, Formato de Documento Portable
X-KDE-Keywords[et]=PDF, Portable Document Format
X-KDE-Keywords[fi]=PDF, Portable Document Format

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/postscript;image/x-eps;application/x-gzpostscript;application/x-bzpostscript;image/x-gzeps;image/x-bzeps;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -152,7 +158,9 @@ X-KDE-Keywords[cs]=PS, PostScript
X-KDE-Keywords[da]=PS, Postscript
X-KDE-Keywords[de]=PS, PostScript
X-KDE-Keywords[el]=PS, PostScript
X-KDE-Keywords[en_GB]=PS, PostScript
X-KDE-Keywords[es]=PS, PostScript
X-KDE-Keywords[et]=PS, PostScript
X-KDE-Keywords[fi]=PS, PostScript
X-KDE-Keywords[fr]=PS, PostScript
X-KDE-Keywords[gl]=PS, PostScript

View file

@ -54,7 +54,6 @@ OKULAR_EXPORT_PLUGIN(GSGenerator, createAboutData())
GSGenerator::GSGenerator( QObject *parent, const QVariantList &args ) :
Okular::Generator( parent, args ),
m_internalDocument(0),
m_docInfo(0),
m_request(0)
{
setFeature( PrintPostscript );
@ -182,9 +181,6 @@ bool GSGenerator::doCloseDocument()
spectre_document_free(m_internalDocument);
m_internalDocument = 0;
delete m_docInfo;
m_docInfo = 0;
return true;
}
@ -265,28 +261,34 @@ bool GSGenerator::canGeneratePixmap() const
return !m_request;
}
const Okular::DocumentInfo * GSGenerator::generateDocumentInfo()
Okular::DocumentInfo GSGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
if (!m_docInfo)
Okular::DocumentInfo docInfo;
if ( keys.contains( Okular::DocumentInfo::Title ) )
docInfo.set( Okular::DocumentInfo::Title, spectre_document_get_title(m_internalDocument) );
if ( keys.contains( Okular::DocumentInfo::Author ) )
docInfo.set( Okular::DocumentInfo::Author, spectre_document_get_for(m_internalDocument) );
if ( keys.contains( Okular::DocumentInfo::Creator ) )
docInfo.set( Okular::DocumentInfo::Creator, spectre_document_get_creator(m_internalDocument) );
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
docInfo.set( Okular::DocumentInfo::CreationDate, spectre_document_get_creation_date(m_internalDocument) );
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
docInfo.set( "dscversion", spectre_document_get_format(m_internalDocument), i18n("Document version") );
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
{
m_docInfo = new Okular::DocumentInfo();
m_docInfo->set( Okular::DocumentInfo::Title, spectre_document_get_title(m_internalDocument) );
m_docInfo->set( Okular::DocumentInfo::Author, spectre_document_get_for(m_internalDocument) );
m_docInfo->set( Okular::DocumentInfo::Creator, spectre_document_get_creator(m_internalDocument) );
m_docInfo->set( Okular::DocumentInfo::CreationDate, spectre_document_get_creation_date(m_internalDocument) );
m_docInfo->set( "dscversion", spectre_document_get_format(m_internalDocument), i18n("Document version") );
int languageLevel = spectre_document_get_language_level(m_internalDocument);
if (languageLevel > 0) m_docInfo->set( "langlevel", QString::number(languageLevel), i18n("Language Level") );
if (languageLevel > 0) docInfo.set( "langlevel", QString::number(languageLevel), i18n("Language Level") );
if (spectre_document_is_eps(m_internalDocument))
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/x-eps" );
docInfo.set( Okular::DocumentInfo::MimeType, "image/x-eps" );
else
m_docInfo->set( Okular::DocumentInfo::MimeType, "application/postscript" );
m_docInfo->set( Okular::DocumentInfo::Pages, QString::number(spectre_document_get_n_pages(m_internalDocument)) );
docInfo.set( Okular::DocumentInfo::MimeType, "application/postscript" );
}
return m_docInfo;
if ( keys.contains( Okular::DocumentInfo::Pages ) )
docInfo.set( Okular::DocumentInfo::Pages, QString::number(spectre_document_get_n_pages(m_internalDocument)) );
return docInfo;
}
Okular::Rotation GSGenerator::orientation(SpectreOrientation pageOrientation) const

View file

@ -26,7 +26,7 @@ class GSGenerator : public Okular::Generator, public Okular::ConfigInterface
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
// Document description and Table of contents
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
const Okular::DocumentSynopsis * generateDocumentSynopsis() { return 0L; }
const Okular::DocumentFonts * generateDocumentFonts() { return 0L; }
@ -59,7 +59,6 @@ class GSGenerator : public Okular::Generator, public Okular::ConfigInterface
// backendish stuff
SpectreDocument *m_internalDocument;
Okular::DocumentInfo *m_docInfo;
Okular::PixmapRequest *m_request;

View file

@ -138,7 +138,9 @@ X-KDE-Keywords[cs]=PS, PostScript
X-KDE-Keywords[da]=PS, Postscript
X-KDE-Keywords[de]=PS, PostScript
X-KDE-Keywords[el]=PS, PostScript
X-KDE-Keywords[en_GB]=PS, PostScript
X-KDE-Keywords[es]=PS, PostScript
X-KDE-Keywords[et]=PS, PostScript
X-KDE-Keywords[fi]=PS, PostScript
X-KDE-Keywords[fr]=PS, PostScript
X-KDE-Keywords[gl]=PS, PostScript

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=image/tiff;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma

View file

@ -178,7 +178,7 @@ OKULAR_EXPORT_PLUGIN( TIFFGenerator, createAboutData() )
TIFFGenerator::TIFFGenerator( QObject *parent, const QVariantList &args )
: Okular::Generator( parent, args ),
d( new Private ), m_docInfo( 0 )
d( new Private )
{
setFeature( Threaded );
setFeature( PrintNative );
@ -194,7 +194,6 @@ TIFFGenerator::~TIFFGenerator()
d->tiff = 0;
}
delete m_docInfo;
delete d;
}
@ -245,8 +244,6 @@ bool TIFFGenerator::doCloseDocument()
delete d->dev;
d->dev = 0;
d->data.clear();
delete m_docInfo;
m_docInfo = 0;
m_pageMapping.clear();
}
@ -304,40 +301,52 @@ QImage TIFFGenerator::image( Okular::PixmapRequest * request )
return img;
}
const Okular::DocumentInfo * TIFFGenerator::generateDocumentInfo()
Okular::DocumentInfo TIFFGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
if ( !d->tiff )
return 0;
Okular::DocumentInfo docInfo;
if ( d->tiff )
{
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
docInfo.set( Okular::DocumentInfo::MimeType, "image/tiff" );
if ( m_docInfo )
return m_docInfo;
if ( keys.contains( Okular::DocumentInfo::Description ) )
{
char* buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_IMAGEDESCRIPTION, &buffer );
docInfo.set( Okular::DocumentInfo::Description, buffer ? QString::fromLatin1( buffer ) : QString() );
}
m_docInfo = new Okular::DocumentInfo();
if ( keys.contains( Okular::DocumentInfo::Producer ) )
{
char* buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_SOFTWARE, &buffer );
docInfo.set( Okular::DocumentInfo::Producer, buffer ? QString::fromLatin1( buffer ) : QString() );
}
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/tiff" );
if ( keys.contains( Okular::DocumentInfo::Copyright ) )
{
char* buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_COPYRIGHT, &buffer );
docInfo.set( Okular::DocumentInfo::Copyright, buffer ? QString::fromLatin1( buffer ) : QString() );
}
char* buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_IMAGEDESCRIPTION, &buffer );
m_docInfo->set( Okular::DocumentInfo::Description, buffer ? QString::fromLatin1( buffer ) : i18nc( "Unknown description", "Unknown" ) );
if ( keys.contains( Okular::DocumentInfo::Author ) )
{
char* buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_ARTIST, &buffer );
docInfo.set( Okular::DocumentInfo::Author, buffer ? QString::fromLatin1( buffer ) : QString() );
}
buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_SOFTWARE, &buffer );
m_docInfo->set( Okular::DocumentInfo::Producer, buffer ? QString::fromLatin1( buffer ) : i18nc( "Unknown producer", "Unknown" ) );
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
{
char* buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_DATETIME, &buffer );
QDateTime date = convertTIFFDateTime( buffer );
docInfo.set( Okular::DocumentInfo::CreationDate, date.isValid() ? KGlobal::locale()->formatDateTime( date, KLocale::LongDate, true ) : QString() );
}
}
buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_COPYRIGHT, &buffer );
m_docInfo->set( Okular::DocumentInfo::Copyright, buffer ? QString::fromLatin1( buffer ) : i18nc( "Unknown copyright statement", "Unknown" ) );
buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_ARTIST, &buffer );
m_docInfo->set( Okular::DocumentInfo::Author, buffer ? QString::fromLatin1( buffer ) : i18nc( "Unknown author", "Unknown" ) );
buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_DATETIME, &buffer );
QDateTime date = convertTIFFDateTime( buffer );
m_docInfo->set( Okular::DocumentInfo::CreationDate, date.isValid() ? KGlobal::locale()->formatDateTime( date, KLocale::LongDate, true ) : i18nc( "Unknown creation date", "Unknown" ) );
return m_docInfo;
return docInfo;
}
void TIFFGenerator::loadPages( QVector<Okular::Page*> & pagesVector )

View file

@ -24,7 +24,7 @@ class TIFFGenerator : public Okular::Generator
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
bool loadDocumentFromData( const QByteArray & fileData, QVector< Okular::Page * > & pagesVector );
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
bool print( QPrinter& printer );
@ -40,7 +40,6 @@ class TIFFGenerator : public Okular::Generator
void loadPages( QVector<Okular::Page*> & pagesVector );
int mapPage( int page ) const;
Okular::DocumentInfo * m_docInfo;
QHash< int, int > m_pageMapping;
};

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=text/plain;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -152,7 +158,9 @@ X-KDE-Keywords[cs]=txt
X-KDE-Keywords[da]=txt
X-KDE-Keywords[de]=Text
X-KDE-Keywords[el]=txt
X-KDE-Keywords[en_GB]=txt
X-KDE-Keywords[es]=txt
X-KDE-Keywords[et]=txt
X-KDE-Keywords[fi]=txt
X-KDE-Keywords[fr]=txt
X-KDE-Keywords[gl]=txt

View file

@ -9,7 +9,9 @@ Name[cs]=txt
Name[da]=txt
Name[de]=Text
Name[el]=txt
Name[en_GB]=txt
Name[es]=txt
Name[et]=txt
Name[fi]=txt
Name[fr]=txt
Name[gl]=txt
@ -51,7 +53,9 @@ Comment[cs]= Implementace Txt pro Okular
Comment[da]=Txt-motor til Okular
Comment[de]=Anzeigemodul für Text in Okular
Comment[el]=Σύστημα υποστήριξης txt για το Okular
Comment[en_GB]=Txt backend for Okular
Comment[es]=Motor Txt para Okular
Comment[et]=Okulari txt-i taustaprogramm
Comment[fi]=TXT-taustaosa Okularille
Comment[fr]=Moteur Txt pour Okular
Comment[gl]=Infraestrutura de Txt para Okular

View file

@ -139,7 +139,9 @@ X-KDE-Keywords[cs]=txt
X-KDE-Keywords[da]=txt
X-KDE-Keywords[de]=Text
X-KDE-Keywords[el]=txt
X-KDE-Keywords[en_GB]=txt
X-KDE-Keywords[es]=txt
X-KDE-Keywords[et]=txt
X-KDE-Keywords[fi]=txt
X-KDE-Keywords[fr]=txt
X-KDE-Keywords[gl]=txt

View file

@ -1,6 +1,7 @@
[Desktop Entry]
MimeType=application/oxps;application/vnd.ms-xpsdocument;
Name=Reader
Name[ar]=التصيير
Name[bg]=Четец
Name[bs]=Čitač
Name[ca]=Lector
@ -9,6 +10,7 @@ Name[cs]=Čtečka
Name[da]=Læser
Name[de]=Lesegerät
Name[el]=Πρόγραμμα ανάγνωσης
Name[en_GB]=Reader
Name[es]=Lector
Name[et]=Lugeja
Name[fi]=Lukija
@ -46,6 +48,7 @@ Name[x-test]=xxReaderxx
Name[zh_CN]=
Name[zh_TW]=
GenericName=Document viewer
GenericName[ar]=عارض المستندات
GenericName[bg]=Преглед на документи
GenericName[bs]=Prikazivač dokumenata
GenericName[ca]=Visualitzador de documents
@ -54,6 +57,7 @@ GenericName[cs]=Prohlížeč dokumentů
GenericName[da]=Dokumentfremviser
GenericName[de]=Dokumentenbetrachter
GenericName[el]=Προβολέας εγγράφων
GenericName[en_GB]=Document Viewer
GenericName[es]=Visor de documentos
GenericName[et]=Dokumendinäitaja
GenericName[fi]=Asiakirjakatselin
@ -90,6 +94,7 @@ GenericName[x-test]=xxDocument viewerxx
GenericName[zh_CN]=
GenericName[zh_TW]=
Comment=Viewer for various types of documents
Comment[ar]=عارض للعديد من أنواع المستندات
Comment[bg]=Преглед на различни видове документи
Comment[bs]=Pregledač raznih vrsta dokumenata
Comment[ca]=Visualitzador de diversos tipus de documents
@ -98,6 +103,7 @@ Comment[cs]=Prohlížeč různých typů dokumentů
Comment[da]=Fremviser af diverse dokumenttyper
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
Comment[en_GB]=Viewer for various types of documents
Comment[es]=Visor de diversos tipos de documentos
Comment[et]=Eri tüüpi dokumentide näitaja
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
@ -153,6 +159,7 @@ X-KDE-Keywords[cs]=XPS
X-KDE-Keywords[da]=XPS
X-KDE-Keywords[de]=XPS
X-KDE-Keywords[el]=XPS
X-KDE-Keywords[en_GB]=XPS
X-KDE-Keywords[es]=XPS
X-KDE-Keywords[et]=XPS
X-KDE-Keywords[fi]=XPS

View file

@ -1892,7 +1892,7 @@ XpsPage* XpsDocument::page(int pageNum) const
return m_pages.at(pageNum);
}
XpsFile::XpsFile() : m_docInfo( 0 )
XpsFile::XpsFile()
{
}
@ -1996,14 +1996,11 @@ bool XpsFile::loadDocument(const QString &filename)
return true;
}
const Okular::DocumentInfo * XpsFile::generateDocumentInfo()
Okular::DocumentInfo XpsFile::generateDocumentInfo() const
{
if ( m_docInfo )
return m_docInfo;
Okular::DocumentInfo docInfo;
m_docInfo = new Okular::DocumentInfo();
m_docInfo->set( Okular::DocumentInfo::MimeType, "application/oxps" );
docInfo.set( Okular::DocumentInfo::MimeType, "application/oxps" );
if ( ! m_corePropertiesFileName.isEmpty() ) {
const KZipFileEntry* corepropsFile = static_cast<const KZipFileEntry *>(m_xpsArchive->directory()->entry(m_corePropertiesFileName));
@ -2018,25 +2015,25 @@ const Okular::DocumentInfo * XpsFile::generateDocumentInfo()
if ( xml.isStartElement() )
{
if (xml.name() == "title") {
m_docInfo->set( Okular::DocumentInfo::Title, xml.readElementText() );
docInfo.set( Okular::DocumentInfo::Title, xml.readElementText() );
} else if (xml.name() == "subject") {
m_docInfo->set( Okular::DocumentInfo::Subject, xml.readElementText() );
docInfo.set( Okular::DocumentInfo::Subject, xml.readElementText() );
} else if (xml.name() == "description") {
m_docInfo->set( Okular::DocumentInfo::Description, xml.readElementText() );
docInfo.set( Okular::DocumentInfo::Description, xml.readElementText() );
} else if (xml.name() == "creator") {
m_docInfo->set( Okular::DocumentInfo::Creator, xml.readElementText() );
docInfo.set( Okular::DocumentInfo::Creator, xml.readElementText() );
} else if (xml.name() == "category") {
m_docInfo->set( Okular::DocumentInfo::Category, xml.readElementText() );
docInfo.set( Okular::DocumentInfo::Category, xml.readElementText() );
} else if (xml.name() == "created") {
QDateTime createdDate = QDateTime::fromString( xml.readElementText(), "yyyy-MM-ddThh:mm:ssZ" );
m_docInfo->set( Okular::DocumentInfo::CreationDate, KGlobal::locale()->formatDateTime( createdDate, KLocale::LongDate, true ) );
docInfo.set( Okular::DocumentInfo::CreationDate, KGlobal::locale()->formatDateTime( createdDate, KLocale::LongDate, true ) );
} else if (xml.name() == "modified") {
QDateTime modifiedDate = QDateTime::fromString( xml.readElementText(), "yyyy-MM-ddThh:mm:ssZ" );
m_docInfo->set( Okular::DocumentInfo::ModificationDate, KGlobal::locale()->formatDateTime( modifiedDate, KLocale::LongDate, true ) );
docInfo.set( Okular::DocumentInfo::ModificationDate, KGlobal::locale()->formatDateTime( modifiedDate, KLocale::LongDate, true ) );
} else if (xml.name() == "keywords") {
m_docInfo->set( Okular::DocumentInfo::Keywords, xml.readElementText() );
docInfo.set( Okular::DocumentInfo::Keywords, xml.readElementText() );
} else if (xml.name() == "revision") {
m_docInfo->set( "revision", xml.readElementText(), i18n( "Revision" ) );
docInfo.set( "revision", xml.readElementText(), i18n( "Revision" ) );
}
}
}
@ -2048,19 +2045,13 @@ const Okular::DocumentInfo * XpsFile::generateDocumentInfo()
kDebug(XpsDebug) << "No core properties filename";
}
m_docInfo->set( Okular::DocumentInfo::Pages, QString::number(numPages()) );
docInfo.set( Okular::DocumentInfo::Pages, QString::number(numPages()) );
return m_docInfo;
return docInfo;
}
bool XpsFile::closeDocument()
{
if ( m_docInfo )
delete m_docInfo;
m_docInfo = 0;
qDeleteAll( m_documents );
m_documents.clear();
@ -2159,7 +2150,7 @@ Okular::TextPage* XpsGenerator::textPage( Okular::Page * page )
return xpsPage->textPage();
}
const Okular::DocumentInfo * XpsGenerator::generateDocumentInfo()
Okular::DocumentInfo XpsGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
{
kDebug(XpsDebug) << "generating document metadata";

View file

@ -235,7 +235,7 @@ public:
bool loadDocument( const QString & fileName );
bool closeDocument();
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo() const;
QImage thumbnail();
@ -287,7 +287,6 @@ private:
bool m_thumbnailIsLoaded;
QString m_corePropertiesFileName;
Okular::DocumentInfo * m_docInfo;
QString m_signatureOrigin;
@ -307,7 +306,7 @@ class XpsGenerator : public Okular::Generator
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
const Okular::DocumentInfo * generateDocumentInfo();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
const Okular::DocumentSynopsis * generateDocumentSynopsis();
Okular::ExportFormat::List exportFormats() const;

View file

@ -139,6 +139,7 @@ X-KDE-Keywords[cs]=XPS
X-KDE-Keywords[da]=XPS
X-KDE-Keywords[de]=XPS
X-KDE-Keywords[el]=XPS
X-KDE-Keywords[en_GB]=XPS
X-KDE-Keywords[es]=XPS
X-KDE-Keywords[et]=XPS
X-KDE-Keywords[fi]=XPS

121
part.cpp
View file

@ -1155,19 +1155,8 @@ QString Part::currentDocument()
QString Part::documentMetaData( const QString &metaData ) const
{
const Okular::DocumentInfo * info = m_document->documentInfo();
if ( info )
{
QDomElement docElement = info->documentElement();
for ( QDomNode node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() )
{
const QDomElement element = node.toElement();
if ( metaData.compare( element.tagName(), Qt::CaseInsensitive ) == 0 )
return element.attribute( "value" );
}
}
return QString();
const Okular::DocumentInfo info = m_document->documentInfo();
return info.get( metaData );
}
@ -1241,54 +1230,47 @@ void Part::unsetFileToWatch()
m_watchedFileSymlinkTarget.clear();
}
bool Part::openFile()
Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QString &fileNameToOpenA, bool *isCompressedFile )
{
KMimeType::Ptr mime;
QString fileNameToOpen = localFilePath();
const bool isstdin = url().isLocalFile() && url().fileName( KUrl::ObeyTrailingSlash ) == QLatin1String( "-" );
const QFileInfo fileInfo( fileNameToOpen );
if ( !isstdin && !fileInfo.exists() )
return false;
if ( !arguments().mimeType().isEmpty() )
{
mime = KMimeType::mimeType( arguments().mimeType() );
}
if ( !mime )
{
mime = KMimeType::findByPath( fileNameToOpen );
}
bool isCompressedFile = false;
Document::OpenResult openResult = Document::OpenError;
bool uncompressOk = true;
KMimeType::Ptr mime = mimeA;
QString fileNameToOpen = fileNameToOpenA;
QString compressedMime = compressedMimeFor( mime->name() );
if ( compressedMime.isEmpty() )
compressedMime = compressedMimeFor( mime->parentMimeType() );
if ( !compressedMime.isEmpty() )
{
isCompressedFile = true;
*isCompressedFile = true;
uncompressOk = handleCompressed( fileNameToOpen, localFilePath(), compressedMime );
mime = KMimeType::findByPath( fileNameToOpen );
}
else
{
*isCompressedFile = false;
}
if ( m_swapInsteadOfOpening )
{
m_swapInsteadOfOpening = false;
if ( !uncompressOk )
return false;
return Document::OpenError;
if ( mime->is( "application/vnd.kde.okular-archive" ) )
{
isDocumentArchive = true;
return m_document->swapBackingFileArchive( fileNameToOpen, url() );
if (!m_document->swapBackingFileArchive( fileNameToOpen, url() ))
return Document::OpenError;
}
else
{
isDocumentArchive = false;
return m_document->swapBackingFile( fileNameToOpen, url() );
if (!m_document->swapBackingFile( fileNameToOpen, url() ))
return Document::OpenError;
}
}
Document::OpenResult openResult = Document::OpenError;
isDocumentArchive = false;
if ( uncompressOk )
{
@ -1373,6 +1355,56 @@ bool Part::openFile()
}
}
return openResult;
}
bool Part::openFile()
{
QList<KMimeType::Ptr> mimes;
QString fileNameToOpen = localFilePath();
const bool isstdin = url().isLocalFile() && url().fileName( KUrl::ObeyTrailingSlash ) == QLatin1String( "-" );
const QFileInfo fileInfo( fileNameToOpen );
if ( !isstdin && !fileInfo.exists() )
return false;
KMimeType::Ptr pathMime = KMimeType::findByPath( fileNameToOpen );
if ( !arguments().mimeType().isEmpty() )
{
KMimeType::Ptr argMime = KMimeType::mimeType( arguments().mimeType() );
// Select the "childmost" mimetype, if none of them
// inherits the other trust more what pathMime says
// but still do a second try if that one fails
if ( argMime->is( pathMime->name() ) )
{
mimes << argMime;
}
else if ( pathMime->is( argMime->name() ) )
{
mimes << pathMime;
}
else
{
mimes << pathMime << argMime;
}
if (mimes[0]->name() == "text/plain") {
KMimeType::Ptr contentMime = KMimeType::findByFileContent( fileNameToOpen );
mimes.prepend( contentMime );
}
}
else
{
mimes << pathMime;
}
KMimeType::Ptr mime;
Document::OpenResult openResult = Document::OpenError;
bool isCompressedFile = false;
while ( !mimes.isEmpty() && openResult == Document::OpenError ) {
mime = mimes.takeFirst();
openResult = doOpenFile( mime, fileNameToOpen, &isCompressedFile );
}
bool canSearch = m_document->supportsSearching();
emit mimeTypeChanged( mime );
@ -2204,12 +2236,9 @@ bool Part::slotSaveFileAs( bool showOkularArchiveAsDefaultFormat )
// Determine the document's mimetype
KMimeType::Ptr originalMimeType;
if ( const Okular::DocumentInfo *documentInfo = m_document->documentInfo() )
{
QString typeName = documentInfo->get("mimeType");
if ( !typeName.isEmpty() )
originalMimeType = KMimeType::mimeType( typeName );
}
const QString typeName = m_document->documentInfo().get( DocumentInfo::MimeType );
if ( !typeName.isEmpty() )
originalMimeType = KMimeType::mimeType( typeName );
// What format choice should we show as default?
const QString defaultMimeType = (isDocumentArchive || showOkularArchiveAsDefaultFormat) ?
@ -2737,14 +2766,12 @@ void Part::slotAboutBackend()
if ( aboutData.programIconName().isEmpty() || aboutData.programIconName() == aboutData.appName() )
{
if ( const Okular::DocumentInfo *documentInfo = m_document->documentInfo() )
const Okular::DocumentInfo documentInfo = m_document->documentInfo(QSet<DocumentInfo::Key>() << DocumentInfo::MimeType);
const QString mimeTypeName = documentInfo.get(DocumentInfo::MimeType);
if ( !mimeTypeName.isEmpty() )
{
const QString mimeTypeName = documentInfo->get("mimeType");
if ( !mimeTypeName.isEmpty() )
{
if ( KMimeType::Ptr type = KMimeType::mimeType( mimeTypeName ) )
aboutData.setProgramIconName( type->iconName() );
}
if ( KMimeType::Ptr type = KMimeType::mimeType( mimeTypeName ) )
aboutData.setProgramIconName( type->iconName() );
}
}

2
part.h
View file

@ -234,7 +234,9 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
void noticeMessage( const QString &message, int duration = -1 );
private:
Document::OpenResult doOpenFile(const KMimeType::Ptr &mime, const QString &fileNameToOpen, bool *isCompressedFile);
bool openUrl( const KUrl &url, bool swapInsteadOfOpening );
void setupViewerActions();
void setViewerShortcuts();
void setupActions();

View file

@ -17,6 +17,7 @@ endif(KActivities_FOUND)
set(okular_SRCS
main.cpp
okular_main.cpp
shell.cpp
shellutils.cpp
)

View file

@ -15,107 +15,10 @@
#include "shell.h"
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <QtDBus/qdbusinterface.h>
#include <QTextStream>
#include <kwindowsystem.h>
#include "aboutdata.h"
#include "okular_main.h"
#include "shellutils.h"
static bool attachUniqueInstance(KCmdLineArgs* args)
{
if (!args->isSet("unique") || args->count() != 1)
return false;
QDBusInterface iface("org.kde.okular", "/okular", "org.kde.okular");
QDBusInterface iface2("org.kde.okular", "/okularshell", "org.kde.okular");
if (!iface.isValid() || !iface2.isValid())
return false;
if (args->isSet("print"))
iface.call("enableStartWithPrint");
if (args->isSet("page"))
iface.call("openDocument", ShellUtils::urlFromArg(args->arg(0), ShellUtils::qfileExistFunc(), args->getOption("page")).url());
else
iface.call("openDocument", ShellUtils::urlFromArg(args->arg(0), ShellUtils::qfileExistFunc()).url());
if (args->isSet("raise")) {
iface2.call("tryRaise");
}
return true;
}
// Ask an existing non-unique instance to open new tabs
static bool attachExistingInstance( KCmdLineArgs* args )
{
if ( args->count() < 1 )
return false;
const QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
// Don't match the service without trailing "-" (unique instance)
const QString pattern = "org.kde.okular-";
const QString myPid = QString::number( kapp->applicationPid() );
QScopedPointer<QDBusInterface> bestService;
const int desktop = KWindowSystem::currentDesktop();
// Select the first instance that isn't us (metric may change in future)
foreach ( const QString& service, services )
{
if ( service.startsWith(pattern) && !service.endsWith( myPid ) )
{
bestService.reset( new QDBusInterface(service, "/okularshell", "org.kde.okular") );
// Find a window that can handle our documents
const QDBusReply<bool> reply = bestService->call( "canOpenDocs", args->count(), desktop );
if( reply.isValid() && reply.value() )
break;
bestService.reset();
}
}
if ( !bestService )
return false;
for( int i = 0; i < args->count(); ++i )
{
QString arg = args->arg( i );
// Copy stdin to temporary file which can be opened by the existing
// window. The temp file is automatically deleted after it has been
// opened. Not sure if this behavior is safe on all platforms.
QScopedPointer<QTemporaryFile> tempFile;
if( arg == "-" )
{
tempFile.reset( new QTemporaryFile );
QFile stdinFile;
if( !tempFile->open() || !stdinFile.open(stdin,QIODevice::ReadOnly) )
return false;
const size_t bufSize = 1024*1024;
QScopedPointer<char,QScopedPointerArrayDeleter<char> > buf( new char[bufSize] );
size_t bytes;
do
{
bytes = stdinFile.read( buf.data(), bufSize );
tempFile->write( buf.data(), bytes );
} while( bytes != 0 );
arg = tempFile->fileName();
}
// Returns false if it can't fit another document
const QDBusReply<bool> reply = bestService->call( "openDocument", arg );
if( !reply.isValid() || !reply.value() )
return false;
}
bestService->call( "tryRaise" );
return true;
}
int main(int argc, char** argv)
{
KAboutData about = okularAboutData( "okular", I18N_NOOP( "Okular" ) );
@ -137,37 +40,24 @@ int main(int argc, char** argv)
if (app.isSessionRestored())
{
RESTORE(Shell);
} else {
}
else
{
// no session.. just start up normally
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
// try to attach to existing session, unique or not
if (attachUniqueInstance(args) || attachExistingInstance(args))
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
QStringList paths;
for ( int i = 0; i < args->count(); ++i )
paths << args->arg(i);
Okular::Status status = Okular::main(paths, ShellUtils::serializeOptions(*args));
switch (status)
{
args->clear();
return 0;
}
if (args->isSet( "unique" ) && args->count() > 1)
{
QTextStream stream(stderr);
stream << i18n( "Error: Can't open more than one document with the --unique switch" ) << endl;
return -1;
}
else
{
Shell* shell = new Shell( args );
shell->show();
for ( int i = 0; i < args->count(); )
{
if ( shell->openDocument( args->arg(i)) )
++i;
else
{
shell = new Shell( args );
shell->show();
}
}
case Okular::Error:
return -1;
case Okular::AttachedOtherProcess:
return 0;
case Okular::Success:
// Do nothing
break;
}
}

180
shell/okular_main.cpp Normal file
View file

@ -0,0 +1,180 @@
/***************************************************************************
* Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
* Copyright (C) 2003 by Christophe Devriese *
* <Christophe.Devriese@student.kuleuven.ac.be> *
* Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
* Copyright (C) 2003-2007 by Albert Astals Cid <aacid@kde.org> *
* Copyright (C) 2004 by Andy Goossens <andygoossens@telenet.be> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "okular_main.h"
#include "shell.h"
#include <kapplication.h>
#include <klocale.h>
#include <QtDBus/qdbusinterface.h>
#include <QTextStream>
#include <kwindowsystem.h>
#include "aboutdata.h"
#include "shellutils.h"
static bool attachUniqueInstance(const QStringList &paths, const QString &serializedOptions)
{
if (!ShellUtils::unique(serializedOptions) || paths.count() != 1)
return false;
QDBusInterface iface("org.kde.okular", "/okularshell", "org.kde.okular");
if (!iface.isValid())
return false;
const QString page = ShellUtils::page(serializedOptions);
iface.call("openDocument", ShellUtils::urlFromArg(paths[0], ShellUtils::qfileExistFunc(), page).url(), serializedOptions);
if (!ShellUtils::noRaise(serializedOptions)) {
iface.call("tryRaise");
}
return true;
}
// Ask an existing non-unique instance to open new tabs
static bool attachExistingInstance(const QStringList &paths, const QString &serializedOptions)
{
if ( paths.count() < 1 )
return false;
const QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
// Don't match the service without trailing "-" (unique instance)
const QString pattern = "org.kde.okular-";
const QString myPid = QString::number( kapp->applicationPid() );
QScopedPointer<QDBusInterface> bestService;
const int desktop = KWindowSystem::currentDesktop();
// Select the first instance that isn't us (metric may change in future)
foreach ( const QString& service, services )
{
if ( service.startsWith(pattern) && !service.endsWith( myPid ) )
{
bestService.reset( new QDBusInterface(service, "/okularshell", "org.kde.okular") );
// Find a window that can handle our documents
const QDBusReply<bool> reply = bestService->call( "canOpenDocs", paths.count(), desktop );
if( reply.isValid() && reply.value() )
break;
bestService.reset();
}
}
if ( !bestService )
return false;
foreach( const QString &arg, paths )
{
// Copy stdin to temporary file which can be opened by the existing
// window. The temp file is automatically deleted after it has been
// opened. Not sure if this behavior is safe on all platforms.
QScopedPointer<QTemporaryFile> tempFile;
QString path;
if( arg == "-" )
{
tempFile.reset( new QTemporaryFile );
QFile stdinFile;
if( !tempFile->open() || !stdinFile.open(stdin,QIODevice::ReadOnly) )
return false;
const size_t bufSize = 1024*1024;
QScopedPointer<char,QScopedPointerArrayDeleter<char> > buf( new char[bufSize] );
size_t bytes;
do
{
bytes = stdinFile.read( buf.data(), bufSize );
tempFile->write( buf.data(), bytes );
} while( bytes != 0 );
path = tempFile->fileName();
}
else
{
// Page only makes sense if we are opening one file
const QString page = ShellUtils::page(serializedOptions);
path = ShellUtils::urlFromArg(arg, ShellUtils::qfileExistFunc(), page).url();
}
// Returns false if it can't fit another document
const QDBusReply<bool> reply = bestService->call( "openDocument", path, serializedOptions );
if( !reply.isValid() || !reply.value() )
return false;
}
bestService->call( "tryRaise" );
return true;
}
namespace Okular {
Status main(const QStringList &paths, const QString &serializedOptions)
{
if (ShellUtils::unique(serializedOptions) && paths.count() > 1)
{
QTextStream stream(stderr);
stream << i18n( "Error: Can't open more than one document with the --unique switch" ) << endl;
return Error;
}
if (ShellUtils::startInPresentation(serializedOptions) && paths.count() > 1)
{
QTextStream stream(stderr);
stream << i18n( "Error: Can't open more than one document with the --presentation switch" ) << endl;
return Error;
}
if (ShellUtils::showPrintDialog(serializedOptions) && paths.count() > 1)
{
QTextStream stream(stderr);
stream << i18n( "Error: Can't open more than one document with the --presentation switch" ) << endl;
return Error;
}
if (!ShellUtils::page(serializedOptions).isEmpty() && paths.count() > 1)
{
QTextStream stream(stderr);
stream << i18n( "Error: Can't open more than one document with the --presentation switch" ) << endl;
return Error;
}
// try to attach to existing session, unique or not
if (attachUniqueInstance(paths, serializedOptions) || attachExistingInstance(paths, serializedOptions))
{
return AttachedOtherProcess;
}
Shell* shell = new Shell( serializedOptions );
shell->show();
for ( int i = 0; i < paths.count(); )
{
// Page only makes sense if we are opening one file
const QString page = ShellUtils::page(serializedOptions);
if ( shell->openDocument( ShellUtils::urlFromArg(paths[i], ShellUtils::qfileExistFunc(), page).url(), serializedOptions) )
{
++i;
}
else
{
shell = new Shell( serializedOptions );
shell->show();
}
}
return Success;
}
}
/* kate: replace-tabs on; indent-width 4; */

27
shell/okular_main.h Normal file
View file

@ -0,0 +1,27 @@
/***************************************************************************
* Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
* Copyright (C) 2003 by Christophe Devriese *
* <Christophe.Devriese@student.kuleuven.ac.be> *
* Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
* Copyright (C) 2003-2007 by Albert Astals Cid <aacid@kde.org> *
* Copyright (C) 2004 by Andy Goossens <andygoossens@telenet.be> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
class QString;
class QStringList;
namespace Okular
{
enum Status { Error, AttachedOtherProcess, Success };
Status main(const QStringList &paths, const QString &serializedOptions);
}
/* kate: replace-tabs on; indent-width 4; */

View file

@ -25,7 +25,6 @@
#include <QtDBus/qdbusconnection.h>
#include <kaction.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kfiledialog.h>
#include <kpluginloader.h>
#include <kmessagebox.h>
@ -46,6 +45,7 @@
#include <ktabwidget.h>
#include <kxmlguifactory.h>
#include <QDragMoveEvent>
#include <QTabBar>
#ifdef KActivities_FOUND
#include <KActivities/ResourceInstance>
@ -59,21 +59,11 @@
static const char *shouldShowMenuBarComingFromFullScreen = "shouldShowMenuBarComingFromFullScreen";
static const char *shouldShowToolBarComingFromFullScreen = "shouldShowToolBarComingFromFullScreen";
Shell::Shell(KCmdLineArgs* args, int argIndex)
: KParts::MainWindow(), m_args(args), m_menuBarWasShown(true), m_toolBarWasShown(true)
Shell::Shell( const QString &serializedOptions )
: KParts::MainWindow(), m_menuBarWasShown(true), m_toolBarWasShown(true)
#ifdef KActivities_FOUND
, m_activityResource(0)
#endif
{
if (m_args && argIndex != -1)
{
m_openUrl = ShellUtils::urlFromArg(m_args->arg(argIndex),
ShellUtils::qfileExistFunc(), m_args->getOption("page"));
}
init();
}
void Shell::init()
{
setObjectName( QLatin1String( "okular::Shell" ) );
setContextMenuPolicy( Qt::NoContextMenu );
@ -103,10 +93,12 @@ void Shell::init()
m_tabWidget->setElideMode( Qt::ElideRight );
m_tabWidget->setTabBarHidden( true );
m_tabWidget->setDocumentMode( true );
m_tabWidget->setMovable( true );
connect( m_tabWidget, SIGNAL(currentChanged(int)), SLOT(setActiveTab(int)) );
connect( m_tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int)) );
connect( m_tabWidget, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), SLOT(testTabDrop(const QDragMoveEvent*,bool&)) );
connect( m_tabWidget, SIGNAL(receivedDropEvent(QDropEvent*)), SLOT(handleTabDrop(QDropEvent*)) );
connect( m_tabWidget->tabBar(), SIGNAL(tabMoved(int,int)), SLOT(moveTabData(int,int)) );
setCentralWidget( m_tabWidget );
@ -122,22 +114,19 @@ void Shell::init()
readSettings();
m_unique = false;
if (m_args && m_args->isSet("unique") && m_args->count() <= 1)
m_unique = ShellUtils::unique(serializedOptions);
if (m_unique)
{
m_unique = QDBusConnection::sessionBus().registerService("org.kde.okular");
if (!m_unique)
KMessageBox::information(this, i18n("There is already a unique Okular instance running. This instance won't be the unique one."));
}
if (m_args && !m_args->isSet("raise"))
if (ShellUtils::noRaise(serializedOptions))
{
setAttribute(Qt::WA_ShowWithoutActivating);
}
QDBusConnection::sessionBus().registerObject("/okularshell", this, QDBusConnection::ExportScriptableSlots);
if (m_openUrl.isValid()) QTimer::singleShot(0, this, SLOT(delayedOpen()));
}
else
{
@ -145,11 +134,6 @@ void Shell::init()
}
}
void Shell::delayedOpen()
{
openUrl( m_openUrl );
}
void Shell::showOpenRecentMenu()
{
m_recent->menu()->popup(QCursor::pos());
@ -165,13 +149,13 @@ Shell::~Shell()
it->part->closeUrl( false );
}
}
if ( m_args )
m_args->clear();
if (m_unique)
QDBusConnection::sessionBus().unregisterService("org.kde.okular");
}
// Open a new document if we have space for it
// This can hang if called on a unique instance and openUrl pops a messageBox
bool Shell::openDocument( const QString& doc )
bool Shell::openDocument( const QString& url, const QString &serializedOptions )
{
if( m_tabs.size() <= 0 )
return false;
@ -179,11 +163,14 @@ bool Shell::openDocument( const QString& doc )
KParts::ReadWritePart* const part = m_tabs[0].part;
// Return false if we can't open new tabs and the only part is occupied
if( !dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs()
&& !part->url().isEmpty() )
if ( !dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs()
&& !part->url().isEmpty()
&& !ShellUtils::unique(serializedOptions))
{
return false;
}
openUrl( ShellUtils::urlFromArg(doc,ShellUtils::qfileExistFunc()) );
openUrl( url, serializedOptions );
return true;
}
@ -206,7 +193,7 @@ bool Shell::canOpenDocs( int numDocs, int desktop )
return true;
}
void Shell::openUrl( const KUrl & url )
void Shell::openUrl( const KUrl & url, const QString &serializedOptions )
{
const int activeTab = m_tabWidget->currentIndex();
if ( activeTab < m_tabs.size() )
@ -216,19 +203,19 @@ void Shell::openUrl( const KUrl & url )
{
if( m_unique )
{
KMessageBox::error(this, i18n("Can't open more than one document in the unique Okular instance."));
applyOptionsToPart( activePart, serializedOptions );
activePart->openUrl( url );
}
else
{
if( dynamic_cast<Okular::ViewerInterface *>(activePart)->openNewFilesInTabs() )
{
openNewTab( url );
setActiveTab( m_tabs.size()-1 );
openNewTab( url, serializedOptions );
}
else
{
Shell* newShell = new Shell();
newShell->openUrl( url );
Shell* newShell = new Shell( serializedOptions );
newShell->openUrl( url, serializedOptions );
newShell->show();
}
}
@ -236,13 +223,7 @@ void Shell::openUrl( const KUrl & url )
else
{
m_tabWidget->setTabText( activeTab, url.fileName() );
if ( m_args ){
KDocumentViewer* const doc = qobject_cast<KDocumentViewer*>(activePart);
if ( doc && m_args->isSet( "presentation" ) )
doc->startPresentation();
if ( m_args->isSet( "print" ) )
QMetaObject::invokeMethod( activePart, "enableStartWithPrint" );
}
applyOptionsToPart( activePart, serializedOptions );
bool openOk = activePart->openUrl( url );
const bool isstdin = url.fileName( KUrl::ObeyTrailingSlash ) == QLatin1String( "-" );
if ( !isstdin )
@ -537,7 +518,7 @@ void Shell::closeTab( int tab )
}
void Shell::openNewTab( const KUrl& url )
void Shell::openNewTab( const KUrl& url, const QString &serializedOptions )
{
// Tabs are hidden when there's only one, so show it
if( m_tabs.size() == 1 )
@ -557,8 +538,24 @@ void Shell::openNewTab( const KUrl& url )
KParts::ReadWritePart* const part = m_tabs[newIndex].part;
m_tabWidget->addTab( part->widget(), url.fileName() );
applyOptionsToPart(part, serializedOptions);
int previousActiveTab = m_tabWidget->currentIndex();
setActiveTab( m_tabs.size() - 1 );
if( part->openUrl(url) )
m_recent->addUrl( url );
else
setActiveTab( previousActiveTab );
}
void Shell::applyOptionsToPart( QObject* part, const QString &serializedOptions )
{
KDocumentViewer* const doc = qobject_cast<KDocumentViewer*>(part);
if ( ShellUtils::startInPresentation(serializedOptions) )
doc->startPresentation();
if ( ShellUtils::showPrintDialog(serializedOptions) )
QMetaObject::invokeMethod( part, "enableStartWithPrint" );
}
void Shell::connectPart( QObject* part )
@ -660,6 +657,11 @@ void Shell::handleTabDrop( QDropEvent* event )
handleDroppedUrls( list );
}
void Shell::moveTabData( int from, int to )
{
m_tabs.move( from, to );
}
#include "shell.moc"
/* kate: replace-tabs on; indent-width 4; */

View file

@ -21,7 +21,6 @@
#include <QtDBus/QtDBus>
class KCmdLineArgs;
class KRecentFilesAction;
class KToggleAction;
class KTabWidget;
@ -47,11 +46,13 @@ class Shell : public KParts::MainWindow
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
friend class MainShellTest;
public:
/**
* Constructor
*/
explicit Shell(KCmdLineArgs* args = 0, int argIndex = -1);
explicit Shell( const QString &serializedOptions = QString() );
/**
* Default Destructor
@ -63,7 +64,7 @@ public slots:
void slotQuit();
Q_SCRIPTABLE Q_NOREPLY void tryRaise();
Q_SCRIPTABLE bool openDocument( const QString& doc );
Q_SCRIPTABLE bool openDocument( const QString& url, const QString &serializedOptions = QString() );
Q_SCRIPTABLE bool canOpenDocs( int numDocs, int desktop );
protected:
@ -95,8 +96,7 @@ private slots:
void slotUpdateFullScreen();
void slotShowMenubar();
void openUrl( const KUrl & url );
void delayedOpen();
void openUrl( const KUrl & url, const QString &serializedOptions = QString() );
void showOpenRecentMenu();
void closeUrl();
void print();
@ -112,6 +112,7 @@ private slots:
void activatePrevTab();
void testTabDrop( const QDragMoveEvent* event, bool& accept );
void handleTabDrop( QDropEvent* event );
void moveTabData( int from, int to );
signals:
void restoreDocument(const KConfigGroup &group);
@ -120,14 +121,13 @@ signals:
private:
void setupAccel();
void setupActions();
void init();
QStringList fileFormats() const;
void openNewTab( const KUrl& url );
void openNewTab( const KUrl& url, const QString &serializedOptions );
void applyOptionsToPart( QObject* part, const QString &serializedOptions );
void connectPart( QObject* part );
int findTabIndex( QObject* sender );
private:
KCmdLineArgs* m_args;
KPluginFactory* m_partFactory;
KRecentFilesAction* m_recent;
QStringList m_fileformats;
@ -138,7 +138,6 @@ private:
KToggleAction* m_showMenuBarAction;
bool m_menuBarWasShown, m_toolBarWasShown;
bool m_unique;
KUrl m_openUrl;
KTabWidget* m_tabWidget;
KToggleAction* m_openInTab;

View file

@ -64,4 +64,71 @@ KUrl urlFromArg( const QString& _arg, FileExistFunc exist_func, const QString& p
return url;
}
QString serializeOptions(const KCmdLineArgs &args)
{
const bool startInPresentation = args.isSet( "presentation" );
const bool showPrintDialog = args.isSet( "print" );
const bool unique = args.isSet("unique") && args.count() <= 1;
const bool noRaise = !args.isSet("raise");
const QString page = args.getOption("page");
return serializeOptions(startInPresentation, showPrintDialog, unique, noRaise, page);
}
QString serializeOptions(bool startInPresentation, bool showPrintDialog, bool unique, bool noRaise, const QString &page)
{
return QString("%1:%2:%3:%4:%5").arg(startInPresentation).arg(showPrintDialog).arg(unique).arg(noRaise).arg(page);
}
bool unserializeOptions(const QString &serializedOptions, bool *presentation, bool *print, bool *unique, bool *noraise, QString *page)
{
const QStringList args = serializedOptions.split(":");
if (args.count() == 5)
{
*presentation = args[0] == "1";
*print = args[1] == "1";
*unique = args[2] == "1";
*noraise = args[3] == "1";
*page = args[4];
return true;
}
return false;
}
bool startInPresentation(const QString &serializedOptions)
{
bool result, dummy;
QString dummyString;
return unserializeOptions(serializedOptions, &result, &dummy, &dummy, &dummy, &dummyString) && result;
}
bool showPrintDialog(const QString &serializedOptions)
{
bool result, dummy;
QString dummyString;
return unserializeOptions(serializedOptions, &dummy, &result, &dummy, &dummy, &dummyString) && result;
}
bool unique(const QString &serializedOptions)
{
bool result, dummy;
QString dummyString;
return unserializeOptions(serializedOptions, &dummy, &dummy, &result, &dummy, &dummyString) && result;
}
bool noRaise(const QString &serializedOptions)
{
bool result, dummy;
QString dummyString;
return unserializeOptions(serializedOptions, &dummy, &dummy, &dummy, &result, &dummyString) && result;
}
QString page(const QString &serializedOptions)
{
QString result;
bool dummy;
unserializeOptions(serializedOptions, &dummy, &dummy, &dummy, &dummy, &result);
return result;
}
}

View file

@ -14,6 +14,8 @@
#include <kurl.h>
class KCmdLineArgs;
namespace ShellUtils
{
@ -21,6 +23,14 @@ typedef bool (*FileExistFunc)( const QString& fileName );
FileExistFunc qfileExistFunc();
KUrl urlFromArg( const QString& _arg, FileExistFunc exist_func, const QString& pageArg = QString() );
QString serializeOptions(const KCmdLineArgs &args);
QString serializeOptions(bool startInPresentation, bool showPrintDialog, bool unique, bool noRaise, const QString &page);
bool unserializeOptions(const QString &serializedOptions, bool *presentation, bool *print, bool *unique, bool *noraise, QString *page);
bool unique(const QString &serializedOptions);
bool noRaise(const QString &serializedOptions);
bool startInPresentation(const QString &serializedOptions);
bool showPrintDialog(const QString &serializedOptions);
QString page(const QString &serializedOptions);
}

View file

@ -1,5 +1,7 @@
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
kde4_add_unit_test( shelltest shelltest.cpp ../shell/shellutils.cpp )
target_link_libraries( shelltest ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} )
@ -32,3 +34,6 @@ target_link_libraries( modifyannotationpropertiestest ${KDE4_KDECORE_LIBS} ${QT_
kde4_add_unit_test( editformstest editformstest.cpp )
target_link_libraries( editformstest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} okularcore )
kde4_add_unit_test( mainshelltest mainshelltest.cpp ../shell/okular_main.cpp ../shell/shellutils.cpp ../shell/shell.cpp )
target_link_libraries( mainshelltest ${KDE4_KPARTS_LIBS} ${QT_QTTEST_LIBRARY} okularpart okularcore )

472
tests/mainshelltest.cpp Normal file
View file

@ -0,0 +1,472 @@
/***************************************************************************
* Copyright (C) 2014 by Albert Astals Cid <aacid@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include <qtest_kde.h>
#include <qprintdialog.h>
#include <qwidget.h>
#include <ktabwidget.h>
#include "../shell/okular_main.h"
#include "../shell/shell.h"
#include "../shell/shellutils.h"
#include "../core/document_p.h"
#include "../ui/presentationwidget.h"
#include "../part.h"
#include "../settings.h"
#include <sys/types.h>
#include <unistd.h>
namespace Okular {
class PartTest
{
public:
Okular::Document *partDocument(Okular::Part *part) const {
return part->m_document;
}
QWidget *presentationWidget(Okular::Part *part) const {
return part->m_presentationWidget;
}
};
}
class ClosePrintDialogHelper : public QObject
{
Q_OBJECT
public:
ClosePrintDialogHelper(int expectedTab) : foundDialog(false), m_expectedTab(expectedTab) { }
bool foundDialog;
private slots:
void closePrintDialog();
private:
int m_expectedTab;
};
class MainShellTest : public QObject, public Okular::PartTest
{
Q_OBJECT
public:
static KTabWidget* tabWidget(Shell *s)
{
return s->m_tabWidget;
}
private slots:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
void testShell_data();
void testShell();
void testFileRemembersPagePosition_data();
void testFileRemembersPagePosition();
void test2FilesError_data();
void test2FilesError();
private:
};
Shell *findShell(Shell *ignore = 0)
{
foreach (QWidget *widget, QApplication::topLevelWidgets())
{
Shell *s = qobject_cast<Shell*>(widget);
if (s && s != ignore)
return s;
}
return 0;
}
void MainShellTest::initTestCase()
{
// Don't pollute people's okular settings
Okular::Settings::instance( "mainshelltest" );
// Register in bus as okular
QDBusConnectionInterface *bus = QDBusConnection::sessionBus().interface();
const QString myPid = QString::number( getpid() );
const QString serviceName = "org.kde.okular-"+ myPid;
QVERIFY( bus->registerService(serviceName) == QDBusConnectionInterface::ServiceRegistered );
// Tell the presentationWidget to not be annoying
KSharedConfigPtr c = KGlobal::config();
KConfigGroup cg = c->group("Notification Messages");
cg.writeEntry("presentationInfo", false);
}
void MainShellTest::cleanupTestCase()
{
}
void MainShellTest::init()
{
// Default settings for every test
Okular::Settings::self()->setDefaults();
// Clean docdatas
QList<KUrl> urls;
urls << KUrl("file://" KDESRCDIR "data/file1.pdf");
urls << KUrl("file://" KDESRCDIR "data/tocreload.pdf");
urls << KUrl("file://" KDESRCDIR "data/contents.epub");
foreach (const KUrl &url, urls)
{
QFileInfo fileReadTest( url.toLocalFile() );
const QString docDataPath = Okular::DocumentPrivate::docDataFileName(url, fileReadTest.size());
QFile::remove(docDataPath);
}
}
void MainShellTest::cleanup()
{
Shell *s;
while ((s = findShell()))
{
delete s;
}
}
void MainShellTest::testShell_data()
{
QTest::addColumn<QStringList>("paths");
QTest::addColumn<QString>("serializedOptions");
QTest::addColumn<bool>("useTabs");
QTest::addColumn<QString>("externalProcessPath");
QTest::addColumn<uint>("expectedPage");
QTest::addColumn<bool>("expectPresentation");
QTest::addColumn<bool>("expectPrintDialog");
QTest::addColumn<bool>("unique");
QTest::addColumn<uint>("externalProcessExpectedPage");
QTest::addColumn<bool>("externalProcessExpectPresentation");
QTest::addColumn<bool>("externalProcessExpectPrintDialog");
const QStringList contentsEpub = QStringList(KDESRCDIR "data/contents.epub");
const QStringList file1 = QStringList(KDESRCDIR "data/file1.pdf");
QStringList file1AndToc;
file1AndToc << KDESRCDIR "data/file1.pdf";
file1AndToc << KDESRCDIR "data/tocreload.pdf";
const QString tocReload = KDESRCDIR "data/tocreload.pdf";
const QString optionsPage2 = ShellUtils::serializeOptions(false, false, false, false, "2");
const QString optionsPage2Presentation = ShellUtils::serializeOptions(true, false, false, false, "2");
const QString optionsPrint = ShellUtils::serializeOptions(false, true, false, false, QString());
const QString optionsUnique = ShellUtils::serializeOptions(false, false, true, false, QString());
QTest::newRow("just show shell") << QStringList() << QString() << false << QString() << 0u << false << false << false << 0u << false << false;
QTest::newRow("open file") << file1 << QString() << false << QString() << 0u << false << false << false << 0u << false << false;
QTest::newRow("two files no tabs") << file1AndToc << QString() << false << QString() << 0u << false << false << false << 0u << false << false;
QTest::newRow("two files with tabs") << file1AndToc << QString() << true << QString() << 0u << false << false << false << 0u << false << false;
QTest::newRow("two files sequence no tabs") << file1 << QString() << false << tocReload << 0u << false << false << false << 0u << false << false;
QTest::newRow("two files sequence with tabs") << file1 << QString() << true << tocReload << 0u << false << false << false << 0u << false << false;
QTest::newRow("open file page number") << contentsEpub << optionsPage2 << false << QString() << 1u << false << false << false << 0u << false << false;
QTest::newRow("open file page number and presentation") << contentsEpub << optionsPage2Presentation << false << QString() << 1u << true << false << false << 0u << false << false;
QTest::newRow("open file print") << file1 << optionsPrint << false << QString() << 0u << false << true << false << 0u << false << false;
QTest::newRow("open two files unique") << file1 << optionsUnique << false << tocReload << 0u << false << false << true << 0u << false << false;
QTest::newRow("open two files unique tabs") << file1 << optionsUnique << true << tocReload << 0u << false << false << true << 0u << false << false;
QTest::newRow("page number attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << false << false << 2u << false << false;
QTest::newRow("presentation attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << false << false << 2u << true << false;
QTest::newRow("print attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << true << false << 2u << false << true;
QTest::newRow("page number attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << true << 3u << false << false;
QTest::newRow("presentation attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << true << 2u << true << false;
QTest::newRow("print attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << true << 2u << false << true;
QTest::newRow("page number attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << true << 3u << false << false;
QTest::newRow("presentation attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << true << 2u << true << false;
QTest::newRow("print attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << true << 2u << false << true;
}
void MainShellTest::testShell()
{
QFETCH(QStringList, paths);
QFETCH(QString, serializedOptions);
QFETCH(bool, useTabs);
QFETCH(QString, externalProcessPath);
QFETCH(uint, expectedPage);
QFETCH(bool, expectPresentation);
QFETCH(bool, expectPrintDialog);
QFETCH(bool, unique);
QFETCH(uint, externalProcessExpectedPage);
QFETCH(bool, externalProcessExpectPresentation);
QFETCH(bool, externalProcessExpectPrintDialog);
QScopedPointer<ClosePrintDialogHelper> helper;
Okular::Settings::self()->setShellOpenFileInTabs(useTabs);
if (expectPrintDialog || externalProcessExpectPrintDialog) {
const int expectedTab = externalProcessExpectPrintDialog && !unique ? 1 : 0;
helper.reset(new ClosePrintDialogHelper(expectedTab));
QTimer::singleShot(0, helper.data(), SLOT(closePrintDialog()));
}
Okular::Status status = Okular::main(paths, serializedOptions);
QCOMPARE(status, Okular::Success);
Shell *s = findShell();
QVERIFY(s);
if (paths.count() == 1)
{
QCOMPARE(s->m_tabs.count(), 1);
Okular::Part *part = s->findChild<Okular::Part*>();
QVERIFY(part);
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
QCOMPARE(partDocument(part)->currentPage(), expectedPage);
}
else if (paths.count() == 2)
{
if (useTabs)
{
QSet<QString> openUrls;
Shell *s = findShell();
QVERIFY(s);
Okular::Part *part = dynamic_cast<Okular::Part*>(s->m_tabs[0].part);
Okular::Part *part2 = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
QCOMPARE(s->m_tabs.count(), 2);
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
QCOMPARE(part2->url().url(), QString("file://%1").arg(paths[1]));
QCOMPARE(partDocument(part)->currentPage(), expectedPage);
QCOMPARE(partDocument(part2)->currentPage(), expectedPage);
}
else
{
QSet<QString> openUrls;
Shell *s = findShell();
QVERIFY(s);
QCOMPARE(s->m_tabs.count(), 1);
Okular::Part *part = s->findChild<Okular::Part*>();
QVERIFY(part);
QCOMPARE(partDocument(part)->currentPage(), expectedPage);
openUrls << part->url().url();
Shell *s2 = findShell(s);
QVERIFY(s2);
QCOMPARE(s2->m_tabs.count(), 1);
Okular::Part *part2 = s2->findChild<Okular::Part*>();
QVERIFY(part2);
QCOMPARE(partDocument(part2)->currentPage(), expectedPage);
openUrls << part2->url().url();
foreach(const QString &path, paths)
{
QVERIFY(openUrls.contains(QString("file://%1").arg(path)));
}
}
}
if (!externalProcessPath.isEmpty())
{
Okular::Part *part = s->findChild<Okular::Part*>();
QProcess p;
QString command = "okular " + externalProcessPath;
if (unique)
command += " -unique";
if (externalProcessExpectedPage != 0)
command += QString(" -page %1").arg(externalProcessExpectedPage + 1);
if (externalProcessExpectPresentation)
command += QString(" -presentation");
if (externalProcessExpectPrintDialog)
command += QString(" -print");
p.start(command);
p.waitForStarted();
QCOMPARE(p.state(), QProcess::Running);
if (useTabs || unique)
{
// It is attaching to us, so will eventually stop
for (int i = 0; p.state() != QProcess::NotRunning && i < 20; ++i) {
QTest::qWait(100);
}
QCOMPARE(p.state(), QProcess::NotRunning);
QCOMPARE(p.exitStatus(), QProcess::NormalExit);
QCOMPARE(p.exitCode(), 0);
if (unique)
{
// It is unique so part got "overriten"
QCOMPARE(s->m_tabs.count(), 1);
QCOMPARE(part->url().url(), QString("file://%1").arg(externalProcessPath));
QCOMPARE(partDocument(part)->currentPage(), externalProcessExpectedPage);
}
else
{
// It is attaching to us so a second tab is there
QCOMPARE(s->m_tabs.count(), 2);
Okular::Part *part2 = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
QCOMPARE(part2->url().url(), QString("file://%1").arg(externalProcessPath));
QCOMPARE(partDocument(part2)->currentPage(), externalProcessExpectedPage);
}
}
else
{
QTest::qWait(750);
// It opened on a new process, so it is still running, we need to kill it
QCOMPARE(p.state(), QProcess::Running);
p.terminate();
p.waitForFinished();
QCOMPARE(p.exitCode(), 0);
// It opened on a new process, so no change for us
QCOMPARE(s->m_tabs.count(), 1);
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
QCOMPARE(partDocument(part)->currentPage(), externalProcessExpectedPage);
}
}
if (expectPresentation)
{
QCOMPARE(paths.count(), 1);
Okular::Part *part = s->findChild<Okular::Part*>();
// Oh Qt5 i want your QTRY_VERIFY
for (int i = 0; presentationWidget(part) == 0 && i < 20; ++i) {
QTest::qWait(100);
}
QVERIFY(presentationWidget(part) != 0);
}
if (externalProcessExpectPresentation)
{
Okular::Part *part;
if (unique)
{
QCOMPARE(s->m_tabs.count(), 1);
part = dynamic_cast<Okular::Part*>(s->m_tabs[0].part);
}
else
{
QCOMPARE(s->m_tabs.count(), 2);
part = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
}
for (int i = 0; presentationWidget(part) == 0 && i < 20; ++i) {
QTest::qWait(100);
}
QVERIFY(presentationWidget(part) != 0);
}
if (helper)
{
QVERIFY(helper->foundDialog);
}
}
void ClosePrintDialogHelper::closePrintDialog()
{
Shell *s = findShell();
QPrintDialog *dialog = s->findChild<QPrintDialog*>();
if (!dialog) {
QTimer::singleShot(0, this, SLOT(closePrintDialog()));
return;
}
QVERIFY(dialog);
QCOMPARE(MainShellTest::tabWidget(s)->currentIndex(), m_expectedTab);
dialog->close();
foundDialog = true;
}
void MainShellTest::testFileRemembersPagePosition_data()
{
QTest::addColumn<int>("mode");
QTest::newRow("normal") << 1;
QTest::newRow("unique") << 2;
QTest::newRow("tabs") << 3;
}
void MainShellTest::testFileRemembersPagePosition()
{
QFETCH(int, mode);
const QStringList paths = QStringList(KDESRCDIR "data/contents.epub");
QString serializedOptions;
if (mode == 1 || mode == 3)
serializedOptions = ShellUtils::serializeOptions(false, false, false, false, QString());
else
serializedOptions = ShellUtils::serializeOptions(false, false, true, false, QString());
Okular::Settings::self()->setShellOpenFileInTabs(mode == 3);
Okular::Status status = Okular::main(paths, serializedOptions);
QCOMPARE(status, Okular::Success);
Shell *s = findShell();
QVERIFY(s);
Okular::Part *part = s->findChild<Okular::Part*>();
QVERIFY(part);
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
QCOMPARE(partDocument(part)->currentPage(), 0u);
partDocument(part)->setViewportPage(3);
QCOMPARE(partDocument(part)->currentPage(), 3u);
s->closeUrl();
QCOMPARE(part->url().url(), QString());
if (mode == 1)
{
delete s;
status = Okular::main(paths, serializedOptions);
QCOMPARE(status, Okular::Success);
}
else
{
QProcess p;
QString command = "okular " + paths[0] ;
if (mode == 2)
command += " -unique";
p.start(command);
p.waitForStarted();
QCOMPARE(p.state(), QProcess::Running);
// It is attaching to us, so will eventually stop
for (int i = 0; p.state() != QProcess::NotRunning && i < 20; ++i) {
QTest::qWait(100);
}
QCOMPARE(p.state(), QProcess::NotRunning);
QCOMPARE(p.exitStatus(), QProcess::NormalExit);
QCOMPARE(p.exitCode(), 0);
}
s = findShell();
QVERIFY(s);
part = s->findChild<Okular::Part*>();
QVERIFY(part);
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
QCOMPARE(partDocument(part)->currentPage(), 3u);
}
void MainShellTest::test2FilesError_data()
{
QTest::addColumn<QString>("serializedOptions");
QTest::newRow("startInPresentation") << ShellUtils::serializeOptions(true, false, false, false, QString());
QTest::newRow("showPrintDialog") << ShellUtils::serializeOptions(false, true, false, false, QString());
QTest::newRow("unique") << ShellUtils::serializeOptions(false, false, true, false, QString());
QTest::newRow("pageNumger") << ShellUtils::serializeOptions(false, false, false, false, "3");
}
void MainShellTest::test2FilesError()
{
QFETCH(QString, serializedOptions);
QStringList paths;
paths << KDESRCDIR "data/file1.pdf" << KDESRCDIR "data/tocreload.pdf";
Okular::Status status = Okular::main(paths, serializedOptions);
QCOMPARE(status, Okular::Error);
QSet<QString> openUrls;
Shell *s = findShell();
QVERIFY(!s);
}
QTEST_KDEMAIN( MainShellTest, GUI )
#include "mainshelltest.moc"

View file

@ -319,7 +319,10 @@ PushButtonEdit::PushButtonEdit( Okular::FormFieldButton * button, QWidget * pare
setVisible( m_form->isVisible() );
setCursor( Qt::ArrowCursor );
connect( this, SIGNAL(clicked()), this, SLOT(slotClicked()) );
if ( !m_form->isReadOnly() )
{
connect( this, SIGNAL(clicked()), this, SLOT(slotClicked()) );
}
}
void PushButtonEdit::slotClicked()
@ -396,8 +399,11 @@ FormLineEdit::FormLineEdit( Okular::FormFieldText * text, QWidget * parent )
m_prevCursorPos = cursorPosition();
m_prevAnchorPos = cursorPosition();
connect( this, SIGNAL( textEdited( QString ) ), this, SLOT( slotChanged() ) );
connect( this, SIGNAL( cursorPositionChanged( int, int ) ), this, SLOT( slotChanged() ) );
if ( !m_form->isReadOnly() )
{
connect( this, SIGNAL( textEdited( QString ) ), this, SLOT( slotChanged() ) );
connect( this, SIGNAL( cursorPositionChanged( int, int ) ), this, SLOT( slotChanged() ) );
}
setVisible( m_form->isVisible() );
}
@ -510,12 +516,13 @@ TextAreaEdit::TextAreaEdit( Okular::FormFieldText * text, QWidget * parent )
setReadOnly( m_form->isReadOnly() );
setUndoRedoEnabled( false );
connect( this, SIGNAL( textChanged() ), this, SLOT( slotChanged() ) );
connect( this, SIGNAL( cursorPositionChanged() ), this, SLOT( slotChanged() ) );
connect( this, SIGNAL( aboutToShowContextMenu( QMenu* ) ),
this, SLOT( slotUpdateUndoAndRedoInContextMenu( QMenu* ) ) );
if ( !m_form->isReadOnly() )
{
connect( this, SIGNAL( textChanged() ), this, SLOT( slotChanged() ) );
connect( this, SIGNAL( cursorPositionChanged() ), this, SLOT( slotChanged() ) );
connect( this, SIGNAL( aboutToShowContextMenu( QMenu* ) ),
this, SLOT( slotUpdateUndoAndRedoInContextMenu( QMenu* ) ) );
}
m_prevCursorPos = textCursor().position();
m_prevAnchorPos = textCursor().anchor();
setVisible( m_form->isVisible() );
@ -622,8 +629,11 @@ FileEdit::FileEdit( Okular::FormFieldText * text, QWidget * parent )
m_prevCursorPos = lineEdit()->cursorPosition();
m_prevAnchorPos = lineEdit()->cursorPosition();
connect( this, SIGNAL( textChanged( QString ) ), this, SLOT( slotChanged() ) );
connect( lineEdit(), SIGNAL( cursorPositionChanged( int, int ) ), this, SLOT( slotChanged() ) );
if ( !m_form->isReadOnly() )
{
connect( this, SIGNAL( textChanged( QString ) ), this, SLOT( slotChanged() ) );
connect( lineEdit(), SIGNAL( cursorPositionChanged( int, int ) ), this, SLOT( slotChanged() ) );
}
setVisible( m_form->isVisible() );
}
@ -757,7 +767,10 @@ ListEdit::ListEdit( Okular::FormFieldChoice * choice, QWidget * parent )
}
setEnabled( !m_form->isReadOnly() );
connect( this, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectionChanged()) );
if ( !m_form->isReadOnly() )
{
connect( this, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectionChanged()) );
}
setVisible( m_form->isVisible() );
setCursor( Qt::ArrowCursor );
}
@ -816,9 +829,12 @@ ComboEdit::ComboEdit( Okular::FormFieldChoice * choice, QWidget * parent )
if ( m_form->isEditable() && !m_form->editChoice().isEmpty() )
lineEdit()->setText( m_form->editChoice() );
connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(slotValueChanged()) );
connect( this, SIGNAL(editTextChanged(QString)), this, SLOT(slotValueChanged()) );
connect( lineEdit(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(slotValueChanged()));
if ( !m_form->isReadOnly() )
{
connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(slotValueChanged()) );
connect( this, SIGNAL(editTextChanged(QString)), this, SLOT(slotValueChanged()) );
connect( lineEdit(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(slotValueChanged()) );
}
setVisible( m_form->isVisible() );
setCursor( Qt::ArrowCursor );

View file

@ -191,7 +191,7 @@ LatexRenderer::Error LatexRenderer::handleLatex( QString& fileName, const QStrin
bool LatexRenderer::securityCheck( const QString &latexFormula )
{
return !latexFormula.contains(QRegExp("\\\\(def|let|futurelet|newcommand|renewcomment|else|fi|write|input|include"
return !latexFormula.contains(QRegExp("\\\\(def|let|futurelet|newcommand|renewcommand|else|fi|write|input|include"
"|chardef|catcode|makeatletter|noexpand|toksdef|every|errhelp|errorstopmode|scrollmode|nonstopmode|batchmode"
"|read|csname|newhelp|relax|afterground|afterassignment|expandafter|noexpand|special|command|loop|repeat|toks"
"|output|line|mathcode|name|item|section|mbox|DeclareRobustCommand)[^a-zA-Z]"));

View file

@ -576,7 +576,7 @@ void PageView::setupActions( KActionCollection * ac )
d->aMouseTextSelect->setActionGroup( d->mouseModeActionGroup );
d->aMouseTextSelect->setChecked( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::TextSelect );
d->aMouseTableSelect = new KAction(KIcon( "select-table" ), i18n("T&able Selection Tool"), this);
d->aMouseTableSelect = new KAction(KIcon( "table" ), i18n("T&able Selection Tool"), this);
ac->addAction("mouse_tableselect", d->aMouseTableSelect );
connect( d->aMouseTableSelect, SIGNAL( triggered() ), this, SLOT( slotSetMouseTableSelect() ) );
d->aMouseTableSelect->setIconText( i18nc( "Table Selection Tool", "Table Selection" ) );
@ -585,7 +585,7 @@ void PageView::setupActions( KActionCollection * ac )
d->aMouseTableSelect->setActionGroup( d->mouseModeActionGroup );
d->aMouseTableSelect->setChecked( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::TableSelect );
d->aMouseMagnifier = new KAction(KIcon( "magnifier" ), i18n("&Magnifier"), this);
d->aMouseMagnifier = new KAction(KIcon( "document-preview" ), i18n("&Magnifier"), this);
ac->addAction("mouse_magnifier", d->aMouseMagnifier );
connect( d->aMouseMagnifier, SIGNAL(triggered()), this, SLOT(slotSetMouseMagnifier()) );
d->aMouseMagnifier->setIconText( i18nc( "Magnifier Tool", "Magnifier" ) );
@ -1205,10 +1205,6 @@ void PageView::slotRealNotifyViewportChanged( bool smoothMove )
// enable setViewport calls
d->blockViewport = false;
// update zoom text if in a ZoomFit/* zoom mode
if ( d->zoomMode != ZoomFixed )
updateZoomText();
if( viewport() )
{
viewport()->update();
@ -1343,6 +1339,10 @@ void PageView::notifyCurrentPageChanged( int previous, int current )
Q_FOREACH ( VideoWidget *videoWidget, item->videoWidgets() )
videoWidget->pageEntered();
}
// update zoom text and factor if in a ZoomFit/* zoom mode
if ( d->zoomMode != ZoomFixed )
updateZoomText();
}
}
@ -1647,7 +1647,7 @@ void PageView::resizeEvent( QResizeEvent *e )
return;
}
if ( ( d->zoomMode == ZoomFitWidth || d->zoomMode == ZoomFitAuto ) && d->verticalScrollBarVisible && !verticalScrollBar()->isVisible() && qAbs(e->oldSize().height() - e->size().height()) < verticalScrollBar()->width() )
if ( ( d->zoomMode == ZoomFitWidth || d->zoomMode == ZoomFitAuto ) && !verticalScrollBar()->isVisible() && qAbs(e->oldSize().height() - e->size().height()) < verticalScrollBar()->width() && d->verticalScrollBarVisible )
{
// this saves us from infinite resizing loop because of scrollbars appearing and disappearing
// see bug 160628 for more info
@ -1657,7 +1657,7 @@ void PageView::resizeEvent( QResizeEvent *e )
resizeContentArea( e->size() );
return;
}
else if ( d->zoomMode == ZoomFitAuto && d->horizontalScrollBarVisible && !horizontalScrollBar()->isVisible() && qAbs(e->oldSize().width() - e->size().width()) < horizontalScrollBar()->height() )
else if ( d->zoomMode == ZoomFitAuto && !horizontalScrollBar()->isVisible() && qAbs(e->oldSize().width() - e->size().width()) < horizontalScrollBar()->height() && d->horizontalScrollBarVisible )
{
// this saves us from infinite resizing loop because of scrollbars appearing and disappearing
// TODO looks are still a bit ugly because things are left uncentered
@ -3384,7 +3384,8 @@ void PageView::updateItemSize( PageViewItem * item, int colWidth, int rowHeight
height = ( height / width ) * colWidth;
zoom = (double)colWidth / width;
item->setWHZC( colWidth, (int)height, zoom, crop );
d->zoomFactor = zoom;
if ((uint)item->pageNumber() == d->document->currentPage())
d->zoomFactor = zoom;
}
else if ( d->zoomMode == ZoomFitPage )
{
@ -3392,7 +3393,8 @@ void PageView::updateItemSize( PageViewItem * item, int colWidth, int rowHeight
const double scaleH = (double)rowHeight / (double)height;
zoom = qMin( scaleW, scaleH );
item->setWHZC( (int)(zoom * width), (int)(zoom * height), zoom, crop );
d->zoomFactor = zoom;
if ((uint)item->pageNumber() == d->document->currentPage())
d->zoomFactor = zoom;
}
else if ( d->zoomMode == ZoomFitAuto )
{
@ -3420,7 +3422,8 @@ void PageView::updateItemSize( PageViewItem * item, int colWidth, int rowHeight
zoom = qMin( scaleW, scaleH );
}
item->setWHZC( (int)(zoom * width), (int)(zoom * height), zoom, crop );
d->zoomFactor = zoom;
if ((uint)item->pageNumber() == d->document->currentPage())
d->zoomFactor = zoom;
}
#ifndef NDEBUG
else
@ -3663,10 +3666,14 @@ void PageView::updateZoom( ZoomMode newZoomMode )
QVector<float>::iterator i;
if ( newZoomMode == ZoomOut )
{
if (newFactor <= zoomValue.first())
return;
i = qLowerBound(zoomValue.begin(), zoomValue.end(), newFactor) - 1;
}
else
{
if (newFactor >= zoomValue.last())
return;
i = qUpperBound(zoomValue.begin(), zoomValue.end(), newFactor);
}
const float tmpFactor = *i;

View file

@ -353,14 +353,11 @@ void PresentationWidget::notifySetup( const QVector< Okular::Page * > & pageSet,
// get metadata from the document
m_metaStrings.clear();
const Okular::DocumentInfo * info = m_document->documentInfo();
if ( info )
{
if ( !info->get( "title" ).isNull() )
m_metaStrings += i18n( "Title: %1", info->get( "title" ) );
if ( !info->get( "author" ).isNull() )
m_metaStrings += i18n( "Author: %1", info->get( "author" ) );
}
const Okular::DocumentInfo info = m_document->documentInfo( QSet<Okular::DocumentInfo::Key>() << Okular::DocumentInfo::Title << Okular::DocumentInfo::Author );
if ( !info.get( Okular::DocumentInfo::Title ).isNull() )
m_metaStrings += i18n( "Title: %1", info.get( Okular::DocumentInfo::Title ) );
if ( !info.get( Okular::DocumentInfo::Author ).isNull() )
m_metaStrings += i18n( "Author: %1", info.get( Okular::DocumentInfo::Author ) );
m_metaStrings += i18n( "Pages: %1", m_document->pages() );
m_metaStrings += i18n( "Click to begin" );

View file

@ -41,71 +41,55 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
m_fontModel( 0 ), m_fontInfo( 0 ), m_fontProgressBar( 0 ),
m_fontScanStarted( false )
{
setFaceType( Tabbed );
setCaption( i18n( "Unknown File" ) );
setButtons( Ok );
setFaceType( Tabbed );
setCaption( i18n( "Unknown File" ) );
setButtons( Ok );
// PROPERTIES
QFrame *page = new QFrame();
KPageWidgetItem *item = addPage( page, i18n( "&Properties" ) );
item->setIcon( KIcon( "document-properties" ) );
// PROPERTIES
QFrame *page = new QFrame();
KPageWidgetItem *item = addPage( page, i18n( "&Properties" ) );
item->setIcon( KIcon( "document-properties" ) );
// get document info, if not present display blank data and a warning
const Okular::DocumentInfo * info = doc->documentInfo();
if ( !info ) {
QVBoxLayout *layout = new QVBoxLayout( page );
layout->addWidget( new QLabel( i18n( "No document opened." ), page ) );
return;
}
// get document info
const Okular::DocumentInfo info = doc->documentInfo();
QFormLayout *layout = new QFormLayout( page );
QFormLayout *layout = new QFormLayout( page );
// mime name based on mimetype id
QString mimeName = info.get( Okular::DocumentInfo::MimeType ).section( '/', -1 ).toUpper();
setCaption( i18n( "%1 Properties", mimeName ) );
// mime name based on mimetype id
QString mimeName = info->get( "mimeType" ).section( '/', -1 ).toUpper();
setCaption( i18n( "%1 Properties", mimeName ) );
int valMaxWidth = 100;
QDomElement docElement = info->documentElement();
int valMaxWidth = 100;
/* obtains the properties list, conveniently ordered */
QStringList orderedProperties;
orderedProperties << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::FilePath )
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::PagesSize )
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::DocumentSize );
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
ks <= Okular::DocumentInfo::Keywords;
ks = Okular::DocumentInfo::Key( ks+1 ) ) {
orderedProperties << Okular::DocumentInfo::getKeyString( ks );
}
for ( QDomNode node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
const QDomElement element = node.toElement();
const QString titleString = element.attribute( "title" );
const QString valueString = element.attribute( "value" );
if ( titleString.isEmpty() || valueString.isEmpty() )
continue;
if ( !orderedProperties.contains( element.tagName() ) ) {
orderedProperties << element.tagName();
/* obtains the properties list, conveniently ordered */
QStringList orderedProperties;
orderedProperties << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::FilePath )
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::PagesSize )
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::DocumentSize );
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
ks <= Okular::DocumentInfo::Keywords;
ks = Okular::DocumentInfo::Key( ks+1 ) )
{
orderedProperties << Okular::DocumentInfo::getKeyString( ks );
}
foreach( const QString &ks, info.keys()) {
if ( !orderedProperties.contains( ks ) ) {
orderedProperties << ks;
}
}
}
QDomNodeList list;
for ( QStringList::Iterator it = orderedProperties.begin();
it != orderedProperties.end(); ++it ) {
list = docElement.elementsByTagName( (*it) );
if ( list.count() == 1 ) {
QDomElement element = list.at(0).toElement();
const QString titleString = element.attribute( "title" );
const QString valueString = element.attribute( "value" );
if ( titleString.isEmpty() || valueString.isEmpty() )
for ( QStringList::Iterator it = orderedProperties.begin();
it != orderedProperties.end();
++it )
{
const QString key = *it;
const QString titleString = info.getKeyTitle( key );
const QString valueString = info.get( key );
if ( titleString.isNull() || valueString.isNull() )
continue;
// create labels and layout them
QWidget *value = NULL;
if ( element.tagName() == Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::MimeType ) ) {
if ( key == Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::MimeType ) ) {
/// for mime type fields, show icon as well
value = new QWidget( page );
/// place icon left of mime type's name
@ -138,53 +122,52 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
// refine maximum width of 'value' labels
valMaxWidth = qMax( valMaxWidth, fontMetrics().width( valueString ) );
}
}
// FONTS
QVBoxLayout *page2Layout = 0;
if ( doc->canProvideFontInformation() ) {
// create fonts tab and layout it
QFrame *page2 = new QFrame();
m_fontPage = addPage(page2, i18n("&Fonts"));
m_fontPage->setIcon( KIcon( "preferences-desktop-font" ) );
page2Layout = new QVBoxLayout(page2);
page2Layout->setMargin(marginHint());
page2Layout->setSpacing(spacingHint());
// add a tree view
QTreeView *view = new QTreeView(page2);
view->setContextMenuPolicy(Qt::CustomContextMenu);
connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showFontsMenu(QPoint)));
page2Layout->addWidget(view);
view->setRootIsDecorated(false);
view->setAlternatingRowColors(true);
view->setSortingEnabled( true );
// creating a proxy model so we can sort the data
QSortFilterProxyModel *proxymodel = new QSortFilterProxyModel(view);
proxymodel->setDynamicSortFilter( true );
proxymodel->setSortCaseSensitivity( Qt::CaseInsensitive );
m_fontModel = new FontsListModel(view);
proxymodel->setSourceModel(m_fontModel);
view->setModel(proxymodel);
view->sortByColumn( 0, Qt::AscendingOrder );
m_fontInfo = new QLabel( this );
page2Layout->addWidget( m_fontInfo );
m_fontInfo->setText( i18n( "Reading font information..." ) );
m_fontInfo->hide();
m_fontProgressBar = new QProgressBar( this );
page2Layout->addWidget( m_fontProgressBar );
m_fontProgressBar->setRange( 0, 100 );
m_fontProgressBar->setValue( 0 );
m_fontProgressBar->hide();
}
// FONTS
QVBoxLayout *page2Layout = 0;
if ( doc->canProvideFontInformation() ) {
// create fonts tab and layout it
QFrame *page2 = new QFrame();
m_fontPage = addPage(page2, i18n("&Fonts"));
m_fontPage->setIcon( KIcon( "preferences-desktop-font" ) );
page2Layout = new QVBoxLayout(page2);
page2Layout->setMargin(marginHint());
page2Layout->setSpacing(spacingHint());
// add a tree view
QTreeView *view = new QTreeView(page2);
view->setContextMenuPolicy(Qt::CustomContextMenu);
connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showFontsMenu(QPoint)));
page2Layout->addWidget(view);
view->setRootIsDecorated(false);
view->setAlternatingRowColors(true);
view->setSortingEnabled( true );
// creating a proxy model so we can sort the data
QSortFilterProxyModel *proxymodel = new QSortFilterProxyModel(view);
proxymodel->setDynamicSortFilter( true );
proxymodel->setSortCaseSensitivity( Qt::CaseInsensitive );
m_fontModel = new FontsListModel(view);
proxymodel->setSourceModel(m_fontModel);
view->setModel(proxymodel);
view->sortByColumn( 0, Qt::AscendingOrder );
m_fontInfo = new QLabel( this );
page2Layout->addWidget( m_fontInfo );
m_fontInfo->setText( i18n( "Reading font information..." ) );
m_fontInfo->hide();
m_fontProgressBar = new QProgressBar( this );
page2Layout->addWidget( m_fontProgressBar );
m_fontProgressBar->setRange( 0, 100 );
m_fontProgressBar->setValue( 0 );
m_fontProgressBar->hide();
}
// current width: left columnt + right column + dialog borders
int width = layout->minimumSize().width() + valMaxWidth + 2 * marginHint() + spacingHint() + 30;
if ( page2Layout )
width = qMax( width, page2Layout->sizeHint().width() + marginHint() + spacingHint() + 31 );
// stay inside the 2/3 of the screen width
QRect screenContainer = KGlobalSettings::desktopGeometry( this );
width = qMin( width, 2*screenContainer.width()/3 );
resize(width, 1);
// current width: left columnt + right column + dialog borders
int width = layout->minimumSize().width() + valMaxWidth + 2 * marginHint() + spacingHint() + 30;
if ( page2Layout )
width = qMax( width, page2Layout->sizeHint().width() + marginHint() + spacingHint() + 31 );
// stay inside the 2/3 of the screen width
QRect screenContainer = KGlobalSettings::desktopGeometry( this );
width = qMin( width, 2*screenContainer.width()/3 );
resize(width, 1);
connect( pageWidget(), SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)),
this, SLOT(pageChanged(KPageWidgetItem*,KPageWidgetItem*)) );