mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Add style colors for the ScrollBar
This commit is contained in:
parent
d6e6ec2581
commit
6415c4125f
5 changed files with 29 additions and 5 deletions
|
@ -26,12 +26,21 @@
|
|||
class ScrollBar : public QScrollBar
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
|
||||
Q_PROPERTY(QColor handleColor READ handleColor WRITE setHandleColor)
|
||||
|
||||
public:
|
||||
ScrollBar(QScrollArea *area, QWidget *parent = nullptr);
|
||||
|
||||
void fadeIn();
|
||||
void fadeOut();
|
||||
|
||||
QColor backgroundColor() const { return bgColor_; }
|
||||
void setBackgroundColor(QColor &color) { bgColor_ = color; }
|
||||
|
||||
QColor handleColor() const { return handleColor_; }
|
||||
void setHandleColor(QColor &color) { handleColor_ = color; }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void sliderChange(SliderChange change) override;
|
||||
|
@ -50,4 +59,7 @@ private:
|
|||
|
||||
QScrollArea *area_;
|
||||
QRect handle_;
|
||||
|
||||
QColor bgColor_ = QColor(33, 33, 33, 30);
|
||||
QColor handleColor_ = QColor(0, 0, 0, 80);
|
||||
};
|
||||
|
|
|
@ -117,3 +117,8 @@ QTextEdit {
|
|||
background-color: #383c4a;
|
||||
color: #caccd1;
|
||||
}
|
||||
|
||||
ScrollBar {
|
||||
qproperty-handleColor: #caccd1;
|
||||
qproperty-backgroundColor: #383c4e;
|
||||
}
|
||||
|
|
|
@ -108,3 +108,8 @@ FloatingButton {
|
|||
qproperty-backgroundColor: #efefef;
|
||||
qproperty-foregroundColor: black;
|
||||
}
|
||||
|
||||
ScrollBar {
|
||||
qproperty-handleColor: #ccc;
|
||||
qproperty-backgroundColor: #efefef;
|
||||
}
|
||||
|
|
|
@ -84,3 +84,8 @@ QTextEdit,
|
|||
QLineEdit {
|
||||
background-color: palette(window);
|
||||
}
|
||||
|
||||
ScrollBar {
|
||||
qproperty-handleColor: palette(text);
|
||||
qproperty-backgroundColor: palette(window);
|
||||
}
|
||||
|
|
|
@ -85,10 +85,7 @@ ScrollBar::paintEvent(QPaintEvent *)
|
|||
|
||||
p.setPen(Qt::NoPen);
|
||||
|
||||
QColor bg(33, 33, 33, 30);
|
||||
QColor handle(0, 0, 0, 80);
|
||||
|
||||
p.setBrush(bg);
|
||||
p.setBrush(backgroundColor());
|
||||
QRect backgroundArea(Padding, 0, handleWidth_, height());
|
||||
p.drawRoundedRect(backgroundArea, roundRadius_, roundRadius_);
|
||||
|
||||
|
@ -104,7 +101,7 @@ ScrollBar::paintEvent(QPaintEvent *)
|
|||
|
||||
int handle_y = (value() * (areaHeight - handleHeight - roundRadius_ / 2)) / maximum();
|
||||
|
||||
p.setBrush(handle);
|
||||
p.setBrush(handleColor());
|
||||
QRect handleArea(Padding, handle_y, handleWidth_, handleHeight);
|
||||
p.drawRoundedRect(handleArea, roundRadius_, roundRadius_);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue