Commit 14ebfddd authored by Laurent Montel's avatar Laurent Montel

Add show/hide scrollbar as in kghostview

svn path=/trunk/kdegraphics/kpdf/; revision=251084
parent 5c58b576
......@@ -120,6 +120,12 @@ namespace KPDF
mutex.unlock();
}
void PageWidget::enableScrollBars( bool b )
{
setHScrollBarMode( b ? Auto : AlwaysOff );
setVScrollBarMode( b ? Auto : AlwaysOff );
}
void PageWidget::updatePixmap()
{
if ( m_doc )
......
......@@ -12,56 +12,56 @@ class QOutputDevPixmap;
namespace KPDF
{
/**
* Widget displaying a pixmap containing a PDF page and Links.
*/
class PageWidget : public QScrollView
{
Q_OBJECT
/**
* Widget displaying a pixmap containing a PDF page and Links.
*/
class PageWidget : public QScrollView
{
Q_OBJECT
enum ZoomMode { FitInWindow, FitWidth, FitVisible, FixedFactor };
enum ZoomMode { FitInWindow, FitWidth, FitVisible, FixedFactor };
public:
PageWidget(QWidget* parent = 0, const char* name = 0);
~PageWidget();
void setPDFDocument(PDFDoc*);
void setPixelsPerPoint(float);
/* void setLinks(); */
public:
PageWidget(QWidget* parent = 0, const char* name = 0);
~PageWidget();
void setPDFDocument(PDFDoc*);
void setPixelsPerPoint(float);
/* void setLinks(); */
void setPage(int pagenum);
int getPage() const { return m_currentPage; };
void setPage(int pagenum);
int getPage() const { return m_currentPage; };
void enableScrollBars( bool b );
public slots:
void nextPage();
void previousPage();
void zoomIn();
void zoomOut();
public slots:
void nextPage();
void previousPage();
void zoomIn();
void zoomOut();
void updatePixmap();
void updatePixmap();
signals:
void linkClicked(LinkAction*);
signals:
void linkClicked(LinkAction*);
protected:
void contentsMousePressEvent(QMouseEvent*);
void contentsMouseReleaseEvent(QMouseEvent*);
void contentsMouseMoveEvent(QMouseEvent*);
protected:
void contentsMousePressEvent(QMouseEvent*);
void contentsMouseReleaseEvent(QMouseEvent*);
void contentsMouseMoveEvent(QMouseEvent*);
virtual void drawContents ( QPainter *p, int, int, int, int );
virtual void drawContents ( QPainter *p, int, int, int, int );
private:
private:
QOutputDevPixmap * m_outputdev;
PDFDoc* m_doc;
QOutputDevPixmap * m_outputdev;
PDFDoc* m_doc;
float m_ppp; // Pixels per point
float m_zoomFactor;
ZoomMode m_zoomMode;
float m_ppp; // Pixels per point
float m_zoomFactor;
ZoomMode m_zoomMode;
int m_currentPage;
int m_currentPage;
LinkAction* m_pressedAction;
};
LinkAction* m_pressedAction;
};
}
#endif
......
......@@ -59,6 +59,15 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
setWidget(pdfpartview);
m_showScrollBars = new KToggleAction( i18n( "Show &Scrollbars" ), 0,
actionCollection(), "show_scrollbars" );
m_showPageList = new KToggleAction( i18n( "Show &Page List" ), 0,
actionCollection(), "show_page_list" );
connect( m_showScrollBars, SIGNAL( toggled( bool ) ),
SLOT( showScrollBars( bool ) ) );
connect( m_showPageList, SIGNAL( toggled( bool ) ),
SLOT( showMarkList( bool ) ) );
// create our actions
KStdAction::find (this, SLOT(find()),
actionCollection(), "find");
......@@ -102,6 +111,20 @@ Part::~Part()
delete globalParams;
}
void Part::showScrollBars( bool show )
{
m_outputDev->enableScrollBars( show );
}
void Part::showMarkList( bool show )
{
#if 0
_markList->setShown( show );
_scrollBox->setShown( show );
_divider->setShown( show );
#endif
}
void Part::slotGotoEnd()
{
if ( m_doc && m_doc->getNumPages() > 0 );
......
......@@ -95,14 +95,19 @@ namespace KPDF
void executeAction(LinkAction*);
void showScrollBars( bool );
void showMarkList( bool );
private:
PDFDoc* m_doc;
PageWidget* m_outputDev;
PDFPartView * pdfpartview;
PDFPartView * pdfpartview;
KAction* m_firstPage;
KAction* m_lastPage;
KAction* m_prevPage;
KAction* m_nextPage;
KToggleAction* m_showScrollBars;
KToggleAction* m_showPageList;
KToggleAction* m_fitToWidth;
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kpdf_part" version="5">
<kpartgui name="kpdf_part" version="6">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Action name="find"/>
......@@ -18,6 +18,10 @@
<Action name="previous_page"/>
<Action name="next_page"/>
</Menu>
<Menu name="settings"><text>&amp;Settings</text>
<Action name="show_scrollbars"/>
<Action name="show_page_list"/>
</Menu>
</MenuBar>
<ToolBar name="mainToolBar">
<Action name="previous_page"/>
......
......@@ -17,6 +17,7 @@
#include <kstdaction.h>
#include <kurl.h>
#include <kdebug.h>
#include <klocale.h>
using namespace KPDF;
......@@ -53,7 +54,7 @@ Shell::Shell()
{
// if we couldn't find our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, "Could not find our Part!");
KMessageBox::error(this, i18n("Could not find our Part!"));
kapp->quit();
// we return here, cause kapp->quit() only means "exit the
// next time we enter the event loop...
......
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