Changeset View
Changeset View
Standalone View
Standalone View
lib/documentview/documentviewcontainer.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | |||||
114 | DocumentViewContainer::~DocumentViewContainer() | 114 | DocumentViewContainer::~DocumentViewContainer() | ||
115 | { | 115 | { | ||
116 | delete d; | 116 | delete d; | ||
117 | } | 117 | } | ||
118 | 118 | | |||
119 | DocumentView* DocumentViewContainer::createView() | 119 | DocumentView* DocumentViewContainer::createView() | ||
120 | { | 120 | { | ||
121 | DocumentView* view = new DocumentView(d->mScene); | 121 | DocumentView* view = new DocumentView(d->mScene); | ||
122 | view->setPalette(palette()); | ||||
122 | d->mAddedViews << view; | 123 | d->mAddedViews << view; | ||
123 | view->show(); | 124 | view->show(); | ||
124 | connect(view, &DocumentView::fadeInFinished, this, &DocumentViewContainer::slotFadeInFinished); | 125 | connect(view, &DocumentView::fadeInFinished, this, &DocumentViewContainer::slotFadeInFinished); | ||
125 | d->scheduleLayoutUpdate(); | 126 | d->scheduleLayoutUpdate(); | ||
126 | return view; | 127 | return view; | ||
127 | } | 128 | } | ||
128 | 129 | | |||
129 | void DocumentViewContainer::deleteView(DocumentView* view) | 130 | void DocumentViewContainer::deleteView(DocumentView* view) | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 174 | { | |||
180 | bool animated = GwenviewConfig::animationMethod() != DocumentView::NoAnimation; | 181 | bool animated = GwenviewConfig::animationMethod() != DocumentView::NoAnimation; | ||
181 | bool crossFade = d->mAddedViews.count() == 1 && d->mRemovedViews.count() == 1; | 182 | bool crossFade = d->mAddedViews.count() == 1 && d->mRemovedViews.count() == 1; | ||
182 | 183 | | |||
183 | if (animated && crossFade) { | 184 | if (animated && crossFade) { | ||
184 | DocumentView* oldView = *d->mRemovedViews.begin(); | 185 | DocumentView* oldView = *d->mRemovedViews.begin(); | ||
185 | DocumentView* newView = *d->mAddedViews.begin(); | 186 | DocumentView* newView = *d->mAddedViews.begin(); | ||
186 | 187 | | |||
187 | newView->setGeometry(rect()); | 188 | newView->setGeometry(rect()); | ||
188 | newView->setEraseBorders(true); | | |||
189 | QPropertyAnimation* anim = newView->fadeIn(); | 189 | QPropertyAnimation* anim = newView->fadeIn(); | ||
190 | 190 | | |||
191 | oldView->setZValue(-1); | 191 | oldView->setZValue(-1); | ||
192 | connect(anim, &QPropertyAnimation::finished, oldView, &DocumentView::hideAndDeleteLater); | 192 | connect(anim, &QPropertyAnimation::finished, oldView, &DocumentView::hideAndDeleteLater); | ||
193 | d->mRemovedViews.clear(); | 193 | d->mRemovedViews.clear(); | ||
194 | 194 | | |||
195 | return; | 195 | return; | ||
196 | } | 196 | } | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 241 | if (d->mViews.contains(view)) { | |||
251 | } | 251 | } | ||
252 | } else { | 252 | } else { | ||
253 | view->setGeometry(rect); | 253 | view->setGeometry(rect); | ||
254 | view->fadeIn(); | 254 | view->fadeIn(); | ||
255 | } | 255 | } | ||
256 | } else { | 256 | } else { | ||
257 | // Not animated, set final geometry and opacity now | 257 | // Not animated, set final geometry and opacity now | ||
258 | view->setGeometry(rect); | 258 | view->setGeometry(rect); | ||
259 | view->setOpacity(1); | 259 | view->setOpacityEffectEnabled(false); | ||
260 | } | 260 | } | ||
261 | 261 | | |||
262 | ++col; | 262 | ++col; | ||
263 | if (col == colCount) { | 263 | if (col == colCount) { | ||
264 | col = 0; | 264 | col = 0; | ||
265 | ++row; | 265 | ++row; | ||
266 | } | 266 | } | ||
267 | } | 267 | } | ||
Show All 27 Lines | |||||
295 | { | 295 | { | ||
296 | if (!d->mAddedViews.contains(view)) { | 296 | if (!d->mAddedViews.contains(view)) { | ||
297 | // This can happen if user goes to next image then quickly goes to the | 297 | // This can happen if user goes to next image then quickly goes to the | ||
298 | // next one before the animation is finished. | 298 | // next one before the animation is finished. | ||
299 | return; | 299 | return; | ||
300 | } | 300 | } | ||
301 | d->mAddedViews.remove(view); | 301 | d->mAddedViews.remove(view); | ||
302 | d->mViews.insert(view); | 302 | d->mViews.insert(view); | ||
303 | view->setEraseBorders(false); | | |||
304 | } | 303 | } | ||
305 | 304 | | |||
306 | void DocumentViewContainer::slotConfigChanged() | 305 | void DocumentViewContainer::slotConfigChanged() | ||
307 | { | 306 | { | ||
308 | bool currentlyGL = qobject_cast<QGLWidget*>(viewport()); | 307 | bool currentlyGL = qobject_cast<QGLWidget*>(viewport()); | ||
309 | bool wantGL = GwenviewConfig::animationMethod() == DocumentView::GLAnimation; | 308 | bool wantGL = GwenviewConfig::animationMethod() == DocumentView::GLAnimation; | ||
310 | if (currentlyGL != wantGL) { | 309 | if (currentlyGL != wantGL) { | ||
311 | setViewport(wantGL ? new QGLWidget() : new QWidget()); | 310 | setViewport(wantGL ? new QGLWidget() : new QWidget()); | ||
Show All 14 Lines | 315 | { | |||
326 | widget->setParentItem(view); | 325 | widget->setParentItem(view); | ||
327 | GraphicsWidgetFloater* floater = new GraphicsWidgetFloater(view); | 326 | GraphicsWidgetFloater* floater = new GraphicsWidgetFloater(view); | ||
328 | floater->setChildWidget(widget); | 327 | floater->setChildWidget(widget); | ||
329 | floater->setAlignment(align); | 328 | floater->setAlignment(align); | ||
330 | widget->show(); | 329 | widget->show(); | ||
331 | widget->setZValue(1); | 330 | widget->setZValue(1); | ||
332 | } | 331 | } | ||
333 | 332 | | |||
333 | void DocumentViewContainer::applyPalette(const QPalette& palette) | ||||
334 | { | ||||
335 | setPalette(palette); | ||||
336 | for (DocumentView* view : d->mViews) { | ||||
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… | |||||
337 | view->setPalette(palette); | ||||
338 | } | ||||
339 | for (DocumentView* view : d->mAddedViews) { | ||||
340 | view->setPalette(palette); | ||||
341 | } | ||||
342 | } | ||||
343 | | ||||
334 | } // namespace | 344 | } // namespace |
Please don't use Q_FOREACH for new code, see https://doc.qt.io/qt-5/qtglobal.html#Q_FOREACH.