wip: customize scroll bar

This commit is contained in:
Hane 2024-05-30 22:36:35 +02:00
commit 0531e2fb71
2 changed files with 436 additions and 39 deletions

View file

@ -41,7 +41,7 @@
#include <QPixmapCache>
#include <QLatin1Char>
#include <QLatin1String>
//#include <QScrollbarStyleAnimation>
//#include <QScrollBar>
/*
* #else
@ -65,7 +65,7 @@ namespace StylingHelper {
return QLatin1String(ch);
}
static inline qreal dpi(const QStyleOption *option) {
static inline qreal calculateDpi(const QStyleOption *option) {
#ifndef Q_OS_DARWIN
// Prioritize the application override, except for on macOS where
// we have historically not supported the AA_Use96Dpi flag.
@ -107,7 +107,7 @@ namespace StylingHelper {
}
static inline qreal dpiScaled(qreal value, const QStyleOption *option) {
return dpiScaled(value, dpi(option));
return dpiScaled(value, calculateDpi(option));
}
static inline bool isMacSystemPalette(const QPalette &pal) {
@ -161,5 +161,18 @@ namespace StylingHelper {
cachePixmap.fill(Qt::transparent);
return cachePixmap;
}
static inline QColor backgroundColor(const QPalette &pal, const QWidget* widget)
{
#if QT_CONFIG(scrollarea)
if (qobject_cast<const QScrollBar *>(widget) && widget->parent() &&
qobject_cast<const QAbstractScrollArea *>(widget->parent()->parent()))
return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base);
#else
Q_UNUSED(widget);
#endif
return pal.color(QPalette::Base);
}
}