From 4526dd2fd0ef9b9b418e53d467dac9658374d46e Mon Sep 17 00:00:00 2001 From: Fabio D'Urso Date: Tue, 28 May 2013 12:46:27 +0200 Subject: [PATCH] Make all parts receive config change notifications Instead of listening on KConfigDialog's signals, this patch makes parts listen on Okular::Settings::self()'s configChanged() signal. Unlike KConfigDialogs, Okular::Settings::self() is unique and never changes during the process lifetime, and therefore: - A part can connect during initialization and receive notifications, without depeding on KConfigDialog objects (which might be instanced or deleted by a different part). - The connection now survives deletion of the KConfigDialog. --- part.cpp | 33 +++------------------------------ part.h | 1 - 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/part.cpp b/part.cpp index 511b4a0b2..790175035 100644 --- a/part.cpp +++ b/part.cpp @@ -502,6 +502,9 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW slotNewConfig(); + // keep us informed when the user changes settings + connect( Okular::Settings::self(), SIGNAL(configChanged()), this, SLOT(slotNewConfig()) ); + // [SPEECH] check for KTTSD presence and usability const KService::Ptr kttsd = KService::serviceByDesktopName("kttsd"); Okular::Settings::setUseKTTSD( kttsd ); @@ -1045,8 +1048,6 @@ void Part::slotGeneratorPreferences( ) m_document->fillConfigDialog( dialog ); - // keep us informed when the user changes settings - connect( dialog, SIGNAL(settingsChanged(QString)), this, SLOT(slotNewGeneratorConfig()) ); dialog->show(); } @@ -2168,9 +2169,6 @@ void Part::slotPreferences() // we didn't find an instance of this dialog, so lets create it PreferencesDialog * dialog = new PreferencesDialog( m_pageView, Okular::Settings::self(), m_embedMode ); - // keep us informed when the user changes settings - connect( dialog, SIGNAL(settingsChanged(QString)), this, SLOT(slotNewConfig()) ); - dialog->show(); } @@ -2205,31 +2203,6 @@ void Part::slotNewConfig() } -void Part::slotNewGeneratorConfig() -{ - // Apply settings here. A good policy is to check whether 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_sidebar->isItemEnabled(0) ) - m_toc->reparseConfig(); - - // update ThumbnailList contents - if ( Okular::Settings::showLeftPanel() && !m_thumbnailList->isHidden() ) - m_thumbnailList->updateWidgets(); - - // update Reviews settings - if ( m_sidebar->isItemEnabled(2) ) - m_reviewsWidget->reparseConfig(); -} - - void Part::slotPrintPreview() { if (m_document->pages() == 0) return; diff --git a/part.h b/part.h index a907386e6..22e88d5a9 100644 --- a/part.h +++ b/part.h @@ -188,7 +188,6 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc void slotSaveCopyAs(); void slotGetNewStuff(); void slotNewConfig(); - void slotNewGeneratorConfig(); void slotShowMenu(const Okular::Page *page, const QPoint &point); void slotShowProperties(); void slotShowEmbeddedFiles();