Commit 89cd5a2f authored by Enrico Ros's avatar Enrico Ros

o Removed the PageViewOverlay class (a hack that permitted transparent

selection) in favour of a new common selection code that uses internal
compositing engine.
o Added 'copy GFX' (in addition to the already existant 'copy text') with
a popup that asks user wether to copy to clipboard or save the image to
a file. (note: maybe a merge between selection tools (text/gfx) is
possible).
o The Zoom Tool is now a mouse mode, not a zoom mode.
o Tuned PageViewMessage class and added tips somewhere.
o Reorganized some actions and cleanup in mouse mode related code.
o Updated plans (roadmap to HEAD and new things) in TODO.
o And.. well, de don't deal with gardening anymore :-) Thanks Michael!
CCMAIL: brade@kde.org

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=360144
parent 03bbbaf2
......@@ -7,18 +7,13 @@ Legend:
(*) - Some parts of this item are already done
In progress on the branch (first item comes first):
-> common layer for selections (zoom outline, select&copy text, select&copy screen)
-> FIX: rework PageView (QScrollView) to gain speed and reduce memory consumption [90% done]
the current behavior, using a large scrollview and the clipper is *Very* bad, wasting
repaints everywhere, even in widgets that get hidden. Need to solve this on its roots, a paintEvent patch
solves this but is a bad way to solve this.
-> ADD: reading aids (accessibility) [settings config done while now]
-> ADD: reading aids (accessibility) [settings config done while now, 20% done]
-> ADD: click over image allows "save image" (and display rect around image too) [50% done]
-> ADD: viewport changes the right way when clicking links [30% 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})
-> fix viewport restoring after zoom
-> fix viewport restoring after zoom (not, fix zoom globally)
-> link thumbnails view with document
-> this may be postponed after merge: implementing async document generator using Albert's generator thread
-> this may be postponed after merge: albert: printing in a good way
......@@ -42,12 +37,13 @@ More items (first items will enter 'In progress list' first):
-> automatic online dictionaries / translators (BR80338)
-> add OCR for building TextPages out of pure graphical (aka scanned) pages
-> merge head copyright headers (by albert)
-> merge head xpdf changes for --enable-final (by adrian de groot/albert)
-> merge head support for show menubar in rmb (by albert)
-> wrong zoom buttons order (BR74248) (check consistancy with kdvi/kghostview/.. (not konq))
Done (newest feature comes firts):
-> ADD: composted renderer framework
-> ADD: gfx capturing tool
-> ADD: composited renderer framework (in addition to a fast light one)
-> FIX: pageview repaint done internally (speed boost and reduced memory consumption)
-> ADD: KConfigXT settings framework and Accessibility config (acc. code mostly not done)
-> FIX: workaround for scrollview bug 1/2 (painting hidden widgets under certain circumstances)
-> ADD: zoom into a rect defined by mouse (aka zoom to window)
......
......@@ -98,7 +98,7 @@
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_TempUseComposting</cstring>
<cstring>kcfg_TempUseCompositing</cstring>
</property>
<property name="text">
<string>USE COMPOSITE</string>
......
......@@ -69,7 +69,7 @@
</entry>
</group>
<group name="Temp" >
<entry key="TempUseComposting" type="Bool" >
<entry key="TempUseCompositing" type="Bool" >
<default>false</default>
</entry>
<entry key="TempDrawBoundaries" type="Bool" >
......
......@@ -12,14 +12,14 @@
</Menu>
<Menu name="view"><text>&amp;View</text>
<Separator/>
<Action name="zoom_in"/>
<Action name="zoom_out"/>
<Action name="zoom_in"/>
<Action name="zoom_fit_width"/>
<Action name="zoom_fit_page"/>
<Action name="zoom_fit_rect"/>
<Separator/>
<Action name="view_twopages"/>
<Action name="view_continous"/>
<Action name="view_twopages"/>
</Menu>
<Menu name="go"><text>&amp;Go</text>
<Action name="first_page"/>
......@@ -38,19 +38,19 @@
<Action name="previous_page"/>
<Action name="next_page"/>
<Separator/>
<Action name="zoom_in"/>
<Action name="zoom_to" />
<Action name="zoom_out"/>
<Action name="zoom_fit_rect"/>
<Action name="zoom_to" />
<Action name="zoom_in"/>
<!--Action name="zoom_fit_width"/-->
<!--Action name="zoom_fit_page"/-->
<Merge/>
<Separator/>
<Action name="view_twopages"/>
<Action name="view_continous"/>
<Action name="view_twopages"/>
<Separator/>
<Action name="mouse_drag"/>
<Action name="mouse_select"/>
<Action name="mouse_zoom"/>
<Action name="mouse_select_text"/>
<Action name="mouse_select_gfx"/>
<Action name="mouse_draw"/>
</ToolBar>
</kpartgui>
This diff is collapsed.
......@@ -45,8 +45,8 @@ class PageView : public QScrollView, public KPDFDocumentObserver
// Zoom mode ( last 4 are internally used only! )
enum ZoomMode { ZoomFixed, ZoomFitWidth, ZoomFitPage, ZoomFitText,
ZoomIn, ZoomOut, ZoomRefreshCurrent, ZoomRect };
enum MouseMode { MouseNormal, MouseSelection, MouseEdit };
ZoomIn, ZoomOut, ZoomRefreshCurrent };
enum MouseMode { MouseNormal, MouseZoom, MouseSelText, MouseSelGfx, MouseEdit };
// create actions that interact with this widget
void setupActions( KActionCollection * collection );
......@@ -79,11 +79,15 @@ class PageView : public QScrollView, public KPDFDocumentObserver
private:
// draw items on the opened qpainter
void paintItems( QPainter * p, const QRect & clipRect, QRegion & remainingArea );
void paintItems( QPainter * p, const QRect & clipRect );
// update item width and height using current zoom parameters
void updateItemSize( PageViewItem * item, int columnWidth, int rowHeight );
// return the widget placed on a certain point or 0 if clicking on empty space
PageViewItem * pickItemOnPoint( int x, int y );
// start / modify / clear selection rectangle
void selectionStart( int x, int y, bool aboveAll = false, PageViewItem * pageLock = 0 );
void selectionEndPoint( int x, int y );
void selectionClear();
// update internal zoom values and end in a slotRelayoutPages();
void updateZoom( ZoomMode newZm );
// update the text on the label using global zoom value or current page's one
......@@ -107,11 +111,12 @@ class PageView : public QScrollView, public KPDFDocumentObserver
void slotFitToWidthToggled( bool );
void slotFitToPageToggled( bool );
void slotFitToTextToggled( bool );
void slotFitToRectToggled( bool );
void slotTwoPagesToggled( bool );
void slotContinousToggled( bool );
void slotSetMouseNormal();
void slotSetMouseSelect();
void slotSetMouseZoom();
void slotSetMouseSelText();
void slotSetMouseSelGfx();
void slotSetMouseDraw();
void slotScrollUp();
void slotScrollDown();
......
......@@ -17,7 +17,8 @@
// local includes
#include "pageviewutils.h"
#include "page.h"
#include "settings.h"
PageViewMessage::PageViewMessage( QWidget * parent )
: QWidget( parent, "pageViewMessage" ), m_timer( 0 )
......@@ -32,6 +33,12 @@ PageViewMessage::PageViewMessage( QWidget * parent )
void PageViewMessage::display( const QString & message, Icon icon, int durationMs )
// give to Caesar what Caesar owns: code taken from Amarok's osd.h/.cpp
{
if ( Settings::hideOSD() )
{
hide();
return;
}
// determine text rectangle
QRect textRect = fontMetrics().boundingRect( message );
textRect.moveBy( -textRect.left(), -textRect.top() );
......@@ -108,7 +115,8 @@ void PageViewMessage::display( const QString & message, Icon icon, int durationM
connect( m_timer, SIGNAL( timeout() ), SLOT( hide() ) );
}
m_timer->start( durationMs, true );
}
} else if ( m_timer )
m_timer->stop();
}
void PageViewMessage::paintEvent( QPaintEvent * e )
......@@ -126,77 +134,55 @@ void PageViewMessage::mousePressEvent( QMouseEvent * /*e*/ )
// window placed in overlay when selecting a window to zoom into
PageViewOverlay::PageViewOverlay( QWidget * parent, OverlayOperation /*op*/ )
: QWidget( parent, "overlayWindow", WNoAutoErase | WPaintUnclipped )
PageViewItem::PageViewItem( const KPDFPage * page )
: m_page( page ), m_zoomFactor( 1.0 )
{
// grab underlying contents
QPoint topLeft = mapToGlobal( QPoint( 0, 0 ) );
m_backPixmap = QPixmap::grabWindow( qt_xrootwin(), topLeft.x(), topLeft.y(), parent->width(), parent->height() );
// resize window
setBackgroundMode( Qt::NoBackground );
resize( parent->width(), parent->height() );
show();
}
void PageViewOverlay::setBeginCorner( int x, int y )
const KPDFPage * PageViewItem::page() const
{
m_startX = x;
m_startY = y;
return m_page;
}
void PageViewOverlay::setEndCorner( int x, int y )
int PageViewItem::pageNumber() const
{
// set previous area to be redrawn
if ( !m_currentRect.isNull() )
update(m_currentRect);
return m_page->number();
}
// update current area and schedule for redrawing
m_currentRect.setRect( m_startX, m_startY, x - m_startX, y - m_startY );
update(m_currentRect = m_currentRect.normalize());
const QRect& PageViewItem::geometry() const
{
return m_geometry;
}
const QRect & PageViewOverlay::selectedRect()
int PageViewItem::width() const
{
return m_currentRect;
return m_geometry.width();
}
void PageViewOverlay::paintEvent( QPaintEvent * )
int PageViewItem::height() const
{
QColor blendColor = palette().active().highlight();
QPainter p( this );
return m_geometry.height();
}
// draw uncovered background (subtracting current from old rect)
QMemArray<QRect> transparentRects = QRegion( m_oldRect ).subtract( m_currentRect ).rects();
for ( uint i = 0; i < transparentRects.count(); i++ )
{
QRect r = transparentRects[i];
p.drawPixmap( r.topLeft(), m_backPixmap, r );
}
double PageViewItem::zoomFactor() const
{
return m_zoomFactor;
}
// draw opaque rects (subtracting old from current rect)
m_oldRect.addCoords( 1, 1, -1, -1 );
QMemArray<QRect> opaqueRects = QRegion( m_currentRect ).subtract( m_oldRect ).rects();
for ( uint i = 0; i < opaqueRects.count(); i++ )
{
QRect r = opaqueRects[i];
// skip rectangles covered by the border from painting
if ( r.width() <= 1 || r.height() <= 1 )
continue;
QPixmap blendedPixmap( r.width(), r.height() );
copyBlt( &blendedPixmap, 0,0, &m_backPixmap, r.left(),r.top(), r.width(),r.height() );
QImage blendedImage = blendedPixmap.convertToImage();
KImageEffect::blend( blendColor.dark(140), blendedImage, 0.2 );
p.drawPixmap( r.left(),r.top(), blendedImage, 0,0,r.width(),r.height() );
}
void PageViewItem::setGeometry( int x, int y, int width, int height )
{
m_geometry.setRect( x, y, width, height );
}
// draw border
if ( m_currentRect.width() > 20 && m_currentRect.height() > 20 )
p.setPen( blendColor );
else
p.setPen( Qt::red );
p.drawRect( m_currentRect );
m_oldRect = m_currentRect;
void PageViewItem::setWHZ( int w, int h, double z )
{
m_geometry.setWidth( w );
m_geometry.setHeight( h );
m_zoomFactor = z;
}
void PageViewItem::moveTo( int x, int y )
{
m_geometry.moveLeft( x );
m_geometry.moveTop( y );
}
......@@ -18,40 +18,29 @@
class QTimer;
class PageView;
#include "page.h"
class KPDFPage;
/**
* @short PageViewItem represents graphically a kpdfpage into the PageView.
*
* It has methods for settings Item's geometry and other visual properties such
* as the individual zoom factor.
*/
class PageViewItem
{
public:
PageViewItem( const KPDFPage * page )
: m_page( page ), m_zoomFactor( 1.0 )
{
// do something
}
PageViewItem( const KPDFPage * page );
void setWHZ( int w, int h, double z )
{
m_geometry.setWidth( w );
m_geometry.setHeight( h );
m_zoomFactor = z;
}
double zoomFactor() { return m_zoomFactor; }
const KPDFPage * page() const;
int pageNumber() const;
const QRect& geometry() const;
int width() const;
int height() const;
double zoomFactor() const;
int pageNumber() const { return m_page->number(); }
const KPDFPage * page() const { return m_page; }
const QRect& geometry() const { return m_geometry; }
int width() const { return m_geometry.width(); }
int height() const { return m_geometry.height(); }
void setGeometry( int x, int y, int width, int height )
{
m_geometry.setRect( x, y, width, height );
}
void moveTo( int x, int y )
{
m_geometry.moveLeft( x );
m_geometry.moveTop( y );
}
void setGeometry( int x, int y, int width, int height );
void setWHZ( int w, int h, double zoom );
void moveTo( int x, int y );
private:
const KPDFPage * m_page;
......@@ -69,7 +58,7 @@ class PageViewMessage : public QWidget
PageViewMessage( QWidget * parent );
enum Icon { None, Info, Warning, Error };
void display( const QString & message, Icon icon, int durationMs = -1 );
void display( const QString & message, Icon icon = Info, int durationMs = 4000 );
protected:
void paintEvent( QPaintEvent * e );
......@@ -80,29 +69,4 @@ class PageViewMessage : public QWidget
QTimer * m_timer;
};
/**
* @short The overlay widget draws transparent selections over the page.
*/
class PageViewOverlay : public QWidget
{
public:
enum OverlayOperation { Zoom, SnapShot };
PageViewOverlay( QWidget * parent, OverlayOperation op );
void setBeginCorner( int x, int y );
void setEndCorner( int x, int y );
const QRect & selectedRect();
protected:
void paintEvent( QPaintEvent * e );
private:
QPixmap m_backPixmap;
QRect m_oldRect;
QRect m_currentRect;
int m_startX;
int m_startY;
};
#endif
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