Commit 5387c509 authored by Pino Toscano's avatar Pino Toscano

Make the Configure backends dialog working, of course if the generators have...

Make the Configure backends dialog working, of course if the generators have the proper support for "mutable" configuration.

svn path=/trunk/KDE/kdegraphics/okular/; revision=687065
parent 65920e10
......@@ -104,6 +104,10 @@ struct GeneratorInfo
QMap< int, DocumentObserver * >::const_iterator it=d->m_observers.begin(), end=d->m_observers.end();\
for ( ; it != end ; ++ it ) { (*it)-> cmd ; } }
#define foreachObserverD( cmd ) {\
QMap< int, DocumentObserver * >::const_iterator it = m_observers.begin(), end = m_observers.end();\
for ( ; it != end ; ++ it ) { (*it)-> cmd ; } }
/***** Document ******/
class Okular::DocumentPrivate
......@@ -149,6 +153,7 @@ class Okular::DocumentPrivate
void rotationFinished( int page );
void fontReadingProgress( int page );
void fontReadingGotFont( const Okular::FontInfo& font );
void slotGeneratorConfigChanged( const QString& );
// member variables
Document *m_parent;
......@@ -734,6 +739,50 @@ void DocumentPrivate::fontReadingGotFont( const Okular::FontInfo& font )
emit m_parent->gotFont( font );
}
void DocumentPrivate::slotGeneratorConfigChanged( const QString& )
{
if ( !m_generator )
return;
// reparse generator config and if something changed clear Pages
bool configchanged = false;
QHash< QString, GeneratorInfo >::const_iterator it = m_loadedGenerators.constBegin(), itEnd = m_loadedGenerators.constEnd();
for ( ; it != itEnd; ++it )
{
Okular::ConfigInterface * iface = qobject_cast< Okular::ConfigInterface * >( it.value().generator );
if ( iface )
{
bool it_changed = iface->reparseConfig();
if ( it_changed && ( m_generator == it.value().generator ) )
configchanged = true;
}
}
if ( configchanged )
{
// invalidate pixmaps
QVector<Page*>::const_iterator it = m_pagesVector.begin(), end = m_pagesVector.end();
for ( ; it != end; ++it ) {
(*it)->deletePixmaps();
}
// [MEM] remove allocation descriptors
QLinkedList< AllocatedPixmap * >::const_iterator aIt = m_allocatedPixmapsFifo.begin();
QLinkedList< AllocatedPixmap * >::const_iterator aEnd = m_allocatedPixmapsFifo.end();
for ( ; aIt != aEnd; ++aIt )
delete *aIt;
m_allocatedPixmapsFifo.clear();
m_allocatedPixmapsTotalMemory = 0;
// send reload signals to observers
foreachObserverD( notifyContentsCleared( DocumentObserver::Pixmap ) );
}
// free memory if in 'low' profile
if ( Settings::memoryLevel() == Settings::EnumMemoryLevel::Low &&
!m_allocatedPixmapsFifo.isEmpty() && !m_pagesVector.isEmpty() )
cleanupPixmapMemory();
}
Document::Document( QWidget *widget )
: QObject( widget ), d( new DocumentPrivate( this ) )
......@@ -2324,6 +2373,7 @@ void Document::fillConfigDialog( KConfigDialog * dialog )
KService::List offers = KServiceTypeTrader::self()->query( "okular/Generator", constraint );
d->loadServiceList( offers );
bool pagesAdded = false;
QHash< QString, GeneratorInfo >::iterator it = d->m_loadedGenerators.begin();
QHash< QString, GeneratorInfo >::iterator itEnd = d->m_loadedGenerators.end();
for ( ; it != itEnd; ++it )
......@@ -2333,8 +2383,14 @@ void Document::fillConfigDialog( KConfigDialog * dialog )
{
iface->addPages( dialog );
it.value().hasConfig = true;
pagesAdded = true;
}
}
if ( pagesAdded )
{
connect( dialog, SIGNAL( settingsChanged( const QString& ) ),
this, SLOT( slotGeneratorConfigChanged( const QString& ) ) );
}
}
int Document::configurableGenerators() const
......
......@@ -604,6 +604,7 @@ class OKULAR_EXPORT Document : public QObject
Q_PRIVATE_SLOT( d, void rotationFinished( int page ) )
Q_PRIVATE_SLOT( d, void fontReadingProgress( int page ) )
Q_PRIVATE_SLOT( d, void fontReadingGotFont( const Okular::FontInfo& font ) )
Q_PRIVATE_SLOT( d, void slotGeneratorConfigChanged( const QString& ) )
};
......
......@@ -560,8 +560,8 @@ void Part::slotGeneratorPreferences( )
m_document->fillConfigDialog( dialog );
// (for now don't FIXME) keep us informed when the user changes settings
// connect( dialog, SIGNAL( settingsChanged() ), this, SLOT( slotNewConfig() ) );
// keep us informed when the user changes settings
connect( dialog, SIGNAL( settingsChanged( const QString& ) ), this, SLOT( slotNewGeneratorConfig() ) );
dialog->show();
}
......@@ -1259,6 +1259,27 @@ void Part::slotNewConfig()
}
void Part::slotNewGeneratorConfig()
{
// Apply settings here. A good policy is to check wether the setting has
// changed before applying changes.
// NOTE: it's not needed to reload the configuration of the Document,
// the Document itself will take care of that
// Main View (pageView)
m_pageView->reparseConfig();
// update TOC settings
if ( m_toolBox->isItemEnabled(0) )
m_toc->reparseConfig();
// update ThumbnailList contents
if ( Okular::Settings::showLeftPanel() && !m_thumbnailList->isHidden() )
m_thumbnailList->updateWidgets();
}
void Part::slotPrintPreview()
{
if (m_document->pages() == 0) return;
......
......@@ -131,6 +131,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
void slotSaveFileAs();
void slotGetNewStuff();
void slotNewConfig();
void slotNewGeneratorConfig();
void slotShowMenu(const Okular::Page *page, const QPoint &point);
void slotShowProperties();
void slotShowEmbeddedFiles();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment