diff --git a/include/ui/ScrollBar.h b/include/ui/ScrollBar.h index 1c056409..fe8ba64a 100644 --- a/include/ui/ScrollBar.h +++ b/include/ui/ScrollBar.h @@ -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); }; diff --git a/resources/styles/nheko-dark.qss b/resources/styles/nheko-dark.qss index 8610c445..84e21f8a 100644 --- a/resources/styles/nheko-dark.qss +++ b/resources/styles/nheko-dark.qss @@ -117,3 +117,8 @@ QTextEdit { background-color: #383c4a; color: #caccd1; } + +ScrollBar { + qproperty-handleColor: #caccd1; + qproperty-backgroundColor: #383c4e; +} diff --git a/resources/styles/nheko.qss b/resources/styles/nheko.qss index 55f9a4f4..115e4a2a 100644 --- a/resources/styles/nheko.qss +++ b/resources/styles/nheko.qss @@ -108,3 +108,8 @@ FloatingButton { qproperty-backgroundColor: #efefef; qproperty-foregroundColor: black; } + +ScrollBar { + qproperty-handleColor: #ccc; + qproperty-backgroundColor: #efefef; +} diff --git a/resources/styles/system.qss b/resources/styles/system.qss index bb24b7a6..cc54402f 100644 --- a/resources/styles/system.qss +++ b/resources/styles/system.qss @@ -84,3 +84,8 @@ QTextEdit, QLineEdit { background-color: palette(window); } + +ScrollBar { + qproperty-handleColor: palette(text); + qproperty-backgroundColor: palette(window); +} diff --git a/src/ui/ScrollBar.cc b/src/ui/ScrollBar.cc index 24f97461..1330ca07 100644 --- a/src/ui/ScrollBar.cc +++ b/src/ui/ScrollBar.cc @@ -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_); }