Commit 537f7253 authored by Laurent Montel's avatar Laurent Montel 😁

Add goto page action

svn path=/trunk/kdegraphics/kpdf/; revision=251362
parent 3653d2a8
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <kparts/genericfactory.h> #include <kparts/genericfactory.h>
#include <kdebug.h> #include <kdebug.h>
#include <kurldrag.h> #include <kurldrag.h>
#include <kinputdialog.h>
#include "part.h" #include "part.h"
...@@ -105,6 +106,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName, ...@@ -105,6 +106,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
actionCollection(), "goToEnd" ); actionCollection(), "goToEnd" );
m_lastPage->setWhatsThis( i18n( "Moves to the last page of the document" ) ); m_lastPage->setWhatsThis( i18n( "Moves to the last page of the document" ) );
m_gotoPage = KStdAction::gotoPage( this, SLOT( slotGoToPage() ),
actionCollection(), "goToPage" );
// set our XML-UI resource file // set our XML-UI resource file
setXMLFile("kpdf_part.rc"); setXMLFile("kpdf_part.rc");
connect( m_outputDev, SIGNAL( ZoomIn() ), SLOT( zoomIn() )); connect( m_outputDev, SIGNAL( ZoomIn() ), SLOT( zoomIn() ));
...@@ -123,6 +126,26 @@ Part::~Part() ...@@ -123,6 +126,26 @@ Part::~Part()
writeSettings(); writeSettings();
} }
void Part::slotGoToPage()
{
if ( m_doc )
{
bool ok = false;
int num = KInputDialog::getInteger(i18n("Go to Page"), i18n("Page:"), 1,
1, m_doc->getNumPages(), 1, 10, &ok/*, _part->widget()*/);
if (ok)
goToPage( num -1 );
}
}
void Part::goToPage( int page )
{
m_currentPage = page;
pdfpartview->pagesListBox->setCurrentItem(m_currentPage);
m_outputDev->setPage(m_currentPage);
updateActionPage();
}
void Part::slotOpenUrlDropped( const KURL &url ) void Part::slotOpenUrlDropped( const KURL &url )
{ {
openURL(url ); openURL(url );
......
...@@ -85,6 +85,7 @@ namespace KPDF ...@@ -85,6 +85,7 @@ namespace KPDF
bool nextPage(); bool nextPage();
bool previousPage(); bool previousPage();
void updateAction(); void updateAction();
void goToPage( int page );
protected slots: protected slots:
void find() { /* stub */ }; void find() { /* stub */ };
...@@ -97,7 +98,7 @@ namespace KPDF ...@@ -97,7 +98,7 @@ namespace KPDF
void slotPreviousPage(); void slotPreviousPage();
void slotGotoEnd(); void slotGotoEnd();
void slotGotoStart(); void slotGotoStart();
void slotGoToPage();
void displayNextPage(); void displayNextPage();
void displayPreviousPage(); void displayPreviousPage();
...@@ -116,6 +117,7 @@ namespace KPDF ...@@ -116,6 +117,7 @@ namespace KPDF
KAction* m_lastPage; KAction* m_lastPage;
KAction* m_prevPage; KAction* m_prevPage;
KAction* m_nextPage; KAction* m_nextPage;
KAction *m_gotoPage;
KToggleAction* m_showScrollBars; KToggleAction* m_showScrollBars;
KToggleAction* m_showPageList; KToggleAction* m_showPageList;
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kpdf_part" version="8"> <kpartgui name="kpdf_part" version="9">
<MenuBar> <MenuBar>
<Menu name="edit"><text>&amp;Edit</text> <Menu name="edit"><text>&amp;Edit</text>
<Action name="find"/> <Action name="find"/>
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
<Separator/> <Separator/>
<Action name="previous_page"/> <Action name="previous_page"/>
<Action name="next_page"/> <Action name="next_page"/>
<Separator/>
<Action name="goToPage"/>
</Menu> </Menu>
<Menu name="settings"><text>&amp;Settings</text> <Menu name="settings"><text>&amp;Settings</text>
<Action name="show_scrollbars"/> <Action name="show_scrollbars"/>
......
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