MCPcopy Create free account
hub / github.com/YACReader/yacreader / newComic

Method newComic

YACReaderLibrary/import_widget.cpp:197–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197void ImportWidget::newComic(const QString &path, const QString &coverPath)
198{
199 if (!this->isVisible())
200 return;
201
202 currentComicLabel->setText(path);
203
204 if (((elapsedTimer->elapsed() >= 1100) || ((previousWidth < coversView->width()) && (elapsedTimer->elapsed() >= 500))) && scrollAnimation->state() != QAbstractAnimation::Running) // todo elapsed time
205 {
206 updatingCovers = true;
207 elapsedTimer->start();
208
209 QPixmap p(coverPath);
210 p = p.scaledToHeight(300, Qt::SmoothTransformation);
211
212 auto item = new QGraphicsPixmapItem(p);
213 item->setPos(previousWidth, 0);
214 coversScene->addItem(item);
215
216 previousWidth += 10 + p.width();
217
218 for (auto *itemToRemove : coversScene->items()) {
219 auto last = dynamic_cast<QGraphicsPixmapItem *>(itemToRemove);
220
221 if ((last->pos().x() + last->pixmap().width()) < coversView->horizontalScrollBar()->value()) // TODO check this
222 {
223 coversScene->removeItem(last);
224 delete last;
225 }
226 }
227
228 QScrollBar *scrollBar = coversView->horizontalScrollBar();
229
230 float speedFactor = 2.5;
231 int origin = scrollBar->value();
232 int dest = origin + 10 + p.width();
233
234 scrollAnimation->setDuration((dest - origin) * speedFactor);
235 scrollAnimation->setStartValue(origin);
236 scrollAnimation->setEndValue(dest);
237 QEasingCurve easing(QEasingCurve::OutQuad);
238 scrollAnimation->setEasingCurve(easing);
239 scrollAnimation->start();
240 }
241}
242
243void ImportWidget::newCover(const QPixmap &image)
244{

Callers

nothing calls this directly

Calls 6

stateMethod · 0.80
startMethod · 0.80
addItemMethod · 0.80
pixmapMethod · 0.80
removeItemMethod · 0.80
setTextMethod · 0.45

Tested by

no test coverage detected