mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 02:45:38 +00:00
Add zoom select action (no works again)
svn path=/trunk/kdegraphics/kpdf/; revision=251375
This commit is contained in:
parent
537f72531a
commit
623e28630a
|
@ -30,7 +30,6 @@
|
|||
// #include "kpdf_canvas.h"
|
||||
#include "kpdf_pagewidget.h"
|
||||
|
||||
|
||||
typedef KParts::GenericFactory<KPDF::Part> KPDFPartFactory;
|
||||
K_EXPORT_COMPONENT_FACTORY(libkpdfpart, KPDFPartFactory)
|
||||
|
||||
|
@ -108,6 +107,29 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
|
|||
|
||||
m_gotoPage = KStdAction::gotoPage( this, SLOT( slotGoToPage() ),
|
||||
actionCollection(), "goToPage" );
|
||||
|
||||
const double zoomValue[14] = {0.125,0.25,0.3333,0.5,0.6667,0.75,1,1.25,1.50,2,3,4,6,8 };
|
||||
|
||||
m_zoomTo = new KSelectAction( i18n( "Zoom" ), "zoomTo", 0, actionCollection(), "zoomTo" );
|
||||
connect( m_zoomTo, SIGNAL( activated( const QString & ) ), this, SLOT( slotZoom( const QString& ) ) );
|
||||
m_zoomTo->setEditable( true );
|
||||
m_zoomTo->clear();
|
||||
|
||||
QStringList translated;
|
||||
int idx = 0;
|
||||
int cur = 0;
|
||||
for ( int i = 0; i < 14;i++)
|
||||
{
|
||||
translated << QString( "%1%" ).arg( zoomValue[i] * 100.0 );
|
||||
if ( zoomValue[i] == 1.0 )
|
||||
idx = cur;
|
||||
++cur;
|
||||
}
|
||||
|
||||
m_zoomTo->setItems( translated );
|
||||
m_zoomTo->setCurrentItem( idx );
|
||||
|
||||
|
||||
// set our XML-UI resource file
|
||||
setXMLFile("kpdf_part.rc");
|
||||
connect( m_outputDev, SIGNAL( ZoomIn() ), SLOT( zoomIn() ));
|
||||
|
@ -126,6 +148,17 @@ Part::~Part()
|
|||
writeSettings();
|
||||
}
|
||||
|
||||
void Part::slotZoom( const QString&nz )
|
||||
{
|
||||
QString z = nz;
|
||||
double zoom;
|
||||
z.remove( z.find( '%' ), 1 );
|
||||
zoom = KGlobal::locale()->readNumber( z ) / 100;
|
||||
kdDebug() << "ZOOM = " << nz << ", setting zoom = " << zoom << endl;
|
||||
m_zoomFactor +=zoom;
|
||||
update();
|
||||
}
|
||||
|
||||
void Part::slotGoToPage()
|
||||
{
|
||||
if ( m_doc )
|
||||
|
|
|
@ -19,6 +19,7 @@ class KAboutData;
|
|||
class KAction;
|
||||
class KURL;
|
||||
class KToggleAction;
|
||||
class KSelectAction;
|
||||
|
||||
class LinkAction;
|
||||
class LinkDest;
|
||||
|
@ -109,6 +110,8 @@ namespace KPDF
|
|||
void slotReadUp();
|
||||
void slotReadDown();
|
||||
void slotOpenUrlDropped( const KURL & );
|
||||
void slotZoom( const QString& );
|
||||
|
||||
private:
|
||||
PDFDoc* m_doc;
|
||||
PageWidget* m_outputDev;
|
||||
|
@ -120,7 +123,7 @@ namespace KPDF
|
|||
KAction *m_gotoPage;
|
||||
KToggleAction* m_showScrollBars;
|
||||
KToggleAction* m_showPageList;
|
||||
|
||||
KSelectAction *m_zoomTo;
|
||||
KToggleAction* m_fitToWidth;
|
||||
|
||||
int m_currentPage;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
<kpartgui name="kpdf_part" version="9">
|
||||
<kpartgui name="kpdf_part" version="10">
|
||||
<MenuBar>
|
||||
<Menu name="edit"><text>&Edit</text>
|
||||
<Action name="find"/>
|
||||
|
@ -27,6 +27,7 @@
|
|||
</MenuBar>
|
||||
<ToolBar name="mainToolBar">
|
||||
<Action name="zoom_in"/>
|
||||
<Action name="zoomTo" />
|
||||
<Action name="zoom_out"/>
|
||||
<Separator/>
|
||||
<Action name="previous_page"/>
|
||||
|
|
Loading…
Reference in a new issue