Utils: Turn StyleHelper into a namespace

It was in fact just a bag of static functions. Most importantly, it
fixes a previouls introduced build error.

Amends 5975657e77

Change-Id: Ia7de8bdcf91e1763f9d3b435316a5df9993717de
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Alessandro Portale
2023-05-11 13:15:55 +02:00
parent 1acd2499e2
commit fb406a26f4
3 changed files with 172 additions and 135 deletions

View File

@@ -37,6 +37,11 @@ static int range(float x, int min, int max)
namespace Utils {
static StyleHelper::ToolbarStyle m_toolbarStyle = StyleHelper::defaultToolbarStyle;
// Invalid by default, setBaseColor needs to be called at least once
static QColor m_baseColor;
static QColor m_requestedBaseColor;
QColor StyleHelper::mergedColors(const QColor &colorA, const QColor &colorB, int factor)
{
const int maxFactor = 100;
@@ -59,6 +64,21 @@ QColor StyleHelper::alphaBlendedColors(const QColor &colorA, const QColor &color
);
}
QColor StyleHelper::sidebarHighlight()
{
return QColor(255, 255, 255, 40);
}
QColor StyleHelper::sidebarShadow()
{
return QColor(0, 0, 0, 40);
}
QColor StyleHelper::toolBarDropShadowColor()
{
return QColor(0, 0, 0, 70);
}
int StyleHelper::navigationWidgetHeight()
{
return m_toolbarStyle == ToolbarStyleCompact ? 24 : 30;
@@ -105,11 +125,6 @@ QColor StyleHelper::panelTextColor(bool lightColored)
return Qt::black;
}
StyleHelper::ToolbarStyle StyleHelper::m_toolbarStyle = StyleHelper::defaultToolbarStyle;
// Invalid by default, setBaseColor needs to be called at least once
QColor StyleHelper::m_baseColor;
QColor StyleHelper::m_requestedBaseColor;
QColor StyleHelper::baseColor(bool lightColored)
{
static const QColor windowColor = QApplication::palette().color(QPalette::Window);
@@ -118,6 +133,11 @@ QColor StyleHelper::baseColor(bool lightColored)
return (lightColored || windowColorAsBase) ? windowColor : m_baseColor;
}
QColor StyleHelper::requestedBaseColor()
{
return m_requestedBaseColor;
}
QColor StyleHelper::toolbarBaseColor(bool lightColored)
{
if (creatorTheme()->flag(Theme::QDSTheme))
@@ -166,6 +186,11 @@ QColor StyleHelper::toolBarBorderColor()
clamp(base.value() * 0.80f));
}
QColor StyleHelper::buttonTextColor()
{
return QColor(0x4c4c4c);
}
// We try to ensure that the actual color used are within
// reasonalbe bounds while generating the actual baseColor
// from the users request.
@@ -495,6 +520,11 @@ void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const Q
}
}
bool StyleHelper::usePixmapCache()
{
return true;
}
QPixmap StyleHelper::disabledSideBarIcon(const QPixmap &enabledicon)
{
QImage im = enabledicon.toImage().convertToFormat(QImage::Format_ARGB32);