mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
Add possibility to change colors in runtime.
This commit is contained in:
parent
2a88e790df
commit
1d27fa9c03
@ -37,6 +37,7 @@ DownloadedPiecesBar::DownloadedPiecesBar(QWidget *parent): QWidget(parent)
|
|||||||
setFixedHeight(BAR_HEIGHT);
|
setFixedHeight(BAR_HEIGHT);
|
||||||
|
|
||||||
bg_color = 0xffffff;
|
bg_color = 0xffffff;
|
||||||
|
border_color = palette().color(QPalette::Dark).rgb();
|
||||||
piece_color = 0x0000ff;
|
piece_color = 0x0000ff;
|
||||||
piece_color_dl = 0x00d000;
|
piece_color_dl = 0x00d000;
|
||||||
|
|
||||||
@ -228,8 +229,20 @@ void DownloadedPiecesBar::paintEvent(QPaintEvent *)
|
|||||||
QPainterPath border;
|
QPainterPath border;
|
||||||
border.addRect(0, 0, width() - 1, height() - 1);
|
border.addRect(0, 0, width() - 1, height() - 1);
|
||||||
|
|
||||||
painter.setPen(palette().color(QPalette::Dark));
|
painter.setPen(border_color);
|
||||||
painter.drawPath(border);
|
painter.drawPath(border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadedPiecesBar::setColors(int background, int border, int complete, int incomplete)
|
||||||
|
{
|
||||||
|
bg_color = background;
|
||||||
|
border_color = border;
|
||||||
|
piece_color = complete;
|
||||||
|
piece_color_dl = incomplete;
|
||||||
|
|
||||||
|
updatePieceColors();
|
||||||
|
updateImage();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ private:
|
|||||||
|
|
||||||
// background color
|
// background color
|
||||||
int bg_color;
|
int bg_color;
|
||||||
|
// border color
|
||||||
|
int border_color;
|
||||||
// complete piece color
|
// complete piece color
|
||||||
int piece_color;
|
int piece_color;
|
||||||
// incomplete piece color
|
// incomplete piece color
|
||||||
@ -76,6 +78,8 @@ public:
|
|||||||
void updatePieceColors();
|
void updatePieceColors();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
void setColors(int background, int border, int complete, int incomplete);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
};
|
};
|
||||||
|
@ -38,6 +38,7 @@ PieceAvailabilityBar::PieceAvailabilityBar(QWidget *parent) :
|
|||||||
setFixedHeight(BAR_HEIGHT);
|
setFixedHeight(BAR_HEIGHT);
|
||||||
|
|
||||||
bg_color = 0xffffff;
|
bg_color = 0xffffff;
|
||||||
|
border_color = palette().color(QPalette::Dark).rgb();
|
||||||
piece_color = 0x0000ff;
|
piece_color = 0x0000ff;
|
||||||
|
|
||||||
updatePieceColors();
|
updatePieceColors();
|
||||||
@ -220,6 +221,17 @@ void PieceAvailabilityBar::paintEvent(QPaintEvent *)
|
|||||||
QPainterPath border;
|
QPainterPath border;
|
||||||
border.addRect(0, 0, width() - 1, height() - 1);
|
border.addRect(0, 0, width() - 1, height() - 1);
|
||||||
|
|
||||||
painter.setPen(palette().color(QPalette::Dark));
|
painter.setPen(border_color);
|
||||||
painter.drawPath(border);
|
painter.drawPath(border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PieceAvailabilityBar::setColors(int background, int border, int available)
|
||||||
|
{
|
||||||
|
bg_color = background;
|
||||||
|
border_color = border;
|
||||||
|
piece_color = available;
|
||||||
|
|
||||||
|
updatePieceColors();
|
||||||
|
updateImage();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
@ -50,6 +50,8 @@ private:
|
|||||||
|
|
||||||
// background color
|
// background color
|
||||||
int bg_color;
|
int bg_color;
|
||||||
|
// border color
|
||||||
|
int border_color;
|
||||||
// complete piece color
|
// complete piece color
|
||||||
int piece_color;
|
int piece_color;
|
||||||
// buffered 256 levels gradient from bg_color to piece_color
|
// buffered 256 levels gradient from bg_color to piece_color
|
||||||
@ -74,6 +76,8 @@ public:
|
|||||||
void updatePieceColors();
|
void updatePieceColors();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
void setColors(int background, int border, int available);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user