Skip to content
Snippets Groups Projects
Commit 6415c412 authored by Konstantinos Sideris's avatar Konstantinos Sideris
Browse files

Add style colors for the ScrollBar

parent d6e6ec25
No related branches found
No related tags found
No related merge requests found
...@@ -26,12 +26,21 @@ ...@@ -26,12 +26,21 @@
class ScrollBar : public QScrollBar class ScrollBar : public QScrollBar
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(QColor handleColor READ handleColor WRITE setHandleColor)
public: public:
ScrollBar(QScrollArea *area, QWidget *parent = nullptr); ScrollBar(QScrollArea *area, QWidget *parent = nullptr);
void fadeIn(); void fadeIn();
void fadeOut(); 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: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void sliderChange(SliderChange change) override; void sliderChange(SliderChange change) override;
...@@ -50,4 +59,7 @@ private: ...@@ -50,4 +59,7 @@ private:
QScrollArea *area_; QScrollArea *area_;
QRect handle_; QRect handle_;
QColor bgColor_ = QColor(33, 33, 33, 30);
QColor handleColor_ = QColor(0, 0, 0, 80);
}; };
...@@ -117,3 +117,8 @@ QTextEdit { ...@@ -117,3 +117,8 @@ QTextEdit {
background-color: #383c4a; background-color: #383c4a;
color: #caccd1; color: #caccd1;
} }
ScrollBar {
qproperty-handleColor: #caccd1;
qproperty-backgroundColor: #383c4e;
}
...@@ -108,3 +108,8 @@ FloatingButton { ...@@ -108,3 +108,8 @@ FloatingButton {
qproperty-backgroundColor: #efefef; qproperty-backgroundColor: #efefef;
qproperty-foregroundColor: black; qproperty-foregroundColor: black;
} }
ScrollBar {
qproperty-handleColor: #ccc;
qproperty-backgroundColor: #efefef;
}
...@@ -84,3 +84,8 @@ QTextEdit, ...@@ -84,3 +84,8 @@ QTextEdit,
QLineEdit { QLineEdit {
background-color: palette(window); background-color: palette(window);
} }
ScrollBar {
qproperty-handleColor: palette(text);
qproperty-backgroundColor: palette(window);
}
...@@ -85,10 +85,7 @@ ScrollBar::paintEvent(QPaintEvent *) ...@@ -85,10 +85,7 @@ ScrollBar::paintEvent(QPaintEvent *)
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
QColor bg(33, 33, 33, 30); p.setBrush(backgroundColor());
QColor handle(0, 0, 0, 80);
p.setBrush(bg);
QRect backgroundArea(Padding, 0, handleWidth_, height()); QRect backgroundArea(Padding, 0, handleWidth_, height());
p.drawRoundedRect(backgroundArea, roundRadius_, roundRadius_); p.drawRoundedRect(backgroundArea, roundRadius_, roundRadius_);
...@@ -104,7 +101,7 @@ ScrollBar::paintEvent(QPaintEvent *) ...@@ -104,7 +101,7 @@ ScrollBar::paintEvent(QPaintEvent *)
int handle_y = (value() * (areaHeight - handleHeight - roundRadius_ / 2)) / maximum(); int handle_y = (value() * (areaHeight - handleHeight - roundRadius_ / 2)) / maximum();
p.setBrush(handle); p.setBrush(handleColor());
QRect handleArea(Padding, handle_y, handleWidth_, handleHeight); QRect handleArea(Padding, handle_y, handleWidth_, handleHeight);
p.drawRoundedRect(handleArea, roundRadius_, roundRadius_); p.drawRoundedRect(handleArea, roundRadius_, roundRadius_);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment