diff --git a/kpdf/kpdf_part.cpp b/kpdf/kpdf_part.cpp index c71a49f18..274fe20ec 100644 --- a/kpdf/kpdf_part.cpp +++ b/kpdf/kpdf_part.cpp @@ -485,6 +485,17 @@ void Part::doPrint( KPrinter& /*printer*/ ) */ } +void Part::restoreDocument(const KURL &url, int page) +{ + if (openURL(url)) goToPage(page); +} + +void Part::saveDocumentRestoreInfo(KConfig* config) +{ + config->writePathEntry( "URL", url().url() ); + if (document->pages() > 0) config->writeEntry( "Page", document->currentPage() + 1); +} + /* * BrowserExtension class */ diff --git a/kpdf/kpdf_part.h b/kpdf/kpdf_part.h index 589fd00e0..ae7daa222 100644 --- a/kpdf/kpdf_part.h +++ b/kpdf/kpdf_part.h @@ -27,6 +27,7 @@ class QToolBox; class KURL; class KAction; +class KConfig; class KToggleAction; class KSelectAction; class KAboutData; @@ -96,6 +97,8 @@ protected slots: public slots: // connected to Shell action (and browserExtension), not local one void slotPrint(); + void restoreDocument(const KURL &url, int page); + void saveDocumentRestoreInfo(KConfig* config); private: void doPrint( KPrinter& printer ); diff --git a/kpdf/kpdf_shell.cpp b/kpdf/kpdf_shell.cpp index 3ec4403c3..fcb0cd73c 100644 --- a/kpdf/kpdf_shell.cpp +++ b/kpdf/kpdf_shell.cpp @@ -74,6 +74,9 @@ Shell::Shell() return; } //FIXME READD: connect( m_part, SIGNAL( rightClick() ),SLOT( slotRMBClick() ) ); + connect( this, SIGNAL( restoreDocument(const KURL &, int) ),m_part, SLOT( restoreDocument(const KURL &, int))); + connect( this, SIGNAL( saveDocumentRestoreInfo(KConfig*) ), m_part, SLOT( saveDocumentRestoreInfo(KConfig*))); + readSettings(); } @@ -134,7 +137,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() @@ -155,8 +158,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 )); } } diff --git a/kpdf/kpdf_shell.h b/kpdf/kpdf_shell.h index 40b7cd26c..a9dccecf8 100644 --- a/kpdf/kpdf_shell.h +++ b/kpdf/kpdf_shell.h @@ -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();