mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-06 23:52: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:
committed by
sledgehammer999
parent
5f2da3a529
commit
b076ff68ac
@@ -31,28 +31,26 @@
|
||||
#ifndef PIECEAVAILABILITYBAR_H
|
||||
#define PIECEAVAILABILITYBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QImage>
|
||||
#include "piecesbar.h"
|
||||
|
||||
class PieceAvailabilityBar: public QWidget
|
||||
class PieceAvailabilityBar: public PiecesBar
|
||||
{
|
||||
using base = PiecesBar;
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(PieceAvailabilityBar)
|
||||
|
||||
public:
|
||||
PieceAvailabilityBar(QWidget *parent);
|
||||
|
||||
void setAvailability(const QVector<int> &avail);
|
||||
|
||||
// PiecesBar interface
|
||||
void clear() override;
|
||||
|
||||
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;
|
||||
// buffered 256 levels gradient from bg_color to piece_color
|
||||
QVector<int> m_pieceColors;
|
||||
bool updateImage(QImage &image) override;
|
||||
QString simpleToolTipText() const override;
|
||||
bool isFileNameCorrectionNeeded() const override;
|
||||
|
||||
// last used int vector, uses to better resize redraw
|
||||
// TODO: make a diff pieces to new pieces and update only changed pixels, speedup when update > 20x faster
|
||||
@@ -60,23 +58,6 @@ private:
|
||||
|
||||
// scale int vector to float vector
|
||||
QVector<float> intToFloatVector(const QVector<int> &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:
|
||||
PieceAvailabilityBar(QWidget *parent);
|
||||
|
||||
void setAvailability(const QVector<int> &avail);
|
||||
void updatePieceColors();
|
||||
void clear();
|
||||
|
||||
void setColors(int background, int border, int available);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
};
|
||||
|
||||
#endif // PIECEAVAILABILITYBAR_H
|
||||
|
||||
Reference in New Issue
Block a user