From d13696ed7f2df7dffd99ad17af1fe4a276b2c2e4 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Wed, 27 Oct 2004 14:15:27 +0000 Subject: [PATCH] Linked KConfigXT config system. Added an empty config dialog via menu->settings->Configure KPDF. Ported old settings to the standard KConfigXT framework. svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=358212 --- kpdf/Makefile.am | 7 +++-- kpdf/kpdf_part.cpp | 74 ++++++++++++++++++++++++++++++--------------- kpdf/kpdf_part.h | 8 +++-- kpdf/kpdf_shell.cpp | 1 - 4 files changed, 59 insertions(+), 31 deletions(-) diff --git a/kpdf/Makefile.am b/kpdf/Makefile.am index 7bbec8b31..3585786f1 100644 --- a/kpdf/Makefile.am +++ b/kpdf/Makefile.am @@ -1,5 +1,8 @@ # set the include path for X, qt and KDE -INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../splash -I$(srcdir)/../goo -I$(srcdir)/../xpdf $(all_includes) $(FREETYPE_CFLAGS) +INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../splash -I$(srcdir)/../goo -I$(srcdir)/../xpdf -I$(srcdir)/conf $(all_includes) $(FREETYPE_CFLAGS) + +# compile sources in subdirectories +SUBDIRS = conf . # let automoc handle all of the meta source files (moc) METASOURCES = AUTO @@ -40,7 +43,7 @@ kde_module_LTLIBRARIES = libkpdfpart.la # the Part's source, library search path, and link libraries libkpdfpart_la_SOURCES = QOutputDev.cpp QOutputDevKPrinter.cpp kpdf_part.cpp pixmapwidget.cpp pageview.cpp thumbnaillist.cpp kpdf_error.cpp xpdf_errors.cpp thumbnailgenerator.cpp document.cpp page.cpp searchwidget.cpp toc.cpp kpdf_dcop.skel pageviewutils.cpp libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT) $(LIB_KUTILS) -lm +libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la conf/libconf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT) $(LIB_KUTILS) -lm # this is where the desktop file will go partdesktopdir = $(kde_servicesdir) diff --git a/kpdf/kpdf_part.cpp b/kpdf/kpdf_part.cpp index b30c5651e..314fa91b3 100644 --- a/kpdf/kpdf_part.cpp +++ b/kpdf/kpdf_part.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -56,6 +55,8 @@ #include "searchwidget.h" #include "document.h" #include "toc.h" +#include "preferencesdialog.h" +#include "settings.h" typedef KParts::GenericFactory KPDFPartFactory; K_EXPORT_COMPONENT_FACTORY(libkpdfpart, KPDFPartFactory) @@ -167,7 +168,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName, m_findNext->setEnabled(false); KStdAction::saveAs( this, SLOT( slotSaveFileAs() ), ac, "save" ); - + KStdAction::preferences( this, SLOT( slotPreferences() ), ac, "preferences" ); KStdAction::printPreview( this, SLOT( slotPrintPreview() ), ac ); KToggleAction * sLp = new KToggleAction( i18n( "Show &Left Panel" ), 0, ac, "show_leftpanel" ); @@ -175,15 +176,14 @@ Part::Part(QWidget *parentWidget, const char *widgetName, connect( sLp, SIGNAL( toggled( bool ) ), SLOT( slotToggleLeftPanel( bool ) ) ); // attach the actions of the 2 children widgets too - KConfigGroup settings( KPDFPartFactory::instance()->config(), "General" ); - m_pageView->setupActions( ac, &settings ); - m_searchWidget->setupActions( ac, &settings ); - m_thumbnailList->setupActions( ac, &settings ); + m_pageView->setupActions( ac ); + m_searchWidget->setupActions( ac ); + m_thumbnailList->setupActions( ac ); // local settings - m_splitter->setSizes( settings.readIntListEntry( "SplitterSizes" ) ); - sLp->setChecked( settings.readBoolEntry( "ShowLeftPanel", true ) ); - slotToggleLeftPanel( sLp->isChecked() ); + m_splitter->setSizes( Settings::splitterSizes() ); + sLp->setChecked( Settings::showLeftPanel() ); + slotToggleLeftPanel( sLp->isChecked() ); // set our XML-UI resource file setXMLFile("kpdf_part.rc"); @@ -192,17 +192,19 @@ Part::Part(QWidget *parentWidget, const char *widgetName, Part::~Part() { - KConfigGroup settings( KPDFPartFactory::instance()->config(), "General" ); - m_pageView->saveSettings( &settings ); - m_searchWidget->saveSettings( &settings ); - m_thumbnailList->saveSettings( &settings ); - settings.writeEntry( "SplitterSizes", m_splitter->sizes() ); - settings.writeEntry( "ShowLeftPanel", m_toolBox->isShown() ); - - settings.sync(); - delete document; - if ( --m_count == 0 ) - delete globalParams; + // save local settings + Settings::setSplitterSizes( m_splitter->sizes() ); + Settings::setShowLeftPanel( m_toolBox->isShown() ); + // save settings of internal widgets + m_pageView->saveSettings(); + m_searchWidget->saveSettings(); + m_thumbnailList->saveSettings(); + // save config file + Settings::writeConfig(); + + delete document; + if ( --m_count == 0 ) + delete globalParams; } void Part::goToPage(uint i) @@ -366,12 +368,26 @@ void Part::slotSaveFileAs() KMessageBox::information( 0, i18n("File could not be saved in '%1'. Try to save it to another location.").arg( url().path() ) ); } -void Part::slotToggleLeftPanel( bool on ) +void Part::slotPreferences() { - // show/hide left qtoolbox - m_toolBox->setShown( on ); - // this needs to be hidden explicitly to disable thumbnails gen - m_thumbnailList->setShown( on ); + // an instance the dialog could be already created and could be cached, + // in which case you want to display the cached dialog + if ( PreferencesDialog::showDialog( "preferences" ) ) + return; + + // we didn't find an instance of this dialog, so lets create it + PreferencesDialog * dialog = new PreferencesDialog( 0, Settings::self() ); + + // keep us informed when the user changes settings + connect( dialog, SIGNAL( settingsChanged() ), + this, SLOT( slotNewConfig() ) ); + + dialog->show(); +} + +void Part::slotNewConfig() +{ + // apply runtime changes TODO apply changes here } void Part::slotPrintPreview() @@ -406,6 +422,14 @@ void Part::slotPrintPreview() */ } +void Part::slotToggleLeftPanel( bool on ) +{ + // show/hide left qtoolbox + m_toolBox->setShown( on ); + // this needs to be hidden explicitly to disable thumbnails gen + m_thumbnailList->setShown( on ); +} + void Part::slotPrint() { /* diff --git a/kpdf/kpdf_part.h b/kpdf/kpdf_part.h index c5fdf60cd..c99cd61bf 100644 --- a/kpdf/kpdf_part.h +++ b/kpdf/kpdf_part.h @@ -85,9 +85,11 @@ protected slots: void slotGotoLast(); void slotFind(); void slotFindNext(); - void slotSaveFileAs(); - void slotPrintPreview(); - void slotToggleLeftPanel( bool ); + void slotSaveFileAs(); + void slotPreferences(); + void slotNewConfig(); + void slotPrintPreview(); + void slotToggleLeftPanel( bool ); // can be connected to widget elements void updateActions(); void enableTOC(bool enable); diff --git a/kpdf/kpdf_shell.cpp b/kpdf/kpdf_shell.cpp index 859096a80..2e34de1e7 100644 --- a/kpdf/kpdf_shell.cpp +++ b/kpdf/kpdf_shell.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include