mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-03 22:54:31 +00:00
Cleanup a bit the GuiInterface, and making it work.
Instead of manually requestion actions and other stuff, we just make the interface as gui client, requesting and integrating it in the part gui. Also, rename the Generator's componentData() to ownComponentData() to avoid clashing with KXMLGUIClient. svn path=/trunk/KDE/kdegraphics/okular/; revision=705933
This commit is contained in:
parent
17e6bdfcfd
commit
a8d747745f
|
@ -542,8 +542,9 @@ Generator * DocumentPrivate::loadGeneratorLibrary( const QString& name, const QS
|
||||||
GeneratorInfo info;
|
GeneratorInfo info;
|
||||||
info.generator = generator;
|
info.generator = generator;
|
||||||
info.library = lib;
|
info.library = lib;
|
||||||
if ( generator->componentData() && generator->componentData()->aboutData() )
|
const KComponentData* compData = m_parent->componentData();
|
||||||
info.catalogName = generator->componentData()->aboutData()->catalogName();
|
if ( compData && compData->aboutData() )
|
||||||
|
info.catalogName = compData->aboutData()->catalogName();
|
||||||
m_loadedGenerators.insert( name, info );
|
m_loadedGenerators.insert( name, info );
|
||||||
return generator;
|
return generator;
|
||||||
}
|
}
|
||||||
|
@ -1343,25 +1344,15 @@ bool Document::openDocument( const QString & docFile, const KUrl& url, const KMi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Document::xmlFile() const
|
KXMLGUIClient* Document::guiClient()
|
||||||
{
|
{
|
||||||
if ( d->m_generator )
|
if ( d->m_generator )
|
||||||
{
|
|
||||||
Okular::GuiInterface * iface = qobject_cast< Okular::GuiInterface * >( d->m_generator );
|
|
||||||
return iface ? iface->xmlFile() : QString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Document::setupGui( KActionCollection *ac, QToolBox *tBox )
|
|
||||||
{
|
|
||||||
if ( d->m_generator && ac && tBox )
|
|
||||||
{
|
{
|
||||||
Okular::GuiInterface * iface = qobject_cast< Okular::GuiInterface * >( d->m_generator );
|
Okular::GuiInterface * iface = qobject_cast< Okular::GuiInterface * >( d->m_generator );
|
||||||
if ( iface )
|
if ( iface )
|
||||||
iface->setupGui( ac, tBox );
|
return iface->guiClient();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::closeDocument()
|
void Document::closeDocument()
|
||||||
|
@ -1389,9 +1380,6 @@ void Document::closeDocument()
|
||||||
|
|
||||||
if ( d->m_generator )
|
if ( d->m_generator )
|
||||||
{
|
{
|
||||||
Okular::GuiInterface * iface = qobject_cast< Okular::GuiInterface * >( d->m_generator );
|
|
||||||
if ( iface )
|
|
||||||
iface->freeGui();
|
|
||||||
// disconnect the generator from this document ...
|
// disconnect the generator from this document ...
|
||||||
d->m_generator->d->m_document = 0;
|
d->m_generator->d->m_document = 0;
|
||||||
// .. and this document from the generator signals
|
// .. and this document from the generator signals
|
||||||
|
@ -2590,7 +2578,7 @@ QStringList Document::supportedMimeTypes() const
|
||||||
|
|
||||||
const KComponentData* Document::componentData() const
|
const KComponentData* Document::componentData() const
|
||||||
{
|
{
|
||||||
return d->m_generator ? d->m_generator->componentData() : 0;
|
return d->m_generator ? d->m_generator->ownComponentData() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::requestDone( PixmapRequest * req )
|
void Document::requestDone( PixmapRequest * req )
|
||||||
|
|
|
@ -26,11 +26,10 @@
|
||||||
class KComponentData;
|
class KComponentData;
|
||||||
class KBookmark;
|
class KBookmark;
|
||||||
class KConfigDialog;
|
class KConfigDialog;
|
||||||
|
class KXMLGUIClient;
|
||||||
class KPrinter;
|
class KPrinter;
|
||||||
class KPrintDialogPage;
|
class KPrintDialogPage;
|
||||||
class KUrl;
|
class KUrl;
|
||||||
class KActionCollection;
|
|
||||||
class QToolBox;
|
|
||||||
|
|
||||||
namespace Okular {
|
namespace Okular {
|
||||||
|
|
||||||
|
@ -279,16 +278,9 @@ class OKULAR_EXPORT Document : public QObject
|
||||||
QString pageSizeString( int page ) const;
|
QString pageSizeString( int page ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the gui description file of the document that shall be merged with
|
* Returns the gui client of the generator, if it provides one.
|
||||||
* Okulars menu/tool bar.
|
|
||||||
*/
|
*/
|
||||||
QString xmlFile() const;
|
KXMLGUIClient* guiClient();
|
||||||
|
|
||||||
/**
|
|
||||||
* Calling this method allows the document to add custom actions to the gui
|
|
||||||
* and extend Okulars side pane via @p toolbox.
|
|
||||||
*/
|
|
||||||
void setupGui( KActionCollection *collection, QToolBox *toolbox );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current document viewport to the given @p page.
|
* Sets the current document viewport to the given @p page.
|
||||||
|
|
|
@ -232,7 +232,7 @@ bool Generator::hasFeature( GeneratorFeature feature ) const
|
||||||
return d->m_features.contains( feature );
|
return d->m_features.contains( feature );
|
||||||
}
|
}
|
||||||
|
|
||||||
const KComponentData* Generator::componentData() const
|
const KComponentData* Generator::ownComponentData() const
|
||||||
{
|
{
|
||||||
return d->m_componentData;
|
return d->m_componentData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,7 +351,7 @@ class OKULAR_EXPORT Generator : public QObject
|
||||||
/**
|
/**
|
||||||
* Returns the component data associated with the generator. May be null.
|
* Returns the component data associated with the generator. May be null.
|
||||||
*/
|
*/
|
||||||
const KComponentData* componentData() const;
|
const KComponentData* ownComponentData() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
class QToolBox;
|
#include <kxmlguiclient.h>
|
||||||
class KActionCollection;
|
|
||||||
|
|
||||||
namespace Okular {
|
namespace Okular {
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ namespace Okular {
|
||||||
* @endcode
|
* @endcode
|
||||||
* and - of course - implementing its methods.
|
* and - of course - implementing its methods.
|
||||||
*/
|
*/
|
||||||
class OKULAR_EXPORT GuiInterface
|
class OKULAR_EXPORT GuiInterface : protected KXMLGUIClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -46,28 +45,9 @@ class OKULAR_EXPORT GuiInterface
|
||||||
virtual ~GuiInterface() {}
|
virtual ~GuiInterface() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the gui description file that shall
|
* This method requests the XML GUI Client provided by the interface.
|
||||||
* be merged with the Okular menu.
|
|
||||||
*/
|
*/
|
||||||
virtual QString xmlFile() const = 0;
|
KXMLGUIClient* guiClient() { return this; }
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called when the Okular gui is set up.
|
|
||||||
*
|
|
||||||
* You can insert the action which are listed in the file returned by
|
|
||||||
* @p xmlFile() into the given @p collection to make them appear in the
|
|
||||||
* menu bar.
|
|
||||||
*
|
|
||||||
* The @p toolbox pointer allows you to add new custom widgets to Okulars left
|
|
||||||
* side pane.
|
|
||||||
*/
|
|
||||||
virtual void setupGui( KActionCollection *collection, QToolBox *toolbox ) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called when the Okular gui is cleaned up.
|
|
||||||
* You should free all the gui elements created in @p setupGui() here.
|
|
||||||
*/
|
|
||||||
virtual void freeGui() = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
11
part.cpp
11
part.cpp
|
@ -120,7 +120,7 @@ QObject *parent,
|
||||||
const QStringList &args )
|
const QStringList &args )
|
||||||
: KParts::ReadOnlyPart(parent),
|
: KParts::ReadOnlyPart(parent),
|
||||||
m_tempfile( 0 ), m_showMenuBarAction( 0 ), m_showFullScreenAction( 0 ), m_actionsSearched( false ),
|
m_tempfile( 0 ), m_showMenuBarAction( 0 ), m_showFullScreenAction( 0 ), m_actionsSearched( false ),
|
||||||
m_searchStarted(false), m_cliPresentation(false)
|
m_searchStarted(false), m_cliPresentation(false), m_generatorGuiClient(0)
|
||||||
{
|
{
|
||||||
// first necessary step: copy the configuration from kpdf, if available
|
// first necessary step: copy the configuration from kpdf, if available
|
||||||
QString newokularconffile = KStandardDirs::locateLocal( "config", "okularpartrc" );
|
QString newokularconffile = KStandardDirs::locateLocal( "config", "okularpartrc" );
|
||||||
|
@ -793,9 +793,9 @@ bool Part::openFile()
|
||||||
m_cliPresentation = false;
|
m_cliPresentation = false;
|
||||||
QMetaObject::invokeMethod(this, "slotShowPresentation", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "slotShowPresentation", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
/* if (m_document->getXMLFile() != QString())
|
m_generatorGuiClient = factory() ? m_document->guiClient() : 0;
|
||||||
setXMLFile(m_document->getXMLFile(),true);*/
|
if ( m_generatorGuiClient )
|
||||||
m_document->setupGui( actionCollection(), 0 );
|
factory()->addClient( m_generatorGuiClient );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,6 +847,9 @@ bool Part::closeUrl()
|
||||||
m_searchStarted = false;
|
m_searchStarted = false;
|
||||||
m_realUrl = KUrl();
|
m_realUrl = KUrl();
|
||||||
if (!localFilePath().isEmpty()) m_watcher->removeFile(localFilePath());
|
if (!localFilePath().isEmpty()) m_watcher->removeFile(localFilePath());
|
||||||
|
if ( m_generatorGuiClient )
|
||||||
|
factory()->removeClient( m_generatorGuiClient );
|
||||||
|
m_generatorGuiClient = 0;
|
||||||
m_document->closeDocument();
|
m_document->closeDocument();
|
||||||
updateViewActions();
|
updateViewActions();
|
||||||
m_searchWidget->clearText();
|
m_searchWidget->clearText();
|
||||||
|
|
Loading…
Reference in a new issue