Changeset View
Changeset View
Standalone View
Standalone View
ui/pageviewannotator.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 53 | { | |||
---|---|---|---|---|---|
60 | bool ok = true; | 60 | bool ok = true; | ||
61 | size = engineElement.attribute( QStringLiteral("size"), QStringLiteral("32") ).toInt( &ok ); | 61 | size = engineElement.attribute( QStringLiteral("size"), QStringLiteral("32") ).toInt( &ok ); | ||
62 | if ( !ok ) | 62 | if ( !ok ) | ||
63 | size = 32; | 63 | size = 32; | ||
64 | m_block = QVariant( engineElement.attribute( QStringLiteral("block") ) ).toBool(); | 64 | m_block = QVariant( engineElement.attribute( QStringLiteral("block") ) ).toBool(); | ||
65 | 65 | | |||
66 | // create engine objects | 66 | // create engine objects | ||
67 | if ( !hoverIconName.simplified().isEmpty() ) | 67 | if ( !hoverIconName.simplified().isEmpty() ) | ||
68 | pixmap = GuiUtils::loadStamp( hoverIconName, QSize( size, size ) ); | 68 | pixmap = GuiUtils::loadStamp( hoverIconName, size ); | ||
69 | } | 69 | } | ||
70 | 70 | | |||
71 | QRect event( EventType type, Button button, double nX, double nY, double xScale, double yScale, const Okular::Page * page ) override | 71 | QRect event( EventType type, Button button, double nX, double nY, double xScale, double yScale, const Okular::Page * page ) override | ||
72 | { | 72 | { | ||
73 | xscale=xScale; | 73 | xscale=xScale; | ||
74 | yscale=yScale; | 74 | yscale=yScale; | ||
75 | pagewidth = page->width(); | 75 | pagewidth = page->width(); | ||
76 | pageheight = page->height(); | 76 | pageheight = page->height(); | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | 234 | { | |||
239 | rect.left = qMin( startpoint.x, point.x ); | 239 | rect.left = qMin( startpoint.x, point.x ); | ||
240 | rect.top = qMin( startpoint.y, point.y ); | 240 | rect.top = qMin( startpoint.y, point.y ); | ||
241 | rect.right = qMax( startpoint.x, point.x ); | 241 | rect.right = qMax( startpoint.x, point.x ); | ||
242 | rect.bottom = qMax( startpoint.y, point.y ); | 242 | rect.bottom = qMax( startpoint.y, point.y ); | ||
243 | const QRectF rcf = rect.geometry( (int)xscale, (int)yscale ); | 243 | const QRectF rcf = rect.geometry( (int)xscale, (int)yscale ); | ||
244 | const int ml = ( rcf.bottomRight() - rcf.topLeft() ).toPoint().manhattanLength(); | 244 | const int ml = ( rcf.bottomRight() - rcf.topLeft() ).toPoint().manhattanLength(); | ||
245 | if ( ml <= QApplication::startDragDistance() ) | 245 | if ( ml <= QApplication::startDragDistance() ) | ||
246 | { | 246 | { | ||
247 | const double stampxscale = size / xscale; | 247 | const double stampxscale = pixmap.width() / xscale; | ||
248 | const double stampyscale = size / yscale; | 248 | const double stampyscale = pixmap.height() / yscale; | ||
249 | if ( center ) | 249 | if ( center ) | ||
250 | { | 250 | { | ||
251 | rect.left = point.x - stampxscale / 2; | 251 | rect.left = point.x - stampxscale / 2; | ||
252 | rect.top = point.y - stampyscale / 2; | 252 | rect.top = point.y - stampyscale / 2; | ||
253 | } | 253 | } | ||
254 | else | 254 | else | ||
255 | { | 255 | { | ||
256 | rect.left = point.x; | 256 | rect.left = point.x; | ||
▲ Show 20 Lines • Show All 973 Lines • ▼ Show 20 Line(s) | 1227 | { | |||
1230 | p.setPen( pen ); | 1230 | p.setPen( pen ); | ||
1231 | p.drawLine( 1, 13, 16, 13 ); | 1231 | p.drawLine( 1, 13, 16, 13 ); | ||
1232 | p.drawLine( 2, 14, 15, 14 ); | 1232 | p.drawLine( 2, 14, 15, 14 ); | ||
1233 | p.drawLine( 0, 20, 19, 20 ); | 1233 | p.drawLine( 0, 20, 19, 20 ); | ||
1234 | p.drawLine( 1, 21, 18, 21 ); | 1234 | p.drawLine( 1, 21, 18, 21 ); | ||
1235 | } | 1235 | } | ||
1236 | else if ( annotType == QLatin1String("stamp") ) | 1236 | else if ( annotType == QLatin1String("stamp") ) | ||
1237 | { | 1237 | { | ||
1238 | QPixmap stamp = GuiUtils::loadStamp( icon, QSize( 16, 16 ) ); | 1238 | QPixmap stamp = GuiUtils::loadStamp( icon, 16, false /* keepAspectRatio */ ); | ||
1239 | p.setRenderHint( QPainter::Antialiasing ); | 1239 | p.setRenderHint( QPainter::Antialiasing ); | ||
1240 | p.drawPixmap( 16, 14, stamp ); | 1240 | p.drawPixmap( 16, 14, stamp ); | ||
1241 | } | 1241 | } | ||
1242 | else if ( annotType == QLatin1String("straight-line") ) | 1242 | else if ( annotType == QLatin1String("straight-line") ) | ||
1243 | { | 1243 | { | ||
1244 | QPainterPath path; | 1244 | QPainterPath path; | ||
1245 | path.moveTo( 1, 8 ); | 1245 | path.moveTo( 1, 8 ); | ||
1246 | path.lineTo( 20, 8 ); | 1246 | path.lineTo( 20, 8 ); | ||
Show All 37 Lines |