]> git.sur5r.net Git - minitube/commitdiff
Video error reporting
authorFlavio Tordini <flavio.tordini@gmail.com>
Sat, 15 Aug 2009 14:48:11 +0000 (16:48 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Sat, 15 Aug 2009 14:48:11 +0000 (16:48 +0200)
src/video.cpp
src/video.h
src/videoareawidget.cpp
src/videoareawidget.h
src/youtubesearch.cpp

index 1ac9871453133da8ba23a27c46eea259de5ddd07..c4c3575955c077264ca9ac99e0679c0684095ba0 100644 (file)
@@ -39,7 +39,7 @@ void Video::scrapeStreamUrl() {
     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);
@@ -52,6 +52,7 @@ void Video::scrapeStreamUrl() {
 
     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...
 }
@@ -76,8 +77,9 @@ void  Video::gotVideoInfo(QByteArray data) {
                 errorMessage = errorMessage.left(indexOfTag);
             }
             if (mainWindow) mainWindow->statusBar()->showMessage(errorMessage);
-        }
-        emit errorStreamUrl();
+            emit errorStreamUrl(errorMessage);
+        } else
+            emit errorStreamUrl("Error parsing video info");
         return;
     }
 
@@ -95,3 +97,7 @@ void  Video::gotVideoInfo(QByteArray data) {
 
     emit gotStreamUrl(videoUrl);
 }
+
+void Video::errorVideoInfo(QNetworkReply *reply) {
+    emit errorStreamUrl(tr("Network error: %1 for %2").arg(reply->errorString(), reply->url().toString()));
+}
index f7d91980633d9efe20f5696ff5095fe82ca8ca01..974f49bead06f07789414ba90bb28940183da49b 100644 (file)
@@ -52,10 +52,11 @@ public slots:
 signals:
     void gotThumbnail();
     void gotStreamUrl(QUrl streamUrl);
-    void errorStreamUrl();
+    void errorStreamUrl(QString message);
 
 private slots:
     void gotVideoInfo(QByteArray);
+    void errorVideoInfo(QNetworkReply*);
 
 private:
     void scrapeStreamUrl();
index 0169148f5bf9db10ef4a76ccfd69a70d209a8f0c..1e873438bb3af26794bcb7ea0f8d8bd24a4d15f6 100644 (file)
@@ -2,10 +2,27 @@
 #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);
@@ -29,13 +46,17 @@ void VideoAreaWidget::showVideo() {
 }
 
 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) {
@@ -67,10 +88,10 @@ void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *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);
index 44e547752e8ac15c5d9f77326ded1365300b5051..34650cc519b413576453c16345e6347c6abb8de7 100644 (file)
@@ -41,7 +41,7 @@ private:
     QWidget *videoWidget;
     LoadingWidget *loadingWidget;
     ListModel *listModel;
-
+    QLabel *messageLabel;
     QTimer *mouseTimer;
 };
 
index a1820993d7c4a7f4b731bc1dc44b7f37eba7cf7c..78d4375ae692bd1562bd70167d654f32a23b1414 100644 (file)
@@ -17,6 +17,7 @@ void YouTubeSearch::search(SearchParams *searchParams, int max, int skip) {
             .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));