QRegExp re("^http://www\\.youtube\\.com/watch\\?v=([0-9A-Za-z_-]+)$");
bool match = re.exactMatch(webpage.toString());
if (!match || re.numCaptures() < 1) {
- emit errorStreamUrl();
+ emit errorStreamUrl(QString("Cannot get video id for %1").arg(webpage.toString()));
return;
}
videoId = re.cap(1);
QObject *reply = The::http()->get(normalizedUrl);
connect(reply, SIGNAL(data(QByteArray)), SLOT(gotVideoInfo(QByteArray)));
+ connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(errorVideoInfo(QNetworkReply*)));
// see you in gotVideoInfo...
}
errorMessage = errorMessage.left(indexOfTag);
}
if (mainWindow) mainWindow->statusBar()->showMessage(errorMessage);
- }
- emit errorStreamUrl();
+ emit errorStreamUrl(errorMessage);
+ } else
+ emit errorStreamUrl("Error parsing video info");
return;
}
emit gotStreamUrl(videoUrl);
}
+
+void Video::errorVideoInfo(QNetworkReply *reply) {
+ emit errorStreamUrl(tr("Network error: %1 for %2").arg(reply->errorString(), reply->url().toString()));
+}
#include "videomimedata.h"
VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
- stackedLayout = new QStackedLayout(this);
- setLayout(stackedLayout);
+ QBoxLayout *vLayout = new QVBoxLayout(this);
+ vLayout->setMargin(0);
+ vLayout->setSpacing(0);
+
+ // hidden message widget
+ messageLabel = new QLabel(this);
+ messageLabel->setOpenExternalLinks(true);
+ messageLabel->setMargin(7);
+ messageLabel->setBackgroundRole(QPalette::ToolTipBase);
+ messageLabel->setForegroundRole(QPalette::ToolTipText);
+ messageLabel->setAutoFillBackground(true);
+ messageLabel->setWordWrap(true);
+ messageLabel->hide();
+ vLayout->addWidget(messageLabel);
+
+ stackedLayout = new QStackedLayout();
+ vLayout->addLayout(stackedLayout);
+
+ setLayout(vLayout);
setAcceptDrops(true);
-
+
// mouse autohide
setMouseTracking(true);
mouseTimer = new QTimer(this);
}
void VideoAreaWidget::showError(QString message) {
- loadingWidget->setError(message);
+ // loadingWidget->setError(message);
+ messageLabel->setText(message);
+ messageLabel->show();
stackedLayout->setCurrentWidget(loadingWidget);
}
void VideoAreaWidget::showLoading(Video *video) {
this->loadingWidget->setVideo(video);
stackedLayout->setCurrentWidget(loadingWidget);
+ messageLabel->hide();
+ messageLabel->clear();
}
void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) {
}
void VideoAreaWidget::dropEvent(QDropEvent *event) {
-
+
const VideoMimeData* videoMimeData = dynamic_cast<const VideoMimeData*>( event->mimeData() );
if(!videoMimeData ) return;
-
+
QList<Video*> droppedVideos = videoMimeData->videos();
foreach( Video *video, droppedVideos) {
int row = listModel->rowForVideo(video);
.arg(searchParams->keywords(), QString::number(max), QString::number(skip));
// Useful to test with a local webserver
+
urlString = QString("http://localhost/oringo/video.xml?q=%1&max-results=%2&start-index=%3")
.arg(searchParams->keywords(), QString::number(max), QString::number(skip));