Browse Source

Add possibility to change colors in runtime.

adaptive-webui-19844
Patryk Stępień 13 years ago
parent
commit
1d27fa9c03
  1. 15
      src/properties/downloadedpiecesbar.cpp
  2. 4
      src/properties/downloadedpiecesbar.h
  3. 14
      src/properties/pieceavailabilitybar.cpp
  4. 4
      src/properties/pieceavailabilitybar.h

15
src/properties/downloadedpiecesbar.cpp

@ -37,6 +37,7 @@ DownloadedPiecesBar::DownloadedPiecesBar(QWidget *parent): QWidget(parent) @@ -37,6 +37,7 @@ DownloadedPiecesBar::DownloadedPiecesBar(QWidget *parent): QWidget(parent)
setFixedHeight(BAR_HEIGHT);
bg_color = 0xffffff;
border_color = palette().color(QPalette::Dark).rgb();
piece_color = 0x0000ff;
piece_color_dl = 0x00d000;
@ -228,8 +229,20 @@ void DownloadedPiecesBar::paintEvent(QPaintEvent *) @@ -228,8 +229,20 @@ void DownloadedPiecesBar::paintEvent(QPaintEvent *)
QPainterPath border;
border.addRect(0, 0, width() - 1, height() - 1);
painter.setPen(palette().color(QPalette::Dark));
painter.setPen(border_color);
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();
}

4
src/properties/downloadedpiecesbar.h

@ -50,6 +50,8 @@ private: @@ -50,6 +50,8 @@ private:
// background color
int bg_color;
// border color
int border_color;
// complete piece color
int piece_color;
// incomplete piece color
@ -76,6 +78,8 @@ public: @@ -76,6 +78,8 @@ public:
void updatePieceColors();
void clear();
void setColors(int background, int border, int complete, int incomplete);
protected:
void paintEvent(QPaintEvent *);
};

14
src/properties/pieceavailabilitybar.cpp

@ -38,6 +38,7 @@ PieceAvailabilityBar::PieceAvailabilityBar(QWidget *parent) : @@ -38,6 +38,7 @@ PieceAvailabilityBar::PieceAvailabilityBar(QWidget *parent) :
setFixedHeight(BAR_HEIGHT);
bg_color = 0xffffff;
border_color = palette().color(QPalette::Dark).rgb();
piece_color = 0x0000ff;
updatePieceColors();
@ -220,6 +221,17 @@ void PieceAvailabilityBar::paintEvent(QPaintEvent *) @@ -220,6 +221,17 @@ void PieceAvailabilityBar::paintEvent(QPaintEvent *)
QPainterPath border;
border.addRect(0, 0, width() - 1, height() - 1);
painter.setPen(palette().color(QPalette::Dark));
painter.setPen(border_color);
painter.drawPath(border);
}
void PieceAvailabilityBar::setColors(int background, int border, int available)
{
bg_color = background;
border_color = border;
piece_color = available;
updatePieceColors();
updateImage();
update();
}

4
src/properties/pieceavailabilitybar.h

@ -50,6 +50,8 @@ private: @@ -50,6 +50,8 @@ private:
// background color
int bg_color;
// border color
int border_color;
// complete piece color
int piece_color;
// buffered 256 levels gradient from bg_color to piece_color
@ -74,6 +76,8 @@ public: @@ -74,6 +76,8 @@ public:
void updatePieceColors();
void clear();
void setColors(int background, int border, int available);
protected:
void paintEvent(QPaintEvent *);

Loading…
Cancel
Save