+
+void ChatScene::webPreviewNextStep()
+{
+ // qDebug() << Q_FUNC_INFO << webPreview.previewState;
+ switch (webPreview.previewState) {
+ case WebPreview::NoPreview:
+ break;
+ case WebPreview::NewPreview:
+ Q_ASSERT(!webPreview.previewItem);
+ webPreview.previewItem = new WebPreviewItem(webPreview.url);
+ webPreview.previewState = WebPreview::DelayPreview;
+ webPreview.timer.start(1000);
+ break;
+ case WebPreview::DelayPreview:
+ Q_ASSERT(webPreview.previewItem);
+ // calc position and show
+ {
+ qreal previewY = webPreview.urlRect.bottom();
+ qreal previewX = webPreview.urlRect.x();
+ if (previewY + webPreview.previewItem->boundingRect().height() > sceneRect().bottom())
+ previewY = webPreview.urlRect.y() - webPreview.previewItem->boundingRect().height();
+
+ if (previewX + webPreview.previewItem->boundingRect().width() > sceneRect().width())
+ previewX = sceneRect().right() - webPreview.previewItem->boundingRect().width();
+
+ webPreview.previewItem->setPos(previewX, previewY);
+ }
+ addItem(webPreview.previewItem);
+ webPreview.previewState = WebPreview::ShowPreview;
+ break;
+ case WebPreview::ShowPreview:
+ qWarning() << "ChatScene::webPreviewNextStep() called while in ShowPreview Step!";
+ qWarning() << "removing preview";
+ if (webPreview.previewItem && webPreview.previewItem->scene())
+ removeItem(webPreview.previewItem);
+ // Fall through to deletion!
+ case WebPreview::HidePreview:
+ if (webPreview.previewItem) {
+ delete webPreview.previewItem;
+ webPreview.previewItem = 0;
+ }
+ webPreview.parentItem = 0;
+ webPreview.url = QUrl();
+ webPreview.urlRect = QRectF();
+ webPreview.previewState = WebPreview::NoPreview;
+ }
+ // qDebug() << " new State:" << webPreview.previewState << webPreview.timer.isActive();
+}
+
+
+void ChatScene::clearWebPreview(ChatItem *parentItem)
+{
+ // qDebug() << Q_FUNC_INFO << webPreview.previewState;
+ switch (webPreview.previewState) {
+ case WebPreview::NewPreview:
+ webPreview.previewState = WebPreview::NoPreview; // we haven't loaded anything yet
+ break;
+ case WebPreview::ShowPreview:
+ if (parentItem == 0 || webPreview.parentItem == parentItem) {
+ if (webPreview.previewItem && webPreview.previewItem->scene())
+ removeItem(webPreview.previewItem);
+ }
+ // fall through into to set hidden state
+ case WebPreview::DelayPreview:
+ // we're just loading, so haven't shown the preview yet.
+ webPreview.previewState = WebPreview::HidePreview;
+ webPreview.timer.start(5000);
+ break;
+ case WebPreview::NoPreview:
+ case WebPreview::HidePreview:
+ break;
+ }
+ // qDebug() << " new State:" << webPreview.previewState << webPreview.timer.isActive();
+}
+
+
+#endif
+
+// ========================================
+// end of webkit only
+// ========================================
+
+void ChatScene::showWebPreviewChanged()
+{
+ ChatViewSettings settings;
+ _showWebPreview = settings.showWebPreview();