Changeset View
Changeset View
Standalone View
Standalone View
lib/documentview/documentview.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 113 | if (adapter->canZoom()) { | |||
---|---|---|---|---|---|
114 | QObject::connect(adapter, SIGNAL(zoomChanged(qreal)), | 114 | QObject::connect(adapter, SIGNAL(zoomChanged(qreal)), | ||
115 | q, SLOT(slotZoomChanged(qreal))); | 115 | q, SLOT(slotZoomChanged(qreal))); | ||
116 | QObject::connect(adapter, SIGNAL(zoomInRequested(QPointF)), | 116 | QObject::connect(adapter, SIGNAL(zoomInRequested(QPointF)), | ||
117 | q, SLOT(zoomIn(QPointF))); | 117 | q, SLOT(zoomIn(QPointF))); | ||
118 | QObject::connect(adapter, SIGNAL(zoomOutRequested(QPointF)), | 118 | QObject::connect(adapter, SIGNAL(zoomOutRequested(QPointF)), | ||
119 | q, SLOT(zoomOut(QPointF))); | 119 | q, SLOT(zoomOut(QPointF))); | ||
120 | QObject::connect(adapter, SIGNAL(zoomToFitChanged(bool)), | 120 | QObject::connect(adapter, SIGNAL(zoomToFitChanged(bool)), | ||
121 | q, SIGNAL(zoomToFitChanged(bool))); | 121 | q, SIGNAL(zoomToFitChanged(bool))); | ||
122 | QObject::connect(adapter, SIGNAL(zoomToFitWidthChanged(bool)), | 122 | QObject::connect(adapter, SIGNAL(zoomToFillChanged(bool)), | ||
123 | q, SIGNAL(zoomToFitWidthChanged(bool))); | 123 | q, SIGNAL(zoomToFillChanged(bool))); | ||
124 | } | 124 | } | ||
125 | QObject::connect(adapter, SIGNAL(scrollPosChanged()), | 125 | QObject::connect(adapter, SIGNAL(scrollPosChanged()), | ||
126 | q, SIGNAL(positionChanged())); | 126 | q, SIGNAL(positionChanged())); | ||
127 | QObject::connect(adapter, SIGNAL(previousImageRequested()), | 127 | QObject::connect(adapter, SIGNAL(previousImageRequested()), | ||
128 | q, SIGNAL(previousImageRequested())); | 128 | q, SIGNAL(previousImageRequested())); | ||
129 | QObject::connect(adapter, SIGNAL(nextImageRequested()), | 129 | QObject::connect(adapter, SIGNAL(nextImageRequested()), | ||
130 | q, SIGNAL(nextImageRequested())); | 130 | q, SIGNAL(nextImageRequested())); | ||
131 | QObject::connect(adapter, SIGNAL(toggleFullScreenRequested()), | 131 | QObject::connect(adapter, SIGNAL(toggleFullScreenRequested()), | ||
132 | q, SIGNAL(toggleFullScreenRequested())); | 132 | q, SIGNAL(toggleFullScreenRequested())); | ||
133 | QObject::connect(adapter, SIGNAL(completed()), | 133 | QObject::connect(adapter, SIGNAL(completed()), | ||
134 | q, SLOT(slotCompleted())); | 134 | q, SLOT(slotCompleted())); | ||
135 | 135 | | |||
136 | adapter->loadConfig(); | 136 | adapter->loadConfig(); | ||
137 | 137 | | |||
138 | adapter->widget()->installSceneEventFilter(q); | 138 | adapter->widget()->installSceneEventFilter(q); | ||
139 | if (mCurrent) { | 139 | if (mCurrent) { | ||
140 | adapter->widget()->setFocus(); | 140 | adapter->widget()->setFocus(); | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | if (mSetup.valid && adapter->canZoom()) { | 143 | if (mSetup.valid && adapter->canZoom()) { | ||
144 | adapter->setZoomToFit(mSetup.zoomToFit); | 144 | adapter->setZoomToFit(mSetup.zoomToFit); | ||
145 | adapter->setZoomToFitWidth(mSetup.zoomToFitWidth); | 145 | adapter->setZoomToFill(mSetup.zoomToFill); | ||
146 | if (!mSetup.zoomToFit && !mSetup.zoomToFitWidth) { | 146 | if (!mSetup.zoomToFit && !mSetup.zoomToFill) { | ||
147 | adapter->setZoom(mSetup.zoom); | 147 | adapter->setZoom(mSetup.zoom); | ||
148 | adapter->setScrollPos(mSetup.position); | 148 | adapter->setScrollPos(mSetup.position); | ||
149 | } | 149 | } | ||
150 | } | 150 | } | ||
151 | q->adapterChanged(); | 151 | q->adapterChanged(); | ||
152 | q->positionChanged(); | 152 | q->positionChanged(); | ||
153 | if (adapter->canZoom()) { | 153 | if (adapter->canZoom()) { | ||
154 | if (adapter->zoomToFit()) { | 154 | if (adapter->zoomToFit()) { | ||
155 | q->zoomToFitChanged(true); | 155 | q->zoomToFitChanged(true); | ||
156 | } else if (adapter->zoomToFitWidth()) { | 156 | } else if (adapter->zoomToFill()) { | ||
157 | q->zoomToFitWidthChanged(true); | 157 | q->zoomToFillChanged(true); | ||
158 | } else { | 158 | } else { | ||
159 | q->zoomChanged(adapter->zoom()); | 159 | q->zoomChanged(adapter->zoom()); | ||
160 | } | 160 | } | ||
161 | } | 161 | } | ||
162 | if (adapter->rasterImageView()) { | 162 | if (adapter->rasterImageView()) { | ||
163 | QObject::connect(adapter->rasterImageView(), SIGNAL(currentToolChanged(AbstractRasterImageViewTool*)), | 163 | QObject::connect(adapter->rasterImageView(), SIGNAL(currentToolChanged(AbstractRasterImageViewTool*)), | ||
164 | q, SIGNAL(currentToolChanged(AbstractRasterImageViewTool*))); | 164 | q, SIGNAL(currentToolChanged(AbstractRasterImageViewTool*))); | ||
165 | } | 165 | } | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | |||||
243 | 243 | | |||
244 | void uncheckZoomToFit() | 244 | void uncheckZoomToFit() | ||
245 | { | 245 | { | ||
246 | if (mAdapter->zoomToFit()) { | 246 | if (mAdapter->zoomToFit()) { | ||
247 | mAdapter->setZoomToFit(false); | 247 | mAdapter->setZoomToFit(false); | ||
248 | } | 248 | } | ||
249 | } | 249 | } | ||
250 | 250 | | |||
251 | void uncheckZoomToFitWidth() | 251 | void uncheckZoomToFill() | ||
252 | { | 252 | { | ||
253 | if (mAdapter->zoomToFitWidth()) { | 253 | if (mAdapter->zoomToFill()) { | ||
254 | mAdapter->setZoomToFitWidth(false); | 254 | mAdapter->setZoomToFill(false); | ||
255 | } | 255 | } | ||
256 | } | 256 | } | ||
257 | 257 | | |||
258 | void setZoom(qreal zoom, const QPointF& center = QPointF(-1, -1)) | 258 | void setZoom(qreal zoom, const QPointF& center = QPointF(-1, -1)) | ||
259 | { | 259 | { | ||
260 | uncheckZoomToFit(); | 260 | uncheckZoomToFit(); | ||
261 | uncheckZoomToFitWidth(); | 261 | uncheckZoomToFill(); | ||
262 | zoom = qBound(q->minimumZoom(), zoom, MAXIMUM_ZOOM_VALUE); | 262 | zoom = qBound(q->minimumZoom(), zoom, MAXIMUM_ZOOM_VALUE); | ||
263 | mAdapter->setZoom(zoom, center); | 263 | mAdapter->setZoom(zoom, center); | ||
264 | } | 264 | } | ||
265 | 265 | | |||
266 | void updateZoomSnapValues() | 266 | void updateZoomSnapValues() | ||
267 | { | 267 | { | ||
268 | qreal min = q->minimumZoom(); | 268 | qreal min = q->minimumZoom(); | ||
269 | 269 | | |||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | 449 | { | |||
450 | return d->mAdapter->rasterImageView(); | 450 | return d->mAdapter->rasterImageView(); | ||
451 | } | 451 | } | ||
452 | 452 | | |||
453 | void DocumentView::slotCompleted() | 453 | void DocumentView::slotCompleted() | ||
454 | { | 454 | { | ||
455 | d->hideLoadingIndicator(); | 455 | d->hideLoadingIndicator(); | ||
456 | d->updateCaption(); | 456 | d->updateCaption(); | ||
457 | d->updateZoomSnapValues(); | 457 | d->updateZoomSnapValues(); | ||
458 | if (!d->mAdapter->zoomToFit()) { | 458 | if (!d->mAdapter->zoomToFit() || !d->mAdapter->zoomToFill()) { | ||
slenz: Was there a reason this was split into if-else? | |||||
Introduced while adding "FitToWidth" in 3e10699ac37c but I can't see any reason too. muhlenpfordt: Introduced while adding "FitToWidth" in 3e10699ac37c but I can't see any reason too. | |||||
rkflx: There are more spots to DRY like this. Material for a follow-up patch!? | |||||
459 | qreal min = minimumZoom(); | | |||
460 | if (d->mAdapter->zoom() < min) { | | |||
461 | d->mAdapter->setZoom(min); | | |||
462 | } | | |||
463 | } else if (!d->mAdapter->zoomToFitWidth()) { | | |||
464 | qreal min = minimumZoom(); | 459 | qreal min = minimumZoom(); | ||
465 | if (d->mAdapter->zoom() < min) { | 460 | if (d->mAdapter->zoom() < min) { | ||
466 | d->mAdapter->setZoom(min); | 461 | d->mAdapter->setZoom(min); | ||
467 | } | 462 | } | ||
468 | } | 463 | } | ||
469 | emit completed(); | 464 | emit completed(); | ||
470 | } | 465 | } | ||
471 | 466 | | |||
472 | DocumentView::Setup DocumentView::setup() const | 467 | DocumentView::Setup DocumentView::setup() const | ||
473 | { | 468 | { | ||
474 | Setup setup; | 469 | Setup setup; | ||
475 | if (d->mAdapter->canZoom()) { | 470 | if (d->mAdapter->canZoom()) { | ||
476 | setup.valid = true; | 471 | setup.valid = true; | ||
477 | setup.zoomToFit = zoomToFit(); | 472 | setup.zoomToFit = zoomToFit(); | ||
478 | setup.zoomToFitWidth = zoomToFitWidth(); | 473 | setup.zoomToFill = zoomToFill(); | ||
479 | if (!setup.zoomToFit && !setup.zoomToFitWidth) { | 474 | if (!setup.zoomToFit && !setup.zoomToFill) { | ||
480 | setup.zoom = zoom(); | 475 | setup.zoom = zoom(); | ||
481 | setup.position = position(); | 476 | setup.position = position(); | ||
482 | } | 477 | } | ||
483 | } | 478 | } | ||
484 | return setup; | 479 | return setup; | ||
485 | } | 480 | } | ||
486 | 481 | | |||
487 | void DocumentView::slotLoadingFailed() | 482 | void DocumentView::slotLoadingFailed() | ||
Show All 15 Lines | |||||
503 | void DocumentView::setZoomToFit(bool on) | 498 | void DocumentView::setZoomToFit(bool on) | ||
504 | { | 499 | { | ||
505 | if (on == d->mAdapter->zoomToFit()) { | 500 | if (on == d->mAdapter->zoomToFit()) { | ||
506 | return; | 501 | return; | ||
507 | } | 502 | } | ||
508 | d->mAdapter->setZoomToFit(on); | 503 | d->mAdapter->setZoomToFit(on); | ||
509 | } | 504 | } | ||
510 | 505 | | |||
511 | void DocumentView::setZoomToFitWidth(bool on) | 506 | void DocumentView::setZoomToFill(bool on) | ||
512 | { | 507 | { | ||
513 | if (on == d->mAdapter->zoomToFitWidth()) { | 508 | if (on == d->mAdapter->zoomToFill()) { | ||
514 | return; | 509 | return; | ||
515 | } | 510 | } | ||
516 | d->mAdapter->setZoomToFitWidth(on); | 511 | d->mAdapter->setZoomToFill(on); | ||
517 | } | 512 | } | ||
518 | 513 | | |||
519 | bool DocumentView::zoomToFit() const | 514 | bool DocumentView::zoomToFit() const | ||
520 | { | 515 | { | ||
521 | return d->mAdapter->zoomToFit(); | 516 | return d->mAdapter->zoomToFit(); | ||
522 | } | 517 | } | ||
523 | 518 | | |||
524 | bool DocumentView::zoomToFitWidth() const | 519 | bool DocumentView::zoomToFill() const | ||
525 | { | 520 | { | ||
526 | return d->mAdapter->zoomToFitWidth(); | 521 | return d->mAdapter->zoomToFill(); | ||
527 | } | 522 | } | ||
528 | 523 | | |||
529 | void DocumentView::zoomActualSize() | 524 | void DocumentView::zoomActualSize() | ||
530 | { | 525 | { | ||
531 | d->uncheckZoomToFit(); | 526 | d->uncheckZoomToFit(); | ||
532 | d->uncheckZoomToFitWidth(); | 527 | d->uncheckZoomToFill(); | ||
533 | d->mAdapter->setZoom(1.); | 528 | d->mAdapter->setZoom(1.); | ||
534 | } | 529 | } | ||
535 | 530 | | |||
536 | void DocumentView::zoomIn(const QPointF& center) | 531 | void DocumentView::zoomIn(const QPointF& center) | ||
537 | { | 532 | { | ||
538 | qreal currentZoom = d->mAdapter->zoom(); | 533 | qreal currentZoom = d->mAdapter->zoom(); | ||
539 | 534 | | |||
540 | Q_FOREACH(qreal zoom, d->mZoomSnapValues) { | 535 | Q_FOREACH(qreal zoom, d->mZoomSnapValues) { | ||
▲ Show 20 Lines • Show All 277 Lines • Show Last 20 Lines |
Was there a reason this was split into if-else?