Improvements to magnifier feature

In an ideal world I would have commented this in reviewboard and Michal would
have fixed it, but Feature Freeze is almost here so I decided just to fix it myself
This commit is contained in:
Albert Astals Cid 2014-02-25 00:04:57 +01:00
parent f22d9d2897
commit 11deb53aa5
3 changed files with 13 additions and 30 deletions

View file

@ -20,16 +20,12 @@
#include "magnifierview.h"
#include <QPainter>
#include <QLabel>
#include <QVBoxLayout>
#include <QLayoutItem>
#include <KLocale>
#include <KColorScheme>
#include "core/document.h"
#include "ui/pagepainter.h"
#include "core/generator.h"
#include "pagepainter.h"
#include "priorities.h"
static const int SCALE = 10;
@ -163,16 +159,16 @@ void MagnifierView::drawTicks( QPainter *p )
{
p->save();
p->setPen(QPen(QBrush(Qt::SolidPattern), 1, Qt::SolidLine, Qt::FlatCap));
p->setPen(QPen(Qt::black, 0));
// the cross
p->drawLine(width() / 2, 0, width() / 2, height());
p->drawLine(0, height() / 2, width(), height() / 2);
p->drawLine(width() / 2, 0, width() / 2, height() - 1);
p->drawLine(0, height() / 2, width() - 1, height() / 2);
// the borders
p->drawLine(1, 1, width() - 1, 1);
p->drawLine(width() - 1, 1, width() - 1, height() - 1);
p->drawLine(1, height() - 1, width() - 1, height() - 1);
p->drawLine(1, height() - 1, 1, 1);
p->drawLine(0, 0, width() - 1, 0);
p->drawLine(width() - 1, 0, width() - 1, height() - 1);
p->drawLine(0, height() - 1, width() - 1, height() - 1);
p->drawLine(0, height() - 1, 0, 0);
// ticks
// TODO posibility to switch units (pt, mm, cc, in, printing dots)
@ -182,19 +178,9 @@ void MagnifierView::drawTicks( QPainter *p )
for ( float x = 0; x < width(); x += ps )
{
p->drawLine(x, 1, x, tw);
p->drawLine(x, height(), x, height() - tw);
p->drawLine(x, height() - 1, x, height() - tw - 1);
p->drawLine(1, x, tw, x);
p->drawLine(width(), x, width() - tw, x);
}
ps *= 5; // thick ones
p->setPen(QPen(QBrush(Qt::SolidPattern), 2, Qt::SolidLine, Qt::FlatCap));
for ( float x = 0; x < width(); x += ps )
{
p->drawLine(x, 1, x, tw);
p->drawLine(x, height(), x, height() - tw);
p->drawLine(1, x, tw, x);
p->drawLine(width(), x, width() - tw, x);
p->drawLine(width() - 1, x, width() - tw - 1, x);
}
p->restore();

View file

@ -21,11 +21,8 @@
#define MAGNIFIERVIEW_H
#include <QWidget>
#include "core/view.h"
#include "core/observer.h"
#include <core/page.h>
class QLabel;
#include "core/page.h"
class MagnifierView : public QWidget, public Okular::DocumentObserver
{
@ -37,7 +34,7 @@ class MagnifierView : public QWidget, public Okular::DocumentObserver
void notifySetup( const QVector< Okular::Page * > & pages, int setupFlags );
void notifyPageChanged( int page, int flags );
void notifyCurrentPageChanged( int previous, int current );
virtual bool canUnloadPixmap( int page ) const;
bool canUnloadPixmap( int page ) const;
void updateView( const Okular::NormalizedPoint &p, const Okular::Page * page );
void move( int x, int y );

View file

@ -391,7 +391,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->magnifierView = new MagnifierView(document, this);
d->magnifierView->hide();
d->magnifierView->setGeometry(0, 0, 350, 200); // TODO: more dynamic?
d->magnifierView->setGeometry(0, 0, 351, 201); // TODO: more dynamic?
document->addObserver(d->magnifierView);
connect(document, SIGNAL(processMovieAction(const Okular::MovieAction*)), this, SLOT(slotProcessMovieAction(const Okular::MovieAction*)));