mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 11:49:01 +03:00
- Put pieces properties on the top of torrent properties (uTorrent like)
This commit is contained in:
parent
f9c8b6a66e
commit
6199d6d543
4 changed files with 90 additions and 77 deletions
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>756</width>
|
||||
<width>758</width>
|
||||
<height>292</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -54,6 +54,48 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<property name="spacing">
|
||||
|
@ -257,12 +299,6 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>115</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
|
@ -450,26 +486,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
<widget class="QCheckBox" name="incrementalDownload">
|
||||
<property name="font">
|
||||
|
|
|
@ -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<size_type> fp;
|
||||
h.file_progress(fp);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -33,85 +33,83 @@
|
|||
#include <QtDebug>
|
||||
#include <QResizeEvent>
|
||||
|
||||
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<array.size(); i++)
|
||||
{
|
||||
painter.setPen(penColor(array[i]));
|
||||
painter.drawPoint(i,0);
|
||||
}
|
||||
update();
|
||||
if(pixmap.width() != array.size())
|
||||
pixmap = QPixmap(array.size(), 1);
|
||||
QPainter painter(&pixmap);
|
||||
for(int i=0; i<array.size(); i++)
|
||||
{
|
||||
painter.setPen(penColor(array[i]));
|
||||
painter.drawPoint(i,0);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
QColor RealProgressBar::penColor(qreal x)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue