Some work about adaptive color scheme for Web UI (PR #19901)
http://[316:c51a:62a3:8b9::4]/d4708/qBittorrent/src/branch/adaptive-webui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.1 KiB
61 lines
1.1 KiB
15 years ago
|
#ifndef DOWNLOADEDPIECESBAR_H
|
||
|
#define DOWNLOADEDPIECESBAR_H
|
||
|
|
||
|
#include <QWidget>
|
||
|
#include <QPainter>
|
||
|
#include <QList>
|
||
|
#include <QPixmap>
|
||
|
#include <libtorrent/bitfield.hpp>
|
||
|
|
||
|
using namespace libtorrent;
|
||
|
#define BAR_HEIGHT 18
|
||
|
|
||
|
class DownloadedPiecesBar: public QWidget {
|
||
|
Q_OBJECT
|
||
|
|
||
|
private:
|
||
|
QPixmap pixmap;
|
||
|
|
||
|
|
||
|
public:
|
||
|
DownloadedPiecesBar(QWidget *parent): QWidget(parent) {
|
||
|
setFixedHeight(BAR_HEIGHT);
|
||
|
}
|
||
|
|
||
|
void setProgress(bitfield pieces) {
|
||
|
if(pieces.empty()) {
|
||
|
// Empty bar
|
||
|
pixmap = QPixmap(1, 1);
|
||
|
QPainter painter(&pixmap);
|
||
|
painter.setPen(Qt::white);
|
||
|
painter.drawPoint(0,0);
|
||
|
} else {
|
||
|
pixmap = QPixmap(pieces.size(), 1);
|
||
|
QPainter painter(&pixmap);
|
||
|
for(uint i=0; i<pieces.size(); ++i) {
|
||
|
if(pieces[i])
|
||
|
painter.setPen(Qt::blue);
|
||
|
else
|
||
|
painter.setPen(Qt::white);
|
||
|
painter.drawPoint(i,0);
|
||
|
}
|
||
|
}
|
||
|
update();
|
||
|
}
|
||
|
|
||
|
void clear() {
|
||
|
pixmap = QPixmap();
|
||
|
update();
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
void paintEvent(QPaintEvent *) {
|
||
|
if(pixmap.isNull()) return;
|
||
|
QPainter painter(this);
|
||
|
painter.drawPixmap(rect(), pixmap);
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif // DOWNLOADEDPIECESBAR_H
|