- Put pieces properties on the top of torrent properties (uTorrent like)

This commit is contained in:
Christophe Dumez 2009-11-11 14:58:13 +00:00
parent f9c8b6a66e
commit 6199d6d543
4 changed files with 90 additions and 77 deletions

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>756</width> <width>758</width>
<height>292</height> <height>292</height>
</rect> </rect>
</property> </property>
@ -54,6 +54,48 @@
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="ProgressHLayout">
<item>
<widget class="QLabel" name="downloaded_pieces_lbl">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Downloaded:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="progress_lbl">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string notr="true">0.0%</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing"> <property name="spacing">
@ -257,12 +299,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>0</width>
<height>115</height>
</size>
</property>
<property name="font"> <property name="font">
<font> <font>
<pointsize>8</pointsize> <pointsize>8</pointsize>
@ -450,26 +486,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QGroupBox" name="RealProgressBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Downloaded pieces</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="incrementalDownload"> <widget class="QCheckBox" name="incrementalDownload">
<property name="font"> <property name="font">

View file

@ -96,8 +96,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
// Downloaded pieces progress bar // Downloaded pieces progress bar
progressBar = new RealProgressBar(this); progressBar = new RealProgressBar(this);
progressBar->setForegroundColor(Qt::blue); progressBar->setForegroundColor(Qt::blue);
progressBarVbox = new QVBoxLayout(RealProgressBox); ProgressHLayout->insertWidget(1, progressBar);
progressBarVbox->addWidget(progressBar); //progressBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
// Pointers init // Pointers init
progressBarUpdater = 0; progressBarUpdater = 0;
// Dynamic data refresher // Dynamic data refresher
@ -112,7 +112,6 @@ PropertiesWidget::~PropertiesWidget() {
if(progressBarUpdater) if(progressBarUpdater)
delete progressBarUpdater; delete progressBarUpdater;
delete progressBar; delete progressBar;
delete progressBarVbox;
delete PropListModel; delete PropListModel;
// Delete QActions // Delete QActions
delete actionIgnored; delete actionIgnored;
@ -246,6 +245,8 @@ void PropertiesWidget::loadDynamicData() {
// Downloaded pieces // Downloaded pieces
if(progressBarUpdater) if(progressBarUpdater)
progressBarUpdater->refresh(); progressBarUpdater->refresh();
// Progress
progress_lbl->setText(QString::number(h.progress(), 'f', 1)+"%");
// Files progress // Files progress
std::vector<size_type> fp; std::vector<size_type> fp;
h.file_progress(fp); h.file_progress(fp);

View file

@ -39,7 +39,6 @@
class TransferListWidget; class TransferListWidget;
class QTimer; class QTimer;
class RealProgressBar; class RealProgressBar;
class QVBoxLayout;
class RealProgressBarThread; class RealProgressBarThread;
class bittorrent; class bittorrent;
class TorrentFilesModel; class TorrentFilesModel;
@ -59,7 +58,6 @@ private:
QTimer *refreshTimer; QTimer *refreshTimer;
RealProgressBar *progressBar; RealProgressBar *progressBar;
RealProgressBarThread *progressBarUpdater; RealProgressBarThread *progressBarUpdater;
QVBoxLayout *progressBarVbox;
bittorrent* BTSession; bittorrent* BTSession;
SlideState state; SlideState state;
TorrentFilesModel *PropListModel; TorrentFilesModel *PropListModel;

View file

@ -33,85 +33,83 @@
#include <QtDebug> #include <QtDebug>
#include <QResizeEvent> #include <QResizeEvent>
RealProgressBar::RealProgressBar(QWidget *parent) RealProgressBar::RealProgressBar(QWidget *parent): QWidget(parent), array(1) {
: QWidget(parent), array(1) background = Qt::white;
{ foreground = Qt::black;
background = Qt::white; setFixedHeight(18);
foreground = Qt::black; active = false;
setFixedHeight(20); array[0] = 0.;
active = false; drawPixmap();
array[0] = 0.;
drawPixmap();
} }
RealProgressBar::~RealProgressBar() RealProgressBar::~RealProgressBar()
{ {
qDebug("RealProgressBar destruction"); qDebug("RealProgressBar destruction");
} }
void RealProgressBar::setBackgroundColor(const QColor &newColor) void RealProgressBar::setBackgroundColor(const QColor &newColor)
{ {
background = newColor; background = newColor;
drawPixmap(); drawPixmap();
} }
void RealProgressBar::setForegroundColor(const QColor &newColor) void RealProgressBar::setForegroundColor(const QColor &newColor)
{ {
foreground = newColor; foreground = newColor;
drawPixmap(); drawPixmap();
} }
/* /*
void RealProgressBar::setThread(const RealProgressBarThread *newThread) void RealProgressBar::setThread(const RealProgressBarThread *newThread)
{ {
thread = newThread; thread = newThread;
} }
*/ */
void RealProgressBar::paintEvent(QPaintEvent *) void RealProgressBar::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
painter.drawPixmap(rect(), pixmap); painter.drawPixmap(rect(), pixmap);
} }
void RealProgressBar::resizeEvent(QResizeEvent *event) void RealProgressBar::resizeEvent(QResizeEvent *event)
{ {
if(width() != event->oldSize().width()) if(width() != event->oldSize().width())
emit widthChanged(width()); emit widthChanged(width());
} }
void RealProgressBar::setProgress(QRealArray progress) void RealProgressBar::setProgress(QRealArray progress)
{ {
qDebug("setProgress called"); qDebug("setProgress called");
array = progress; array = progress;
drawPixmap(); drawPixmap();
} }
void RealProgressBar::drawPixmap() void RealProgressBar::drawPixmap()
{ {
if(pixmap.width() != array.size()) if(pixmap.width() != array.size())
pixmap = QPixmap(array.size(), 1); pixmap = QPixmap(array.size(), 1);
QPainter painter(&pixmap); QPainter painter(&pixmap);
for(int i=0; i<array.size(); i++) for(int i=0; i<array.size(); i++)
{ {
painter.setPen(penColor(array[i])); painter.setPen(penColor(array[i]));
painter.drawPoint(i,0); painter.drawPoint(i,0);
} }
update(); update();
} }
QColor RealProgressBar::penColor(qreal x) QColor RealProgressBar::penColor(qreal x)
{ {
if(x < 0.) if(x < 0.)
x = 0.; x = 0.;
else else
if(x > 1.) if(x > 1.)
x = 1.; x = 1.;
qreal y = 1. - x; qreal y = 1. - x;
// Q_ASSERT(x >= 0.); // Q_ASSERT(x >= 0.);
// Q_ASSERT(y >= 0.); // Q_ASSERT(y >= 0.);
qreal r1, g1, b1, a1, r2, g2, b2, a2; qreal r1, g1, b1, a1, r2, g2, b2, a2;
foreground.getRgbF(&r1, &g1, &b1, &a1); foreground.getRgbF(&r1, &g1, &b1, &a1);
background.getRgbF(&r2, &g2, &b2, &a2); background.getRgbF(&r2, &g2, &b2, &a2);
QColor color; QColor color;
color.setRgbF(x*r1+y*r2, x*g1+y*g2, x*b1+y*b2, x*a1+y*a2); color.setRgbF(x*r1+y*r2, x*g1+y*g2, x*b1+y*b2, x*a1+y*a2);
return color; return color;
} }