mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-08 00:22:31 -06:00
Show files in tooltips for pieces progress bars
In addition to the current tooltip, which shows color legend, if user holds the Shift key during hovering we show another tooltip which contains a table of contents for the piece under the moue cursor. The table lists file sizes and names. If the cursor points to a part of a file which spans several pieces, those pieces are highlighted.
This commit is contained in:
@@ -32,54 +32,39 @@
|
||||
#define DOWNLOADEDPIECESBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QImage>
|
||||
#include <QBitArray>
|
||||
#include <QVector>
|
||||
|
||||
class DownloadedPiecesBar: public QWidget {
|
||||
#include "piecesbar.h"
|
||||
|
||||
class DownloadedPiecesBar: public PiecesBar
|
||||
{
|
||||
using base = PiecesBar;
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(DownloadedPiecesBar)
|
||||
|
||||
private:
|
||||
QImage m_image;
|
||||
|
||||
// I used values, because it should be possible to change colors in runtime
|
||||
|
||||
// background color
|
||||
int m_bgColor;
|
||||
// border color
|
||||
int m_borderColor;
|
||||
// complete piece color
|
||||
int m_pieceColor;
|
||||
// incomplete piece color
|
||||
int m_dlPieceColor;
|
||||
// buffered 256 levels gradient from bg_color to piece_color
|
||||
QVector<int> m_pieceColors;
|
||||
|
||||
// last used bitfields, uses to better resize redraw
|
||||
// TODO: make a diff pieces to new pieces and update only changed pixels, speedup when update > 20x faster
|
||||
QBitArray m_pieces;
|
||||
QBitArray m_downloadedPieces;
|
||||
|
||||
// scale bitfield vector to float vector
|
||||
QVector<float> bitfieldToFloatVector(const QBitArray &vecin, int reqSize);
|
||||
// mix two colors by light model, ratio <0, 1>
|
||||
int mixTwoColors(int &rgb1, int &rgb2, float ratio);
|
||||
// draw new image and replace actual image
|
||||
void updateImage();
|
||||
|
||||
public:
|
||||
DownloadedPiecesBar(QWidget *parent);
|
||||
|
||||
void setProgress(const QBitArray &m_pieces, const QBitArray &downloadedPieces);
|
||||
void updatePieceColors();
|
||||
void clear();
|
||||
void setProgress(const QBitArray &pieces, const QBitArray &downloadedPieces);
|
||||
|
||||
void setColors(int background, int border, int complete, int incomplete);
|
||||
void setColors(const QColor &background, const QColor &border, const QColor &complete, const QColor &incomplete);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
// PiecesBar interface
|
||||
void clear() override;
|
||||
|
||||
private:
|
||||
// scale bitfield vector to float vector
|
||||
QVector<float> bitfieldToFloatVector(const QBitArray &vecin, int reqSize);
|
||||
virtual bool updateImage(QImage &image) override;
|
||||
QString simpleToolTipText() const override;
|
||||
|
||||
// incomplete piece color
|
||||
QColor m_dlPieceColor;
|
||||
// last used bitfields, uses to better resize redraw
|
||||
// TODO: make a diff pieces to new pieces and update only changed pixels, speedup when update > 20x faster
|
||||
QBitArray m_pieces;
|
||||
QBitArray m_downloadedPieces;
|
||||
};
|
||||
|
||||
#endif // DOWNLOADEDPIECESBAR_H
|
||||
|
||||
Reference in New Issue
Block a user