for (int i=0; i<tabWidget->count(); i++) {
delete(item);
}
invalidate(sceneRect());
items.clear();
int batchSz = 4;
for (int i=0; i<tabWidget->count(); i++) {
pm = pm.scaled(300,200, Qt::IgnoreAspectRatio);
ThumbnailItem * item = new ThumbnailItem(pm, i); // TODO Take size from config
items << item;
connect(item, SIGNAL(tabSelected(int)), tabWidget, SLOT(onTabSelected(int)));
connect(item, SIGNAL(tabSelected(int)), this, SIGNAL(toggleThumbnailMode()));
if (items.count() % batchSz == 0) {
addItem(i);
}
}
foreach
(QGraphicsItem *i, items.
mid(items.
count() - items.
count()%batchSz
)) addItem(i);
}
for (int i=0; i<tabWidget->count(); i++) {
foreach(QGraphicsItem *item, items) {
delete(item);
}
invalidate(sceneRect());
items.clear();
int batchSz = 4;
for (int i=0; i<tabWidget->count(); i++) {
QWidget *w = tabWidget->widget(i);
QPixmap pm = QPixmap::grabWidget(w);
pm = pm.scaled(300,200, Qt::IgnoreAspectRatio);
ThumbnailItem * item = new ThumbnailItem(pm, i); // TODO Take size from config
items << item;
connect(item, SIGNAL(tabSelected(int)), tabWidget, SLOT(onTabSelected(int)));
connect(item, SIGNAL(tabSelected(int)), this, SIGNAL(toggleThumbnailMode()));
if (items.count() % batchSz == 0) {
foreach(QGraphicsItem *i, items.mid(items.count()-4))
addItem(i);
QCoreApplication::processEvents();
}
}
foreach(QGraphicsItem *i, items.mid(items.count() - items.count()%batchSz))
addItem(i);
}
To copy to clipboard, switch view to plain text mode
Now the switch to thumbnail-mode is immediate which is a good thing. But, now the users see the items being created which is not optimal. Is it expensive to add some QGV Animation to hide this from the user? Maybe to display an opaque QGraphicsRectItem that covers the whole scene and then fading it out using QTimeLine in conjunction with QGraphicsItemAnimation?
Bookmarks