mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-03 22:54:31 +00:00
Fix switching Paper color on the fly. Fix clearing viewport when can't open
a document. Fix countour drawing on links and images. Synced TODO. svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=362414
This commit is contained in:
parent
79412e732e
commit
7befe4e9f6
12
kpdf/TODO
12
kpdf/TODO
|
@ -7,8 +7,7 @@ Legend:
|
|||
(*) - Some parts of this item are already done
|
||||
|
||||
In progress on the branch (first item comes first):
|
||||
-> ADD: click over image allows "save image" [60% done]
|
||||
-> ADD: viewport changes the right way when clicking links [40% done]
|
||||
-> ADD: viewport changes the right way when clicking links (also suggested by Mikolaj Machowski) [40% done]
|
||||
|
||||
Things to do in order to merge in HEAD (first item has highest priority):
|
||||
-> memory manager with different profiles (mem/cpu tradeoff: {memory saving, normal, memory aggressive})
|
||||
|
@ -17,13 +16,14 @@ Things to do in order to merge in HEAD (first item has highest priority):
|
|||
-> usability: layout 2PPV [1 2,3 4,5 6] -> [1,2 3,4 5]. add option for 'ebook' style alignemnt. (by Mikolaj)
|
||||
-> usability: clear search must restore the full thumbs list (by Mikolaj)
|
||||
-> usability: trigger redraw on 'filter text' on current page (by Mikolaj)
|
||||
-> fix viewport change on link (also suggested by Mikolaj Machowski)
|
||||
-> new icons (contest at kde-look has ended and we know the winner. good choice :-)
|
||||
-> take care of naming on merge, too differences (remove some kpdf_* prefixes
|
||||
and rename internals toodocument->kpdfdocument)
|
||||
|
||||
More items (first items will enter 'In progress list' first):
|
||||
*THIS ITEMS ARE CURRENTLY FROZEN SINCE "HEAD-MERGE" LIST IS CLEARED*
|
||||
-> find: scroll page if the the searched string is not visible [after 'viewport changes']
|
||||
-> ADD: click over image allows "save image" [60% done]
|
||||
-> screen editing (annotations): framework (BR67300,BR62793)
|
||||
-> screen editing (annotations): tools (BR67300)
|
||||
-> display current page / total pages (with analog indicator too (progressbar/indicator/...))
|
||||
|
@ -34,9 +34,9 @@ More items (first items will enter 'In progress list' first):
|
|||
-> implement history (mainly for actionNamed)
|
||||
-> history as a toolbox child (collecting DOs's setPage calls)
|
||||
-> zoom: fit text (with configurable margin)
|
||||
-> find: scroll page if the the searched string is not visible
|
||||
-> open gzipped (.pdf.gz?) files
|
||||
-> autodetect "/dev/speech" and provide {document/page/selection} -> reading
|
||||
-> kttsd output with menu entries. speech{document/page/selection}. (see kdenonbeta/kttsd)
|
||||
-> kttsd alternative (1): autodetect "/dev/speech" (speechd/festival) and provide reading
|
||||
-> automatic online dictionaries / translators (BR80338)
|
||||
-> add OCR for building TextPages out of pure graphical (aka scanned) pages
|
||||
-> merge head copyright headers (by albert)
|
||||
|
@ -46,7 +46,7 @@ More items (first items will enter 'In progress list' first):
|
|||
|
||||
Done (newest feature comes firts):
|
||||
-> ADD: reading aids (inverted display, recolor, black/white, draw link border, draw image border)
|
||||
-> FIX: zoom preserved when switching modes and flickerless
|
||||
-> FIX: zoom preserved when switching modes and flickerless drawing
|
||||
-> ADD: Printing as PS instead of as image (Albert)
|
||||
-> ADD: Remember page on session logout and put the document in it on session restore (Albert)
|
||||
-> ADD: gfx capturing tool
|
||||
|
|
|
@ -220,6 +220,9 @@ void KPDFDocument::reparseConfig()
|
|||
// load paper color from Settings or use the white default color
|
||||
QColor color = ( (Settings::renderMode() == Settings::EnumRenderMode::Paper ) &&
|
||||
Settings::changeColors() ) ? Settings::paperColor() : Qt::white;
|
||||
// if paper color changed we have to rebuild every visible pixmap in addition to
|
||||
// the outputDevice. it's the 'heaviest' case, other effect are just recoloring
|
||||
// over the page rendered on 'standard' white background.
|
||||
if ( color != d->paperColor || !d->kpdfOutputDev )
|
||||
{
|
||||
d->paperColor = color;
|
||||
|
@ -232,8 +235,11 @@ void KPDFDocument::reparseConfig()
|
|||
if ( d->pdfdoc )
|
||||
d->kpdfOutputDev->startDoc( d->pdfdoc->getXRef() );
|
||||
d->docLock.unlock();
|
||||
// invalidate pixmaps
|
||||
//FIXME missing
|
||||
// invalidate pixmaps and send reload signals to observers
|
||||
QValueVector<KPDFPage*>::iterator it = d->pages.begin(), end = d->pages.end();
|
||||
for ( ; it != end; ++it )
|
||||
(*it)->deletePixmapsAndLinks();
|
||||
foreachObserver( notifyPixmapsCleared() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class KPDFDocumentObserver
|
|||
|
||||
// monitor changes in pixmaps (generation thread complete)
|
||||
virtual void notifyPixmapChanged( int /*pageNumber*/ ) {};
|
||||
virtual void notifyPixmapsCleared() {};
|
||||
|
||||
// commands from the Document to all observers
|
||||
virtual void pageSetup( const QValueVector<KPDFPage*> & /*pages*/, bool /*documentChanged*/ ) {};
|
||||
|
|
|
@ -234,9 +234,15 @@ bool Part::openFile()
|
|||
|
||||
bool Part::openURL(const KURL &url)
|
||||
{
|
||||
bool b = KParts::ReadOnlyPart::openURL(url);
|
||||
if (!b) KMessageBox::error(widget(), i18n("Could not open %1").arg(url.prettyURL()));
|
||||
return b;
|
||||
bool b = KParts::ReadOnlyPart::openURL(url);
|
||||
// if can't open document, update windows so they display blank contents
|
||||
if ( !b )
|
||||
{
|
||||
m_pageView->updateContents();
|
||||
m_thumbnailList->updateContents();
|
||||
KMessageBox::error( widget(), i18n("Could not open %1").arg(url.prettyURL()) );
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
bool Part::closeURL()
|
||||
|
|
|
@ -41,15 +41,7 @@ KPDFPage::KPDFPage( uint page, float w, float h, int r )
|
|||
|
||||
KPDFPage::~KPDFPage()
|
||||
{
|
||||
QMap<int,QPixmap *>::iterator it = m_pixmaps.begin(), end = m_pixmaps.end();
|
||||
for ( ; it != end; ++it )
|
||||
delete *it;
|
||||
QValueList< KPDFLink * >::iterator lIt = m_links.begin(), lEnd = m_links.end();
|
||||
for ( ; lIt != lEnd; ++lIt )
|
||||
delete *lIt;
|
||||
QValueList< KPDFActiveRect * >::iterator rIt = m_rects.begin(), rEnd = m_rects.end();
|
||||
for ( ; rIt != rEnd; ++rIt )
|
||||
delete *rIt;
|
||||
deletePixmapsAndLinks();
|
||||
delete m_text;
|
||||
}
|
||||
|
||||
|
@ -126,7 +118,6 @@ bool KPDFPage::hasText( const QString & text, bool strictCase, bool fromTop )
|
|||
return found;
|
||||
}
|
||||
|
||||
|
||||
void KPDFPage::setPixmap( int id, QPixmap * pixmap )
|
||||
{
|
||||
if ( m_pixmaps.contains( id ) )
|
||||
|
@ -156,6 +147,25 @@ void KPDFPage::setActiveRects( const QValueList<KPDFActiveRect *> rects )
|
|||
m_rects = rects;
|
||||
}
|
||||
|
||||
void KPDFPage::deletePixmapsAndLinks()
|
||||
{
|
||||
// delete all stored pixmaps
|
||||
QMap<int,QPixmap *>::iterator it = m_pixmaps.begin(), end = m_pixmaps.end();
|
||||
for ( ; it != end; ++it )
|
||||
delete *it;
|
||||
m_pixmaps.clear();
|
||||
// delete Links
|
||||
QValueList< KPDFLink * >::iterator lIt = m_links.begin(), lEnd = m_links.end();
|
||||
for ( ; lIt != lEnd; ++lIt )
|
||||
delete *lIt;
|
||||
m_links.clear();
|
||||
// delete ActiveRects
|
||||
QValueList< KPDFActiveRect * >::iterator rIt = m_rects.begin(), rEnd = m_rects.end();
|
||||
for ( ; rIt != rEnd; ++rIt )
|
||||
delete *rIt;
|
||||
m_rects.clear();
|
||||
}
|
||||
|
||||
|
||||
void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
|
||||
QPainter * destPainter, const QRect & limits, int width, int height )
|
||||
|
@ -270,12 +280,15 @@ void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
|
|||
{
|
||||
QColor normalColor = QApplication::palette().active().highlight();
|
||||
QColor lightColor = normalColor.light( 140 );
|
||||
// enlarging limits for intersection is like growing the 'linkGeometry' below
|
||||
QRect limitsEnlarged = limits;
|
||||
limitsEnlarged.addCoords( -2, -2, 2, 2 );
|
||||
// draw links that are inside the 'limits' paint region as opaque rects
|
||||
QValueList< KPDFLink * >::const_iterator lIt = page->m_links.begin(), lEnd = page->m_links.end();
|
||||
for ( ; lIt != lEnd; ++lIt )
|
||||
{
|
||||
QRect linkGeometry = (*lIt)->geometry();
|
||||
if ( linkGeometry.intersects( limits ) )
|
||||
if ( linkGeometry.intersects( limitsEnlarged ) )
|
||||
{
|
||||
// expand rect and draw inner border
|
||||
linkGeometry.addCoords( -1,-1,1,1 );
|
||||
|
@ -294,12 +307,15 @@ void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
|
|||
{
|
||||
QColor normalColor = QApplication::palette().active().highlight();
|
||||
QColor lightColor = normalColor.light( 140 );
|
||||
// enlarging limits for intersection is like growing the 'linkGeometry' below
|
||||
QRect limitsEnlarged = limits;
|
||||
limitsEnlarged.addCoords( -2, -2, 2, 2 );
|
||||
// draw links that are inside the 'limits' paint region as opaque rects
|
||||
QValueList< KPDFActiveRect * >::const_iterator rIt = page->m_rects.begin(), rEnd = page->m_rects.end();
|
||||
for ( ; rIt != rEnd; ++rIt )
|
||||
{
|
||||
QRect rectGeometry = (*rIt)->geometry();
|
||||
if ( rectGeometry.intersects( limits ) )
|
||||
if ( rectGeometry.intersects( limitsEnlarged ) )
|
||||
{
|
||||
// expand rect and draw inner border
|
||||
rectGeometry.addCoords( -1,-1,1,1 );
|
||||
|
|
|
@ -54,17 +54,18 @@ class KPDFPage
|
|||
const QString getTextInRect( const QRect & rect, double zoom = 1.0 ) const;
|
||||
const KPDFLink * getLink( int mouseX, int mouseY ) const;
|
||||
|
||||
// operations (not const methods caled by KPDFDocument)
|
||||
// operations (by KPDFDocument)
|
||||
inline void setAttribute( int att ) { m_attributes |= att; }
|
||||
inline void clearAttribute( int att ) { m_attributes &= ~att; }
|
||||
inline void toggleAttribute( int att ) { m_attributes ^= att; }
|
||||
bool hasText( const QString & text, bool strictCase, bool fromTop );
|
||||
|
||||
// set contents (not const methods caled by KPDFDocument)
|
||||
// set contents (by KPDFDocument)
|
||||
void setPixmap( int id, QPixmap * pixmap );
|
||||
void setSearchPage( TextPage * text );
|
||||
void setLinks( const QValueList<KPDFLink *> links );
|
||||
void setActiveRects( const QValueList<KPDFActiveRect *> rects );
|
||||
void deletePixmapsAndLinks();
|
||||
|
||||
private:
|
||||
friend class PagePainter;
|
||||
|
|
|
@ -194,6 +194,25 @@ void PageView::setupActions( KActionCollection * ac )
|
|||
|
||||
|
||||
//BEGIN KPDFDocumentObserver inherited methods
|
||||
void PageView::notifyPixmapChanged( int pageNumber )
|
||||
{
|
||||
QValueVector< PageViewItem * >::iterator iIt = d->items.begin(), iEnd = d->items.end();
|
||||
for ( ; iIt != iEnd; ++iIt )
|
||||
if ( (*iIt)->pageNumber() == pageNumber )
|
||||
{
|
||||
// update item's rectangle plus the little outline
|
||||
QRect expandedRect = (*iIt)->geometry();
|
||||
expandedRect.addCoords( -1, -1, 3, 3 );
|
||||
updateContents( expandedRect );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PageView::notifyPixmapsCleared()
|
||||
{
|
||||
slotRequestVisiblePixmaps();
|
||||
}
|
||||
|
||||
void PageView::pageSetup( const QValueVector<KPDFPage*> & pageSet, bool documentChanged )
|
||||
{
|
||||
// reuse current pages if nothing new
|
||||
|
@ -263,20 +282,6 @@ void PageView::pageSetCurrent( int pageNumber, const QRect & viewport )
|
|||
if ( d->zoomMode != ZoomFixed )
|
||||
updateZoomText();
|
||||
}
|
||||
|
||||
void PageView::notifyPixmapChanged( int pageNumber )
|
||||
{
|
||||
QValueVector< PageViewItem * >::iterator iIt = d->items.begin(), iEnd = d->items.end();
|
||||
for ( ; iIt != iEnd; ++iIt )
|
||||
if ( (*iIt)->pageNumber() == pageNumber )
|
||||
{
|
||||
// update item's rectangle plus the little outline
|
||||
QRect expandedRect = (*iIt)->geometry();
|
||||
expandedRect.addCoords( -1, -1, 3, 3 );
|
||||
updateContents( expandedRect );
|
||||
break;
|
||||
}
|
||||
}
|
||||
//END KPDFDocumentObserver inherited methods
|
||||
|
||||
//BEGIN widget events
|
||||
|
|
|
@ -53,9 +53,10 @@ class PageView : public QScrollView, public KPDFDocumentObserver
|
|||
|
||||
// inherited from KPDFDocumentObserver
|
||||
uint observerId() const { return PAGEVIEW_ID; }
|
||||
void notifyPixmapChanged( int pageNumber );
|
||||
void notifyPixmapsCleared();
|
||||
void pageSetup( const QValueVector<KPDFPage*> & pages, bool documentChanged );
|
||||
void pageSetCurrent( int pageNumber, const QRect & viewport );
|
||||
void notifyPixmapChanged( int pageNumber );
|
||||
|
||||
signals:
|
||||
void urlDropped( const KURL& );
|
||||
|
|
|
@ -75,6 +75,22 @@ ThumbnailList::ThumbnailList( QWidget *parent, KPDFDocument *document )
|
|||
|
||||
|
||||
//BEGIN KPDFDocumentObserver inherited methods
|
||||
void ThumbnailList::notifyPixmapChanged( int pageNumber )
|
||||
{
|
||||
QValueVector<ThumbnailWidget *>::iterator thumbIt = m_thumbnails.begin(), thumbEnd = m_thumbnails.end();
|
||||
for (; thumbIt != thumbEnd; ++thumbIt)
|
||||
if ( (*thumbIt)->pageNumber() == pageNumber )
|
||||
{
|
||||
(*thumbIt)->update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ThumbnailList::notifyPixmapsCleared()
|
||||
{
|
||||
slotRequestPixmaps();
|
||||
}
|
||||
|
||||
void ThumbnailList::pageSetup( const QValueVector<KPDFPage*> & pages, bool /*documentChanged*/ )
|
||||
{
|
||||
// delete all the Thumbnails
|
||||
|
@ -149,16 +165,6 @@ void ThumbnailList::pageSetCurrent( int pageNumber, const QRect & /*viewport*/ )
|
|||
}
|
||||
}
|
||||
|
||||
void ThumbnailList::notifyPixmapChanged( int pageNumber )
|
||||
{
|
||||
QValueVector<ThumbnailWidget *>::iterator thumbIt = m_thumbnails.begin(), thumbEnd = m_thumbnails.end();
|
||||
for (; thumbIt != thumbEnd; ++thumbIt)
|
||||
if ( (*thumbIt)->pageNumber() == pageNumber )
|
||||
{
|
||||
(*thumbIt)->update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ThumbnailList::updateWidgets()
|
||||
{
|
||||
|
|
|
@ -33,15 +33,18 @@ Q_OBJECT
|
|||
// return thumbnails observer id
|
||||
uint observerId() const { return THUMBNAILS_ID; }
|
||||
|
||||
// redraw thumbnail ( inherited as DocumentObserver )
|
||||
void notifyPixmapChanged( int pageNumber );
|
||||
|
||||
// request all visible pixmap (due to a global shange or so..)
|
||||
void notifyPixmapsCleared();
|
||||
|
||||
// create thumbnails ( inherited as a DocumentObserver )
|
||||
void pageSetup( const QValueVector<KPDFPage*> & pages, bool documentChanged );
|
||||
|
||||
// hilihght current thumbnail ( inherited as DocumentObserver )
|
||||
void pageSetCurrent( int pageNumber, const QRect & viewport );
|
||||
|
||||
// redraw thumbnail ( inherited as DocumentObserver )
|
||||
void notifyPixmapChanged( int pageNumber );
|
||||
|
||||
// redraw visible widgets (useful for refreshing contents...)
|
||||
void updateWidgets();
|
||||
|
||||
|
|
Loading…
Reference in a new issue