Commit d13696ed authored by Enrico Ros's avatar Enrico Ros

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
parent 860d83c7
# 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)
......
......@@ -35,7 +35,6 @@
#include <kprinter.h>
#include <kstdaction.h>
#include <kdeversion.h>
#include <kconfig.h>
#include <kparts/genericfactory.h>
#include <kurldrag.h>
#include <kfiledialog.h>
......@@ -56,6 +55,8 @@
#include "searchwidget.h"
#include "document.h"
#include "toc.h"
#include "preferencesdialog.h"
#include "settings.h"
typedef KParts::GenericFactory<KPDF::Part> 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()
{
/*
......
......@@ -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);
......
......@@ -22,7 +22,6 @@
#include <kaction.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kfiledialog.h>
#include <klibloader.h>
#include <kmessagebox.h>
......
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