]> git.sur5r.net Git - minitube/commitdiff
Monochrome flat progress bar
authorFlavio <flavio@odisseo.local>
Sat, 29 Jan 2011 21:09:34 +0000 (22:09 +0100)
committerFlavio <flavio@odisseo.local>
Sat, 29 Jan 2011 21:09:34 +0000 (22:09 +0100)
src/loadingwidget.cpp
src/loadingwidget.h

index ce830bad78b52d6cf4f076ea98502b952228a69f..a1c81dd931107ae37392c493d004dad958b8fc56 100644 (file)
@@ -40,11 +40,14 @@ LoadingWidget::LoadingWidget(QWidget *parent) : QWidget(parent) {
     descriptionLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     layout->addWidget(descriptionLabel);
 
-    /*
     progressBar = new QProgressBar(this);
-    progressBar->hide();
+    progressBar->setAutoFillBackground(false);
+    progressBar->setBackgroundRole(QPalette::Window);
+    progressBar->setPalette(p);
+    // progressBar->hide();
+    progressBar->setStyleSheet("QProgressBar {max-height:3px; background:black; border:0} QProgressBar::chunk {background:white}");
+    progressBar->setTextVisible(false);
     layout->addWidget(progressBar);
-    */
 
     setMouseTracking(true);
 
@@ -60,24 +63,38 @@ void LoadingWidget::setVideo(Video *video) {
     titleLabel->setText(title);
     descriptionLabel->setText(video->description());
     // progressBar->hide();
+    progressBar->setValue(0);
+    startTime.start();
 }
 
 void LoadingWidget::setError(QString message) {
     titleLabel->setText(tr("Error"));
     descriptionLabel->setText(message);
     // progressBar->hide();
+    progressBar->setValue(0);
 }
 
-void LoadingWidget::bufferStatus(int /* percent */) {
+void LoadingWidget::bufferStatus(int percent) {
+    // qDebug() << percent;
+
     /*
-    qDebug() << percent;
-    progressBar->setShown(percent > 0);
+    if (progressBar->isHidden() && percent > 0) {
+        progressBar->show();
+        QPropertyAnimation *animation = new QPropertyAnimation(progressBar, "opacity");
+        animation->setDuration(1000);
+        animation->setStartValue(0.0);
+        animation->setEndValue(1.0);
+        animation->start();
+    }*/
+    // progressBar->setShown(percent > 0);
+    if (startTime.elapsed() < 1000) return;
+    if (progressBar->value() == 0 && percent > 80) return;
     progressBar->setValue(percent);
-    */
 }
 
 void LoadingWidget::clear() {
     titleLabel->clear();
     descriptionLabel->clear();
     // progressBar->hide();
+    progressBar->setValue(0);
 }
index 77a3b1dfce1bea6c507572c603863014f97c3376..96a8b44f790d2f8b3460758541578ad8a99479c3 100644 (file)
@@ -20,9 +20,8 @@ public slots:
 private:
     QLabel *titleLabel;
     QLabel *descriptionLabel;
-    // TODO uncomment the whole progress bar feature
-    // when the Phonon backends will correctly emit bufferStatus(int)
-    // QProgressBar *progressBar;
+    QProgressBar *progressBar;
+    QTime startTime;
 
 };