mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +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
|
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:
|
||||||
|
|
||||||
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 {
|
||||||
background-color: #383c4a;
|
background-color: #383c4a;
|
||||||
color: #caccd1;
|
color: #caccd1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScrollBar {
|
||||||
|
qproperty-handleColor: #caccd1;
|
||||||
|
qproperty-backgroundColor: #383c4e;
|
||||||
|
}
|
||||||
|
|
|
@ -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,
|
||||||
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 *)
|
||||||
|
|
||||||
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 *)
|
||||||
|
|
||||||
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_);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue