Browse Source

- FEATURE: Real progress bar in torrent properties that displays downloaded pieces (contribution by

Ishan Arora)
adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
58c78fa6f6
  1. 1
      AUTHORS
  2. 1
      Changelog
  3. 21
      src/properties.ui
  4. 13
      src/properties_imp.cpp
  5. 4
      src/properties_imp.h
  6. 28
      src/qtorrenthandle.cpp
  7. 6
      src/qtorrenthandle.h
  8. 102
      src/realprogressbar.cpp
  9. 70
      src/realprogressbar.h
  10. 113
      src/src.pro

1
AUTHORS

@ -3,3 +3,4 @@ Author: @@ -3,3 +3,4 @@ Author:
Contributors:
* Arnaud Demaizière <arnaud@qbittorrent.org>
* Ishan Arora <ishanarora@gmail.com>

1
Changelog

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
- FEATURE: Option to start qBittorrent minimized in systray
- FEATURE: Allow to define double-click actions in torrents lists
- FEATURE: Allow to open torrent destination folder
- FEATURE: Real progress bar in torrent properties that displays downloaded pieces
- BUGFIX: Do not display seeds number in seeding list (always 0)
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.0.0

21
src/properties.ui

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>594</width>
<height>567</height>
<height>621</height>
</rect>
</property>
<property name="windowTitle" >
@ -312,6 +312,25 @@ @@ -312,6 +312,25 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="RealProgressBox" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title" >
<string>Downloaded pieces</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="sizePolicy" >

13
src/properties_imp.cpp

@ -24,6 +24,8 @@ @@ -24,6 +24,8 @@
#include "PropListDelegate.h"
#include "bittorrent.h"
#include "arborescence.h"
#include "realprogressbar.h"
#include "realprogressbarthread.h"
#include <QInputDialog>
#include <QMessageBox>
@ -120,6 +122,15 @@ properties::properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h @@ -120,6 +122,15 @@ properties::properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h
updateInfosTimer = new QTimer(this);
connect(updateInfosTimer, SIGNAL(timeout()), this, SLOT(updateInfos()));
updateInfosTimer->start(3000);
progressBar = new RealProgressBar(this);
progressBar->setForegroundColor(Qt::blue);
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->addWidget(progressBar);
RealProgressBox->setLayout(vbox);
progressBarUpdater = new RealProgressBarThread(progressBar, h);
progressBarUpdater->start();
// progressBarUpdater->refresh();
connect(updateInfosTimer, SIGNAL(timeout()), progressBarUpdater, SLOT(refresh()));
loadSettings();
}
@ -128,6 +139,8 @@ properties::~properties(){ @@ -128,6 +139,8 @@ properties::~properties(){
delete updateInfosTimer;
delete PropDelegate;
delete PropListModel;
delete progressBarUpdater;
delete progressBar;
}
void properties::addFilesToTree(file *root, QStandardItem *parent) {

4
src/properties_imp.h

@ -31,6 +31,8 @@ class bittorrent; @@ -31,6 +31,8 @@ class bittorrent;
class QStandardItemModel;
class file;
class QStandardItem;
class RealProgressBar;
class RealProgressBarThread;
using namespace libtorrent;
@ -46,6 +48,8 @@ class properties : public QDialog, private Ui::properties{ @@ -46,6 +48,8 @@ class properties : public QDialog, private Ui::properties{
QTimer *updateInfosTimer;
bool has_filtered_files;
QStringList urlSeeds;
RealProgressBar *progressBar;
RealProgressBarThread *progressBarUpdater;
protected slots:
void on_okButton_clicked();

28
src/qtorrenthandle.cpp

@ -60,6 +60,16 @@ float QTorrentHandle::progress() const { @@ -60,6 +60,16 @@ float QTorrentHandle::progress() const {
return progress;
}
const std::vector<bool>* QTorrentHandle::pieces() const {
Q_ASSERT(h.is_valid());
return h.status().pieces;
}
void QTorrentHandle::get_download_queue(std::vector<partial_piece_info>& queue) const {
Q_ASSERT(h.is_valid());
h.get_download_queue(queue);
}
QString QTorrentHandle::current_tracker() const {
Q_ASSERT(h.is_valid());
return misc::toQString(h.status().current_tracker);
@ -74,10 +84,20 @@ bool QTorrentHandle::is_paused() const { @@ -74,10 +84,20 @@ bool QTorrentHandle::is_paused() const {
return h.is_paused();
}
// size_type QTorrentHandle::total_size() const {
// Q_ASSERT(h.is_valid());
// return h.get_torrent_info().total_size();
// }
size_type QTorrentHandle::total_size() const {
Q_ASSERT(h.is_valid());
return h.get_torrent_info().total_size();
}
size_type QTorrentHandle::piece_length() const {
Q_ASSERT(h.is_valid());
return h.get_torrent_info().piece_length();
}
int QTorrentHandle::num_pieces() const {
Q_ASSERT(h.is_valid());
return h.get_torrent_info().num_pieces();
}
size_type QTorrentHandle::total_wanted_done() const {
Q_ASSERT(h.is_valid());

6
src/qtorrenthandle.h

@ -54,11 +54,15 @@ class QTorrentHandle { @@ -54,11 +54,15 @@ class QTorrentHandle {
QString hash() const;
QString name() const;
float progress() const;
const std::vector<bool>* pieces() const;
void get_download_queue(std::vector<partial_piece_info>& queue) const;
QString current_tracker() const;
bool is_valid() const;
bool is_paused() const;
bool has_filtered_pieces() const;
// size_type total_size() const;
size_type total_size() const;
size_type piece_length() const;
int num_pieces() const;
size_type total_wanted_done() const;
float download_payload_rate() const;
float upload_payload_rate() const;

102
src/realprogressbar.cpp

@ -0,0 +1,102 @@ @@ -0,0 +1,102 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez, Arnaud Demaiziere
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org, arnaud@qbittorrent.org
*/
#include "realprogressbar.h"
#include <QPainter>
#include <QtDebug>
#include <QResizeEvent>
RealProgressBar::RealProgressBar(QWidget *parent)
: QWidget(parent), array(1)
{
background = Qt::white;
foreground = Qt::black;
active = false;
array[0] = 0.;
drawPixmap();
}
RealProgressBar::~RealProgressBar()
{
qDebug("RealProgressBar destruction");
}
void RealProgressBar::setBackgroundColor(const QColor &newColor)
{
background = newColor;
drawPixmap();
}
void RealProgressBar::setForegroundColor(const QColor &newColor)
{
foreground = newColor;
drawPixmap();
}
/*
void RealProgressBar::setThread(const RealProgressBarThread *newThread)
{
thread = newThread;
}
*/
void RealProgressBar::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.drawPixmap(rect(), pixmap);
}
void RealProgressBar::resizeEvent(QResizeEvent *event)
{
if(width() != event->oldSize().width())
emit widthChanged(width());
}
void RealProgressBar::setProgress(QRealArray progress)
{
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();
}
QColor RealProgressBar::penColor(qreal x)
{
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;
}

70
src/realprogressbar.h

@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez, Arnaud Demaiziere
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org, arnaud@qbittorrent.org
*/
#ifndef REALPROGRESSBAR_H
#define REALPROGRESSBAR_H
#include "qrealarray.h"
#include <QWidget>
#include <QPixmap>
class RealProgressBar : public QWidget
{
Q_OBJECT
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(QColor foregroundColor READ foregroundColor WRITE setForegroundColor)
private:
QColor foreground;
QColor background;
bool active;
QPixmap pixmap;
// RealProgressBarThread *thread;
QRealArray array;
public:
RealProgressBar(QWidget *parent = 0);
~RealProgressBar();
void setBackgroundColor(const QColor &newColor);
QColor backgroundColor() const {return background;}
void setForegroundColor(const QColor &newColor);
QColor foregroundColor() const {return foreground;}
// void setThread(const RealProgressBarThread *newThread);
// RealProgressBarThread *thread() const {return thread;}
public slots:
void setProgress(QRealArray progress);
signals:
void widthChanged(int width);
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
private:
void drawPixmap();
QColor penColor(qreal f);
};
#endif

113
src/src.pro

@ -17,15 +17,15 @@ DEFINES += VERSION_MINOR=0 @@ -17,15 +17,15 @@ DEFINES += VERSION_MINOR=0
DEFINES += VERSION_BUGFIX=0
contains(DEBUG_MODE, 1){
CONFIG += debug
CONFIG -= release
message(Debug build!)
CONFIG += debug
CONFIG -= release
message(Debug build!)
}
contains(DEBUG_MODE, 0){
CONFIG -= debug
CONFIG += release
DEFINES += QT_NO_DEBUG_OUTPUT
message(Release build!)
CONFIG -= debug
CONFIG += release
DEFINES += QT_NO_DEBUG_OUTPUT
message(Release build!)
}
# For libtorrent stuff
@ -35,56 +35,56 @@ contains(DEBUG_MODE, 0){ @@ -35,56 +35,56 @@ contains(DEBUG_MODE, 0){
# Install
!win32 {
# Binary
exists(../conf.pri) {
include(../conf.pri)
# Target
target.path = $$BINDIR
INSTALLS += target
}
# Man page
man.files = ../doc/qbittorrent.1.gz
man.path = $$PREFIX/share/man/man1/
INSTALLS += man
# Menu Icon
menuicon.files = Icons/qBittorrent.desktop
menuicon.path = $$PREFIX/share/applications/
INSTALLS += menuicon
icon16.files = menuicons/16x16/apps/qbittorrent.png
icon16.path = $$PREFIX/share/icons/hicolor/16x16/apps/
icon22.files = menuicons/22x22/apps/qbittorrent.png
icon22.path = $$PREFIX/share/icons/hicolor/22x22/apps/
icon24.files = menuicons/24x24/apps/qbittorrent.png
icon24.path = $$PREFIX/share/icons/hicolor/24x24/apps/
icon32.files = menuicons/32x32/apps/qbittorrent.png
icon32.path = $$PREFIX/share/icons/hicolor/32x32/apps/
icon36.files = menuicons/36x36/apps/qbittorrent.png
icon36.path = $$PREFIX/share/icons/hicolor/36x36/apps/
icon48.files = menuicons/48x48/apps/qbittorrent.png
icon48.path = $$PREFIX/share/icons/hicolor/48x48/apps/
icon64.files = menuicons/64x64/apps/qbittorrent.png
icon64.path = $$PREFIX/share/icons/hicolor/64x64/apps/
icon72.files = menuicons/72x72/apps/qbittorrent.png
icon72.path = $$PREFIX/share/icons/hicolor/72x72/apps/
icon96.files = menuicons/96x96/apps/qbittorrent.png
icon96.path = $$PREFIX/share/icons/hicolor/96x96/apps/
icon128.files = menuicons/128x128/apps/qbittorrent.png
icon128.path = $$PREFIX/share/icons/hicolor/128x128/apps/
icon192.files = menuicons/192x192/apps/qbittorrent.png
icon192.path = $$PREFIX/share/icons/hicolor/192x192/apps/
INSTALLS += icon16 icon22 icon24 icon32 icon36 icon48 icon64 icon72 icon96 icon128 icon192
# Binary
exists(../conf.pri){
include(../conf.pri)
# Target
target.path = $$BINDIR
INSTALLS += target
}
# Man page
man.files = ../doc/qbittorrent.1.gz
man.path = $$PREFIX/share/man/man1/
INSTALLS += man
# Menu Icon
menuicon.files = Icons/qBittorrent.desktop
menuicon.path = $$PREFIX/share/applications/
INSTALLS += menuicon
icon16.files = menuicons/16x16/apps/qbittorrent.png
icon16.path = $$PREFIX/share/icons/hicolor/16x16/apps/
icon22.files = menuicons/22x22/apps/qbittorrent.png
icon22.path = $$PREFIX/share/icons/hicolor/22x22/apps/
icon24.files = menuicons/24x24/apps/qbittorrent.png
icon24.path = $$PREFIX/share/icons/hicolor/24x24/apps/
icon32.files = menuicons/32x32/apps/qbittorrent.png
icon32.path = $$PREFIX/share/icons/hicolor/32x32/apps/
icon36.files = menuicons/36x36/apps/qbittorrent.png
icon36.path = $$PREFIX/share/icons/hicolor/36x36/apps/
icon48.files = menuicons/48x48/apps/qbittorrent.png
icon48.path = $$PREFIX/share/icons/hicolor/48x48/apps/
icon64.files = menuicons/64x64/apps/qbittorrent.png
icon64.path = $$PREFIX/share/icons/hicolor/64x64/apps/
icon72.files = menuicons/72x72/apps/qbittorrent.png
icon72.path = $$PREFIX/share/icons/hicolor/72x72/apps/
icon96.files = menuicons/96x96/apps/qbittorrent.png
icon96.path = $$PREFIX/share/icons/hicolor/96x96/apps/
icon128.files = menuicons/128x128/apps/qbittorrent.png
icon128.path = $$PREFIX/share/icons/hicolor/128x128/apps/
icon192.files = menuicons/192x192/apps/qbittorrent.png
icon192.path = $$PREFIX/share/icons/hicolor/192x192/apps/
INSTALLS += icon16 icon22 icon24 icon32 icon36 icon48 icon64 icon72 icon96 icon128 icon192
}
QMAKE_CXXFLAGS_RELEASE += -fwrapv -O2
QMAKE_CXXFLAGS_DEBUG += -fwrapv -O1
CONFIG += link_pkgconfig
PKGCONFIG += libtorrent libccext2 libccgnu2
PKGCONFIG += "libtorrent libccext2 libccgnu2"
!contains(DEFINES, HAVE_MAGICK){
message(ImageMagick disabled)
message(ImageMagick disabled)
}
QT += network xml
@ -94,8 +94,8 @@ DEFINES += QT_NO_CAST_TO_ASCII @@ -94,8 +94,8 @@ DEFINES += QT_NO_CAST_TO_ASCII
# Windows
win32 {
LIBS += -ltorrent -lccext2 -lccgnu2
#-lMagick++ -lWand -lMagick
LIBS += -ltorrent -lccext2 -lccgnu2
#-lMagick++ -lWand -lMagick
}
RESOURCES = icons.qrc \
@ -142,7 +142,9 @@ HEADERS += GUI.h misc.h options_imp.h about_imp.h \ @@ -142,7 +142,9 @@ HEADERS += GUI.h misc.h options_imp.h about_imp.h \
allocationDlg.h FinishedListDelegate.h \
qtorrenthandle.h downloadingTorrents.h \
engineSelectDlg.h pluginSource.h \
arborescence.h qgnomelook.h
arborescence.h qgnomelook.h realprogressbar.h \
realprogressbarthread.h \
qrealarray.h
FORMS += MainWindow.ui options.ui about.ui \
properties.ui createtorrent.ui preview.ui \
login.ui downloadFromURL.ui addTorrentDialog.ui \
@ -160,5 +162,10 @@ SOURCES += GUI.cpp \ @@ -160,5 +162,10 @@ SOURCES += GUI.cpp \
qtorrenthandle.cpp \
downloadingTorrents.cpp \
engineSelectDlg.cpp \
downloadThread.cpp
downloadThread.cpp \
realprogressbar.cpp \
realprogressbarthread.cpp \
qrealarray.cpp
DESTDIR = .

Loading…
Cancel
Save