Commit a98ff329 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Bring the document to the page it was when the session was closed on session restore

FEATURE: 92503

svn path=/trunk/kdegraphics/kpdf/; revision=359686
parent d2b7e020
......@@ -23,9 +23,9 @@ KDE_ICON = kpdf
bin_PROGRAMS = kpdf
# the application source, library search path, and link libraries
kpdf_SOURCES = main.cpp kpdf_shell.cpp
kpdf_SOURCES = main.cpp kpdf_shell.cpp
kpdf_LDFLAGS = $(KDE_RPATH) $(all_libraries)
kpdf_LDADD = $(LIB_KPARTS)
kpdf_LDADD = $(LIB_KPARTS)
kpdf_COMPILE_FIRST = part.h
EXTRA_DIST = kpdf.desktop
......
......@@ -607,6 +607,17 @@ Part::print()
}
}
void Part::restoreDocument(const KURL &url, int page)
{
if (openURL(url)) goToPage(page);
}
void Part::saveDocumentRestoreInfo(KConfig* config)
{
config->writePathEntry( "URL", url().url() );
if (m_doc) config->writeEntry( "Page", m_currentPage );
}
/*
void
Part::setFixedZoomFactor(float zoomFactor)
......
......@@ -25,6 +25,7 @@ class QWidget;
class KAboutData;
class KAction;
class KConfig;
class KURL;
class KToggleAction;
class KSelectAction;
......@@ -82,6 +83,8 @@ namespace KPDF
public slots:
void print();
void restoreDocument(const KURL &url, int page);
void saveDocumentRestoreInfo(KConfig* config);
protected:
......
......@@ -78,7 +78,10 @@ Shell::Shell()
return;
}
PDFPartView * partView = static_cast<PDFPartView *>(m_part->widget());
Part* part = static_cast<Part*>(m_part);
connect( partView->outputdev, SIGNAL( rightClick() ),SLOT( slotRMBClick() ) );
connect( this, SIGNAL( restoreDocument(const KURL &, int) ),part, SLOT( restoreDocument(const KURL &, int)));
connect( this, SIGNAL( saveDocumentRestoreInfo(KConfig*) ),part, SLOT( saveDocumentRestoreInfo(KConfig*)));
readSettings();
}
......@@ -136,7 +139,7 @@ Shell::saveProperties(KConfig* config)
// the 'config' object points to the session managed
// config file. anything you write here will be available
// later when this app is restored
config->writePathEntry( "URL", m_part->url().url() );
emit saveDocumentRestoreInfo(config);
}
void Shell::slotShowMenubar()
......@@ -163,8 +166,7 @@ void Shell::readProperties(KConfig* config)
if(m_part)
{
KURL url ( config->readPathEntry( "URL" ) );
if ( url.isValid() )
openURL( url );
if ( url.isValid() ) emit restoreDocument(url, config->readNumEntry( "Page", 1 ));
}
}
......
......@@ -79,6 +79,10 @@ namespace KPDF
public slots:
void openURL( const KURL & url );
signals:
void restoreDocument(const KURL &url, int page);
void saveDocumentRestoreInfo(KConfig* config);
private:
void setupAccel();
void setupActions();
......
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