Commit 03bbbaf2 authored by Albert Astals Cid's avatar Albert Astals Cid

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
parent 8bdea8da
......@@ -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
*/
......
......@@ -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 );
......
......@@ -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 ));
}
}
......
......@@ -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