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

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=359685
This commit is contained in:
Albert Astals Cid 2004-11-01 21:56:08 +00:00
parent 8bdea8daaf
commit 03bbbaf2c4
4 changed files with 23 additions and 3 deletions

View file

@ -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
*/

View file

@ -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 );

View file

@ -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 ));
}
}

View file

@ -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();