Commit e65c7058 authored by Enrico Ros's avatar Enrico Ros

Added the MiniBar class, a layouted widget that displays current page

 number, the total number of pages and a little grahical 'progress'
 indicator. Moved 'next page' and 'prev page' buttons from the main toolbar
 to the MiniBar. Minibar lets you edit the page number, click or wheel on
 progress, go to next/prev page, show the gotoPage dialog.
Added rmb popup when clicking on thumbnails. When clicking, the
 ThumbnailList only emits the same signal emitted by PageView so the same
 context menu is displayed.
Misc fixes: [MEM] enabled allocated pages raising in queue when displayed
 again, [ThumbnailList] enabled PageUp/PageDown.

svn path=/trunk/kdegraphics/kpdf/; revision=382597
parent bbfb5301
......@@ -12,19 +12,13 @@ Status:
In progress:
-> new word highlighting for searches / other highlights
-> implement history (for actionNamed and restoring previous viewports on navigation)
High priority 3.4 features (deadline is 2k5-Feb-2):
-> display current page / total pages (with analog indicator too (progressbar/...))
maybe this can be done on a small widget at the top of the toolbox, displaying
'document' informations (pages, current pg, some metadata, etc..)
Tested a 16px ktoolbar in the left-bottom corner.. looks goos and can be used to
insert some actions that aren't so useful in the main (and bigger) toolbar
-> implement history (for actionNamed and restoring previous viewports on navigation)
-> rmb popup for bookmarking pages on thumbnailslist, showing bkmarked pages and
go to next/previous bookmark actions (support for showing bookmarked pages
is already in, but disabled)
- empty! -
More items (first items will enter 'In progress list' first):
-> go to next/previous bookmark actions (showing in thumbnailslist rmb popup too)
-> viewport restoring: sometimes it seems to restore the viewport a bit under where it was
-> presentation: provide a pageX/totalPages indicator in addition to the circle one
-> add scrollbar marks for bookmarks (like kate)
......@@ -91,6 +85,8 @@ More items (first items will enter 'In progress list' first):
-> export: export to other formats keeping formatting (a dream.. except for PNG :-) (PS is easy, we just have PSOutputDev that does it :-D)
Done (newest features come first):
-> ADD: rmb popup on thumbnailslist (the popup shared with pageView: same behavior)
-> ADD: display 'current page' / 'total pages' with analog indicator, active labels, etc
-> CHG: Presentation mode is now Ctrl+Shift+p instead of F9 because it was colliding with Konqueror's toggle sidebar
-> FIX: various in memory unallocator, preload with single pages, pageview
-> FIX: optimized pageView (removed 1 waster req on start, lowered reqs)
......
......@@ -51,7 +51,7 @@ class KPDFDocumentPrivate
QString docFileName;
QString xmlFileName;
// observers / requests stuff
// observers / requests / allocator stuff
QMap< int, DocumentObserver * > observers;
QValueList< PixmapRequest * > pixmapRequestsStack;
QValueList< class AllocatedPixmap * > allocatedPixmapsFifo;
......@@ -76,6 +76,9 @@ struct AllocatedPixmap
QMap< int, DocumentObserver * >::iterator it=d->observers.begin(), end=d->observers.end();\
for ( ; it != end ; ++ it ) { (*it)-> cmd ; } }
/** KPDFDocument **/
KPDFDocument::KPDFDocument()
: generator( 0 ), d( new KPDFDocumentPrivate )
{
......@@ -201,7 +204,7 @@ void KPDFDocument::closeDocument()
delete *pIt;
pages_vector.clear();
// clear memory allocation descriptors
// clear 'memory allocation' descriptors
QValueList< AllocatedPixmap * >::iterator aIt = d->allocatedPixmapsFifo.begin();
QValueList< AllocatedPixmap * >::iterator aEnd = d->allocatedPixmapsFifo.end();
for ( ; aIt != aEnd; ++aIt )
......@@ -260,7 +263,7 @@ void KPDFDocument::reparseConfig()
d->allocatedPixmapsTotalMemory = 0;
// send reload signals to observers
foreachObserver( notifyContentsCleared( DocumentObserver::Pixmap) );
foreachObserver( notifyContentsCleared( DocumentObserver::Pixmap ) );
}
// free memory if in 'low' profile
......@@ -320,12 +323,6 @@ void KPDFDocument::requestPixmaps( const QValueList< PixmapRequest * > & request
if ( !generator || requests.isEmpty() )
return;
#ifndef NDEBUG
//TODO REMOVE THIS
if ( !d->pixmapRequestsStack.isEmpty() && (*d->pixmapRequestsStack.begin())->priority == 0 )
kdDebug() << "calling requestPixmaps when SYNC generation has not yet finished." << endl;
#endif
// 1. [CLEAN STACK] remove previous requests of requesterID
int requesterID = requests.first()->id;
QValueList< PixmapRequest * >::iterator sIt = d->pixmapRequestsStack.begin(), sEnd = d->pixmapRequestsStack.end();
......@@ -427,24 +424,26 @@ void KPDFDocument::setViewport( const DocumentViewport & viewport, int id )
if ( it.key() != id )
(*it)->notifyViewportChanged();
/* [MEM] raise position of currently viewed page in allocation queue
// [MEM] raise position of currently viewed page in allocation queue
if ( d->allocatedPixmapsFifo.count() > 1 )
{
const int page = viewport.pageNumber;
QValueList< AllocatedPixmap * > viewportPixmaps;
QValueList< AllocatedPixmap * >::iterator aIt = d->allocatedPixmapsFifo.begin();
QValueList< AllocatedPixmap * >::iterator aLast = d->allocatedPixmapsFifo.end();
--aLast;
while ( aIt != aLast )
QValueList< AllocatedPixmap * >::iterator aEnd = d->allocatedPixmapsFifo.end();
while ( aIt != aEnd )
{
if ( (*aIt)->page == viewport.pageNumber )
if ( (*aIt)->page == page )
{
d->allocatedPixmapsFifo.append( *aIt );
viewportPixmaps.append( *aIt );
aIt = d->allocatedPixmapsFifo.remove( aIt );
p--rintf("%d raised prio of %d %d\n",d->allocatedPixmapsFifo.count(), (*aIt)->id, (*aIt)->page);
continue;
}
else
++aIt;
++aIt;
}
}*/
if ( !viewportPixmaps.isEmpty() )
d->allocatedPixmapsFifo += viewportPixmaps;
}
}
bool KPDFDocument::findText( const QString & string, bool keepCase, bool findAhead )
......
......@@ -20,6 +20,7 @@
#define PAGEVIEW_ID 3
#define THUMBNAILS_ID 4
#define TOC_ID 5
#define MINIBAR_ID 6
/** PRIORITIES for requests. Globally defined here. **/
#define PAGEVIEW_PRIO 1
......
......@@ -55,6 +55,7 @@
#include "ui/thumbnaillist.h"
#include "ui/searchwidget.h"
#include "ui/toc.h"
#include "ui/minibar.h"
#include "ui/propertiesdialog.h"
#include "ui/presentationwidget.h"
#include "conf/preferencesdialog.h"
......@@ -110,10 +111,15 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_watchFile = new KToggleAction( i18n( "&Watch File" ), 0, this, SLOT( slotWatchFile() ), actionCollection(), "watch_file" );
m_watchFile->setChecked( Settings::watchFile() );
// widgets: [left toolbox] | []
m_toolBox = new QToolBox( m_splitter );
m_toolBox->setMinimumWidth( 80 );
m_toolBox->setMaximumWidth( 300 );
// widgets: [left panel] | []
QWidget * leftPanel = new QWidget( m_splitter );
leftPanel->setMinimumWidth( 90 );
leftPanel->setMaximumWidth( 300 );
QVBoxLayout * leftPanelLayout = new QVBoxLayout( leftPanel );
// widgets: [left toolbox/..] | []
m_toolBox = new QToolBox( leftPanel );
leftPanelLayout->addWidget( m_toolBox );
// [left toolbox: Table of Contents] | []
TOC * tocFrame = new TOC( m_toolBox, m_document );
......@@ -127,6 +133,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_thumbnailList = new ThumbnailList( thumbsBox, m_document );
// ThumbnailController * m_tc = new ThumbnailController( thumbsBox, m_thumbnailList );
connect( m_thumbnailList, SIGNAL( urlDropped( const KURL& ) ), SLOT( openURL( const KURL & )) );
connect( m_thumbnailList, SIGNAL( rightClick(const KPDFPage *, const QPoint &) ), this, SLOT( slotShowMenu(const KPDFPage *, const QPoint &) ) );
// shrink the bottom toolbar (todo: find a less hackish way)
thumbsBox->setStretchFactor( m_searchWidget, 100 );
thumbsBox->setStretchFactor( m_thumbnailList, 100 );
......@@ -139,6 +146,18 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
int iIdx = m_toolBox->addItem( editFrame, QIconSet(SmallIcon("pencil")), i18n("Annotations") );
m_toolBox->setItemEnabled( iIdx, false );*/
// widgets: [../miniBarContainer] | []
QWidget * miniBarContainer = new QWidget( leftPanel );
leftPanelLayout->addWidget( miniBarContainer );
QVBoxLayout * miniBarLayout = new QVBoxLayout( miniBarContainer );
// widgets: [../[spacer/..]] | []
QWidget * miniSpacer = new QWidget( miniBarContainer );
miniSpacer->setFixedHeight( 6 );
miniBarLayout->addWidget( miniSpacer );
// widgets: [../[../MiniBar]] | []
MiniBar * miniBar = new MiniBar( miniBarContainer, m_document );
miniBarLayout->addWidget( miniBar );
// widgets: [] | [right 'pageView']
m_pageView = new PageView( m_splitter, m_document );
m_pageView->setFocus(); //usability setting
......@@ -150,6 +169,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_document->addObserver( m_thumbnailList );
m_document->addObserver( m_pageView );
m_document->addObserver( tocFrame );
m_document->addObserver( miniBar );
// ACTIONS
KActionCollection * ac = actionCollection();
......@@ -157,14 +177,20 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
// Page Traversal actions
m_gotoPage = KStdAction::gotoPage( this, SLOT( slotGoToPage() ), ac, "goto_page" );
m_gotoPage->setShortcut( "CTRL+G" );
// dirty way to activate gotopage when pressing miniBar's button
connect( miniBar, SIGNAL( gotoPage() ), m_gotoPage, SLOT( activate() ) );
m_prevPage = KStdAction::prior(this, SLOT(slotPreviousPage()), ac, "previous_page");
m_prevPage->setWhatsThis( i18n( "Moves to the previous page of the document" ) );
m_prevPage->setShortcut( "Backspace" );
// dirty way to activate prev page when pressing miniBar's button
connect( miniBar, SIGNAL( prevPage() ), m_prevPage, SLOT( activate() ) );
m_nextPage = KStdAction::next(this, SLOT(slotNextPage()), ac, "next_page" );
m_nextPage->setWhatsThis( i18n( "Moves to the next page of the document" ) );
m_nextPage->setShortcut( "Space" );
// dirty way to activate next page when pressing miniBar's button
connect( miniBar, SIGNAL( nextPage() ), m_nextPage, SLOT( activate() ) );
m_firstPage = KStdAction::firstPage( this, SLOT( slotGotoFirst() ), ac, "first_page" );
m_firstPage->setWhatsThis( i18n( "Moves to the first page of the document" ) );
......@@ -189,7 +215,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_showPresentation = new KAction( i18n("P&resentation"), "kpresenter_kpr", "Ctrl+Shift+P", this, SLOT(slotShowPresentation()), ac, "presentation");
m_showPresentation->setEnabled( false );
// attach the actions of the 2 children widgets too
// attach the actions of the children widgets too
m_pageView->setupActions( ac );
// apply configuration (both internal settings and GUI configured items)
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kpdf_part" version="14">
<kpartgui name="kpdf_part" version="15">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="save" group="file_save"/>
......@@ -42,9 +42,6 @@
</Menu>
</MenuBar>
<ToolBar name="mainToolBar"><text>Main Toolbar</text>
<Separator/>
<Action name="previous_page"/>
<Action name="next_page"/>
<Separator/>
<Action name="zoom_in"/>
<Action name="zoom_to" />
......
......@@ -145,6 +145,8 @@ void Shell::setupActions()
KAction * openAction = KStdAction::open(this, SLOT(fileOpen()), actionCollection());
m_recent = KStdAction::openRecent( this, SLOT( openURL( const KURL& ) ), actionCollection() );
connect( m_recent, SIGNAL( activated() ), openAction, SLOT( activate() ) );
// the following line doesn't work! don't know why... -enrico
//m_recent->setToolTip( i18n("Click to open a file\nClick and hold to open a recent file") );
KStdAction::print(m_part, SLOT(slotPrint()), actionCollection());
KStdAction::quit(this, SLOT(slotQuit()), actionCollection());
......
......@@ -4,7 +4,8 @@ METASOURCES = AUTO
libkpdfui_la_SOURCES = pageview.cpp pageviewutils.cpp thumbnaillist.cpp \
toc.cpp searchwidget.cpp \
propertiesdialog.cpp presentationwidget.cpp
propertiesdialog.cpp presentationwidget.cpp \
minibar.cpp
noinst_LTLIBRARIES = libkpdfui.la
......
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef _KPDF_MINIBAR_H_
#define _KPDF_MINIBAR_H_
#include <qframe.h>
#include "core/observer.h"
class KPDFDocument;
class PagesEdit;
class HoverButton;
class ProgressWidget;
/**
* @short A widget to display page number and change current page.
*/
class MiniBar : public QFrame, public DocumentObserver
{
Q_OBJECT
public:
MiniBar( QWidget *parent, KPDFDocument * document );
// [INHERITED] from DocumentObserver
uint observerId() const { return MINIBAR_ID; }
void notifySetup( const QValueVector< KPDFPage * > & pages, bool );
void notifyViewportChanged();
signals:
void gotoPage();
void prevPage();
void nextPage();
public slots:
void slotChangePage();
void slotGotoNormalizedPage( float normIndex );
void slotEmitNextPage();
void slotEmitPrevPage();
protected:
void resizeEvent( QResizeEvent * );
private:
KPDFDocument * m_document;
PagesEdit * m_pagesEdit;
HoverButton * m_prevButton;
HoverButton * m_pagesButton;
HoverButton * m_nextButton;
ProgressWidget * m_progressWidget;
int m_currentPage;
};
#endif
......@@ -68,7 +68,7 @@ class PageView : public QScrollView, public DocumentObserver
signals:
void urlDropped( const KURL& );
void rightClick(const KPDFPage *, const QPoint &);
void rightClick( const KPDFPage *, const QPoint & );
protected:
// main draw loop, draws pageViews on viewport
......
......@@ -27,7 +27,7 @@
class ThumbnailWidget : public QWidget
{
public:
ThumbnailWidget( QWidget * parent, const KPDFPage * page );
ThumbnailWidget( QWidget * parent, const KPDFPage * page, ThumbnailList * tl );
// set internal parameters to fit the page in the given width
void resizeFitWidth( int width );
......@@ -42,9 +42,11 @@ class ThumbnailWidget : public QWidget
const KPDFPage * page() const { return m_page; }
protected:
void mouseReleaseEvent( QMouseEvent * e );
void paintEvent(QPaintEvent *);
private:
ThumbnailList * m_tl; // only for accessing 'forwardRightClick( .. )'
const KPDFPage * m_page;
bool m_selected;
int m_pixmapWidth, m_pixmapHeight;
......@@ -113,7 +115,7 @@ void ThumbnailList::notifySetup( const QValueVector< KPDFPage * > & pages, bool
for ( pIt = pages.begin(); pIt != pEnd ; ++pIt )
if ( skipCheck || (*pIt)->attributes() & flags )
{
ThumbnailWidget * t = new ThumbnailWidget( viewport(), *pIt );
ThumbnailWidget * t = new ThumbnailWidget( viewport(), *pIt, this );
t->setFocusProxy( this );
// add to the scrollview
addChild( t, 0, totalHeight );
......@@ -218,6 +220,11 @@ void ThumbnailList::updateWidgets()
}
}
void ThumbnailList::forwardRightClick( const KPDFPage * p, const QPoint & t )
{
emit rightClick( p, t );
}
void ThumbnailList::slotFilterBookmarks( bool filterOn )
{
// save state
......@@ -250,6 +257,10 @@ void ThumbnailList::keyPressEvent( QKeyEvent * keyEvent )
else if ( m_vectorIndex < (int)m_thumbnails.count() - 1 )
nextPage = m_thumbnails[ m_vectorIndex + 1 ]->pageNumber();
}
else if ( keyEvent->key() == Key_PageUp )
verticalScrollBar()->subtractPage();
else if ( keyEvent->key() == Key_PageDown )
verticalScrollBar()->addPage();
else if ( keyEvent->key() == Key_Home )
nextPage = m_thumbnails[ 0 ]->pageNumber();
else if ( keyEvent->key() == Key_End )
......@@ -385,8 +396,8 @@ void ThumbnailList::delayedRequestVisiblePixmaps( int delayMs )
/** ThumbnailWidget implementation **/
ThumbnailWidget::ThumbnailWidget( QWidget * parent, const KPDFPage * kp )
: QWidget( parent, 0, WNoAutoErase ), m_page( kp ),
ThumbnailWidget::ThumbnailWidget( QWidget * parent, const KPDFPage * kp, ThumbnailList * tl )
: QWidget( parent, 0, WNoAutoErase ), m_tl( tl ), m_page( kp ),
m_selected( false ), m_pixmapWidth( 10 ), m_pixmapHeight( 10 )
{
m_labelNumber = m_page->number() + 1;
......@@ -410,6 +421,14 @@ void ThumbnailWidget::setSelected( bool selected )
}
}
void ThumbnailWidget::mouseReleaseEvent( QMouseEvent * e )
{
if ( e->button() != Qt::RightButton )
return;
m_tl->forwardRightClick( m_page, e->globalPos() );
}
void ThumbnailWidget::paintEvent( QPaintEvent * e )
{
int width = m_pixmapWidth + 4;
......
......@@ -49,6 +49,9 @@ Q_OBJECT
// redraw visible widgets (useful for refreshing contents...)
void updateWidgets();
// called by ThumbnailWidgets to send (forward) rightClick signals
void forwardRightClick( const KPDFPage *, const QPoint & );
public slots:
// these are connected to ThumbnailController buttons
void slotFilterBookmarks( bool filterOn );
......@@ -69,6 +72,7 @@ Q_OBJECT
signals:
void urlDropped( const KURL& );
void rightClick( const KPDFPage *, const QPoint & );
private:
void delayedRequestVisiblePixmaps( int delayMs = 0 );
......
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