- // TODO - create tip during requestTip(...) - this makes it more likely that the previews
- // job will have completed by the time the tooltip is shown, resulting in less flicker.
- // The memory management will be more intricate, though.
- DolphinToolTipItem *tip = new DolphinToolTipItem(m_item);
+ if (m_generatingPreview) {
+ if (m_previewPass == 1) {
+ // We waited 250msec and the preview is still not finished,
+ // so show the toolTip with a transparent image of maximal width.
+ // When the preview finishes, m_previewIsLate will cause
+ // a direct update of the tooltip, via m_emptyRenderedKToolTipItem.
+ QPixmap paddedImage(QSize(PREVIEW_WIDTH, 32));
+ m_previewIsLate = true;
+ paddedImage.fill(Qt::transparent);
+ KToolTipItem* toolTip = new KToolTipItem(paddedImage, m_item.getToolTipText());
+ m_emptyRenderedKToolTipItem = toolTip; // make toolTip accessible everywhere
+ showToolTip(toolTip);
+ }
+
+ ++m_previewPass;
+ m_waitOnPreviewTimer->start(250);
+ } else {
+ // The preview generation has finished, find out under which circumstances.
+ if (m_preview && m_previewIsLate) {
+ // We got a preview, but it is late, the tooltip has already been shown.
+ // So update the tooltip directly.
+ if (m_emptyRenderedKToolTipItem != 0) {
+ m_emptyRenderedKToolTipItem->setData(Qt::DecorationRole, KIcon(m_pix));
+ }
+ return;
+ }
+
+ KIcon icon;
+ if (m_preview) {
+ // We got a preview.
+ icon = KIcon(m_pix);
+ } else {
+ // No preview, so use an icon.
+ // Force a 128x128 icon, a 256x256 one is far too big.
+ icon = KIcon(KIcon(m_item.iconName()).pixmap(ICON_WIDTH, ICON_HEIGHT));
+ }