From 11deb53aa5564693c4cb419ea4db2ef0d4a3a3c5 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 25 Feb 2014 00:04:57 +0100 Subject: [PATCH] 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 --- ui/magnifierview.cpp | 34 ++++++++++------------------------ ui/magnifierview.h | 7 ++----- ui/pageview.cpp | 2 +- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/ui/magnifierview.cpp b/ui/magnifierview.cpp index 331fd656a..75c6cb9cd 100644 --- a/ui/magnifierview.cpp +++ b/ui/magnifierview.cpp @@ -20,16 +20,12 @@ #include "magnifierview.h" #include -#include -#include -#include #include -#include #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(); diff --git a/ui/magnifierview.h b/ui/magnifierview.h index a647e71af..d047406e5 100644 --- a/ui/magnifierview.h +++ b/ui/magnifierview.h @@ -21,11 +21,8 @@ #define MAGNIFIERVIEW_H #include -#include "core/view.h" #include "core/observer.h" -#include - -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 ); diff --git a/ui/pageview.cpp b/ui/pageview.cpp index b3a7a93cd..89db06d8a 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -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*)));