mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-03 22:54:31 +00:00
Add support for custom generator about data (and potentially for custom configuration).
svn path=/trunk/playground/graphics/okular/; revision=640348
This commit is contained in:
parent
9c27194383
commit
fd7434c95a
|
@ -2158,6 +2158,11 @@ QStringList Document::supportedMimeTypes() const
|
|||
return d->m_supportedMimeTypes;
|
||||
}
|
||||
|
||||
const KComponentData* Document::componentData() const
|
||||
{
|
||||
return d->m_generator ? d->m_generator->componentData() : 0;
|
||||
}
|
||||
|
||||
void Document::requestDone( PixmapRequest * req )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <kmimetype.h>
|
||||
|
||||
class KComponentData;
|
||||
class KBookmark;
|
||||
class KConfigDialog;
|
||||
class KPrinter;
|
||||
|
@ -449,6 +450,11 @@ class OKULAR_EXPORT Document : public QObject
|
|||
*/
|
||||
QStringList supportedMimeTypes() const;
|
||||
|
||||
/**
|
||||
* Returns the component data associated with the generator. May be null.
|
||||
*/
|
||||
const KComponentData* componentData() const;
|
||||
|
||||
/**
|
||||
* This method is used by the generators to signal the finish of
|
||||
* the pixmap generation @p request.
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <qset.h>
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <kcomponentdata.h>
|
||||
#include <kdebug.h>
|
||||
#include <kicon.h>
|
||||
|
||||
|
@ -24,6 +26,7 @@ class Generator::Private
|
|||
public:
|
||||
Private( Generator *parent )
|
||||
: m_document( 0 ),
|
||||
m_about( 0 ), m_componentData( 0 ),
|
||||
m_generator( parent ),
|
||||
mPixmapGenerationThread( 0 ),
|
||||
mTextPageGenerationThread( 0 ),
|
||||
|
@ -43,6 +46,10 @@ class Generator::Private
|
|||
mTextPageGenerationThread->wait();
|
||||
|
||||
delete mTextPageGenerationThread;
|
||||
|
||||
// first delete the component data, then the about
|
||||
delete m_componentData;
|
||||
delete m_about;
|
||||
}
|
||||
|
||||
void createPixmapGenerationThread();
|
||||
|
@ -53,6 +60,8 @@ class Generator::Private
|
|||
|
||||
Document * m_document;
|
||||
QSet< GeneratorFeature > m_features;
|
||||
KAboutData* m_about;
|
||||
KComponentData* m_componentData;
|
||||
Generator *m_generator;
|
||||
PixmapGenerationThread *mPixmapGenerationThread;
|
||||
TextPageGenerationThread *mTextPageGenerationThread;
|
||||
|
@ -261,6 +270,10 @@ bool Generator::hasFeature( GeneratorFeature feature ) const
|
|||
return d->m_features.contains( feature );
|
||||
}
|
||||
|
||||
const KComponentData* Generator::componentData() const
|
||||
{
|
||||
return d->m_componentData;
|
||||
}
|
||||
|
||||
void Generator::signalPixmapRequestDone( PixmapRequest * request )
|
||||
{
|
||||
|
@ -283,6 +296,14 @@ void Generator::setFeature( GeneratorFeature feature, bool on )
|
|||
d->m_features.remove( feature );
|
||||
}
|
||||
|
||||
void Generator::setAboutData( KAboutData* data )
|
||||
{
|
||||
delete d->m_componentData;
|
||||
delete d->m_about;
|
||||
d->m_about = data;
|
||||
d->m_componentData = d->m_about ? new KComponentData( d->m_about ) : 0;
|
||||
}
|
||||
|
||||
|
||||
class PixmapRequest::Private
|
||||
{
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
OKULAR_EXPORT Okular::Generator* create_plugin() { return new classname(); } \
|
||||
}
|
||||
|
||||
class KAboutData;
|
||||
class KComponentData;
|
||||
class KIcon;
|
||||
class KPrinter;
|
||||
class kdbgstream;
|
||||
|
@ -316,6 +318,11 @@ class OKULAR_EXPORT Generator : public QObject
|
|||
*/
|
||||
bool hasFeature( GeneratorFeature feature ) const;
|
||||
|
||||
/**
|
||||
* Returns the component data associated with the generator. May be null.
|
||||
*/
|
||||
const KComponentData* componentData() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal should be emitted whenever an error occurred in the generator.
|
||||
|
@ -375,6 +382,25 @@ class OKULAR_EXPORT Generator : public QObject
|
|||
*/
|
||||
void setFeature( GeneratorFeature feature, bool on = true );
|
||||
|
||||
/**
|
||||
* Sets a new about @p data for the generator. The base generator
|
||||
* class will take ownership of the data.
|
||||
*
|
||||
* Create it on the heap (\b never on the stack!), and fill it with
|
||||
* data like:
|
||||
* @code
|
||||
KAboutData *about = new KAboutData(
|
||||
"generator_foo", // we reccomend to use okular_xxx for the component name
|
||||
I18N_NOOP( "Foo Backend" ), "0.1",
|
||||
I18N_NOOP( "A foo backend" ),
|
||||
KAboutData::License_GPL,
|
||||
I18N_NOOP( "Copyright (c) 2007 Developer" ) );
|
||||
about->addAuthor( "Joe Developer", I18N_NOOP( "Developer" ), " joe@host.com" );
|
||||
setAboutData( about );
|
||||
* @endcode
|
||||
*/
|
||||
void setAboutData( KAboutData* data );
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* const d;
|
||||
|
|
30
part.cpp
30
part.cpp
|
@ -28,6 +28,7 @@
|
|||
#include <qlabel.h>
|
||||
#include <kvbox.h>
|
||||
#include <qtoolbox.h>
|
||||
#include <kaboutapplicationdialog.h>
|
||||
#include <kaction.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <kdirwatch.h>
|
||||
|
@ -379,6 +380,10 @@ m_searchStarted(false), m_cliPresentation(false)
|
|||
m_exportAsText = menu->addAction( KIcon( "text" ), i18n( "Text..." ) );
|
||||
m_exportAsText->setEnabled( false );
|
||||
|
||||
m_aboutBackend = ac->addAction("help_about_backend");
|
||||
m_aboutBackend->setText(i18n("About backend..."));
|
||||
connect(m_aboutBackend, SIGNAL(triggered()), this, SLOT(slotAboutBackend()));
|
||||
|
||||
// attach the actions of the children widgets too
|
||||
m_pageView->setupActions( ac );
|
||||
m_formsMessage->setActionButton( m_pageView->toggleFormsAction() );
|
||||
|
@ -513,6 +518,7 @@ void Part::notifySetup( const QVector< Okular::Page * > & /*pages*/, bool docume
|
|||
return;
|
||||
|
||||
rebuildBookmarkMenu();
|
||||
updateAboutBackendAction();
|
||||
}
|
||||
|
||||
void Part::notifyViewportChanged( bool /*smoothMove*/ )
|
||||
|
@ -1295,6 +1301,17 @@ void Part::slotHidePresentation()
|
|||
}
|
||||
|
||||
|
||||
void Part::slotAboutBackend()
|
||||
{
|
||||
const KComponentData *data = m_document->componentData();
|
||||
if ( !data )
|
||||
return;
|
||||
|
||||
KAboutApplicationDialog dlg( data->aboutData(), widget() );
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
|
||||
void Part::slotExportAs(QAction * act)
|
||||
{
|
||||
QList<QAction*> acts = m_exportAs->menu() ? m_exportAs->menu()->actions() : QList<QAction*>();
|
||||
|
@ -1563,6 +1580,19 @@ void Part::rebuildBookmarkMenu( bool unplugActions )
|
|||
m_nextBookmark->setEnabled( havebookmarks );
|
||||
}
|
||||
|
||||
void Part::updateAboutBackendAction()
|
||||
{
|
||||
const KComponentData *data = m_document->componentData();
|
||||
if ( data )
|
||||
{
|
||||
m_aboutBackend->setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aboutBackend->setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* BrowserExtension class
|
||||
|
|
3
part.h
3
part.h
|
@ -135,6 +135,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
|
|||
void slotHidePresentation();
|
||||
void slotExportAs(QAction *);
|
||||
bool slotImportPSFile();
|
||||
void slotAboutBackend();
|
||||
void close();
|
||||
void cannotQuit();
|
||||
void splitterMoved( int pos, int index );
|
||||
|
@ -158,6 +159,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
|
|||
void doPrint( KPrinter& printer );
|
||||
bool handleCompressed(KUrl & url, const QString &path, const KMimeType::Ptr mimetype);
|
||||
void rebuildBookmarkMenu( bool unplugActions = true );
|
||||
void updateAboutBackendAction();
|
||||
KTemporaryFile *m_tempfile;
|
||||
|
||||
// the document
|
||||
|
@ -214,6 +216,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
|
|||
KToggleAction* m_showMenuBarAction;
|
||||
KToggleAction* m_showLeftPanel;
|
||||
KToggleFullScreenAction* m_showFullScreenAction;
|
||||
QAction *m_aboutBackend;
|
||||
|
||||
bool m_actionsSearched;
|
||||
bool m_searchStarted;
|
||||
|
|
Loading…
Reference in a new issue