Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 623e2863 authored by Laurent Montel's avatar Laurent Montel 😁

Add zoom select action (no works again)

svn path=/trunk/kdegraphics/kpdf/; revision=251375
parent 537f7253
......@@ -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;
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kpdf_part" version="9">
<kpartgui name="kpdf_part" version="10">
<MenuBar>
<Menu name="edit"><text>&amp;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"/>
......
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