Changeset View
Changeset View
Standalone View
Standalone View
lib/documentview/documentviewcontainer.cpp
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Line(s) | 173 | { | |||
---|---|---|---|---|---|
180 | bool animated = GwenviewConfig::animationMethod() != DocumentView::NoAnimation; | 180 | bool animated = GwenviewConfig::animationMethod() != DocumentView::NoAnimation; | ||
181 | bool crossFade = d->mAddedViews.count() == 1 && d->mRemovedViews.count() == 1; | 181 | bool crossFade = d->mAddedViews.count() == 1 && d->mRemovedViews.count() == 1; | ||
182 | 182 | | |||
183 | if (animated && crossFade) { | 183 | if (animated && crossFade) { | ||
184 | DocumentView* oldView = *d->mRemovedViews.begin(); | 184 | DocumentView* oldView = *d->mRemovedViews.begin(); | ||
185 | DocumentView* newView = *d->mAddedViews.begin(); | 185 | DocumentView* newView = *d->mAddedViews.begin(); | ||
186 | 186 | | |||
187 | newView->setGeometry(rect()); | 187 | newView->setGeometry(rect()); | ||
188 | newView->setEraseBorders(true); | | |||
189 | QPropertyAnimation* anim = newView->fadeIn(); | 188 | QPropertyAnimation* anim = newView->fadeIn(); | ||
190 | 189 | | |||
191 | oldView->setZValue(-1); | 190 | oldView->setZValue(-1); | ||
192 | connect(anim, &QPropertyAnimation::finished, oldView, &DocumentView::hideAndDeleteLater); | 191 | connect(anim, &QPropertyAnimation::finished, oldView, &DocumentView::hideAndDeleteLater); | ||
193 | d->mRemovedViews.clear(); | 192 | d->mRemovedViews.clear(); | ||
194 | 193 | | |||
195 | return; | 194 | return; | ||
196 | } | 195 | } | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
295 | { | 294 | { | ||
296 | if (!d->mAddedViews.contains(view)) { | 295 | if (!d->mAddedViews.contains(view)) { | ||
297 | // This can happen if user goes to next image then quickly goes to the | 296 | // This can happen if user goes to next image then quickly goes to the | ||
298 | // next one before the animation is finished. | 297 | // next one before the animation is finished. | ||
299 | return; | 298 | return; | ||
300 | } | 299 | } | ||
301 | d->mAddedViews.remove(view); | 300 | d->mAddedViews.remove(view); | ||
302 | d->mViews.insert(view); | 301 | d->mViews.insert(view); | ||
303 | view->setEraseBorders(false); | | |||
304 | } | 302 | } | ||
305 | 303 | | |||
306 | void DocumentViewContainer::slotConfigChanged() | 304 | void DocumentViewContainer::slotConfigChanged() | ||
307 | { | 305 | { | ||
308 | bool currentlyGL = qobject_cast<QGLWidget*>(viewport()); | 306 | bool currentlyGL = qobject_cast<QGLWidget*>(viewport()); | ||
309 | bool wantGL = GwenviewConfig::animationMethod() == DocumentView::GLAnimation; | 307 | bool wantGL = GwenviewConfig::animationMethod() == DocumentView::GLAnimation; | ||
310 | if (currentlyGL != wantGL) { | 308 | if (currentlyGL != wantGL) { | ||
311 | setViewport(wantGL ? new QGLWidget() : new QWidget()); | 309 | setViewport(wantGL ? new QGLWidget() : new QWidget()); | ||
Show All 14 Lines | 314 | { | |||
326 | widget->setParentItem(view); | 324 | widget->setParentItem(view); | ||
327 | GraphicsWidgetFloater* floater = new GraphicsWidgetFloater(view); | 325 | GraphicsWidgetFloater* floater = new GraphicsWidgetFloater(view); | ||
328 | floater->setChildWidget(widget); | 326 | floater->setChildWidget(widget); | ||
329 | floater->setAlignment(align); | 327 | floater->setAlignment(align); | ||
330 | widget->show(); | 328 | widget->show(); | ||
331 | widget->setZValue(1); | 329 | widget->setZValue(1); | ||
332 | } | 330 | } | ||
333 | 331 | | |||
334 | } // namespace | 332 | } // namespace | ||
rkflx: Please don't use `Q_FOREACH` for new code, see https://doc.qt.io/qt-5/qtglobal.html#Q_FOREACH. | |||||
rkflx: Would this also work without `(…).toList()`? | |||||
…and without the braces? (At least to me the operator precedence it pretty clear here.) rkflx: …and without the braces? (At least to me the operator precedence it pretty clear here.) | |||||
I usually prefer being explicit than relying on operator precedence, but in this case there's really no other way to interpret it! huoni: I usually prefer being explicit than relying on operator precedence, but in this case there's… |
Please don't use Q_FOREACH for new code, see https://doc.qt.io/qt-5/qtglobal.html#Q_FOREACH.