From 6199d6d5431d6188a8b530b71419aa3abd3aa6f2 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 11 Nov 2009 14:58:13 +0000 Subject: [PATCH] - Put pieces properties on the top of torrent properties (uTorrent like) --- src/propertiesWidget.ui | 70 ++++++++++++++++++++------------ src/propertieswidget.cpp | 7 ++-- src/propertieswidget.h | 2 - src/realprogressbar.cpp | 88 ++++++++++++++++++++-------------------- 4 files changed, 90 insertions(+), 77 deletions(-) diff --git a/src/propertiesWidget.ui b/src/propertiesWidget.ui index 58a551048..f5897252a 100644 --- a/src/propertiesWidget.ui +++ b/src/propertiesWidget.ui @@ -6,7 +6,7 @@ 0 0 - 756 + 758 292 @@ -54,6 +54,48 @@ + + + + + + + 0 + 0 + + + + + 100 + 16777215 + + + + Downloaded: + + + + + + + + 0 + 0 + + + + + 44 + 16777215 + + + + 0.0% + + + + + @@ -257,12 +299,6 @@ 0 - - - 0 - 115 - - 8 @@ -450,26 +486,6 @@ - - - - - 0 - 50 - - - - - 8 - 75 - true - - - - Downloaded pieces - - - diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 2c7f3f83f..ab1a06e57 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -96,8 +96,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer // Downloaded pieces progress bar progressBar = new RealProgressBar(this); progressBar->setForegroundColor(Qt::blue); - progressBarVbox = new QVBoxLayout(RealProgressBox); - progressBarVbox->addWidget(progressBar); + ProgressHLayout->insertWidget(1, progressBar); + //progressBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); // Pointers init progressBarUpdater = 0; // Dynamic data refresher @@ -112,7 +112,6 @@ PropertiesWidget::~PropertiesWidget() { if(progressBarUpdater) delete progressBarUpdater; delete progressBar; - delete progressBarVbox; delete PropListModel; // Delete QActions delete actionIgnored; @@ -246,6 +245,8 @@ void PropertiesWidget::loadDynamicData() { // Downloaded pieces if(progressBarUpdater) progressBarUpdater->refresh(); + // Progress + progress_lbl->setText(QString::number(h.progress(), 'f', 1)+"%"); // Files progress std::vector fp; h.file_progress(fp); diff --git a/src/propertieswidget.h b/src/propertieswidget.h index a9e625ccc..c9efd25db 100644 --- a/src/propertieswidget.h +++ b/src/propertieswidget.h @@ -39,7 +39,6 @@ class TransferListWidget; class QTimer; class RealProgressBar; -class QVBoxLayout; class RealProgressBarThread; class bittorrent; class TorrentFilesModel; @@ -59,7 +58,6 @@ private: QTimer *refreshTimer; RealProgressBar *progressBar; RealProgressBarThread *progressBarUpdater; - QVBoxLayout *progressBarVbox; bittorrent* BTSession; SlideState state; TorrentFilesModel *PropListModel; diff --git a/src/realprogressbar.cpp b/src/realprogressbar.cpp index 8ae80c0ec..7479064e4 100644 --- a/src/realprogressbar.cpp +++ b/src/realprogressbar.cpp @@ -33,85 +33,83 @@ #include #include -RealProgressBar::RealProgressBar(QWidget *parent) - : QWidget(parent), array(1) -{ - background = Qt::white; - foreground = Qt::black; - setFixedHeight(20); - active = false; - array[0] = 0.; - drawPixmap(); +RealProgressBar::RealProgressBar(QWidget *parent): QWidget(parent), array(1) { + background = Qt::white; + foreground = Qt::black; + setFixedHeight(18); + active = false; + array[0] = 0.; + drawPixmap(); } RealProgressBar::~RealProgressBar() { - qDebug("RealProgressBar destruction"); + qDebug("RealProgressBar destruction"); } void RealProgressBar::setBackgroundColor(const QColor &newColor) { - background = newColor; - drawPixmap(); + background = newColor; + drawPixmap(); } void RealProgressBar::setForegroundColor(const QColor &newColor) { - foreground = newColor; - drawPixmap(); + foreground = newColor; + drawPixmap(); } /* void RealProgressBar::setThread(const RealProgressBarThread *newThread) { - thread = newThread; + thread = newThread; } */ void RealProgressBar::paintEvent(QPaintEvent *) { - QPainter painter(this); - painter.drawPixmap(rect(), pixmap); + QPainter painter(this); + painter.drawPixmap(rect(), pixmap); } void RealProgressBar::resizeEvent(QResizeEvent *event) { - if(width() != event->oldSize().width()) - emit widthChanged(width()); + if(width() != event->oldSize().width()) + emit widthChanged(width()); } void RealProgressBar::setProgress(QRealArray progress) { - qDebug("setProgress called"); - array = progress; - drawPixmap(); + qDebug("setProgress called"); + array = progress; + drawPixmap(); } void RealProgressBar::drawPixmap() { - if(pixmap.width() != array.size()) - pixmap = QPixmap(array.size(), 1); - QPainter painter(&pixmap); - for(int i=0; i 1.) - x = 1.; - qreal y = 1. - x; -// Q_ASSERT(x >= 0.); -// Q_ASSERT(y >= 0.); - qreal r1, g1, b1, a1, r2, g2, b2, a2; - foreground.getRgbF(&r1, &g1, &b1, &a1); - background.getRgbF(&r2, &g2, &b2, &a2); - QColor color; - color.setRgbF(x*r1+y*r2, x*g1+y*g2, x*b1+y*b2, x*a1+y*a2); - return color; + if(x < 0.) + x = 0.; + else + if(x > 1.) + x = 1.; + qreal y = 1. - x; + // Q_ASSERT(x >= 0.); + // Q_ASSERT(y >= 0.); + qreal r1, g1, b1, a1, r2, g2, b2, a2; + foreground.getRgbF(&r1, &g1, &b1, &a1); + background.getRgbF(&r2, &g2, &b2, &a2); + QColor color; + color.setRgbF(x*r1+y*r2, x*g1+y*g2, x*b1+y*b2, x*a1+y*a2); + return color; }